diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..fa73ddb54b --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +.classpath +.project +.settings +*.iml +*.class +target/ +bin/ +.idea +*.iws +*.ipr +.DS_Store +felix-cache +dependency-reduced-pom.xml +/reports/ +pom.xml.versionsBackup diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..f4985ecc77 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +sudo: false +cache: + directories: + - $HOME/.m2 + +language: java +script: "mvn verify" +jdk: + - openjdk8 diff --git a/README.md b/README.md new file mode 100644 index 0000000000..1177915cbb --- /dev/null +++ b/README.md @@ -0,0 +1,1522 @@ +# OWLAPI +====== + +## OWL API main repository + +The OWL API is a Java API for creating, manipulating and serialising OWL Ontologies. + +* The latest version of the API supports OWL 2. + +* It is available under Open Source licenses (LGPL and Apache). + +The following components are included: + +* An API for OWL 2 and an in-memory reference implementation. +* Read and write support for RDF/XML, OWL/XML, Functional syntax, Manchester syntax, Turtle, OBO. +* Write support for KRSS, DL syntax, LaTeX. +* Other formats via RIO integration (NTriples, JSON, etc.). +* Reasoner interfaces for working with reasoners such as FaCT++, HermiT, Pellet, Racer, JFact and Chainsaw. +* See documentation pages on the wiki for more details. + +## Release notes + +## 5.1.18 30 July 2021 + +### Features: + +* Specify RioSetting values for Rio renderers #614 + +### Bug fixes: + +* Fix sameAs failure when more than 2 entities included #994 +* Fix Trig and rdf/json should include a named graph. #1002 +* Fix ObjectHasSelf rendered wrongly in manchester syntax #1005 + +## 5.1.17 6 November 2020 + +### Features: + +* Remove @Deprecated annotations for Set based methods in OWLAPI 5 #981 +* Support RDF4J Rio HDT parser #931 +* OWLLiteral for XSD:Long #970 + +### Bug fixes: + +* Fix Performance of signature checks during ontology changes #968 +* Fix Error on RIO renderer when expression has 6000 elements #971 +* Fix OWLOntology#datatypesInSignature to include ontology header #965 +* Fix EntitySearcher.getSuperProperties fails when parent is inverse #964 +* Update guava and junit versions +* Fix OWLParser not ensuring streams are closed on exit #973 +* Error with undeclared classes in domain axioms #962 +* Fix Ontology caches should use weak keys #984 + +## 5.1.16 28 July 2020 + +### Bug fixes: + +* Fix follow multiple redirects across protocols #954 +* Javadoc fixes for deprecated stream methods #950 + +## 5.1.15 02 July 2020 + +### Features: + +* Allow creation of tautologies for n-ary axioms #776 +* Configurable fast pruning window size + +### Bug fixes: + +* Fix javadoc for OWLObject::nestedClassExpressions #937 +* Fix classAssertionAxioms with OWLClassExpression fails #930 +* Fix Include ontology annotations in signature #928 +* Fix Unable to set base directive for turtle writers #938 +* Fix OWLAPI accepts IRIs with leading spaces #940 +* Fix SWRL body reordered when structure shared #936 +* Fix roundtrip through OBO changes IRI of owl:versionInfo #947 + + + +## 5.1.14 18 April 2020 + +### Features: +* General modularity classes contributed by Robn Nolte + +### Bug fixes: + +* Fix XSD datatypes are erroneously quoted in OBO writer #918 +* Fix referencingAxioms(OWLPrimitive) misses nested literals #912 +* Fix Empty line in META-INF/services/ files causes exceptions #924 +* Fix OWLOntologyWriterConfiguration does not disable banner comments #904 + + +## 5.1.13 27 January 2020 + +### Bug fixes: + +* Fix OWLEntityRenamer and anonymous individuals #892 +* Fix Builtin annotation properties lost during parsing #895 +* Deal with OWLAnnotationProperty entities in OWLEntityURIConverter class #896 + + +## 5.1.12 20 October 2019 + +### Bug fixes: + +* Implement Allow gzipped imports #887 +* Fix Race condition in Injector #883 +* Jackson update +* Fix containsReference(OWLEntity) should be deprecated #864 +* Fix referencingAxioms(OWLPrimitive) misses IRI appearances #865 +* Fix Javadoc on applyChange/applyChanges and using the wrong manager #868 +* Fix OWLObjectPropertyExpression#getSimplified() used incorrectly #882 +* Fix Incomplete javadoc on OWLNaryAxiom#asPairwiseAxioms #884 +* Fix OWLNegative*AssertionAxiom#containsAnonymousIndividuals javadoc #885 +* Fix Annotated axiom with anon expression saved incorrectly #881 +* Fix Ontology with relative IRIs is serialized incorrectly #880 +* Fix Ann. annotation with anon individual saved in RDF incorrectly #877 +* Fix Annotations dropped if annotation property is undeclared #875 +* Fix SAXException from AutoIRIMapper at debug logging level #878 +* Ensure isAnonymous is implemented correctly #867 +* Fix Null pointers with imports and relation declarations #859 +* Amend base and escaped characters in Tutle parsing #857 +* Fix Exception when converting obi to obo #860 + + +## 5.1.11 02 June 2019 + +### Features: + +* Add support to load an ontology from classpath #837 +* Implement Allow annotations to be skipped in module extraction #838 +* Add support for custom tags in obo files. + +### Bug fixes: + +* Fix Unescaping characters: OBOFormatParser#handleNextChar() #822 +* Fix IRI PREFIX_CACHE instance uses too much memory #825 +* Fix roundtrip of escaped values #833 +* Fix MaximumNumberOfNamedSuperclasses should count super classes #836 +* Fix OWLDataPropertyAxiom not a subinterface of OWLPropertyAxiom #831 +* Fix HTTP 307 and HTTP 308 redirects are not followed (in 4.x) #821 +* Fix Missing escape character in OBO output #828 +* Fix 5.1.10 Regression in OwlStringTools#translate(..) #829 +* Fixed several incorrect XSD datatype matching patterns. +* Fix OWLDataFactory::getLiteral error with empty string and integer #846 +* Fix Unnecessary dc prefix added by Manchester syntax parser #845 +* Fix Multiple Ontology Definitions should obey strict parsing #840 +* Fix OWLLogicalEntity is not an OWLAnnotationProperty #847 +* Security: Jackson to 2.9.9 +* Fix Manchester syntax parser crashes on class/property punning #851 +* Fix OBO parser does not support qualifier block #852 + + +## 5.1.10 04 March 2019 + +### Bug fixes: + +* Fix DLExpressivity checker never computes anything #810 +* Jackson version to 2.9.8 +* Fix ensure allValuesFrom axioms are not lost #808 +* Fix HTTP 307 and HTTP 308 redirects are not followed #821 +* Fix OBO renderer stuck with untranslatable axioms on concurrent managers +* Fix Annotations on DifferentIndividualsAxioms lost #816 +* Fix No roundtrip for IRIs with colons in the fragment or path #817 +* Fix EOFException in CustomTokenizer #813 +* Fix Cyclic imports and missing declarations cause parsing error #798 + +## 5.1.9 12 December 2018 + +### Bug fixes: + +* Refactor OWLProfile implementations #638 +* Fix Missing user defined datatype violation in literals #639 +* Fix RDFGraph getSubjectsForObjects caught in infinite loop #809 + +## 5.1.8 1 December 2018 + +### Features: + +* Add OWLClassExpression.isNamed method #790 +* Fix injection problem under OSGi +* Implement Allow Atomic Decomposition to skip assertions #796 +* Expressivity Checker for EL and FL #500 + +### Bug fixes: + +* Fix ReadWriteLock should be injector singleton #785 +* Fix Cyclic import of versioned ontologies fails #788 +* Fix Annotate ontology annotations #791 +* Fix Incorrect documentation for OWLOntologyManager methods. #795 +* DisjointClasses with OWL:Thing produces incorrect axiom #747 +* Fix Concurrent managers with own lock shared with own ontologies #806 + +## 5.1.7 2 September 2018 + +### Features: + +* PROV and TIME vocabularies + +### Bug fixes: + +* Add representativeInstances() to OWLReasoner #772 +* SWRLRule hash code computed incorrectly +* Fix OWLOntology with shared structure causes incorrect RDF/XML #780 + +## 5.1.6 24 July 2018 + +### Features: + +* Remove Guice dependencies +* Upgrade to jsonld-java version 0.12.0 (performance) #763 +* Allow building with Java 10 + +### Bug fixes: + +* Move from Trove4j to HPPC-RT #774 +* Fix incorrect sorting of OBO header tags +* Fix Line breaks in rdfs:label cause invalid FS output #758 +* Fix AutoIriMapper chooses wrong IRIs. #755 + +## 5.1.5 23 April 2018 + +### Features: + +* Add an option to represent version build as strings +* Implement #375 OWLZip reader and writer +* Allow trimming to size after load to be disabled +* do not register deprecated oboparser by default #729 + +### Bug fixes: + +* Fix SWRL variable IRIs violate URN spec #732 +* default IRI for unnamed ontologies is not valid +* doubling of # at the end of default namespace +* IRI should return true for isIRI() +* Fix OWL/XML writes langString unnecessarily #748 +* Fix importsDeclaration not returning imports for *.obo #727 + +## 5.1.4 4 January 2018 + +### Features: + +* Support Authorization header in remote loading + +### Bug fixes: + +* Fix Problem saving ontologies in Turtle #719 +* Fix Null pointer in OWLObjectPropertyManager #723 +* Remove com.google.inject and add exclusion of javax.annotation. #720 + +## 5.1.3 4 November 2017 + +Features: + +* Performance improvements on parsing of large ontologies. + +## 5.1.2 13 October 2017 + +### Features: + +* Accept Headers to include all MIME types with supporting parsers #705 +* Add HasAnnotationValue interface with methods for mapping +* Optional methods for OWLOntologyChange +* Implement efficient way to test if an ontology refers entity type #698 + +### Bug fixes: + +* Do not output xsd:string when unnecessary #640 +* OWL/XML should reject XML files that are not valid OWL/XML #657 +* getFragment advices an non existent replacement #684 +* OWLObject immutable collections sorted #702 +* Sort imports and imports closure #702 +* Sort namespace prefixes for XML serialization #702 +* OWLOntologyMerger fails with ConcurrentModificationException #673 +* Poor performance in OWLImmutableOntologyImpl.getImportsClosure #696 +* Fix AtomicDecomposition throws Nullpointer #695 +* Fix hashcode and equals on OWLOntology differ #694 + +## 5.1.1 25 July 2017 + +### Features: + +* Add REPAIR_ILLEGAL_PUNNINGS property to disable fix of illegal punnings +* Move punning log to warning + +### Bug fixes: + +* Fix Profiles.OWL2_FULL returns Profiles.OWL2_DL #667 +* Fix EntitySearcher.getEquivalentClasses incorrectly returns itself #663 +* OWLEntityRenamer should rename annotation props in ontology annotations +* Fix blank node ids should be NCNames in the RDF/XML output #689 + +## 5.1.0 30 March 2017 + +### Features: + +* Add stream support on reasoning interface. +* Allow SyntacticLocalityModuleExtractor to exclude assertions. #462 +* Explanations: do not fail hard for profile violations +* Latex formatting improvements +* ensure ontology annotations are sorted +* Implement HasApplyChanges.applyChanges returns ChangeApplied #544 +* recompile parsers with javacc 7 +* issue #612 : Add japicmp maven plugin to track API changes +* Implement Zip with dependencies included for non Maven users #584 +* Dependencies update, move to rdf4j + +### Bug fixes: + +* Fix Relating to inferred axiom generators #646 +* Fix duplication and inverseOf properties in generators #646 +* Fix SimpleRenderer writes InverseOf instead of ObjectInverseOf #647 +* Fix nested annotation bug +* Fix Turtle parser failure on some bioportal ontology #610 +* Fix Manchester expression parser bug with data cardinalities #609 + +## 5.0.5 4 January 2017 + +### Bug fixes: + +* Allow supplier for null error messages +* IsAnonymous, isIndividual, isAxiom, isAnonymousExpression on OWLObject +* Performance improved in creating OWLOntologyManager +* Ensure XXE vulnerability is prevented +* Fix Structural sharing in GCIs causes errors #564 +* Fix Issue with serialization - OWLAPI version 3.5.5 #586 +* Fix Problems compiling version5 for Android v24 Nougat #585 +* Fix Order of RDF triples affects annotation parsing #574 +* Fix Property Axiom Generator should check set size #527 +* Fix Imports not properly loaded after all ontologies removed #580 +* Fix Incomplete Parsing of DifferentIndividuals with distinctMembers #569 +* Fix Apache Harmoony SAX parser not supported #581 +* Fix line separators in `DLSyntaxHTMLStorer` #583 +* Fix IRIs with query string cause OFN unparseable output #570 +* Fix Unqualified data restriction considered qualified #576 + +## 5.0.4 16 October 2016 + +### Bug fixes: + +* Serializability issues + +## 5.0.3 10 September 2016 + +### Bug fixes: + +* Fix OMN Parser mistakes punned class for object property #548 +* Fix OWL/XML format does not support SWRL variable IRIs #535 +* Fix Explicit prefix ignored during serialization #529 +* Fix Saving to OFN loses namespaces due to double default prefix #537 +* Fix DL-Syntax HTML formatter issues #536 +* Fix ManchesterOWLSyntaxRenderer SubPropertyOf render inconsistent #534 +* Fix Slow inferred disjoint generator #542 +* Fix Relative Ontology IRI causes missing declaration #557 +* Fix Invalid Turtle ontologies when hash IRIs are used #543 +* Fix Calling setOntologyDocumentIRI reset imports closure cache #541 +* Fix OWLOntology::annotationPropertiesInSignature has duplicates #555 +* Fix Latex Renderer produces bad LaTeX for property inverses #526 +* Fix ManchesterOWLSyntaxParser doesn't handle the OWL 2 datatypes #556 +* Fix Turtle Renderer doesn't escape periods #525 +* Fix Import IRI not resolved correctly in OBO input #523 + +## 5.0.2 7 May 2016 + +### Features: + +* Allow banning of parsers #510 +* Allow disabling banner comments +* Move builders to api to be able to use them in parsers +* Make AxiomType Comparable + +### Bug fixes: + +* Fix performance regression in String.intern() and improve memory footprint +* Fix Default prefix overrides explicit prefixes #522 +* Fix Anonymous individuals parsing problems #494 +* Fix Noisy print messages from logging framework #516 +* Fix SWRL rules with incorrect equals() #512 +* Fix OWL 2 Full Profile #508 +* Fix Annotated entities not declared in RDF/XML #511 +* Fix XML literal is not self contained #509 + +## 5.0.1 19 March 2016 + +### Bug fixes: + +* Fix Fixing punnings fails on dp subDataPropertyOf rdfs:label #505 +* "Dumping remaining triples" displayed when no triples left #502 +* Fix Annotations lost on entity renaming of SWRLRules #501 +* Fix Profile validation throws exception on ontology annotations #498 +* Fix RDF/XML parser failing to load ontology containing XMLLiteral #496 +* Fix #489 makeLoadImportRequest log should be a warning #489 +* Fix Anonymous individuals parsing problems #494 +* Fix Saving fails for ontologies containing XMLLiteral #495 +* Fix Anonymous individuals parsing problems #494 + +## 5.0.0 28 February 2015 + +### Features: + +* Allow overridable and defaultable properties +* FaCT++ AD implementation from OWLAPITOOLS +* Add OWLObjectTransformer to replace any part of an ontology +* Add HasOperands interface +* Ad componentsWithoutAnnotations() to simplify equalsIgnoreAnnotations +* Add componentsAnnotationsFirst() to OWLObject +* Add component() to OWLObject to create a common interface for hashcode +* Add rdf:langString data type +* commons-rdf-api integration +* Add InferenceDepth and convenience methods to OWLReasoner +* OWLRDFConsumer fills guessed type declaration table with blank nodes +* Marked methods returning sets where a stream is available as deprecated +* Update guice version to beta 5 +* Replace Google Optional with Java 8 Optional (#250) +* OWLProfileViolationVisitorEx returns Optional rather than nulls +* Add default methods to OWLOntology for direct add/remove of axioms +* Added a getFormat method to OWLOntology +* Merged visitor adapters into the interfaces with default methods +* isAvailable/get pattern in OWLOntologyDocumentSource changed to Optional +* OWLOntology.getReferencingAxioms() finds any of the OWLPrimitive objects +* Enabled OWLOntologyManager to build and keep an OntologyConfigurator instance +* Declaration of save methods on OWLOntology +* OWLAPI 5 uses Java 8 + + +## 4.5.19 7 November 2020 + +### Bug fixes: + +* Fix OWLParser not ensuring streams are closed on exit #973 +* Error with undeclared classes in domain axioms #962 +* Fix Ontology caches should use weak keys #984 + + +## 4.5.18 23 October 2020 + +### Bug fixes: + +* Fix Performance of signature checks during ontology changes #968 +* Fix Error on RIO renderer when expression has 6000 elements #971 +* Fix OWLOntology#datatypesInSignature to include ontology header #965 +* Fix Ontology not loaded in case of multiple HTTP redirects #954 + + +## 4.5.17 02 July 2020 + +### Features: + +* Let OBO parser follow redirects +* Allow creation of tautologies for n-ary axioms #776 +* Configurable fast pruning window size + +### Bug fixes: + +* Fix javadoc for OWLObject::nestedClassExpressions #937 +* Fix classAssertionAxioms with OWLClassExpression fails #930 +* Fix Include ontology annotations in signature #928 +* Fix Unable to set base directive for turtle writers #938 +* Fix OWLAPI accepts IRIs with leading spaces #940 +* Fix SWRL body reordered when structure shared #936 +* Fix roundtrip through OBO changes IRI of owl:versionInfo #947 + + +## 4.5.16 18 April 2020 + +### Bug fixes: + +* Fix XSD datatypes are erroneously quoted in OBO writer #918 +* Fix referencingAxioms(OWLPrimitive) misses nested literals #912 +* Fix Empty line in META-INF/services/ files causes exceptions #924 + + +## 4.5.15 28 January 2020 + +### Bug fixes: + +* Fix OWLEntityRenamer and anonymous individuals #892 +* Fix Builtin annotation properties lost during parsing #895 +* Deal with OWLAnnotationProperty entities in OWLEntityURIConverter class #896 + + +## 4.5.14 19 October 2019 + +### Bug fixes: + +* Implement Allow gzipped imports #887 +* Fix Race condition in Injector #883 +* Jackson update +* Fix containsReference(OWLEntity) should be deprecated #864 +* Fix Javadoc on applyChange/applyChanges and using the wrong manager #868 +* Fix OWLObjectPropertyExpression#getSimplified() used incorrectly #882 +* Fix Incomplete javadoc on OWLNaryAxiom#asPairwiseAxioms #884 +* Fix OWLNegative*AssertionAxiom#containsAnonymousIndividuals javadoc #885 +* Fix Annotated axiom with anon expression saved incorrectly #881 +* Fix Ontology with relative IRIs is serialized incorrectly #880 +* Fix Ann. annotation with anon individual saved in RDF incorrectly #877 +* Fix Annotations dropped if annotation property is undeclared #875 +* Fix SAXException from AutoIRIMapper at debug logging level #878 +* Ensure isAnonymous is implemented correctly #867 +* Fix Null pointers with imports and relation declarations #859 +* Amend base and escaped characters in Tutle parsing #857 + +## 4.5.13 02 June 2019 + +### Features: + +* Add support for custom tags in obo files. #848 + +### Bug fixes: + +* Fix OWLLogicalEntity is not an OWLAnnotationProperty #847 +* Security: Jackson to 2.9.9 +* Fix Manchester syntax parser crashes on class/property punning #851 +* Fix OBO parser does not support qualifier block #852 + +## 4.5.12 06 May 2019 + +### Features: + +* Add support to load an ontology from classpath #837 +* Implement Allow annotations to be skipped in module extraction #838 + +### Bug fixes: + +* Fix Multiple Ontology Definitions should obey strict parsing #840 +* Fix Unnecessary dc prefix added by Manchester syntax parser #845 +* Fix OWLDataFactory::getLiteral error with empty string and integer #846 +* Fixed several incorrect XSD datatype matching patterns #844 + +## 4.5.11 17 April 2019 + +### Bug fixes: + +* Fix HTTP 307 and HTTP 308 redirects are not followed (in 4.x) #821 +* Fix Missing escape character in OBO output #828 +* Fix OWLDataPropertyAxiom not a subinterface of OWLPropertyAxiom #831 +* Fix MaximumNumberOfNamedSuperclasses should count super classes #836 +* Fix OWLOntology::getGeneralClassAxioms slow #839 +* Fix roundtrip of escaped values #833 + +## 4.5.10 14 March 2019 + +### Bug fixes: + +* Fix HTTP 307 and HTTP 308 redirects are not followed (in 4.x) #821 +* Fix Ensure allValuesFrom axioms are not lost #808 +* Fix EOFException in CustomTokenizer #813 +* Fix Cyclic imports and missing declarations cause parsing error #798 +* Fix Unescaping characters: OBOFormatParser#handleNextChar() #822 +* Fix IRI PREFIX_CACHE instance uses too much memory #825 + + +## 4.5.9 1 February 2019 + +### Bug fixes: + +* Jackson version to 2.9.8 +* Fix compatibility with Guava 27 #814 +* Fix OBO renderer stuck with untranslatable axioms on concurrent managers +* Fix Annotations on DifferentIndividualsAxioms lost #816 +* Fix No roundtrip for IRIs with colons in the fragment or path #817 + +## 4.5.8 22 December 2018 + +### Features: + +* Refactor OWLProfile implementations #638 + +### Bug fixes: + +* Fix Missing user defined datatype violation in literals #639 +* Fix RDFGraph getSubjectsForObjects caught in infinite loop #809 +* Fix DLExpressivity checker never computes anything #810 + +## 4.5.7 1 December 2018 + +### Features: + +* Add OWLClassExpression.isNamed method #790 +* Fix injection problem under OSGi +* Expressivity Checker for EL and FL #500 + +### Bug fixes: + +* Fix ReadWriteLock should be injector singleton #785 +* Fix Cyclic import of versioned ontologies fails #788 +* Fix Annotate ontology annotations #791 +* Fix Incorrect documentation for OWLOntologyManager methods. #795 +* DisjointClasses with OWL:Thing produces incorrect axiom #747 +* Fix Concurrent managers with own lock shared with own ontologies #806 + +## 4.5.6 6 September 2018 + +### Bug fixes: + +* OSGi issues fixed + +## 4.5.5 2 September 2018 + +### Features: + +* PROV and TIME vocabularies + +### Bug fixes: + +* Prefix splitting at wrong place with percent encoded IRI #737 +* Fix OWLOntology with shared structure causes incorrect RDF/XML #780 + +## 4.5.4 26 July 2018 + +### Features: + +* Remove Guice dependencies +* Upgrade to jsonld-java version 0.12.0 (performance) #763 +* Build with Java 10 + +### Bug fixes: + +* Move from Trove4j to HPPC-RT #774 +* Literals with no lang and string literals must equal each other +* Fix OWLLiteral.parseDouble should throw NumberFormatException #764 +* No need for Guice and Guava version updates +* Amend pom files to build vaild osgi distribution #768 +* Fix incorrect sorting of OBO header tags +* Fix Line breaks in rdfs:label cause invalid FS output #758 +* Fix AutoIriMapper chooses wrong IRIs. #755 + +## 4.5.2 22 April 2018 + +### Features: + +* Add an option to represent version build as strings +* Implement #375 OWLZip reader and writer +* Signature cache for ontologies +* Allow trimming to size after load to be disabled +* do not register deprecated oboparser by default #729 + +### Bug fixes: + +* Fix SWRL variable IRIs violate URN spec #732 +* default IRI for unnamed ontologies is not valid +* doubling of # at the end of default namespace +* IRI should return true for isIRI() +* Fix OWL/XML writes langString unnecessarily #748 + +## 4.5.1 7 December 2017 + +### Features: + +* Support Authorization header in remote loading + +## 4.5.0 13 October 2017 + +### Features: + +* Accept Headers to include all MIME types with supporting parsers #705 +* Add HasAnnotationValue interface with methods for mapping +* Optional methods for OWLOntologyChange +* Implement efficient way to test if an ontology refers entity type #698 + +### Bug fixes: + +* OWL/XML should reject XML files that are not valid OWL/XML #657 +* OWLObject immutable collections sorted #702 +* Sort imports and imports closure #702 +* Sort namespace prefixes for XML serialization #702 +* OWLOntologyMerger fails with ConcurrentModificationException #673 +* getFragment advices an non existent replacement #684 +* Fix Poor performance in OWLImmutableOntologyImpl.getImportsClosure #696 + +## 4.3.2 25 July 2017 + +### Features: + +* Add REPAIR_ILLEGAL_PUNNINGS property to disable fix of illegal punnings +* Move punning log to warning + +### Bug fixes: + +* Fix Profiles.OWL2_FULL returns Profiles.OWL2_DL #667 +* Fix EntitySearcher.getEquivalentClasses incorrectly returns itself #663 +* Fix blank node ids should be NCNames in the RDF/XML output #689 +* OWLEntityRenamer should rename annotation props in ontology annotations + +## 4.3.1 27 March 2017 + +### Features: + +* Allow SyntacticLocalityModuleExtractor to exclude assertions. #462 +* Explanations: do not fail hard for profile violations + +### Bug fixes: + +* Fix Relating to inferred axiom generators #646 +* Fix duplication and inverseOf properties in generators #646 + +## 4.3.0 22 March 2017 + +### Features: + +* Implement HasApplyChanges.applyChanges returns ChangeApplied #544 +* Implement Zip with dependencies included for non Maven users #584 +* issue #612 : Add japicmp maven plugin to track API changes +* dependencies update + +### Bug fixes: + +* Fix OWLLiteral produce different hash codes in version 4 #645 +* Multiple nested annotations fail in RDF/XML #470 +* Parsing of nested anonymous nodes broken in 4.1.1 #478 +* ensure ontology annotations are sorted +* Fix Turtle parser failure on some bioportal ontology #610 +* Fix Manchester expression parser bug with data cardinalities #609 + +## 4.2.8 4 January 2017 + +### Bug fixes: + +* Fix Structural sharing in GCIs causes errors #564 +* Fix Issue with serialization - OWLAPI version 3.5.5 #586 +* Fix Order of RDF triples affects annotation parsing #574 +* Fix Property Axiom Generator should check set size #527 +* Fix Imports not properly loaded after all ontologies removed #580 +* Performance improved in creating OWLOntologyManager +* Fix Incomplete Parsing of DifferentIndividuals with distinctMembers #569 +* Fix Apache Harmoony SAX parser not supported #581 +* Ensure XXE vulnerability does not exist +* Fix line separators in `DLSyntaxHTMLStorer` #583 +* Fix IRIs with query string cause OFN unparseable output #570 +* Fix Unqualified data restriction considered qualified #576 +* Fix OWLOntologyManager in OWLImmutableOntologyImpl should be @Nullable #568 + + +## 4.2.7 16 October 2016 + +### Bug fixes: + +* Serialization issues + + +## 4.2.6 10 September 2016 + +### Bug fixes: + +* Fix OMN Parser mistakes punned class for object property #548 +* Fix OWL/XML format does not support SWRL variable IRIs #535 +* Fix Explicit prefix ignored during serialization #529 +* Fix Saving to OFN loses namespaces due to double default prefix #537 +* Fix DL-Syntax HTML formatter issues #536 +* Fix ManchesterOWLSyntaxRenderer SubPropertyOf render inconsistent #534 +* Fix Slow inferred disjoint generator #542 +* Fix Relative Ontology IRI causes missing declaration #557 +* Fix Invalid Turtle ontologies when hash IRIs are used #543 +* Fix Calling setOntologyDocumentIRI reset imports closure cache #541 +* Fix Latex Renderer produces bad LaTeX for property inverses #526 +* Fix ManchesterOWLSyntaxParser doesn't handle the OWL 2 datatypes #556 + +## 4.2.5 17 May 2016 + +### Bug fixes: + +* Fix Turtle Renderer doesn't escape periods #525 +* Fix Import IRI not resolved correctly in OBO input #523 + +## 4.2.4 7 May 2016 + +### Bug fixes: + +* Fix Default prefix overrides explicit prefixes #522 +* Fix Anonymous individuals parsing problems #494 +* Fix OWL 2 Full Profile #508 +* Fix Annotated entities not declared in RDF/XML #511 +* Fix XML literal is not self contained #509 + +### Features: + +* Allow banning of parsers #510 +* Allow disabling banner comments +* Fix Noisy print messages from logging framework #516 + +## 4.2.3 19 March 2016 + +### Bug fixes: + +* Fix Fixing punnings fails on dp subDataPropertyOf rdfs:label #505 + +## 4.2.2 15 March 2016 + +### Bug fixes: + +* Fix RDF/XML parser failing to load ontology containing XMLLiteral #496 +* Fix Profile validation throws exception on ontology annotations #498 +* Fix Annotations lost on entity renaming of SWRLRules #501 +* Fix "Dumping remaining triples" displayed when no triples left #502 + +## 4.2.1 5 March 2016 + +### Bug fixes: + +* Fix Anonymous individuals parsing problems #494 +* Fix makeLoadImportRequest log should be a warning #489 +* Fix Saving fails for ontologies containing XMLLiteral #495 + +## 4.2.0 28 February 2016 + +### Features: + +* Allow overridable and defaultable properties + +### Bug fixes: + +* Fix EntitySearcher.getDomains(OWLAnnotationProperty, OWLOntology) returns the range axioms instead of the domain axioms #492 + +## 4.1.4 3 February 2016 + +### Features: + +* Add OWLObjectTransformer to replace any part of an ontology #487 +* Add OWLLiteralReplacer to replace literals with different values #487 +* Throw error on malformed ontologies when parsing is strict (avoid Error1 classes) #444 + +### Bug fixes: + +* Fix RBox axiom types #479 +* Fix Parsing of nested anonymous nodes broken in 4.1.1 #478 +* Fix Error in rdf handling of deep nested annotations +* Fix EntitySearcher.subPropertiesFilter is broken #486 +* Fix Cyclic imports cause illegal punning #483 +* Fix OWLOntologyManager.copyOntology does not copy imports #480 +* Fix Changes not successfully applied broadcasted as applied #476 +* Add restriction on aduna packages #471 +* Fix BOM removal wrapper is applied to all input streams #212 +* Fix Serialization into incorrect OWL syntax #468 +* Fix Constraint Sesame Versions in OSGi Imports #471 +* Fix ExplanationOrdererImpl.SeedExtractor throws exception #469 +* Fix for Multiple nested annotations fail in RDF/XML #470 + +## 4.1.0 25 October 2015 + +### Features: + +* Port protege-owlapi concurrency support to the OWL API +* Enabled the creation of a concurrent manager +* Part of Add transactional support to OWLOntology #382 : ability to rollback the application of a set of changes if one fails. Added a ChangeApplied.NO_OPERATION to track those changes that did not have any effect (e.g., adding an axiom that is already present or removing an axiom that is not present). +* ManchesterOWLSyntaxParser could use a convenience method parseClassExpression(String s) #384 +* Add setting to use labels as banner comment or use IRIs as before +* Add config to switch saving all anon individuals +* Enforce correct argument types for OWLObjectInverseProperty in default impl +* Add control flag to structure walking to allow annotations to be walked +* Reduce space used by OBO Parser +* update jackson dependency to 2.5.1 + +### Bug fixes: + +* OWLImmutableOntologyImpl.asSet() assumes input iterable is coming from a duplicate free collection #404 +* OWLOntologyManagerImpl.getVersions() calls get() on Optional without checking if the contained value is present #401 +* OWLOntologyManagerImpl tests storers with keys rather than canStoreOntology #400 +* setOntologyLoaderConfigurationProvider should accept a javax.inject.Provider #399 +* Cleaned distribution jar +* Losing Annotations on Annotation Assertion Axioms #406 +* Return types of RemoveAxiom(s) vs. AddAxiom(s) #408 +* Examples file needs review #407 +* BFO fails to load in API version 4.0.X #405 +* Fix RDF/XML renderer does not like properties using urns (or almost urns) #301 +* All anonymous individuals are remapped consistently upon loading. #443 +* Only output node id for anonymous individuals if needed +* Anon individuals appearing more than once as objects #443 +* Sort annotation assertions on output for manchester syntax #332 +* OWL 2 profile validation mistakes #435 +* [Typedef] created_by don't support space #419 +* ttl namespace abbreviations not preserved on serialization #421 +* Use EntitySearcher.getAnnotationObjects() when interested only in the object of annotation assertion axioms on an entity rather than the annotations on the annotation assertion axioms. +* convincing owlapi-distribution to export rio dependencies +* RDF issues testing 4.1.0 RC 1 #412 +* Annotation subproperty/domain/range disappear after save/load cycle (punning enhancement) #351 + + +## 4.0.2 17 April 2015 + +### Features: + +* Simple OWL/FSS IRI sniffing for AutoIRIMapper. +* Fix #373 Individuals in SWRL rules get extra type +* XZ compression support +* Sorting of FunctionalSyntaxObjectRenderer +* Sort untyped IRI Annotation Assertions, general axioms. +* Sort axiom Annotations, if they are output using the translateAnnotations method. Negative property assertions not yet ordered; neither are nary axioms and class expressions. +* Add legacy files to the OSGI distribution for version 3.5 backwards compatibility. +* Some reasoners may not support certain types of reasoning. They may also not support OWLReasoner::isEntailed, and hence may return false for all calls to OWLReasoner::isEntailmentCheckingSupported. +* Support preserving, transferring, and adding annotations during OBO Macro expansion +* Add Extensions to link document formats and common file extensions +* Optimise annotation lookup for module extraction enrichment +* Change strategy for MapPointer storage: do all initial insertions in a list, and turn it into a THashSet upon first call to trimToSize or any get/size calls +* Add benchmarking util to load ontology then dump to an hprof file for use with MAT +* Improve conversion from OWL to OBO, add test case + +### Bug fixes: + +* Fix PriorityCollectionSorting should be fixed at manager creation time #395 +* Fix OWLOntologyManagerImpl.getVersions() calls get() on Optional without checking if the contained value is present #401 +* Fix XMLLiterals should be output as XML, not quoted XML #333 +* Fix Should RDF/XML Renderer include annotation assertions from the entire closure? #371 +* Fix Using a PriorityCollection for IRI mappers (and perhaps other things) is confusing #386 +* Fix THashSets got left using default load factor (0.50) after construction is finished. #380 +* Fix RDF Consumer failing to guess property types #322 +* Fix NonMappingOntologyIRIMapper confuses extra OWLOntologyIRIMapper implementations #383 +* Fix Data property with xsd:integer range parsed as Object property (RDF/XML source) #378 +* Fix imports in OWL Manchester Notation fail #347 +* Fix ELProfile incorrectly rejects DisjointClasses axioms. #343 +* Fix OWLRDFConsumer fills guessed type declaration table with blank nodes #336 +* Fix #338 OWL-API: DOCTYPE declaration missing in XML serialization +* Fix #337 Axiom Equality short-circuits are in the wrong place +* Fixed bug when rendering anonymous individual in Manchester OWL syntax. +* Reverted incorrect setting of all packaging types to bundle + +## 4.0.1 22 November 2014 + +### Features: + +* trimToSize available to cut ontology internals collections to minimal size after loading (Simon Spero) +* various memory optimizations and caching of rarely used values removed (Simon Spero) +* use of Trove collections for ontology internals +* OBOFormat: Configuration option to skip validation before writing OBO file #290 + +### Bug fixes: + +* fix a multithread bug revealed by owlapitools tests +* fix #299 roundtrip errors on TriX and various other syntaxes +* fix #292 SWRL rules saved by older versions of OWLAPI/Protege lose annotations +* fix #288 Errors with object property assertions with inverseOf properties +* fix #289 Manchester syntax errors: inverse() not recognized, SWRL rules rendered twice +* fix #287 Error parsing RDF/Turtle with triple quoted literals - mismatching single and double quotes +* fix #281 OntologyIRIShortFormProvider does wrong shortform generation + + +## 4.0.0 10 September 2014 + +Supported Java versions: Java 7, Java 8 + +### Features: + +* added HasAnnotationPropertiesInSignature to uniform treatment of annotation properties +* added missing EntitySearcher methods for negative property assertions +* Use Trove collections for ontology internals +* improved performance of OWLAxiomImpl.equals +* Transform functions from Collection and Collection to Collection +* PMD critical violations addressed +* fix ServiceLoader use to be OSGi compatible +* create osgidistribution: osgidistribution is a jar with embedded dependencies and including the compatibility module. It addresses the issues due to the OWLAPI dependencies not being wrapped in OSGi bundles separately. +* enabled OWLOntologyManager to build and keep a loader configuration +* OBO 1.2 ontologies cannot be parsed by the 1.4 parser. Added 1.2 parser from OWLAPITOOLS to compatibility package. +* added saveOntology() methods to OWLMutableOntology +* Add a copy/move ontology method to OWLOntologyManager #12 +* Search introduced to replace forSuperPosition, forSubPosition, ignoreAnnotations booleans +* Imports.INCLUDED, Imports.EXCLUDED introduced instead of boolean arguments #156 +* introduced ChangeApplied to simplify code around applying changes and remove null warnings +* Introduction of Searcher with transform functions +* OWLOntology now exposes a new method for searching for axioms referring an entity, abstracting all various getAxiomsBy... methods. +* Refactor OWLSignature for uniform imports closure use +* Refactored OWLAxiomCollection for uniform use of import closure +* Added targeted parsing to allow one and only one parser to be tried on a document input source. Takes into account MIME type as well. +* Use MultiMap from Guava throughout V4.0.0 #153 +* OBO parser updated and replaced with oboformat 5.5 release +* @Nonnull annotations and warnings +* Centralised and uniformed sax parser factories +* OWLOntologyID to use Optional #160 +* Refactored property hierarchy to remove generics. +* Added an OWLParser implementation to enable actual use of DL parser +* Added a pairwise visitor, changed storage strategy for nary axioms. The pairwise visitor interface is a functional interface that is applied to all distinct pairs in a collection of objects. +* Added asPairwiseAxioms to all nary axiom types +* Added HasPriority annotation and comparator for prioritizable objects +* Added PriorityCollection for managing injected collections +* Added ServiceLoader adapter for Guice injection +* Added ManchesterOWLSyntaxParser interface to api +* OWLAPITOOLS profiles and fixers included +* Added Profiles enumeration and supported OWL profile for known reasoners. +* Dependency injection enabled for fixers. +* Added Guice module for creating OWLOntologyManager and OWLDataFactory +* Introduced OWLOntologyBuilder to allow swapping OWLOntology implementations via Guice +* Service loader module in api to be used independently of the owlapi-impl module +* Add RDFa parser and use static META-INF/services files for owlapi-rio +* Add JSON-LD support +* Add rdf:langString from RDF 1.1 to OWL/RDF vocabulary. +* Better BOM treatment through Apache BOMInputStream +* Use SLFJ for logging +* Guava 17 +* Guice 4.0-beta +* Added jsr305 for Nonnull and Nullable annotations +* Fix build and javadoc for Java 8 +* Do not raise violations from entities used only in declarations. +* Do not add declarations for illegal punnings when saving ontologies #112 +* Do not cache any literals in OWLDataFactoryInternalsImpl. Overall improvement of about 9% when parsing Gene Ontology in FSS. +* Implement Default prefix manager in prefix ontology format objects cannot be overriden #9 +* Implement automatic retries when loading from URLs, managed through OWLOntologyLoaderConfiguration #66 +* Switched OWLDataFactory IllegalArgumentExceptions to NullPointerExceptions #131 +* Handle annotations on punned types when rendering RDF #183 +* Add OWLOntologyManagerFactory and code to allow use of RioOWLRDFParser through an injector +* Convert RioParserImpl to stream statements through wherever possible +* Default datatype in RDFLiteral to PLAIN_LITERAL. +* Made generated classes package protected +* Rename OWLObjectRenderer to FunctionalSyntaxObjectRenderer +* OWLReasoner change lists generic +* Moved OWLOntologyFormat implementation to formats package +* Performance improvement for rdf/xml rendering +* Optimised functional renderer and prefix manager +* feature: OBO parser replaced with oboformat. +* OWL2Datatype implements HasIRI +* Add XSD IRIs simple parsing support #56 +* GZip read/write ability +* Manchester OWL syntax cleanup + +### Bug fixes: + +* Fix #278 AutoIRIMapper is not namespace aware +* Direct imports result not updated correctly after manual load #277 +* fix #275 DL Syntax rendering of disjoint classes missing comma +* fix #271 OWLOntology.getXXXInSignature(boolean) and similar methods +* fix #270 Add OWLOntology.getReferencingAxioms(OWLPrimitive) +* fix #268 Add documentation to OWLOntologyID to clarify the relationship between isAnonymous() and getOntologyIRI() +* fix #267 Consider adding containsXInSignature methods that do not have an imports flag to OWLOntology. +* fix #254 OWLAsymmetricObjectPropertyAxiom not rendered in DL Syntax +* fix OWLDocumentFormat as interface #258 #259 +* fix #260 and fix #261 data and object cardinality are quantified restricitons +* fix #255 PrefixOWLOntologyFormat is missing from the compatibility module +* fix #253 StructuralReasoner.getSameIndividuals does not behave as advertised +* Fixed #198 A SubClassOf B will not parse +* Fixed IRI with a space: %20 escape #146 +* Old OWLEntityCollector brought forward as DeprecatedOWLEntityCollector +* Fixed serialization warnings reported in #163 +* Use AtomicLong for concurrency support in gzip document sources +* Moved transitive object property type to rbox +* Set turtle default prefix slash aware #121 +* Fixed #116 import statement erroneously names anonymous ontology +* Added test for roundtripping annotated SWRL rules and datatype definitions +* Fixed annotations on datatype definition axioms fixed in OWL/XML +* Fixed #20 and #60 use zipped buffer for StreamDocumentBase +* Fixed #71 Misleading message on resolving illegal IRI +* Fixed variable rendering in Manchester OWL Syntax to preserve ns. +* Fixed #46 Round tripping error in functional syntax +* Fixed #40 RDFGraph.getSortedTriplesForSubject throws exception in Java7 +* Fixed infinite recursion on cyclic import structures when declaration does not match location. + +## 3.4.10 18 January 2014 + +### Features: + +* Improved feature 32 implementation (simple SWRL variables rendering) +* javadoc warnings and errors removed to allow building with Java 8 +* refactored OWLAxiomVisitorExAdapter for general use +* performance improvement for rdf/xml +* Renamed variables, added explicit flush. Fixes #67 slow functional sytnax renderer on Java 6 +* default, final and abstract classes changed to allow interface verification +* add oraclejdk8 early access build to travis +* update oboformat class names to sync with oboformat project +* make OBOFormatException extend OWLParserException + +### Bug fixes: + +* Fixes #72 Manchester syntax roundtrip of doubles and SWRL rules fails +* Fixes #24 Manchester Syntax writer generates unparsable file +* simple renderer writes duplicate annotations +* Optimised functional renderer and prefix manager +* Fix #63 null pointer exception loading an ontology and fix #64 empty ontology returned +* Fixes #63 OBO Ontology Parsing throws NullPointer +* updated OSGi settings for oboformat, module name, dependencies +* fix bundle configuration for oboformat + +## 3.4.9 25 November 2013 + +### Features: + +* Added default methods and return values for a few visitor adapters +* #57 Reimplement NodeID so that it doesn't use an inner class +* #56 parse things like xsd:string easily +* OBO parser replaced with oboformat. Original code at: https://code.google.com/p/oboformat/ + +### Bug fixes: + +* Fixed wrong naming of gzip file source and target and added stream only versions. +* Restore UnparseableOntologyException interface +* Added back deprecated parseConstant for compatibility with Pellet CLI code. Warning: it has bugs. + + +## 3.4.8 02 November 2013 + +### Features: + +* GZip read/write ability. Compressed gzip input and output streams, but make sure to close the stream in the calling code. +* OSGI dependency removed +* Added Namespaces.inNamespace +* Made ParserException to extend OWLParserException, and OWLParserException a runtime exception. +* Tidying up Manchester OWL Syntax parser code +* Added to the documentation on getOWLDatatype(OWLDataFactory) +* Added a convenience method to convert an OWL2Datatype object to an OWLDatatype. +* mvn install and mvn deploy now make aggregate sources available. +* Added more well known namespaces, removed non-explanatory comments +* Added RDFa Core Initial Context prefixes and other well known prefixes and prefix names. +* GITHUB-10 : Add RDFa Core Initial Context prefixes +* Extend Namespaces enum with common prefixes + +### Bug fixes: + +* Fixes #40 Fixes #7 RDFGraph.getSortedTriplesForSubject throws exception in Java7 Refactored TripleComparator into RDFTriple and RDFNode as Comparable +* DLQueryExample did not print the StringBuilder with the answers +* Fixes #50 Null anonymous individual parsing ObjectHasValue from OWL/XML +* Fixes SF 313 Man Syntax Parser gives facets unexpected datatype +* Fixes SF 101 Manchester OWL Syntax Parser doesn't do precedence correctly +* Fixes #43 Functional Syntax Parser does not support comments +* Fixes #41 Parsing error of SWRL atom. +* Fixes #46 Round tripping error in functional syntax +* Fixes #37 setAddMissingTypes logging if disabled +* Missed serialization transients and tests, serialization bug fixes +* Patch IRI.create(String,String) to match IRI.create(String) + +## 3.4.5 25 July 2013 + +### Features: + +* Refactored DefaultPrefixManager to expose addPrefixes +* Updated pom files for OSGI compatible artifacts. +* Allow override of DefaultPrefixManager in PrefixOWLOntologyFormat +* Add CollectionFactory.getExpectedThreads +* Reduce expected threads from 16 to 8 to improve general performance + +### Bug fixes: + +* literal parsing error was stopping HermiT builds with 3.4.4. +* errors in OSGI support were stopping Protege from using the feature. +* Fix #370 Typo in website/htdocs/reasoners.html. +* Fixed a bug with large integer values being parsed as negative ints. +* Fix infinite recursion on cyclic import structures. +* Reverted the use of ThreadLocal as this causes memory leaks in webapps. +* Bug #343 SWRL roundtrip in manchester syntax + +## 3.4.4 19 May 2013 + +Features and updates implemented: + +* feature 103 - Add methods to get EntityType names. +* Updated IRI prefix caching to use thread local caches rather than synchronized caches. +* added test for annotation retrieval for anonymous individuals. +* WeakIndexCache vulnerability fixed. +* Improved redirect following. +* Added method to OWLOntologyLoaderConfiguration to disable cross protocol redirects on URLConnections. +* Added parameter to OWLOntologyFormat for temp files, default disabled. +* Update all JavaCharStream versions to fix the UTF BOM issue. +* Travis Integration (on github). +* Update KE interface with getBlocker method. +* OSGI compatible build. +* Removed IRI.toString() call when checking blank nodes. +* Change logging of remaining triples to use less memory. +* updates for javadoc. +* Update Mockito to 1.9.5. + +### Bug fixes: + +* Bug #369 IRI.create(String) uses / and # to look for namespace and fragments. +* Bug #348 ManchesterOWLSyntax round trip problem with disjoint classes. +* Bug #269 single anonymous individual split in two on save to RDF. +* Bug #319 redirects from http to https are not followed. +* Bug #367 Serving ontologies from github as well. +* Bug 4 (github) Missing method in OWLIndividual. +* Bug 359 Incorrect Javadoc in OWL2DatatypeImpl and redundant javadoc. +* Bug 360 - Axiom annotations are not parsed correctly. +* Bug 364 Null pointer checking for containment of anonymous ontologies. +* Bug #363 Turtle parser fails when loading valid Turtle document. +* Bug 362 - owlapi files in temp folder. +* Bug 357 duplicate axioms saving in OWL functional syntax. +* Bug 355 - added assertions. Ability to parse 1+e7 as 10000000. +* Bug 355 - Turtle Parser + Integer format Problem. +* OntologyAlreadyExist bug when calls are made too fast. + + +## 3.4.3 26 Jan 2013 + +Features implemented: + +* Updated OWLFunctionalSyntaxFactory with more methods. +* Removed deprecated method calls. +* Test package broken up in smaller packages. +* Web site updated and added to version management. + +### Bug fixes: + +* Changed VersionInfo message default to provide more information. +* Bug 354 fixed: There is AnnotationChange, but no AnnotationChangeData +* Bug 353 fixed: SimpleRenderer renders SubDataPropertyOfAxiom wrong. +* Bug 351 fixed: QNameShortFormProvider swapped prefix and iri. +* Bug 352 fixed: SimpleRenderer does not escape double quotes in literals. + + +## 3.4.2 4 December 2012 + +Features implemented: + +* Repository migrated to Git. +* Fixed memory leak with OWLObject signatures never being released once cached. +* Improved Serializable implementation. +* Made timeout property functional. +* 3585007 Make OWLAxiomChange.isAdd(). +* 3579488 Clean documentation page. +* 3578004 Javadoc OWLRDFVocabulary. +* 3578003 Add OWLOntologyManager.removeOntology(OntologyID). +* 3578002 Add new constructor for SetOntologyID. +* 3576182 Bump minimum java version to 1.6. +* 3575834 Improvements to OWLOntologyManager and related contrib. +* 3566810 Lack of support in OWLOntologyManager for version IRIs. +* 3521809 KRSS parser throws Error instead of RuntimeException. + +### Bug fixes: + +* Some OWLLiterals cannot be optimised: -0.0^^xsd:float, 01^^xsd:int (optimisation with primitive types makes reasoners queasy in combination with W3C tests). +* 3590243 hashCode for literals inconsistent. +* 3590084 misuse of XMLUtils.getNCNameSuffix(). +* 3581575 OWLOntologyDocumentAlreadyExistsException in OWL API 3.4.1. +* 3580114 IRI isAbsolute method. +* 3579862 OWLDataFactory.getRDFPlainLiteral creates new objects. +* 3579861 rdf:PlainLiteral is not in the allowed OWL2EL datatypes. + +## 3.4.1 16 September 2012 + +### Features: + +* 3578004 OWLRDFVocabulary Javadoc +* 3575834 Improvements to OWLOntologyManager and related contrib + +### Bug fixes: + +* 3463200 rdf/functional round trip problem (anonymous individuals) +* 3341637 round trip problem with owl functional or rdf/xml syntax +* 3576182 Bump minimum java version to 1.6 (Fixed the bugs, moved the request to feature requests) +* 3497161 Manchester syntax imports +* 3403855 Imports of multiple ont docs containing the same ont fails +* 3491516 unhelpful Manchester parse exception +* 3536150 TypeOntologyHandler/TPVersionIRIHandler overwrite ontologyID +* 3314432 Manchester OWL parser does not handle data ranges in rules +* 3186250 annotation assertion lost when annotation prop undeclared +* 3309666 [Turtle] Parsing turtle files containing relative IRIs +* 3562296 Switch version 3.4.1 to 3.4.1-SNAPSHOT +* 3560287 Is QNameShortFormProvider deprecated? +* 3566820 Missing Imports are not reported +* 3306980 file in Manchester OWL Syntax with BOM doesn't parse +* 3559116 Wrong VersionInfo in OWL-API 3.4 release +* 2887890 Parsing hasValue restrictions with punned properties fails +* 3178902 RDF/XML round trip problem with 3-way equivalent classes +* 3174734 ManSyntax fails to read ontology with single data property +* 3440117 Turtle parser doesn't handle qnames with empty name part + +## 3.4 12 August 2012 + +This version restructures the Maven modules into six modules: api, impl, parsers, +tools, apibinding and contract. Code is unchanged, only its organization in +the SVN is changed. + +To split the dependencies accordingly, DefaultExplanationOrderer is in +contract and is only a shell for ExplanationOrdererImpl, which does not +depend on OWLManager directly. This enables the tools module to be +used with a different apibinfing without recompilation. + +### Bug fixes: + +* 3554073 Manchester Syntax Parser won't parse DisjointUnionOf +* 3552028 DataFactory returns integer instead of double restrictions +* 3550607 property cycle detection does not work +* 3545194 OWLEquivalentObjectProperties as SubObjectPropertyOfAxioms +* 3541476 OWLRDFConsumer.getErrorEntity counter is not thread safe +* 3541475 Remove shared static in OWLOntologyXMLNamespaceManager +* 3535046 Use ArrayList instead of TreeSet in TurtleRenderer +* 3532600 Use AtomicInteger in OWLOntologyID for counter + +### 3.3 15 May 2012 + +This version wraps together some minor bug fixes and some performance improvements for loading time and memory footprint for large ontologies. +Maven support has been much improved, thanks to Thomas Scharrenbach's efforts and Peter Ansell's feedback and suggestions. + +### Features: + +* Performance improvements at loading time + +### Bug fixes: + +* OBO Parser updated to be more compliant with the latest draft of the OBO syntax and semantics spec. +* OBO Parser doesn't expand XREF values (3515525) +* Integrating with OpenRDF (3512217) +* maven should use snapshot versions during development (3511755) +* junit should be in maven test scope (3511754) +* mvn clean install requires gpg key (3511732) +* OWLOntologyManager.contains(IRI) bug (3497086) +* Functional and Manchester syntax writers prefix problem (3479677) +* SyntacticLocalityModuleExtractor and SubAnnotationPropertyOf (3477470) +* Ignored Imports List uses the wrong IRIs (3472712) +* OWLLiteralImpl corrupts non-ascii unicode (3452932) +* OWLOntologyXMLNamespaceManager QName problem (3449316) +* MultiImportsTestCase assumes incorrect working directory (3448125) +* Mismatch between HasKeyTestCase and corresponding resource (3447280) +* functional Renderer: OWLObjectRenderer swaps SWRL variables (3442060) +* maven build fails because of dependency issue (3440757) +* manchester owl syntax doesn't handle rules with anon classes (3421317) +* RDFTurtleFormatter doesn't escape '\' (3415108) +* RDF consumer does not check for all annotated axiom triples (3405822) +* mis-parsing/mis-serialization of haskey (3403359) +* Literal not a builtin (3305113) +* OWL API throws NullPointerException loading ontology (3302982) + +## 3.2.1 22 July 2011 + +This version of the API is released under both LGPL v3 and Apache license v2; developers are therefore free to choose which one to use. + +### Features: + +* Tutorial code has been added following the OWLED 2011 tutorial (subpackage tutorialowled2011); +* A visitor to determine whether a set of axioms is a Horn-SHIQ ontology has been added (HornAxiomVisitorEx.java). + +### Bug fixes: + +* Some test files and extra modules had not had their copyright notices updated to the new license; this has now been fixed. + +## 3.2.3 27 May 2011 + +This version of the API is released under both LGPL v3 and Apache license v2; developers are therefore free to choose which one to use. + +### Bug fixes: + +* MAVEN support has been fixed (3296393). +* Some minor problems with rdfs:Literal have been fixed (3305113). +* Parsers and renderers for various languages have had some corner case errors fixed (3302982, 3300090, 3207844, 3235181, 3277496, 3294069, 3293620, 3235198). +* An error in OWLOntologyManager.removeAxioms() which was throwing ConcurrentModificationExceptions when called on a specific axiom type has been fixed (3290632). +* OWLOntologyLoaderConfiguration has been introduced to provide ontology wise parsing configuration (strict and lax parsing modes now enabled) (3203646) More options coming up. +* Parsers no longer leave streams open when a parsing error is detected (3189947). + + +## 3.2.2 17 February 2011 + +### Bug fixes: + +* In RDF based serialisations, type triples for entities that don't have "defining axioms" don't get added even if the renderer is instructed to type undeclared entities (related to 3184131). Fixed. +* The RDF parser would not recognise XSD datatypes that aren't OWL 2 Datatypes even in lax parsing mode (related to 3184131). Fixed. +* OWLOntologyManager.createOntology() methods don't set the document IRI of the created ontologies as adverstised if there aren't any ontology IRI mappers installed (3184878). Fixed. + + +## 3.2.1 4 February 2011 + +### Bug fixes: + +* Issues with -INF as serialisation for -infinity for floating point literals. Fixed. +* Null pointer exception can be thrown by OBO parser (3162800). Fixed. +* OWLOntologyManager.loadOntology() can throw unchecked exceptions (IllegalArgumentException) (3158293). Fixed. +* OWLOntologyAlreadyExistsException get wrapped as as a parse exception by the OBO parser. (3165446). Fixed. +* OWLRDFConsumer (OWL RDFParser) used owl:Datatype instead of rdfs:Datatype. Fixed. +* OWLOntology.getDisjointUnionAxioms() does not work as expected. (3165000). Fixed. +* Anonymous ontologies do not get typed as owl:Ontology during saving in RDF. (3158177). Fixed. +* OWLOntology hashCode is not implemented properly. (3165583). Fixed. + +## 3.2.0 14 January 2011 + +This version of the API includes various bug fixes and performance enhancements since version 3.1.0 + +### Bug fixes: + +* Various round tripping problems for various syntaxes (3155509, 3154524, 3149789, 3141366, 3140693, 3137303, 3121903) +* Plain Literals are rendered incorrectly. Fixed. +* Cyclic imports cause an OntologyAlreadyExistsException to be thrown. Fixed. +* OWLAxiom.getAnnotatedAxiom() does not merge annotations. Fixed. +* OWLObject.getSignature() returns an unmodifiable collection. Fixed. +* Various problems with character encodings (3068076, 3077637, 3096546, 3140693). Fixed. +* IRI.create resulted in a memory leak. Fixed. +* Imports by location does not work. Fixed. +* Various problems with anonymous individuals (2998616, 2943908, 3073742). Fixed. +* Dublin Core Vocabulary is built into OWL API parsers. Fixed. +* Files are left open on parse errors. Fixed. + +## 3.1.0 20 August 2010 + +This version of the API includes various bug fixes and enhancements since version 3.0.0. + +### Features: + +Changes to the representation of literals: + +Please note that there is a slight incompatibility between version 3.1.0 and version 3.0.0. This is due to some changes +in the way that literals are represented and handled in the API. There was a disparity between how they are described +in the OWL 2 specification and how they are represented in version 3.0.0 of the API. The changes bring 3.1.0 inline +with the OWL 2 specification. The changes are as follows: OWLStringLiteral and OWLTypedLiteral have been removed and +replaced OWLLiteral. In version 3.0.0 OWLLiteral was a super-interface of OWLStringLiteral and OWLTypedLiteral. +Clients therefore need to replace occurrences of OWLStringLiteral and OWLTypedLiteral with OWLLiteral. Method calls +need not be changed - methods on OWLStringLiteral and OWLTypedLiteral have corresponding methods on OWLLiteral. Note +that all literals are now typed. What used to be regarded as OWLStringLiterals are now OWLLiterals with the datatype +rdf:PlainLiteral. Although this change introduces a slight backward incompatibility with the previous version of the +API we believe that the handling of literals in 3.1.0 is much cleaner and follows the specification more closely. + +Changes to the OWLReasoner interface: + +The OWLReasoner interface has been updated. There are now methods which allow for fine-grained control over reasoning +tasks. For example, it is now possible to request that a reasoner just classifies the class hierarchy, when in +version 3.0.0 the prepare reasoner method caused realisation to occur as well. The prepareReasoner method has been removed from +the interface due to the huge amount of confusion it caused (it was not necessary to call this method to get correct +results, but the name suggested that it was necessary). Clients should update their code to replace any calls to +prepareReasoner with appropriate calls to precomputeInferences. + +JavaDoc for various methods has been cleaned up. + +### Bug fixes: + +* Annotations on Declaration axioms were not save. Fixed. +* OWLObjectMaxCardinality restrictions incorrectly resulted in a profile violation of the OWL2RL profile. Fixed. +* OWLOntology.containsAxiom() failed various round trip tests. Fixed. +* OWLObjectPropertyExpression.getInverses() did not include properties that were asserted to be inverses of themselves. Fixed. +* Writing large rdf:Lists can cause a stack overflow on saving. Fixed. +* System.out is closed when using SystemOutDocumentTarget. Fixed. +* An OWLOntologyAlreadyExists exception is thrown when an imports graph contains multiple imports of the same ontology. Fixed. +* OWLReasoner.getSubclasses() is missing declarations in the throws list for runtime exceptions that get thrown. Fixed. +* Parsing RDF graphs containing blank nodes with NodeIDs is broken. Fixed. +* Some methods on OWLOntology return sets of object that change with ontology changes. Fixed. +* Double dashes (--) are not escaped in XML comments output by the XMLWriter. Fixed. +* The API sometimes prints to System.err. Fixed. +* The functional syntax writer writes out annotation assertions twice. Fixed. +* Ontologies with DataSomeValuesFrom restrictions are incorrectly considered non-OWL2QL. Fixed. +* Ontologies with Functional data properties are incorrectly considered non-OWL2RL. Fixed. +* OWL2Datatype.XSD_NAME has the wrong regex pattern. Fixed. +* RDF rendering of GCIs with multiple elements is broken. Fixed. +* SubObjectPropertyOf axioms with annotations and property chains don't get parsed correctly from RDF. Fixed. +* StructuralReasoner sometimes crashes when determining superclasses. Fixed. +* SimpleRenderer renders declarations incorrectly. Fixed. +* Object property characteristics are not answered correctly. Fixed. +* OWLOntology.getReferencingAxioms gives mutable and incorrect results. Fixed. +* StructuralReasoner call OWLClassExpression.asOWLClass() on anonymous classes. Fixed. +* SKOSVocabulary is not up to date. Fixed. +* Regular expression for xsd:double has extra white space. Fixed. +* Structural reasoner sometimes misses subclasses of owl:Thing. Fixed. +* OWLOntologyManager.getImportsClosure() fails on reload. Fixed. +* PrefixOWLOntologyFormat has not methods to remove prefixes. Fixed. +* RDF/XML rendering of unicode characters is ugly. Fixed. +* Turtle parser does parse shared blank nodes correctly. Fixed. + +## 3.0.0 28 January 2010 + +Version 3.0.0 is incompatible with previous releases. Many interface names have been changed in order to acheive a +close alignment with the names used in the OWL 2 Structural Specification and Functional Style Syntax. +(See http://www.w3.org/TR/2009/REC-owl2-syntax-20091027/) + +The opportunity to clean up method names was also taken. + + +## 2.2.0 17 April 2008 + +### Features: + +* Added support for building using ANT +* OWL 1.1 namespaces changed to OWL 2. Old ontologies that are written using the owl11 namespace will still load, but will be converted to use the owl2 namespace. +* Updated the RDF parser and RDF rendere to support AllDisjointClasses and AllDisjointProperties +* Added the ability to save ontologies in Turtle. +* Added the ability to load ontologies that are written in Turtle +* Added explanation code contributed by Clark & Parsia +* Added a KRSS renderer (contributed by Olaf Noppens) +* Added a new, more comprehensive KRSS parser (contributed by Olaf Noppens). This parser can parser the version of the KRSS syntax that is used by Racer. +* Added the ability to specify a connection timeout for URL connections via a system property (owlapi.connectionTimeOut) - the default value for the timeout is 20 seconds. +* Added a method to OWLOntologyManager to clear all registered URI mappers +* Added a method to OWLOntologyManager so that imports can be obtained by an imports declaration. +* Added a convenience method to OWLOntologyManager to add a set of axioms to an ontology without having to create the AddAxiom changes +* Added a makeLoadImportsRequest method on OWLOntologyManager which should be used by parsers and other loaders in order to load imports +* Added the ability to set an option for silent missing imports handling on OWLOntologyManager. When this option is set, exceptions are not thrown when imports cannot be found or cannot be loaded. It is possible to set a listeners that gets informed when an import cannot be found, so that the exception doesn't get lost entirely. +* Added the ability to add a ontology loader listener to OWLOntologyManager. The listener gets informed when the loading process for an ontology starts and finishes (which ontology is being loaded, from where and whether it was successfully loaded etc.). +* Added a method to OWLReasonerFactory to obtain the human readable name of the reasoner that a factory creates. +* Added a convenience method to OWLOntology to obtain all referenced entities +* Added convenience methods to OWLEntity that check whether the entity is an OWLClass, OWLObjectProperty, OWLDataProperty, OWLIndividual or OWLDatatype. Also added asXXX to obtain an entity in its more specific form. +* Added convenience methods to OWLDataFactory for creating disjoint class axioms and equivalent classes axioms. +* Added a general purpose renderer interface for OWLObjects +* Added an OWLInconsistentOntologyException to the inference module. +* Added SKOS core to the list of well known namespaces +* Added a SKOS vocabulary enum +* Added methods to the OWLOntologyManager interface, so that ontologies can be saved to an output target as well as a URI. Added implementations of OWLOntologyOutputTarget to enable writing directly to OutputStreams and Writers. +* Added a StringOutputTarget for writing ontologies into a buffer that can be obtained as a string. +* Added some new input sources: StreamInputSource, ReaderInputSource, FileInputSource +* RDF Parser. Made the classExpression translator selector more intelligent so that when properties aren't typed as either object or data properties, other triples are examined to make the appropriate choice. +* OWLRestrictedDataRangeFacetVocabulary. Added methods to obtain facets by their symbolic name (e.g. >=) +* BidirectionalShortFormProvider. Added a method to obtain all short forms cached by the provider. +* Added an option to turn tabbing on/off when rendering Manchester Syntax +* Added more documentation for the method which adds ontology URI mappers +* Improved error handling when loading ontologies: For errors that have nothing to do with parse errors e.g. unknown host exceptions, the factory will rethrow the error at the earliest opportunity rather than trying all parsers. +* Updated parser to throw ManchesterOWLSyntaxOntologyParserException which is a more specific type of OWLParserException +* Updated the BidirectionalShortFormProviderAdapter with functionality to track ontology changes and update the rendering cache depending on whether entities are referenced or not. +* Added a latex renderer for rendering ontology axioms in a latex format +* Added the ability to parse ontologies written in ManchesterOWLSyntax +* Added URIShortFormProvider as a general purpose interface for providing short forms for URIs. Changed SimpleShortFormProvider to use the SimpleURIShortFormProvider as a base +* Made the toString rendering of the default implementation pluggable via the ToStringRenderer singleton class. +* Added some convenience methods to the OWLDataFactory to make creating certain types of objects less tedious. Specifically: ObjectIntersectionOf, ObjectUnionOf, ObjectOneOf and DataOneOf can now be created using methods that take a variable number of arguments (OWLDescriptions, OWLIndividuals or OWLConstants as appropriate). Also, added convenience methods that create typed literals directly from Java Strings, ints, doubles, floats and booleans. For example, createOWLTypedConstant(3) will create a typed literal with a lexical value of "3" and a datatype of xsd:integer. Added convenice methods for creating entity annotations without manually having to create OWLAnnotation objects. +* Added a getAxiomType method on to the OWLAxiom interface for convenience. +* Added functionality to the debugging module for ordering explanations +* Added generics to the inferred axiom generator API +* Added a new constructor to OWLOntologyNamespaceManager so that it is possible to override the ontology format that is used as a hint when generating namespaces. +* Added a dlsyntax renderer module that can renderer axioms etc. in the traditional dlsyntax using unicode for the dlsyntax symbols. +* Modified the RDFXMLNamespaceManager to select the minimal amount of entities for which namespaces need to be generated. Namespaces are only generated for classes in OWLClassAssertionAxioms, and properties in OWLObjectPropertyAssertionAxioms and OWLDataPropertyAssertionAxioms. This basically corresponds to the places where valid QNames are needed for entities. +* Added code to add declarations for "dangling entities". If an RDF graph contains and ClsA has not been referenced by any other axioms then this would have been dropped by the parser - this has been changed so that declaration axioms are added to the ontology in such cases. (Hopefully, the OWL 1.1 spec will be updated to do something like this in the mapping to RDF graphs). +* Added a utility class, AxiomSubjectProvider, which given an axiom returns an object which is regarded to be the "subject" of the axioms. For example given SubClassOf(ClsA ClsB), ClsA is regarded as being the subject. +* Modified the ontology URI short form provider to provide nicer looking short forms. +* Added a convenience method to get the individuals that have been asserted to be an instance of an OWLClass. +* Commons lang is no longer used in the API because it had been replaced with a lightweight utility class in order to escape strings. +* Removed the fragments module and replaced it with the profiles module. The EL++ profile is currently implemented. +* Added support for extended visitors that can return objects in the visit method. +* Turned off logging in the RDF parser classes by default. + +### Bug fixes: + +* The getOntologyURIs method on AutoURIMapper would return physical rather than logic URIs. Fixed. +* Namespaces for annotation URIs weren't generated. Fixed. +* Removing a subclass axiom from an ontology cause the axiom to be added to the ontology as a GCI. Fixed. +* When parsing an ontology, the accept types has been set to include RDF/XML. This means that ontologies can be parsed correctly from servers that are configured to return RDF or HTML depending on the request type. +* OWL/XML writer has been modified to write the datatype URI attribute name correctly. Previously the name was written as "Datatype", however it should be "datatypeURI". +* OWL/XML parser. Modified the literal handler to parse literals using the correct datatype URI attribute name (was "Datatype" and should have been "datatypeURI"). +* The constructor that required a manager in BidirectionalShortFormProviderAdapter did not rebuild the cache. Fixed. +* Unqualified cardinality restrictions were rendered out as qualified cardinality restrictions. Fixed. +* Saving an ontology would fail if the necessary directories did not exist. Fixed. +* Rendering anonymous property inverses in OWL/XML was incorrect. Fixed. +* Label and Comment annotations in the functional syntax weren't parsed properly, they were parsed as regular annotations. Fixed. +* In the OWLXMLParserHandler, no handler for negative data property assertions was registered. Fixed. +* Annotations that have anonymous individuals as values weren't rendered correctly. Fixed. +* RDFXMLOntologyStorer and RDFXMLRenderer always used the ontology format that is obtainable from the manager, regardless of whether or not a custom ontology format was specified - fixed. +* Rules that contained individual or data value objects couldn't be rendered. Fixed. +* Declaration axioms were automatically added for data properties whether an ontology contained declaredAs triples or not. Fixed. +* Anonymous properties weren't rendered correcty. Fixed. +* RDF rendering for sub property axioms whose sub property is a property chain used an old rendering. The rendering now complies with the latest OWL 2 specification. Ontologies that use the old rendering can still be parsed. +* RDF lists were reordered on rendering. Fixed. \ No newline at end of file diff --git a/api/pom.xml b/api/pom.xml new file mode 100644 index 0000000000..c114931fce --- /dev/null +++ b/api/pom.xml @@ -0,0 +1,43 @@ + + 4.0.0 + owlapi-api + OWLAPI :: Interfaces + + net.sourceforge.owlapi + owlapi-parent + 5.1.18 + + + + org.tukaani + xz + 1.6 + + + org.apache.commons + commons-rdf-api + + + org.apache.commons + commons-rdf-api + tests + test + + + javax.inject + javax.inject + 1 + + + + diff --git a/api/src/main/java/org/semanticweb/owlapi/annotations/HasPriority.java b/api/src/main/java/org/semanticweb/owlapi/annotations/HasPriority.java new file mode 100644 index 0000000000..6e6bac625b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/annotations/HasPriority.java @@ -0,0 +1,36 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.annotations; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Annotation for objects that have a priority that can be used for sorting + * purposes. The priority is represented as a double so that it's always + * possible to place an object's priority between two existing priorities + * (within the limits of double representation). + * + * @author ignazio + * @since 4.0.0 + */ +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface HasPriority { + + /** + * @return priority value for this object + */ + double value(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/annotations/package-info.java b/api/src/main/java/org/semanticweb/owlapi/annotations/package-info.java new file mode 100644 index 0000000000..aaded85b14 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/annotations/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Annotation classes. + */ +package org.semanticweb.owlapi.annotations; + diff --git a/api/src/main/java/org/semanticweb/owlapi/annotations/packageinfo b/api/src/main/java/org/semanticweb/owlapi/annotations/packageinfo new file mode 100644 index 0000000000..8ce0371286 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/annotations/packageinfo @@ -0,0 +1 @@ +version 5.0.0 diff --git a/api/src/main/java/org/semanticweb/owlapi/change/AbstractCompositeOntologyChange.java b/api/src/main/java/org/semanticweb/owlapi/change/AbstractCompositeOntologyChange.java new file mode 100644 index 0000000000..d4d6c4ce33 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/AbstractCompositeOntologyChange.java @@ -0,0 +1,69 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLOntologyChange; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public abstract class AbstractCompositeOntologyChange implements OWLCompositeOntologyChange { + + /** + * The data factory. + */ + protected final OWLDataFactory df; + /** + * The changes. + */ + private final List changes = new ArrayList<>(); + + /** + * Instantiates a new abstract composite ontology change. + * + * @param dataFactory the data factory + */ + protected AbstractCompositeOntologyChange(OWLDataFactory dataFactory) { + df = checkNotNull(dataFactory, "dataFactory cannot be null"); + } + + /** + * Adds the change. + * + * @param change the change + */ + protected void addChange(OWLOntologyChange change) { + changes.add(change); + } + + /** + * Adds the changes. + * + * @param c the changes + */ + protected void addChanges(Collection c) { + changes.addAll(c); + } + + @Override + public List getChanges() { + return changes; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/AddAxiomData.java b/api/src/main/java/org/semanticweb/owlapi/change/AddAxiomData.java new file mode 100644 index 0000000000..c7b7cda918 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/AddAxiomData.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import javax.annotation.Nonnull; +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * Represents the specific non-ontology data required by an {@link AddAxiom} + * change.
+ * Instances of this class are immutable. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.3 + */ +public class AddAxiomData extends AxiomChangeData { + + /** + * Constructs an {@code AddAxiomData} object which specifies the addition of + * an axiom to "some ontology". + * + * @param axiom The {@link OWLAxiom} being added. + */ + public AddAxiomData(OWLAxiom axiom) { + super(axiom); + } + + @Override + @Nonnull + public AddAxiom createOntologyChange(@Nonnull OWLOntology ontology) { + return new AddAxiom(ontology, getAxiom()); + } + + @Override + public O accept(@Nonnull OWLOntologyChangeDataVisitor visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/AddClassExpressionClosureAxiom.java b/api/src/main/java/org/semanticweb/owlapi/change/AddClassExpressionClosureAxiom.java new file mode 100644 index 0000000000..0c4e207edb --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/AddClassExpressionClosureAxiom.java @@ -0,0 +1,111 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLClassExpressionVisitor; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * This composite change adds a 'closure' axiom to an ontology for a given class + * and object property. In this case, a closure axiom is defined for a given + * class, A, and object property, P, to be a subclass axiom, whose subclass is + * class A, and whose superclass is a universal restriction along the property, + * P, whose filler is the union of any other existential (including hasValue + * restrictions - i.e. nominals) restriction fillers that are the superclasses + * of class A.
+ * This code is based on the tutorial examples by Sean Bechhofer (see the + * tutorial module). + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class AddClassExpressionClosureAxiom extends AbstractCompositeOntologyChange { + + /** + * Creates a composite change that will add a closure axiom for a given + * class along a specified property. + * + * @param dataFactory The data factory that should be used to create the necessary objects + * @param cls The class for which the closure axiom will be generated + * @param property The property that the closure axiom will act along + * @param ontologies The ontologies that will be examined for subclass axioms + * @param targetOntology The target ontology that changes will be applied to. + */ + public AddClassExpressionClosureAxiom(OWLDataFactory dataFactory, OWLClass cls, + OWLObjectPropertyExpression property, Collection ontologies, + OWLOntology targetOntology) { + super(dataFactory); + checkNotNull(cls, "cls cannot be null"); + checkNotNull(property, "property cannot be null"); + checkNotNull(ontologies, "ontologies cannot be null"); + checkNotNull(targetOntology, "targetOntology cannot be null"); + generateChanges(cls, property, ontologies, targetOntology); + } + + private void generateChanges(OWLClass cls, OWLObjectPropertyExpression property, + Collection ontologies, + OWLOntology targetOntology) { + // We collect all of the fillers for existential restrictions along + // the target property and all of the fillers for hasValue restrictions + // as nominals + FillerCollector collector = new FillerCollector(property); + ontologies.forEach(o -> o.subClassAxiomsForSubClass(cls) + .forEach(ax -> ax.getSuperClass().accept(collector))); + if (collector.fillers.isEmpty()) { + return; + } + OWLObjectUnionOf union = df.getOWLObjectUnionOf(collector.fillers); + OWLClassExpression closureAxiomDesc = df.getOWLObjectAllValuesFrom(property, union); + addChange(new AddAxiom(targetOntology, df.getOWLSubClassOfAxiom(cls, closureAxiomDesc))); + } + + private class FillerCollector implements OWLClassExpressionVisitor { + + final List fillers = new ArrayList<>(); + final OWLObjectPropertyExpression property; + + /** + * @param p the p + */ + FillerCollector(OWLObjectPropertyExpression p) { + property = checkNotNull(p, "p cannot be null"); + } + + @Override + public void visit(OWLObjectSomeValuesFrom ce) { + if (ce.getProperty().equals(property)) { + fillers.add(ce.getFiller()); + } + } + + @Override + public void visit(OWLObjectHasValue ce) { + if (ce.getProperty().equals(property)) { + fillers.add(df.getOWLObjectOneOf(ce.getFiller())); + } + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/AddImportData.java b/api/src/main/java/org/semanticweb/owlapi/change/AddImportData.java new file mode 100644 index 0000000000..082f9c86e7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/AddImportData.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import org.semanticweb.owlapi.model.AddImport; +import org.semanticweb.owlapi.model.OWLImportsDeclaration; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * Represents the specific non-ontology data required by an {@link AddImport} + * change.
+ * Instances of this class are immutable. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.3 + */ +public class AddImportData extends ImportChangeData { + + /** + * Constructs an {@link AddImportData} object that describes an + * {@link AddImport} change for the {@link OWLImportsDeclaration} specified + * by the {@code declaration} parameter. + * + * @param declaration The {@link OWLImportsDeclaration} that is the focus of some change. + */ + public AddImportData(OWLImportsDeclaration declaration) { + super(declaration); + } + + @Override + public AddImport createOntologyChange(OWLOntology ontology) { + return new AddImport(ontology, getDeclaration()); + } + + @Override + public O accept(OWLOntologyChangeDataVisitor visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/AddOntologyAnnotationData.java b/api/src/main/java/org/semanticweb/owlapi/change/AddOntologyAnnotationData.java new file mode 100644 index 0000000000..344568f386 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/AddOntologyAnnotationData.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import org.semanticweb.owlapi.model.AddOntologyAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * Represents the specific non-ontology data required by an + * {@link AddOntologyAnnotation} change.
+ * Instances of this class are immutable. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.3 + */ +public class AddOntologyAnnotationData extends OntologyAnnotationChangeData { + + /** + * Constructs an {@code AddOntologyAnnotationData} object that describes an + * {@link AddOntologyAnnotation} change for the {@link OWLAnnotation} + * specified by the {@code annotation} parameter. + * + * @param annotation The {@link OWLAnnotation} that is the focus of some change. + */ + public AddOntologyAnnotationData(OWLAnnotation annotation) { + super(annotation); + } + + @Override + public AddOntologyAnnotation createOntologyChange(OWLOntology ontology) { + return new AddOntologyAnnotation(ontology, getAnnotation()); + } + + @Override + public O accept(OWLOntologyChangeDataVisitor visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/AmalgamateSubClassAxioms.java b/api/src/main/java/org/semanticweb/owlapi/change/AmalgamateSubClassAxioms.java new file mode 100644 index 0000000000..3fbec796ca --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/AmalgamateSubClassAxioms.java @@ -0,0 +1,66 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.RemoveAxiom; + +/** + * Given a set of ontologies S, for each ontology, O, in S, this change combines + * multiple subclass axioms with a common left hand side into one subclass + * axiom. For example, given A subClassOf B, A subClassOf C, this change will + * remove these two axioms and replace them by adding one subclass axiom, A + * subClassOf (B and C). + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.1 + */ +public class AmalgamateSubClassAxioms extends AbstractCompositeOntologyChange { + + /** + * Instantiates a new amalgamate sub class axioms. + * + * @param dataFactory the data factory + * @param ontologies the ontologies to use + */ + public AmalgamateSubClassAxioms(OWLDataFactory dataFactory, + Collection ontologies) { + super(dataFactory); + checkNotNull(ontologies, "ontologies cannot be null"); + ontologies.forEach(o -> o.classesInSignature().forEach(cls -> amalgamate(o, cls))); + } + + protected void amalgamate(OWLOntology ont, OWLClass cls) { + List axioms = asList(ont.subClassAxiomsForSubClass(cls)); + if (axioms.size() < 2) { + return; + } + axioms.forEach(ax -> addChange(new RemoveAxiom(ont, ax))); + Stream superclasses = axioms.stream() + .map(OWLSubClassOfAxiom::getSuperClass); + OWLObjectIntersectionOf intersection = df.getOWLObjectIntersectionOf(superclasses); + addChange(new AddAxiom(ont, df.getOWLSubClassOfAxiom(cls, intersection))); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/AxiomChangeData.java b/api/src/main/java/org/semanticweb/owlapi/change/AxiomChangeData.java new file mode 100644 index 0000000000..b17a8fbefb --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/AxiomChangeData.java @@ -0,0 +1,53 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import org.semanticweb.owlapi.model.OWLAxiom; + +/** + * Represent the common non-ontology data required by instances of + * {@link org.semanticweb.owlapi.model.OWLAxiomChange}. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.3 + */ +public abstract class AxiomChangeData extends OWLOntologyChangeData { + + private final OWLAxiom axiom; + + /** + * Constructs an {@code AxiomChangeData} object that describes a change + * involving the specified {@code axiom}. + * + * @param axiom The {@link OWLAxiom} involved in a change. + **/ + public AxiomChangeData(OWLAxiom axiom) { + this.axiom = checkNotNull(axiom, "axiom must not be null"); + } + + /** + * Gets the {@link OWLAxiom} that is associated with this change data. + * + * @return The {@link OWLAxiom}. + */ + public OWLAxiom getAxiom() { + return axiom; + } + + @Override + public OWLAxiom getItem() { + return getAxiom(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/CoerceConstantsIntoDataPropertyRange.java b/api/src/main/java/org/semanticweb/owlapi/change/CoerceConstantsIntoDataPropertyRange.java new file mode 100644 index 0000000000..dbd5dde284 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/CoerceConstantsIntoDataPropertyRange.java @@ -0,0 +1,180 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asMap; + +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLLogicalAxiom; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.RemoveAxiom; +import org.semanticweb.owlapi.util.OWLObjectDuplicator; +import org.semanticweb.owlapi.util.RemappingIndividualProvider; + +/** + * Coerces constants to have the same type as the range of a property in axioms where the two are + * used. For example, given, p value "xyz", the "xyz" constant would be typed with the range of p. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.1 + */ +public class CoerceConstantsIntoDataPropertyRange extends AbstractCompositeOntologyChange { + + /** + * Instantiates a new coerce constants into data property range. + * + * @param m The manager providing data factory and config to be used for the duplication. + * @param ontologies the ontologies to use + */ + public CoerceConstantsIntoDataPropertyRange(OWLOntologyManager m, + Collection ontologies) { + super(m.getOWLDataFactory()); + checkNotNull(ontologies, "ontologies cannot be null"); + Map map = asMap(datatypes(ontologies), + ax -> ax.getProperty(), ax -> ax.getRange().asOWLDatatype()); + OWLConstantReplacer replacer = new OWLConstantReplacer(m, map); + ontologies.forEach(o -> o.logicalAxioms().forEach(ax -> duplicate(replacer, o, ax))); + } + + /** + * @param ontologies ontologies to inspect + * @return datatypes declared in the ontologies (not including OWL 2 standard datatypes) + */ + public Stream datatypes(Collection ontologies) { + return ontologies.stream().flatMap(ont -> ont.axioms(AxiomType.DATA_PROPERTY_RANGE)) + .filter(ax -> ax.getRange().isOWLDatatype()); + } + + protected void duplicate(OWLConstantReplacer replacer, OWLOntology o, OWLLogicalAxiom ax) { + OWLAxiom dupAx = replacer.duplicateObject(ax); + if (!ax.equals(dupAx)) { + addChange(new RemoveAxiom(o, ax)); + addChange(new AddAxiom(o, dupAx)); + } + } + + /** + * The Class OWLConstantReplacer. + */ + private class OWLConstantReplacer extends OWLObjectDuplicator { + + private final Map map; + + /** + * @param m The manager providing data factory and config to be used for the duplication. + * @param map the map + */ + OWLConstantReplacer(OWLOntologyManager m, Map map) { + super(Collections.emptyMap(), Collections.emptyMap(), m, + new RemappingIndividualProvider(false, m.getOWLDataFactory())); + this.map = map; + } + + private OWLDataOneOf process(OWLDataPropertyExpression prop, OWLDataOneOf oneOf) { + return df.getOWLDataOneOf(oneOf.values().map(c -> process(prop, c))); + } + + private OWLLiteral process(OWLDataPropertyExpression prop, OWLLiteral con) { + OWLDatatype dt = map.get(prop); + if (dt == null) { + return con; + } + return df.getOWLLiteral(con.getLiteral(), dt); + } + + @Override + public OWLDataHasValue visit(OWLDataHasValue ce) { + return df.getOWLDataHasValue(ce.getProperty(), + process(ce.getProperty(), ce.getFiller())); + } + + @Override + public OWLDataSomeValuesFrom visit(OWLDataSomeValuesFrom ce) { + if (ce.getFiller() instanceof OWLDataOneOf) { + return df.getOWLDataSomeValuesFrom(ce.getProperty(), + process(ce.getProperty(), (OWLDataOneOf) ce.getFiller())); + } + return super.visit(ce); + } + + @Override + public OWLDataMinCardinality visit(OWLDataMinCardinality ce) { + if (ce.getFiller() instanceof OWLDataOneOf) { + return df.getOWLDataMinCardinality(ce.getCardinality(), ce.getProperty(), + process(ce.getProperty(), (OWLDataOneOf) ce.getFiller())); + } + return super.visit(ce); + } + + @Override + public OWLDataMaxCardinality visit(OWLDataMaxCardinality ce) { + if (ce.getFiller() instanceof OWLDataOneOf) { + return df.getOWLDataMaxCardinality(ce.getCardinality(), ce.getProperty(), + process(ce.getProperty(), (OWLDataOneOf) ce.getFiller())); + } + return super.visit(ce); + } + + @Override + public OWLDataExactCardinality visit(OWLDataExactCardinality ce) { + if (ce.getFiller() instanceof OWLDataOneOf) { + return df.getOWLDataExactCardinality(ce.getCardinality(), ce.getProperty(), + process(ce.getProperty(), (OWLDataOneOf) ce.getFiller())); + } + return super.visit(ce); + } + + @Override + public OWLDataAllValuesFrom visit(OWLDataAllValuesFrom ce) { + if (ce.getFiller() instanceof OWLDataOneOf) { + return df.getOWLDataAllValuesFrom(ce.getProperty(), + process(ce.getProperty(), (OWLDataOneOf) ce.getFiller())); + } + return super.visit(ce); + } + + @Override + public OWLDataPropertyAssertionAxiom visit(OWLDataPropertyAssertionAxiom axiom) { + return df.getOWLDataPropertyAssertionAxiom(axiom.getProperty(), axiom.getSubject(), + process(axiom.getProperty(), axiom.getObject())); + } + + @Override + public OWLNegativeDataPropertyAssertionAxiom visit( + OWLNegativeDataPropertyAssertionAxiom axiom) { + return df.getOWLNegativeDataPropertyAssertionAxiom(axiom.getProperty(), + axiom.getSubject(), process(axiom.getProperty(), axiom.getObject())); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/ConvertEquivalentClassesToSuperClasses.java b/api/src/main/java/org/semanticweb/owlapi/change/ConvertEquivalentClassesToSuperClasses.java new file mode 100644 index 0000000000..3b5df30422 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/ConvertEquivalentClassesToSuperClasses.java @@ -0,0 +1,128 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.empty; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.RemoveAxiom; + +/** + * This composite change will convert a defined class to a primitive class by replacing equivalent + * classes axioms where the class in question is a class in the equivalent classes axioms to a set + * of subclass axioms whose superclasses are the set of classes which were originally equivalent to + * the class in question.
+ * More formally, for a given class A, a set of ontologies S, and a target ontology T, this + * composite change will remove all equivalent axioms from each ontology O in S where the equivalent + * class axiom contains A as a 'top level' class (e.g. EquivalentClasses(A, C, D)). For each class, + * D, that was made equivalent to A via an equivalent classes axiom, a subclass axiom SubClassOf(A, + * D) will be added to the target ontology T.
+ * This change supports a common pattern of working, where a class is converted from a defined class + * to a primitive class. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class ConvertEquivalentClassesToSuperClasses extends AbstractCompositeOntologyChange { + + private static final OWLClassExpressionVisitorEx> INTERSECTION_SPLITTER = + new OWLClassExpressionVisitorEx>() { + + @Override + public Stream visit(OWLObjectIntersectionOf ce) { + return ce.operands(); + } + + @Override + public Stream doDefault(Object o) { + return empty(); + } + }; + /** + * The target ontology. + */ + private final OWLOntology targetOntology; + /** + * The OWL class. + */ + private final OWLClass cls; + /** + * The ontologies. + */ + private final Collection ontologies; + /** + * true if intersections should be split. + */ + private final boolean splitIntersections; + + /** + * Instantiates a new convert equivalent classes to super classes. + * + * @param dataFactory the data factory + * @param cls the class to convert + * @param ontologies the ontologies to use + * @param targetOntology the target ontology + * @param splitIntersections whether or not intersections should be split + */ + public ConvertEquivalentClassesToSuperClasses(OWLDataFactory dataFactory, OWLClass cls, + Collection ontologies, OWLOntology targetOntology, + boolean splitIntersections) { + super(dataFactory); + this.targetOntology = checkNotNull(targetOntology, "targetOntology cannot be null"); + this.cls = checkNotNull(cls, "cls cannot be null"); + this.ontologies = checkNotNull(ontologies, "ontologies cannot be null"); + this.splitIntersections = splitIntersections; + generateChanges(); + } + + private void generateChanges() { + Set supers = new HashSet<>(); + for (OWLOntology o : ontologies) { + o.equivalentClassesAxioms(cls).forEach(ax -> { + addChange(new RemoveAxiom(o, ax)); + ax.classExpressions().forEach(c -> collectClassExpressions(c, supers)); + }); + } + supers.remove(cls); + supers.forEach( + sup -> addChange(new AddAxiom(targetOntology, df.getOWLSubClassOfAxiom(cls, sup)))); + } + + private void collectClassExpressions(OWLClassExpression desc, + Collection supers) { + if (!splitIntersections) { + supers.add(desc); + return; + } + Iterator iterator = + desc.accept(INTERSECTION_SPLITTER).iterator(); + if (iterator.hasNext()) { + iterator.forEachRemaining(supers::add); + } else { + supers.add(desc); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/ConvertPropertyAssertionsToAnnotations.java b/api/src/main/java/org/semanticweb/owlapi/change/ConvertPropertyAssertionsToAnnotations.java new file mode 100644 index 0000000000..105a2bbbf2 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/ConvertPropertyAssertionsToAnnotations.java @@ -0,0 +1,127 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.Collection; +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.RemoveAxiom; + +/** + * Given a set of ontologies, this composite change will convert all property + * assertion axioms whose subject is a 'punned' individual (i.e. an individual + * that shares a name with a class), removes these axioms and replaces them with + * annotations on the class that shares the same name as the individual. For + * example for a class A and an individual A, the data property assertion + * hasX(A, "Val") would be converted to an entity annotation on the class A with + * an annotation URI of "hasX" and a value of "Val".
+ * This composite change supports refactoring an ontology where punning was used + * to simulate annotations on a class rather than using actual annotations on a + * class. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class ConvertPropertyAssertionsToAnnotations extends AbstractCompositeOntologyChange { + + private final Collection ontologies; + + /** + * Instantiates a new convert property assertions to annotations. + * + * @param dataFactory factory to use + * @param ontologies ontologies to change + */ + public ConvertPropertyAssertionsToAnnotations(OWLDataFactory dataFactory, + Collection ontologies) { + super(dataFactory); + this.ontologies = checkNotNull(ontologies, "ontologies cannot be null"); + generateChanges(); + } + + private Stream ontologies() { + return ontologies.stream(); + } + + /** + * Gets the punned individuals. + * + * @param individuals the individuals + * @return the punned individuals + */ + private Collection getPunnedIndividuals( + Stream individuals) { + return asList(individuals + .filter(i -> ontologies().anyMatch(o -> o.containsClassInSignature(i.getIRI())))); + } + + private void generateChanges() { + Stream inds = ontologies().flatMap(OWLOntology::individualsInSignature); + getPunnedIndividuals(inds).forEach(this::convertToAnnotations); + } + + private void remove(Stream c, OWLOntology o) { + c.forEach(ax -> addChange(new RemoveAxiom(o, ax))); + } + + private void remove(OWLDataProperty prop) { + ontologies().forEach(o -> { + remove(o.declarationAxioms(prop), o); + remove(o.axioms(prop), o); + }); + } + + private void remove(OWLNamedIndividual ind) { + ontologies().forEach(o -> { + remove(o.declarationAxioms(ind), o); + remove(o.classAssertionAxioms(ind), o); + }); + } + + private void convertToAnnotations(OWLNamedIndividual ind) { + ontologies.forEach(ont -> addAnnotations(ind, ont)); + remove(ind); + } + + protected void addAnnotations(OWLNamedIndividual ind, OWLOntology ont) { + ont.dataPropertyAssertionAxioms(ind).filter(ax -> !ax.getProperty().isAnonymous()) + .forEach(ax -> addAnnotation( + ind, ont, ax)); + } + + protected void addAnnotation(OWLNamedIndividual ind, OWLOntology ont, + OWLDataPropertyAssertionAxiom ax) { + addChange(new RemoveAxiom(ont, ax)); + addChange(new AddAxiom(ont, convertToAnnotation(ind, ax))); + remove(ax.getProperty().asOWLDataProperty()); + } + + private OWLAnnotationAssertionAxiom convertToAnnotation(OWLNamedIndividual ind, + OWLDataPropertyAssertionAxiom ax) { + OWLDataProperty hasIRI = ax.getProperty().asOWLDataProperty(); + OWLAnnotation anno = df + .getOWLAnnotation(df.getOWLAnnotationProperty(hasIRI), ax.getObject()); + return df.getOWLAnnotationAssertionAxiom(ind.getIRI(), anno); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/ConvertSuperClassesToEquivalentClass.java b/api/src/main/java/org/semanticweb/owlapi/change/ConvertSuperClassesToEquivalentClass.java new file mode 100644 index 0000000000..6cbbd097a9 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/ConvertSuperClassesToEquivalentClass.java @@ -0,0 +1,78 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.RemoveAxiom; + +/** + * This composite change will convert a primitive class to a defined class by replacing subclass + * axioms where the class in question is on the left hand side of the subclass axiom to an + * equivalent classes axiom which makes the class equivalent to the intersection of its + * superclasses.
+ * More formally, given a class A, a set of ontologies S, and a target targetOntology T, for each + * targetOntology O in S, subclass axioms whose LHS is A will be removed from O. The superclasses + * from these axioms will be combined into an intersection class which will be made equivalent to A + * using an equivalent classes axioms E. E will be added to the target targetOntology T.
+ * This composite change supports the pattern of working where a primitive class is converted to a + * defined class - functionality which is usually found in editors. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class ConvertSuperClassesToEquivalentClass extends AbstractCompositeOntologyChange { + + /** + * Instantiates a new convert super classes to equivalent class. + * + * @param dataFactory A data factory which can be used to create the appropriate axioms + * @param cls The class whose superclasses will be converted to an equivalent class. + * @param ontologies The ontologies which should be examined for subclass axioms. + * @param targetOntology The target ontology which the equivalent classes axiom should be added + * to + */ + public ConvertSuperClassesToEquivalentClass(OWLDataFactory dataFactory, OWLClass cls, + Collection ontologies, OWLOntology targetOntology) { + super(dataFactory); + generateChanges(checkNotNull(targetOntology, "targetOntology cannot be null"), + checkNotNull(cls, "cls cannot be null"), + checkNotNull(ontologies, "ontologies cannot be null")); + } + + private void generateChanges(OWLOntology targetOntology, OWLClass cls, + Collection ontologies) { + // We remove the existing superclasses and then combine these + // into an intersection which is made equivalent. + List descs = new ArrayList<>(); + for (OWLOntology ont : ontologies) { + ont.subClassAxiomsForSubClass(cls).forEach(ax -> { + addChange(new RemoveAxiom(ont, ax)); + descs.add(ax.getSuperClass()); + }); + } + OWLClassExpression equivalentClass = df.getOWLObjectIntersectionOf(descs); + addChange(new AddAxiom(targetOntology, + df.getOWLEquivalentClassesAxiom(Arrays.asList(cls, equivalentClass)))); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/CreateValuePartition.java b/api/src/main/java/org/semanticweb/owlapi/change/CreateValuePartition.java new file mode 100644 index 0000000000..59e73a15af --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/CreateValuePartition.java @@ -0,0 +1,89 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.Collection; + +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * This composite change will create a value partitiion - see "pattern 2" in "Representing Specified + * Values in OWL: "value partitions" and "value sets"" + * (http://www.w3.org/TR/swbp-specified-values.)
+ * A value partition is an ontology design pattern which is used to represent a set of closed values + * for a particular property. For example the property hasSize might only take values from + * SmallSize, MediumSize and LargeSize. In this case, the value partition is Size, and has the + * values SmallSize, MediumSize and LargeSize. This composite change will set hasSize to be + * functional and its range as Size. Size will be covered by SmallSize, MediumSize and LargeSize and + * these classes which represent the values will be made disjoint with each other. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class CreateValuePartition extends AbstractCompositeOntologyChange { + + /** + * Creates a composite change that will create a value partition. + * + * @param dataFactory A data factory which can be used to create the necessary axioms + * @param valuePartitionClass The class which represents the value partition. + * @param valuePartionClasses The classes that represent the various values of the value + * partition. + * @param valuePartitionProperty the property which should be used in conjunction with the value + * partition. + * @param targetOntology The target ontology which the axioms that are necessary to create the + * value partition will be added to. + */ + public CreateValuePartition(OWLDataFactory dataFactory, OWLClass valuePartitionClass, + Collection valuePartionClasses, OWLObjectProperty valuePartitionProperty, + OWLOntology targetOntology) { + super(dataFactory); + generateChanges(checkNotNull(targetOntology, "targetOntology cannot be null"), + checkNotNull(valuePartionClasses, "valuePartionClasses cannot be null"), + checkNotNull(valuePartitionClass, "valuePartitionClass cannot be null"), + checkNotNull(valuePartitionProperty, "valuePartitionProperty cannot be null")); + } + + private void generateChanges(OWLOntology targetOntology, + Collection valuePartitionClasses, OWLClass valuePartitionClass, + OWLObjectProperty valuePartitionProperty) { + // To create a value partition from a set of classes which represent the + // values, a value partition class, a property we... + // 1) Make the classes which represent the values, subclasses of the + // value partition class + for (OWLClassExpression valuePartitionValue : valuePartitionClasses) { + addChange(new AddAxiom(targetOntology, + df.getOWLSubClassOfAxiom(valuePartitionValue, valuePartitionClass))); + } + // 2) Make the values disjoint + addChange( + new AddAxiom(targetOntology, df.getOWLDisjointClassesAxiom(valuePartitionClasses))); + // 3) Add a covering axiom to the value partition + OWLClassExpression union = df.getOWLObjectUnionOf(valuePartitionClasses); + addChange( + new AddAxiom(targetOntology, df.getOWLSubClassOfAxiom(valuePartitionClass, union))); + // 4) Make the property functional + addChange(new AddAxiom(targetOntology, + df.getOWLFunctionalObjectPropertyAxiom(valuePartitionProperty))); + // 5) Set the range of the property to be the value partition + addChange(new AddAxiom(targetOntology, + df.getOWLObjectPropertyRangeAxiom(valuePartitionProperty, valuePartitionClass))); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/ImportChangeData.java b/api/src/main/java/org/semanticweb/owlapi/change/ImportChangeData.java new file mode 100644 index 0000000000..1f623eeca8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/ImportChangeData.java @@ -0,0 +1,56 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import org.semanticweb.owlapi.model.OWLImportsDeclaration; + +/** + * Instances of this class represent {@link OWLOntologyChangeData} for changes + * that that are specific to the addition or removal of import statements + * to/from an ontology. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.3 + */ +public abstract class ImportChangeData extends OWLOntologyChangeData { + + private final OWLImportsDeclaration declaration; + + /** + * Constructs an {@code ImportChangeData} object that describes an + * {@link org.semanticweb.owlapi.model.ImportChange} based on the + * {@link OWLImportsDeclaration} specified by the {@code declaration} + * parameter. + * + * @param declaration The {@link OWLImportsDeclaration} that is the focus of some change. + */ + protected ImportChangeData(OWLImportsDeclaration declaration) { + this.declaration = checkNotNull(declaration, "declaration must not be null"); + } + + /** + * Gets the {@link OWLImportsDeclaration} that this change data describes. + * + * @return The {@link OWLImportsDeclaration}. + */ + public OWLImportsDeclaration getDeclaration() { + return declaration; + } + + @Override + public OWLImportsDeclaration getItem() { + return getDeclaration(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/MakeClassesMutuallyDisjoint.java b/api/src/main/java/org/semanticweb/owlapi/change/MakeClassesMutuallyDisjoint.java new file mode 100644 index 0000000000..671641ab10 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/MakeClassesMutuallyDisjoint.java @@ -0,0 +1,68 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.pairs; + +import java.util.Collection; +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * Given a set of class expressions, this composite change will make them + * mutually disjoint. The composite change offers the option of using one + * disjoint classes axiom to do this or using multiple disjoint classes axioms + * to make them pairwise disjoint (for backwards compatibility with OWL 1.0). + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class MakeClassesMutuallyDisjoint extends AbstractCompositeOntologyChange { + + /** + * Creates a composite change which makes a set of classes mutually + * disjoint. + * + * @param dataFactory The data factory which should be used for creating the axioms + * @param classExpressions The class expressions which should be made mutually disjoint. + * @param usePairwiseDisjointAxioms the use pairwise disjoint axioms + * @param targetOntology The target ontology which the changes will be applied to. {@code true} + * if multiple disjoint classes axioms should be used to make the class expressions pairwise + * disjoint (for backwards compatibility with OWL 1.0), or {@code false} if one disjoint classes + * axiom should be used (preferred OWL 1.1 method). + */ + public MakeClassesMutuallyDisjoint(OWLDataFactory dataFactory, + Collection classExpressions, + boolean usePairwiseDisjointAxioms, + OWLOntology targetOntology) { + super(dataFactory); + checkNotNull(classExpressions, "classExpressions cannot be null"); + checkNotNull(targetOntology, "targetOntology cannot be null"); + generateChanges(classExpressions, usePairwiseDisjointAxioms, targetOntology); + } + + private void generateChanges(Collection classExpressions, + boolean usePairwiseDisjointAxioms, OWLOntology targetOntology) { + if (usePairwiseDisjointAxioms) { + pairs(classExpressions) + .forEach(v -> addChange( + new AddAxiom(targetOntology, df.getOWLDisjointClassesAxiom(v.i, v.j)))); + } else { + addChange( + new AddAxiom(targetOntology, df.getOWLDisjointClassesAxiom(classExpressions))); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/MakePrimitiveSubClassesMutuallyDisjoint.java b/api/src/main/java/org/semanticweb/owlapi/change/MakePrimitiveSubClassesMutuallyDisjoint.java new file mode 100644 index 0000000000..cb42d645f1 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/MakePrimitiveSubClassesMutuallyDisjoint.java @@ -0,0 +1,83 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import static org.semanticweb.owlapi.search.EntitySearcher.isDefined; +import static org.semanticweb.owlapi.search.Searcher.sub; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.Collection; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * For a given class, this composite change makes its told primitive subclasses + * mutually disjoint. For example, if B, C, and D are primitive subclasses of A + * then this composite change will make B, C, and D mutually disjoint.
+ * More formally, for a given class, A, and a set of ontologies, S, this method + * will obtain a set of classes, G, where all classes in G are named and + * primitive. Moreover, for any class, B in G, some ontology O in S will contain + * an axiom, SubClassOf(B, A). All classes in G will be made mutually disjoint + * by creating axiom(s) in a target ontology T.
+ * This composite change supports a common design pattern where primitive + * subclasses of a class are made mutually disjoint. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class MakePrimitiveSubClassesMutuallyDisjoint extends AbstractCompositeOntologyChange { + + /** + * Instantiates a new make primitive sub classes mutually disjoint. + * + * @param dataFactory the datafactory to use + * @param cls the class to convert + * @param targetOntology the target ontology + */ + public MakePrimitiveSubClassesMutuallyDisjoint(OWLDataFactory dataFactory, OWLClass cls, + OWLOntology targetOntology) { + this(dataFactory, cls, targetOntology, false); + } + + /** + * Instantiates a new make primitive sub classes mutually disjoint. + * + * @param dataFactory the datafactory to use + * @param cls the class to convert + * @param targetOntology the target ontology + * @param usePairwiseDisjointAxioms true if pairwise disjoint axioms should be used + */ + public MakePrimitiveSubClassesMutuallyDisjoint(OWLDataFactory dataFactory, OWLClass cls, + OWLOntology targetOntology, + boolean usePairwiseDisjointAxioms) { + super(dataFactory); + generateChanges(checkNotNull(cls, "cls cannot be null"), + checkNotNull(targetOntology, "targetOntology cannot be null"), + usePairwiseDisjointAxioms); + } + + private void generateChanges(OWLClass cls, OWLOntology o, boolean usePairwiseDisjointAxioms) { + Collection sub = asList( + sub(o.subClassAxiomsForSuperClass(cls), OWLClassExpression.class) + .filter(c -> undefinedPrimitive(o, c))); + addChanges( + new MakeClassesMutuallyDisjoint(df, sub, usePairwiseDisjointAxioms, o).getChanges()); + } + + protected boolean undefinedPrimitive(OWLOntology o, OWLClassExpression subCls) { + return !subCls.isAnonymous() && !isDefined(subCls.asOWLClass(), o); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/OWLCompositeOntologyChange.java b/api/src/main/java/org/semanticweb/owlapi/change/OWLCompositeOntologyChange.java new file mode 100644 index 0000000000..b042cd7634 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/OWLCompositeOntologyChange.java @@ -0,0 +1,36 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import java.io.Serializable; +import java.util.List; +import org.semanticweb.owlapi.model.OWLOntologyChange; + +/** + * A composite ontology change encapsulates a list of ontology changes, which + * should be applied as a logical unit. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +@FunctionalInterface +public interface OWLCompositeOntologyChange extends Serializable { + + /** + * Gets the changes which compose this composite change. Once this method + * has been invoked, it will always return the same list of changes. + * + * @return A list of ontology changes. + */ + List getChanges(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/OWLOntologyChangeData.java b/api/src/main/java/org/semanticweb/owlapi/change/OWLOntologyChangeData.java new file mode 100644 index 0000000000..965d95a92e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/OWLOntologyChangeData.java @@ -0,0 +1,104 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import java.io.Serializable; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.HasSignature; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; + +/** + * Represents an abstraction of the essential non-ontology data required by a + * particular kind of {@link OWLOntologyChange}. There is a concrete subclass of + * this class for each concrete class of {@link OWLOntologyChange}.
+ * Instances of this class are immutable. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @see org.semanticweb.owlapi.model.OWLOntologyChange#getChangeData() + * @since 3.3 + */ +public abstract class OWLOntologyChangeData implements HasSignature, Serializable { + + /** + * Default constructor for serialization purposes. + */ + protected OWLOntologyChangeData() { + super(); + } + + /** + * Accepts a visit from an {@link OWLOntologyChangeDataVisitor}. + * + * @param visitor The visitor + * @param The return type for visitor's visit methods. + * @return The object returned by the visitor's visit methods. + */ + public abstract R accept(OWLOntologyChangeDataVisitor visitor); + + /** + * Creates an {@link OWLOntologyChange} object that pertains to the + * specified {@code ontology}, which when applied to the specified ontology + * enacts the change described by this info object. + * + * @param ontology The {@link OWLOntology} that the change should apply to. + * @return An {@link OWLOntologyChange} object that applies to {@code ontology} and changes + * {@code ontology} in a way that is consistent with this the information held in this {@code + * OWLOntologyChangeData} object. + **/ + public abstract OWLOntologyChange createOntologyChange(OWLOntology ontology); + + /** + * @return a name for the object class + */ + protected String getName() { + return getClass().getSimpleName(); + } + + protected String getTemplate() { + return getName() + "(%s)"; + } + + protected String toString(Object o) { + return String.format(getTemplate(), o); + } + + @Override + public String toString() { + return toString(getItem()); + } + + /** + * @return the object this change is adding or removing + */ + public abstract Object getItem(); + + @Override + public int hashCode() { + return getClass().hashCode() + getItem().hashCode(); + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == this) { + return true; + } + if (obj == null) { + return false; + } + if (!getClass().equals(obj.getClass())) { + return false; + } + return getItem().equals(((OWLOntologyChangeData) obj).getItem()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/OWLOntologyChangeDataVisitor.java b/api/src/main/java/org/semanticweb/owlapi/change/OWLOntologyChangeDataVisitor.java new file mode 100644 index 0000000000..2b8b62daae --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/OWLOntologyChangeDataVisitor.java @@ -0,0 +1,63 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +/** + * @param return type + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.3 + */ +public interface OWLOntologyChangeDataVisitor { + + /** + * @param data object to visit + * @return result of visit + */ + R visit(AddAxiomData data); + + /** + * @param data object to visit + * @return result of visit + */ + R visit(RemoveAxiomData data); + + /** + * @param data object to visit + * @return result of visit + */ + R visit(AddOntologyAnnotationData data); + + /** + * @param data object to visit + * @return result of visit + */ + R visit(RemoveOntologyAnnotationData data); + + /** + * @param data object to visit + * @return result of visit + */ + R visit(SetOntologyIDData data); + + /** + * @param data object to visit + * @return result of visit + */ + R visit(AddImportData data); + + /** + * @param data object to visit + * @return result of visit + */ + R visit(RemoveImportData data); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/OWLOntologyChangeRecord.java b/api/src/main/java/org/semanticweb/owlapi/change/OWLOntologyChangeRecord.java new file mode 100644 index 0000000000..9157926110 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/OWLOntologyChangeRecord.java @@ -0,0 +1,160 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.io.Serializable; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.UnknownOWLOntologyException; + +/** + * Associates an {@link OWLOntologyID} with ontology-less change data.
+ * An {@link OWLOntologyChangeRecord} captures information about an {@link OWLOntologyChange} in a + * way that does not require a reference to an {@link OWLOntology} object. It does this by + * referencing an {@link OWLOntologyID} instead of referencing an {@link OWLOntology}. The primary + * reason for doing this is so that changes can be serialized and logged more easily. It should be + * kept in mind that {@link OWLOntologyChangeRecord} objects can represent changes for which there + * might be no in memory representation of a specific {@link OWLOntology}. This is also true if an + * {@link OWLOntology} object has its {@link OWLOntologyID} changed.
+ * An {@link OWLOntologyChange} object contains two important pieces of information: + *
    + *
  1. The {@link OWLOntologyID} that identifies the ontology that the change pertains to.
  2. + *
  3. The {@link OWLOntologyChangeData} that describes the change specific data. For each kind of + * {@link OWLOntologyChange} there is a corresponding {@link OWLOntologyChangeData} class which + * captures the essential details that pertain to the change. The reason for this separation is that + * it allows change information to be captured where the context of the change (the ontology) is + * known via some other mechanism.
  4. + *
+ * {@code OWLOntologyChangeRecord} objects are immutable. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.3 + */ +public class OWLOntologyChangeRecord implements Serializable { + + private final OWLOntologyID ontologyID; + private final OWLOntologyChangeData data; + + /** + * Constructs an {@code OWLOntologyChangeRecord} object which holds information about a change + * to a particular ontology identified by an {@link OWLOntologyID} object and also change + * details specified by the {@link OWLOntologyChangeData} object. + * + * @param ontologyID The {@link OWLOntologyID} which identifies the ontology that the change was + * applied to. + * @param data The {@link OWLOntologyChangeData} that describes the particular details of the + * change. + */ + public OWLOntologyChangeRecord(OWLOntologyID ontologyID, OWLOntologyChangeData data) { + this.ontologyID = checkNotNull(ontologyID, "ontologyID must not be null"); + this.data = checkNotNull(data, "data must not be null"); + } + + /** + * A convenience method that creates an {@code OWLOntologyChangeRecord} by deriving data from an + * {@link OWLOntologyChange} object. + * + * @param change The {@link OWLOntologyChange} object. + * @return instance of {@code OWLOntologyChangeRecord} + */ + public static OWLOntologyChangeRecord createFromOWLOntologyChange(OWLOntologyChange change) { + checkNotNull(change, "change must not be null"); + OWLOntologyID ontologyId = change.getOntology().getOntologyID(); + OWLOntologyChangeData data = change.getChangeData(); + return new OWLOntologyChangeRecord(ontologyId, data); + } + + /** + * Gets the {@link OWLOntologyID} that identifies the ontology associated with this change + * record. + * + * @return The {@link OWLOntologyID}. + */ + public OWLOntologyID getOntologyID() { + return ontologyID; + } + + /** + * Gets the {@link OWLOntologyChangeData} which is associated with this + * {@code OWLOntologyChangeRecord}. + * + * @return The {@link OWLOntologyChangeData}. + */ + public OWLOntologyChangeData getData() { + return data; + } + + /** + * Creates an {@link OWLOntologyChange} from the {@link OWLOntologyID} and + * {@link OWLOntologyChangeData} associated with this {@code OWLOntologyChangeRecord} object. + * The {@link OWLOntology} that is the target of the resulting {@link OWLOntologyChange} is + * derived from an {@link OWLOntologyManager}. The manager must contain an ontology that + * has an {@link OWLOntologyID} which is equal to the {@link OWLOntologyID} associated with this + * {@code OWLOntologyChangeRecord} object. + * + * @param manager The manager which will be used to obtain a reference to an {@link OWLOntology} + * object having the same {@link OWLOntologyID} as the {@link OWLOntologyID} associated + * with this {@code OWLOntologyChangeRecord}. + * @return The {@link OWLOntologyChange} object that is derived from this record's + * {@link OWLOntologyID} and {@link OWLOntologyChangeData}. The specific concrete + * subclass of the returned {@link OWLOntologyChange} will depend upon the specific + * concrete subclass of the {@link OWLOntologyChangeData} associated with this + * {@code OWLOntologyChangeRecord}. + * @throws UnknownOWLOntologyException if the specified manager does not contain an ontology + * which has an {@link OWLOntologyID} equal to the {@link OWLOntologyID} associated with + * this {@code OWLOntologyChangeRecord}. + */ + public OWLOntologyChange createOntologyChange(OWLOntologyManager manager) { + OWLOntology ontology = manager.getOntology(ontologyID); + if (ontology == null) { + throw new UnknownOWLOntologyException(ontologyID); + } + return data.createOntologyChange(ontology); + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OWLOntologyChangeRecord)) { + return false; + } + OWLOntologyChangeRecord other = (OWLOntologyChangeRecord) obj; + return ontologyID.equals(other.ontologyID) && data.equals(other.data); + } + + @Override + public int hashCode() { + return getClass().hashCode() + ontologyID.hashCode() + data.hashCode(); + } + + @Override + public String toString() { + return getName() + '(' + ontologyID + ' ' + data + ')'; + } + + /** + * @return a name for the object class + */ + public String getName() { + return getClass().getSimpleName(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/OntologyAnnotationChangeData.java b/api/src/main/java/org/semanticweb/owlapi/change/OntologyAnnotationChangeData.java new file mode 100644 index 0000000000..f9f0cc8489 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/OntologyAnnotationChangeData.java @@ -0,0 +1,64 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.AddOntologyAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLEntity; + +/** + * Represents the specific non-ontology data required by an + * {@link AddOntologyAnnotation} change.
+ * Instances of this class are immutable. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.3 + */ +public abstract class OntologyAnnotationChangeData extends OWLOntologyChangeData { + + private final OWLAnnotation annotation; + + /** + * Constructs an {@code OntologyAnnotationChangeData} object that describes + * an {@link AddOntologyAnnotation} change for the {@link OWLAnnotation} + * specified by the {@code annotation} parameter. + * + * @param annotation The {@link OWLAnnotation} that is the focus of some change. + */ + public OntologyAnnotationChangeData(OWLAnnotation annotation) { + this.annotation = checkNotNull(annotation, "annotation must not be null"); + } + + /** + * Gets the {@link OWLAnnotation} that is the focus of some + * {@link AddOntologyAnnotation} change. + * + * @return The {@link OWLAnnotation}. + */ + public OWLAnnotation getAnnotation() { + return annotation; + } + + @Override + public OWLAnnotation getItem() { + return getAnnotation(); + } + + @Override + public Stream signature() { + return annotation.signature(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/RemoveAllDisjointAxioms.java b/api/src/main/java/org/semanticweb/owlapi/change/RemoveAllDisjointAxioms.java new file mode 100644 index 0000000000..e73004d228 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/RemoveAllDisjointAxioms.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.Collection; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.RemoveAxiom; + +/** + * Given a set of ontologies, this composite change will remove all disjoint + * classes axioms from these ontologies. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class RemoveAllDisjointAxioms extends AbstractCompositeOntologyChange { + + /** + * Instantiates a new removes the all disjoint axioms. + * + * @param dataFactory factory to use + * @param ontologies ontologies to change + */ + public RemoveAllDisjointAxioms(OWLDataFactory dataFactory, Collection ontologies) { + super(dataFactory); + generateChanges(checkNotNull(ontologies, "ontologies cannot be null")); + } + + private void generateChanges(Collection ontologies) { + for (OWLOntology ont : ontologies) { + ont.axioms(AxiomType.DISJOINT_CLASSES) + .forEach(ax -> addChange(new RemoveAxiom(ont, ax))); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/RemoveAxiomData.java b/api/src/main/java/org/semanticweb/owlapi/change/RemoveAxiomData.java new file mode 100644 index 0000000000..c377711320 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/RemoveAxiomData.java @@ -0,0 +1,48 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.RemoveAxiom; + +/** + * Represents the specific non-ontology data required by an {@link RemoveAxiom} + * change.
+ * Instances of this class are immutable. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.3 + */ +public class RemoveAxiomData extends AxiomChangeData { + + /** + * Constructs an {@code RemoveAxiomData} object which specifies the removal + * of an axiom from an ontology. + * + * @param axiom The {@link OWLAxiom} being added. + */ + public RemoveAxiomData(OWLAxiom axiom) { + super(axiom); + } + + @Override + public RemoveAxiom createOntologyChange(OWLOntology ontology) { + return new RemoveAxiom(ontology, getAxiom()); + } + + @Override + public O accept(OWLOntologyChangeDataVisitor visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/RemoveImportData.java b/api/src/main/java/org/semanticweb/owlapi/change/RemoveImportData.java new file mode 100644 index 0000000000..6308645d12 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/RemoveImportData.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import org.semanticweb.owlapi.model.OWLImportsDeclaration; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.RemoveImport; + +/** + * Represents the specific non-ontology data required by a + * {@link org.semanticweb.owlapi.model.RemoveImport} change.
+ * Instances of this class are immutable. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.3 + */ +public class RemoveImportData extends ImportChangeData { + + /** + * Constructs a {@code RemoveImportData} object that describes a + * {@link org.semanticweb.owlapi.model.RemoveImport} change for the + * {@link OWLImportsDeclaration} specified by the {@code declaration} + * parameter. + * + * @param declaration The {@link OWLImportsDeclaration} that is the focus of some change. + */ + public RemoveImportData(OWLImportsDeclaration declaration) { + super(declaration); + } + + @Override + public RemoveImport createOntologyChange(OWLOntology ontology) { + return new RemoveImport(ontology, getDeclaration()); + } + + @Override + public O accept(OWLOntologyChangeDataVisitor visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/RemoveOntologyAnnotationData.java b/api/src/main/java/org/semanticweb/owlapi/change/RemoveOntologyAnnotationData.java new file mode 100644 index 0000000000..c400a85e0e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/RemoveOntologyAnnotationData.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.RemoveOntologyAnnotation; + +/** + * Represents the specific non-ontology data required by a + * {@link org.semanticweb.owlapi.model.RemoveOntologyAnnotation} change.
+ * Instances of this class are immutable. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.3 + */ +public class RemoveOntologyAnnotationData extends OntologyAnnotationChangeData { + + /** + * Constructs a {@code RemoveOntologyAnnotationData} object that describes a + * {@link org.semanticweb.owlapi.model.RemoveOntologyAnnotation} change for + * the {@link OWLAnnotation} specified by the {@code annotation} parameter. + * + * @param annotation The {@link OWLAnnotation} that is the focus of some change. + */ + public RemoveOntologyAnnotationData(OWLAnnotation annotation) { + super(annotation); + } + + @Override + public RemoveOntologyAnnotation createOntologyChange(OWLOntology ontology) { + return new RemoveOntologyAnnotation(ontology, getAnnotation()); + } + + @Override + public O accept(OWLOntologyChangeDataVisitor visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/SetOntologyIDData.java b/api/src/main/java/org/semanticweb/owlapi/change/SetOntologyIDData.java new file mode 100644 index 0000000000..5221cb37bb --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/SetOntologyIDData.java @@ -0,0 +1,68 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.SetOntologyID; + +/** + * Represents the specific non-ontology data required by a + * {@link org.semanticweb.owlapi.model.SetOntologyID} change.
+ * Instances of this class are immutable. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.3 + */ +public class SetOntologyIDData extends OWLOntologyChangeData { + + private final OWLOntologyID newId; + + /** + * Constructs a {@code SetOntologyIDData} object that describes an + * {@link SetOntologyID} change for the {@link OWLOntologyID} object + * specified by the {@code newId} parameter. + * + * @param newId The {@link OWLOntologyID} that is the focus of some change. + */ + public SetOntologyIDData(OWLOntologyID newId) { + this.newId = checkNotNull(newId, "newId must not be null"); + } + + /** + * Gets the {@link OWLOntologyID} that is associated with some + * {@link SetOntologyID} change. + * + * @return The {@link OWLOntologyID}. + */ + public OWLOntologyID getNewId() { + return newId; + } + + @Override + public SetOntologyID createOntologyChange(OWLOntology ontology) { + return new SetOntologyID(ontology, newId); + } + + @Override + public O accept(OWLOntologyChangeDataVisitor visitor) { + return visitor.visit(this); + } + + @Override + public OWLOntologyID getItem() { + return getNewId(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/ShortForm2AnnotationGenerator.java b/api/src/main/java/org/semanticweb/owlapi/change/ShortForm2AnnotationGenerator.java new file mode 100644 index 0000000000..34f3b1bc52 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/ShortForm2AnnotationGenerator.java @@ -0,0 +1,89 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.util.ImportsStructureEntitySorter; +import org.semanticweb.owlapi.util.ShortFormProvider; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class ShortForm2AnnotationGenerator extends AbstractCompositeOntologyChange { + + /** + * Instantiates a new short form2 annotation generator. + * + * @param df data factory + * @param ontologyManager the ontology manager + * @param ontology the ontology + * @param shortFormProvider the short form provider + * @param annotationIRI The annotation IRI to be used + * @param languageTag language + */ + public ShortForm2AnnotationGenerator(OWLDataFactory df, OWLOntologyManager ontologyManager, + OWLOntology ontology, + ShortFormProvider shortFormProvider, IRI annotationIRI, @Nullable String languageTag) { + super(df); + generateChanges(checkNotNull(ontologyManager, "ontologyManager cannot be null"), + checkNotNull(ontology, "ontology cannot be null"), + checkNotNull(shortFormProvider, "shortFormProvider cannot be null"), + checkNotNull(annotationIRI, "annotationIRI cannot be null"), languageTag); + } + + /** + * Instantiates a new short form2 annotation generator. + * + * @param df data factory + * @param ontologyManager the ontology manager + * @param ontology the ontology + * @param shortFormProvider the short form provider + * @param annotationIRI iri for annotation property + */ + public ShortForm2AnnotationGenerator(OWLDataFactory df, OWLOntologyManager ontologyManager, + OWLOntology ontology, + ShortFormProvider shortFormProvider, IRI annotationIRI) { + this(df, ontologyManager, ontology, shortFormProvider, annotationIRI, null); + } + + private static void generateChanges(OWLOntologyManager ontologyManager, OWLOntology o, + ShortFormProvider provider, + IRI annotationIRI, @Nullable String lang) { + OWLDataFactory df = ontologyManager.getOWLDataFactory(); + OWLAnnotationProperty ap = df.getOWLAnnotationProperty(annotationIRI); + new ImportsStructureEntitySorter(o).getObjects().forEach((ont, ent) -> ent.forEach(e -> { + if (o.containsEntityInSignature(e)) { + ont.add(df.getOWLAnnotationAssertionAxiom(ap, e.getIRI(), + action(e, lang, provider, df))); + } + })); + } + + private static OWLLiteral action(OWLEntity e, @Nullable String lang, ShortFormProvider provider, + OWLDataFactory df) { + if (lang != null) { + return df.getOWLLiteral(provider.getShortForm(e), lang); + } + return df.getOWLLiteral(provider.getShortForm(e)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/SplitSubClassAxioms.java b/api/src/main/java/org/semanticweb/owlapi/change/SplitSubClassAxioms.java new file mode 100644 index 0000000000..ecd8fb3f93 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/SplitSubClassAxioms.java @@ -0,0 +1,87 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLClassExpressionVisitor; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.RemoveAxiom; + +/** + * Given a set of ontologies, this composite change will replace all subclass axioms in each + * ontology, whose super class is an object intersection (conjunction) with multiple subclass axioms + * - one for each conjunct. For example, A subClassOf (B and C), would be replaced with two subclass + * axioms, A subClassOf B, and A subClassOf C. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.1 + */ +public class SplitSubClassAxioms extends AbstractCompositeOntologyChange { + + /** + * Creates a composite change to split subclass axioms into multiple more fine grained subclass + * axioms. + * + * @param ontologies The ontologies whose subclass axioms should be processed. + * @param dataFactory The data factory which should be used to create new axioms. + */ + public SplitSubClassAxioms(Collection ontologies, OWLDataFactory dataFactory) { + super(dataFactory); + ontologies.forEach(o -> o.axioms(AxiomType.SUBCLASS_OF).forEach(ax -> split(o, ax))); + } + + protected void split(OWLOntology o, OWLSubClassOfAxiom ax) { + ConjunctSplitter splitter = new ConjunctSplitter(); + ax.getSuperClass().accept(splitter); + if (splitter.result.size() > 1) { + addChange(new RemoveAxiom(o, ax)); + splitter.result.forEach(desc -> addChange( + new AddAxiom(o, df.getOWLSubClassOfAxiom(ax.getSubClass(), desc)))); + } + } + + /** + * The Class ConjunctSplitter. + */ + private static class ConjunctSplitter implements OWLClassExpressionVisitor { + + /** + * The result. + */ + final Set result = new HashSet<>(); + + /** + * Instantiates a new conjunct splitter. + */ + ConjunctSplitter() {} + + @Override + public void doDefault(Object object) { + result.add((OWLClassExpression) object); + } + + @Override + public void visit(OWLObjectIntersectionOf ce) { + ce.operands().forEach(op -> op.accept(this)); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/change/package-info.java b/api/src/main/java/org/semanticweb/owlapi/change/package-info.java new file mode 100644 index 0000000000..a82776927a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Ontology change classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.change; diff --git a/api/src/main/java/org/semanticweb/owlapi/change/packageinfo b/api/src/main/java/org/semanticweb/owlapi/change/packageinfo new file mode 100644 index 0000000000..7c7a9efd9c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/change/packageinfo @@ -0,0 +1 @@ +version 5.1.0 diff --git a/api/src/main/java/org/semanticweb/owlapi/expression/OWLClassExpressionParser.java b/api/src/main/java/org/semanticweb/owlapi/expression/OWLClassExpressionParser.java new file mode 100644 index 0000000000..b825dece85 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/expression/OWLClassExpressionParser.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.expression; + +import org.semanticweb.owlapi.model.OWLClassExpression; + +/** + * An expression parser that parses expressions that correspond to class + * expressions. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public interface OWLClassExpressionParser extends + OWLExpressionParser { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/expression/OWLEntityChecker.java b/api/src/main/java/org/semanticweb/owlapi/expression/OWLEntityChecker.java new file mode 100644 index 0000000000..b734d49c8e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/expression/OWLEntityChecker.java @@ -0,0 +1,72 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.expression; + +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; + +/** + * Maps strings to OWL objects. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public interface OWLEntityChecker { + + /** + * @param name name to resolve + * @return OWLClass corresponding to name + */ + @Nullable + OWLClass getOWLClass(String name); + + /** + * @param name name to resolve + * @return OWLObjectProperty corresponding to name + */ + @Nullable + OWLObjectProperty getOWLObjectProperty(String name); + + /** + * @param name name to resolve + * @return OWLDataProperty corresponding to name + */ + @Nullable + OWLDataProperty getOWLDataProperty(String name); + + /** + * @param name name to resolve + * @return OWLNamedIndividual corresponding to name + */ + @Nullable + OWLNamedIndividual getOWLIndividual(String name); + + /** + * @param name name to resolve + * @return OWLDatatype corresponding to name + */ + @Nullable + OWLDatatype getOWLDatatype(String name); + + /** + * @param name name to resolve + * @return OWLAnnotationProperty corresponding to name + */ + @Nullable + OWLAnnotationProperty getOWLAnnotationProperty(String name); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/expression/OWLExpressionParser.java b/api/src/main/java/org/semanticweb/owlapi/expression/OWLExpressionParser.java new file mode 100644 index 0000000000..9c21b9f53f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/expression/OWLExpressionParser.java @@ -0,0 +1,38 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.expression; + +import org.semanticweb.owlapi.io.OWLParserException; + +/** + * A general purpose interface which provides the ability to parse some + * expression into some kind of object. + * + * @param the kind of parsed expression + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public interface OWLExpressionParser { + + /** + * @param entityChecker the entity checker to use + */ + void setOWLEntityChecker(OWLEntityChecker entityChecker); + + /** + * @param expression the expression to parse + * @return the parsed expression + * @throws OWLParserException parse exception + */ + O parse(String expression); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/expression/OWLOntologyChecker.java b/api/src/main/java/org/semanticweb/owlapi/expression/OWLOntologyChecker.java new file mode 100644 index 0000000000..7b44455b7b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/expression/OWLOntologyChecker.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.expression; + +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +@FunctionalInterface +public interface OWLOntologyChecker { + + /** + * @param name the ontology name + * @return the ontology + */ + @Nullable + OWLOntology getOntology(@Nullable String name); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/expression/ShortFormEntityChecker.java b/api/src/main/java/org/semanticweb/owlapi/expression/ShortFormEntityChecker.java new file mode 100644 index 0000000000..5f4ce96d70 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/expression/ShortFormEntityChecker.java @@ -0,0 +1,99 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.expression; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.Optional; +import java.util.function.Function; +import java.util.function.Predicate; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.util.BidirectionalShortFormProvider; + +/** + * An entity checker that maps from string to entities using a bidirectional + * short form provider. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class ShortFormEntityChecker implements OWLEntityChecker { + + private final BidirectionalShortFormProvider shortFormProvider; + + /** + * Creates a short form entity checker, which uses the specified + * bidirectional short form provider to map entity name strings to entities. + * + * @param shortFormProvider The BidirectionalShortFormProvider that should be used to perform + * the required mapping. + */ + public ShortFormEntityChecker(BidirectionalShortFormProvider shortFormProvider) { + this.shortFormProvider = checkNotNull(shortFormProvider, + "shortFormProvider cannot be null"); + } + + @Override + @Nullable + public OWLClass getOWLClass(String name) { + return find(name, OWLEntity::isOWLClass, OWLEntity::asOWLClass); + } + + @Override + @Nullable + public OWLDataProperty getOWLDataProperty(String name) { + return find(name, OWLEntity::isOWLDataProperty, OWLEntity::asOWLDataProperty); + } + + @Override + @Nullable + public OWLDatatype getOWLDatatype(String name) { + return find(name, OWLEntity::isOWLDatatype, OWLEntity::asOWLDatatype); + } + + @Override + @Nullable + public OWLNamedIndividual getOWLIndividual(String name) { + return find(name, OWLEntity::isOWLNamedIndividual, OWLEntity::asOWLNamedIndividual); + } + + @Override + @Nullable + public OWLObjectProperty getOWLObjectProperty(String name) { + return find(name, OWLEntity::isOWLObjectProperty, OWLEntity::asOWLObjectProperty); + } + + @Override + @Nullable + public OWLAnnotationProperty getOWLAnnotationProperty(String name) { + return find(name, OWLEntity::isOWLAnnotationProperty, OWLEntity::asOWLAnnotationProperty); + } + + @Nullable + protected T find(String name, Predicate p, + Function f) { + checkNotNull(name, "name cannot be null"); + Optional findFirst = shortFormProvider.entities(name).filter(p).findFirst(); + if (findFirst.isPresent()) { + return f.apply(findFirst.get()); + } + return null; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/expression/package-info.java b/api/src/main/java/org/semanticweb/owlapi/expression/package-info.java new file mode 100644 index 0000000000..c065eaebaa --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/expression/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Expression parsers package. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.expression; diff --git a/api/src/main/java/org/semanticweb/owlapi/expression/packageinfo b/api/src/main/java/org/semanticweb/owlapi/expression/packageinfo new file mode 100644 index 0000000000..3e36a90ba1 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/expression/packageinfo @@ -0,0 +1 @@ +version 5.0.1 diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/AbstractRDFNonPrefixDocumentFormat.java b/api/src/main/java/org/semanticweb/owlapi/formats/AbstractRDFNonPrefixDocumentFormat.java new file mode 100644 index 0000000000..bde5b80db2 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/AbstractRDFNonPrefixDocumentFormat.java @@ -0,0 +1,36 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import java.util.HashSet; +import java.util.Set; + +import org.semanticweb.owlapi.io.RDFResourceParseError; +import org.semanticweb.owlapi.model.OWLDocumentFormatImpl; + +/** + * An abstract base class for RDF Document Formats that are not prefix aware. + * + * @since 4.0.1 + */ +public abstract class AbstractRDFNonPrefixDocumentFormat extends OWLDocumentFormatImpl implements + RDFDocumentFormat { + + // TODO make something of these + private final Set errors = new HashSet<>(); + + @Override + public void addError(RDFResourceParseError error) { + errors.add(error); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/AbstractRDFPrefixDocumentFormat.java b/api/src/main/java/org/semanticweb/owlapi/formats/AbstractRDFPrefixDocumentFormat.java new file mode 100644 index 0000000000..ac8a89715b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/AbstractRDFPrefixDocumentFormat.java @@ -0,0 +1,38 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import java.util.HashSet; +import java.util.Set; + +import org.semanticweb.owlapi.io.RDFResourceParseError; + +/** + * An Abstract Document Format for Prefix aware RDF formats. Renamed from + * AbstractDFDocumentFormat + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @author Simon Spero + * @since 4.0.1 + */ +public abstract class AbstractRDFPrefixDocumentFormat extends PrefixDocumentFormatImpl implements + RDFDocumentFormat { + + // TODO make something of these + private final Set errors = new HashSet<>(); + + @Override + public void addError(RDFResourceParseError error) { + errors.add(error); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/DLSyntaxDocumentFormat.java b/api/src/main/java/org/semanticweb/owlapi/formats/DLSyntaxDocumentFormat.java new file mode 100644 index 0000000000..732cbdd06e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/DLSyntaxDocumentFormat.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import org.semanticweb.owlapi.model.OWLDocumentFormatImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class DLSyntaxDocumentFormat extends OWLDocumentFormatImpl { + + @Override + public String getKey() { + return "DL Syntax Format"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/DLSyntaxDocumentFormatFactory.java b/api/src/main/java/org/semanticweb/owlapi/formats/DLSyntaxDocumentFormatFactory.java new file mode 100644 index 0000000000..3d46176ac0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/DLSyntaxDocumentFormatFactory.java @@ -0,0 +1,33 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.util.OWLDocumentFormatFactoryImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class DLSyntaxDocumentFormatFactory extends OWLDocumentFormatFactoryImpl { + + @Override + public String getKey() { + return "DL Syntax Format"; + } + + @Override + public OWLDocumentFormat createFormat() { + return new DLSyntaxDocumentFormat(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/DLSyntaxHTMLDocumentFormat.java b/api/src/main/java/org/semanticweb/owlapi/formats/DLSyntaxHTMLDocumentFormat.java new file mode 100644 index 0000000000..3226efb25e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/DLSyntaxHTMLDocumentFormat.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import org.semanticweb.owlapi.model.OWLDocumentFormatImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class DLSyntaxHTMLDocumentFormat extends OWLDocumentFormatImpl { + + @Override + public String getKey() { + return "DL Syntax - HTML Format"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/DLSyntaxHTMLDocumentFormatFactory.java b/api/src/main/java/org/semanticweb/owlapi/formats/DLSyntaxHTMLDocumentFormatFactory.java new file mode 100644 index 0000000000..c4c59df729 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/DLSyntaxHTMLDocumentFormatFactory.java @@ -0,0 +1,33 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.util.OWLDocumentFormatFactoryImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class DLSyntaxHTMLDocumentFormatFactory extends OWLDocumentFormatFactoryImpl { + + @Override + public String getKey() { + return "DL Syntax - HTML Format"; + } + + @Override + public OWLDocumentFormat createFormat() { + return new DLSyntaxHTMLDocumentFormat(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/FunctionalSyntaxDocumentFormat.java b/api/src/main/java/org/semanticweb/owlapi/formats/FunctionalSyntaxDocumentFormat.java new file mode 100644 index 0000000000..4bd33cd25a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/FunctionalSyntaxDocumentFormat.java @@ -0,0 +1,25 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class FunctionalSyntaxDocumentFormat extends PrefixDocumentFormatImpl { + + @Override + public String getKey() { + return "OWL Functional Syntax"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/FunctionalSyntaxDocumentFormatFactory.java b/api/src/main/java/org/semanticweb/owlapi/formats/FunctionalSyntaxDocumentFormatFactory.java new file mode 100644 index 0000000000..1c8095263f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/FunctionalSyntaxDocumentFormatFactory.java @@ -0,0 +1,39 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import java.util.Collections; + +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.util.OWLDocumentFormatFactoryImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class FunctionalSyntaxDocumentFormatFactory extends OWLDocumentFormatFactoryImpl { + /** MIME type is text/owl-functional */ + public FunctionalSyntaxDocumentFormatFactory() { + super(Collections.singletonList("text/owl-functional")); + } + + @Override + public String getKey() { + return "OWL Functional Syntax"; + } + + @Override + public OWLDocumentFormat createFormat() { + return new FunctionalSyntaxDocumentFormat(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/KRSS2DocumentFormat.java b/api/src/main/java/org/semanticweb/owlapi/formats/KRSS2DocumentFormat.java new file mode 100755 index 0000000000..7d97cde39a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/KRSS2DocumentFormat.java @@ -0,0 +1,26 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import org.semanticweb.owlapi.model.OWLDocumentFormatImpl; + +/** + * @author Olaf Noppens, Ulm University, Institute of Artificial Intelligence + */ +public class KRSS2DocumentFormat extends OWLDocumentFormatImpl { + + @Override + public String getKey() { + return "KRSS2 Syntax"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/KRSS2DocumentFormatFactory.java b/api/src/main/java/org/semanticweb/owlapi/formats/KRSS2DocumentFormatFactory.java new file mode 100644 index 0000000000..bbbbf2a258 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/KRSS2DocumentFormatFactory.java @@ -0,0 +1,33 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.util.OWLDocumentFormatFactoryImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class KRSS2DocumentFormatFactory extends OWLDocumentFormatFactoryImpl { + + @Override + public String getKey() { + return "KRSS2 Syntax"; + } + + @Override + public OWLDocumentFormat createFormat() { + return new KRSS2DocumentFormat(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/KRSSDocumentFormat.java b/api/src/main/java/org/semanticweb/owlapi/formats/KRSSDocumentFormat.java new file mode 100644 index 0000000000..c5c2e880db --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/KRSSDocumentFormat.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import org.semanticweb.owlapi.model.OWLDocumentFormatImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class KRSSDocumentFormat extends OWLDocumentFormatImpl { + + @Override + public String getKey() { + return "KRSS Syntax"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/KRSSDocumentFormatFactory.java b/api/src/main/java/org/semanticweb/owlapi/formats/KRSSDocumentFormatFactory.java new file mode 100644 index 0000000000..e79b7d0bad --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/KRSSDocumentFormatFactory.java @@ -0,0 +1,33 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.util.OWLDocumentFormatFactoryImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class KRSSDocumentFormatFactory extends OWLDocumentFormatFactoryImpl { + + @Override + public String getKey() { + return "KRSS Syntax"; + } + + @Override + public OWLDocumentFormat createFormat() { + return new KRSSDocumentFormat(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/LabelFunctionalDocumentFormat.java b/api/src/main/java/org/semanticweb/owlapi/formats/LabelFunctionalDocumentFormat.java new file mode 100644 index 0000000000..acb3824010 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/LabelFunctionalDocumentFormat.java @@ -0,0 +1,29 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import org.semanticweb.owlapi.model.OWLDocumentFormatImpl; + +/** + * Format for serializing an OWL ontology in a functional syntax format and + * labels instead of identifiers. WARNING: This will produce a file, which + * cannot be read with the OWL-API. This is only intended to be used as basis + * for human readable version version control diffs. + */ +public class LabelFunctionalDocumentFormat extends OWLDocumentFormatImpl { + + @Override + public String getKey() { + return "Label functional Syntax"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/LabelFunctionalDocumentFormatFactory.java b/api/src/main/java/org/semanticweb/owlapi/formats/LabelFunctionalDocumentFormatFactory.java new file mode 100644 index 0000000000..65eb3b9f00 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/LabelFunctionalDocumentFormatFactory.java @@ -0,0 +1,33 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.util.OWLDocumentFormatFactoryImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class LabelFunctionalDocumentFormatFactory extends OWLDocumentFormatFactoryImpl { + + @Override + public String getKey() { + return "Label functional Syntax"; + } + + @Override + public OWLDocumentFormat createFormat() { + return new LabelFunctionalDocumentFormat(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/LatexAxiomsListDocumentFormat.java b/api/src/main/java/org/semanticweb/owlapi/formats/LatexAxiomsListDocumentFormat.java new file mode 100644 index 0000000000..1c92410eaa --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/LatexAxiomsListDocumentFormat.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import org.semanticweb.owlapi.model.OWLDocumentFormatImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Information Management Group + * @since 2.2.0 + */ +public class LatexAxiomsListDocumentFormat extends OWLDocumentFormatImpl { + + @Override + public String getKey() { + return "Latex Axiom List"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/LatexAxiomsListDocumentFormatFactory.java b/api/src/main/java/org/semanticweb/owlapi/formats/LatexAxiomsListDocumentFormatFactory.java new file mode 100644 index 0000000000..342cc311d9 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/LatexAxiomsListDocumentFormatFactory.java @@ -0,0 +1,33 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.util.OWLDocumentFormatFactoryImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class LatexAxiomsListDocumentFormatFactory extends OWLDocumentFormatFactoryImpl { + + @Override + public String getKey() { + return "Latex Axiom List"; + } + + @Override + public OWLDocumentFormat createFormat() { + return new LatexAxiomsListDocumentFormat(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/LatexDocumentFormat.java b/api/src/main/java/org/semanticweb/owlapi/formats/LatexDocumentFormat.java new file mode 100644 index 0000000000..af224fdf0a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/LatexDocumentFormat.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import org.semanticweb.owlapi.model.OWLDocumentFormatImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class LatexDocumentFormat extends OWLDocumentFormatImpl { + + @Override + public String getKey() { + return "LaTeX Syntax"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/LatexDocumentFormatFactory.java b/api/src/main/java/org/semanticweb/owlapi/formats/LatexDocumentFormatFactory.java new file mode 100644 index 0000000000..9d03861036 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/LatexDocumentFormatFactory.java @@ -0,0 +1,33 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.util.OWLDocumentFormatFactoryImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class LatexDocumentFormatFactory extends OWLDocumentFormatFactoryImpl { + + @Override + public String getKey() { + return "LaTeX Syntax"; + } + + @Override + public OWLDocumentFormat createFormat() { + return new LatexDocumentFormat(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/ManchesterSyntaxDocumentFormat.java b/api/src/main/java/org/semanticweb/owlapi/formats/ManchesterSyntaxDocumentFormat.java new file mode 100644 index 0000000000..d7581c49a6 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/ManchesterSyntaxDocumentFormat.java @@ -0,0 +1,25 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class ManchesterSyntaxDocumentFormat extends PrefixDocumentFormatImpl { + + @Override + public String getKey() { + return "Manchester OWL Syntax"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/ManchesterSyntaxDocumentFormatFactory.java b/api/src/main/java/org/semanticweb/owlapi/formats/ManchesterSyntaxDocumentFormatFactory.java new file mode 100644 index 0000000000..f4e99a2300 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/ManchesterSyntaxDocumentFormatFactory.java @@ -0,0 +1,39 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import java.util.Collections; + +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.util.OWLDocumentFormatFactoryImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class ManchesterSyntaxDocumentFormatFactory extends OWLDocumentFormatFactoryImpl { + /** Default MIME type is text/owl-manchester */ + public ManchesterSyntaxDocumentFormatFactory() { + super(Collections.singletonList("text/owl-manchester")); + } + + @Override + public String getKey() { + return "Manchester OWL Syntax"; + } + + @Override + public OWLDocumentFormat createFormat() { + return new ManchesterSyntaxDocumentFormat(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/OBODocumentFormat.java b/api/src/main/java/org/semanticweb/owlapi/formats/OBODocumentFormat.java new file mode 100644 index 0000000000..c45143016e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/OBODocumentFormat.java @@ -0,0 +1,33 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import org.semanticweb.owlapi.model.OWLDocumentFormatImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OBODocumentFormat extends OWLDocumentFormatImpl { + + /** + * Key for validation parameter. Currently supports Boolean.TRUE and + * Boolean.FALSE. No parameter is interpreted as TRUE. + */ + public static final String VALIDATION = "obo.validation"; + + @Override + public String getKey() { + return "OBO Format"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/OBODocumentFormatFactory.java b/api/src/main/java/org/semanticweb/owlapi/formats/OBODocumentFormatFactory.java new file mode 100644 index 0000000000..5022334927 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/OBODocumentFormatFactory.java @@ -0,0 +1,33 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.util.OWLDocumentFormatFactoryImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class OBODocumentFormatFactory extends OWLDocumentFormatFactoryImpl { + + @Override + public String getKey() { + return "OBO Format"; + } + + @Override + public OWLDocumentFormat createFormat() { + return new OBODocumentFormat(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/OWLXMLDocumentFormat.java b/api/src/main/java/org/semanticweb/owlapi/formats/OWLXMLDocumentFormat.java new file mode 100644 index 0000000000..f7e4119d7f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/OWLXMLDocumentFormat.java @@ -0,0 +1,25 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLXMLDocumentFormat extends PrefixDocumentFormatImpl { + + @Override + public String getKey() { + return "OWL/XML Syntax"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/OWLXMLDocumentFormatFactory.java b/api/src/main/java/org/semanticweb/owlapi/formats/OWLXMLDocumentFormatFactory.java new file mode 100644 index 0000000000..c1ea19cb9f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/OWLXMLDocumentFormatFactory.java @@ -0,0 +1,39 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import java.util.Arrays; + +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.util.OWLDocumentFormatFactoryImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class OWLXMLDocumentFormatFactory extends OWLDocumentFormatFactoryImpl { + /** MIME types are application/owl+xml, text/xml, or default */ + public OWLXMLDocumentFormatFactory() { + super(Arrays.asList("application/owl+xml", "text/xml")); + } + + @Override + public String getKey() { + return "OWL/XML Syntax"; + } + + @Override + public OWLDocumentFormat createFormat() { + return new OWLXMLDocumentFormat(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/PrefixDocumentFormat.java b/api/src/main/java/org/semanticweb/owlapi/formats/PrefixDocumentFormat.java new file mode 100644 index 0000000000..34cfeaa70a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/PrefixDocumentFormat.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.PrefixManager; + +/** + * A PrefixOWLDocumentFormat delegates all PrefixManager operations to a + * PrefixManager implementation. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface PrefixDocumentFormat extends OWLDocumentFormat, PrefixManager { + + /** + * @param m prefix manager to use + */ + void setPrefixManager(PrefixManager m); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/PrefixDocumentFormatImpl.java b/api/src/main/java/org/semanticweb/owlapi/formats/PrefixDocumentFormatImpl.java new file mode 100644 index 0000000000..56c3f225a4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/PrefixDocumentFormatImpl.java @@ -0,0 +1,151 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.Map; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDocumentFormatImpl; +import org.semanticweb.owlapi.model.PrefixManager; +import org.semanticweb.owlapi.util.DefaultPrefixManager; +import org.semanticweb.owlapi.util.StringComparator; + +/** + * A PrefixOWLDocumentFormat delegates all PrefixManager operations to a + * PrefixManager implementation. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class PrefixDocumentFormatImpl extends OWLDocumentFormatImpl implements + PrefixDocumentFormat { + + private PrefixManager nsm; + + /** + * Default constructor. + */ + public PrefixDocumentFormatImpl() { + this(new DefaultPrefixManager()); + } + + /** + * @param manager prefix manager to use + */ + public PrefixDocumentFormatImpl(PrefixManager manager) { + nsm = checkNotNull(manager, "manager cannot be null"); + } + + @Override + public void setPrefixManager(PrefixManager m) { + nsm = checkNotNull(m, "m cannot be null"); + } + + @Override + public void setPrefix(String prefixName, String prefix) { + nsm.setPrefix(prefixName, prefix); + } + + @Override + public void clear() { + nsm.clear(); + } + + @Override + public Stream prefixNames() { + return nsm.prefixNames(); + } + + @Override + public boolean containsPrefixMapping(String prefixName) { + return nsm.containsPrefixMapping(prefixName); + } + + @Override + @Nullable + public String getDefaultPrefix() { + return nsm.getDefaultPrefix(); + } + + @Override + public void setDefaultPrefix(@Nullable String defaultPrefix) { + nsm.setDefaultPrefix(defaultPrefix); + } + + @Override + public Map getPrefixName2PrefixMap() { + return nsm.getPrefixName2PrefixMap(); + } + + @Override + @Nullable + public String getPrefix(String prefixName) { + return nsm.getPrefix(prefixName); + } + + @Override + public IRI getIRI(String prefixIRI) { + return nsm.getIRI(prefixIRI); + } + + @Override + @Nullable + public String getPrefixIRI(IRI iri) { + return nsm.getPrefixIRI(iri); + } + + @Override + public String getPrefixIRIIgnoreQName(IRI iri) { + return nsm.getPrefixIRIIgnoreQName(iri); + } + + @Override + public void copyPrefixesFrom(PrefixManager from) { + nsm.copyPrefixesFrom(from); + } + + @Override + public void copyPrefixesFrom(Map from) { + nsm.copyPrefixesFrom(from); + } + + @Override + public void unregisterNamespace(String namespace) { + nsm.unregisterNamespace(namespace); + } + + @Override + public StringComparator getPrefixComparator() { + return nsm.getPrefixComparator(); + } + + @Override + public void setPrefixComparator(StringComparator comparator) { + nsm.setPrefixComparator(comparator); + } + + @Override + public String getKey() { + return "Generic prefix ontology format"; + } + + @Override + public boolean isPrefixOWLDocumentFormat() { + return true; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/RDFDocumentFormat.java b/api/src/main/java/org/semanticweb/owlapi/formats/RDFDocumentFormat.java new file mode 100644 index 0000000000..b52f9bca23 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/RDFDocumentFormat.java @@ -0,0 +1,15 @@ +package org.semanticweb.owlapi.formats; + +import org.semanticweb.owlapi.io.RDFResourceParseError; +import org.semanticweb.owlapi.model.OWLDocumentFormat; + +/** + * An RDF OWL Document Format. + */ +public interface RDFDocumentFormat extends OWLDocumentFormat { + + /** + * @param error error to add to the error set + */ + public void addError(RDFResourceParseError error); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/RDFXMLDocumentFormat.java b/api/src/main/java/org/semanticweb/owlapi/formats/RDFXMLDocumentFormat.java new file mode 100644 index 0000000000..cfb2836013 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/RDFXMLDocumentFormat.java @@ -0,0 +1,25 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class RDFXMLDocumentFormat extends AbstractRDFPrefixDocumentFormat { + + @Override + public String getKey() { + return "RDF/XML Syntax"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/RDFXMLDocumentFormatFactory.java b/api/src/main/java/org/semanticweb/owlapi/formats/RDFXMLDocumentFormatFactory.java new file mode 100644 index 0000000000..f573d0bfa4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/RDFXMLDocumentFormatFactory.java @@ -0,0 +1,40 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import java.util.Arrays; + +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.util.OWLDocumentFormatFactoryImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class RDFXMLDocumentFormatFactory extends OWLDocumentFormatFactoryImpl { + /** MIME types are application/rdf+xml, application/xml, text/xml */ + public RDFXMLDocumentFormatFactory() { + super(Arrays.asList("application/rdf+xml", "application/xml", + "text/xml")); + } + + @Override + public String getKey() { + return "RDF/XML Syntax"; + } + + @Override + public OWLDocumentFormat createFormat() { + return new RDFXMLDocumentFormat(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/TurtleDocumentFormat.java b/api/src/main/java/org/semanticweb/owlapi/formats/TurtleDocumentFormat.java new file mode 100644 index 0000000000..fba74a1edc --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/TurtleDocumentFormat.java @@ -0,0 +1,25 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class TurtleDocumentFormat extends AbstractRDFPrefixDocumentFormat { + + @Override + public String getKey() { + return "Turtle Syntax"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/TurtleDocumentFormatFactory.java b/api/src/main/java/org/semanticweb/owlapi/formats/TurtleDocumentFormatFactory.java new file mode 100644 index 0000000000..6022d21837 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/TurtleDocumentFormatFactory.java @@ -0,0 +1,39 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.formats; + +import java.util.Arrays; + +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.util.OWLDocumentFormatFactoryImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class TurtleDocumentFormatFactory extends OWLDocumentFormatFactoryImpl { + /** MIME types are text/turtle, application/x-turtle */ + public TurtleDocumentFormatFactory() { + super(Arrays.asList("text/turtle", "application/x-turtle")); + } + + @Override + public String getKey() { + return "Turtle Syntax"; + } + + @Override + public OWLDocumentFormat createFormat() { + return new TurtleDocumentFormat(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/package-info.java b/api/src/main/java/org/semanticweb/owlapi/formats/package-info.java new file mode 100644 index 0000000000..a231d2e460 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Formats package. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.formats; diff --git a/api/src/main/java/org/semanticweb/owlapi/formats/packageinfo b/api/src/main/java/org/semanticweb/owlapi/formats/packageinfo new file mode 100644 index 0000000000..992045e711 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/formats/packageinfo @@ -0,0 +1 @@ +version 6.0.0 diff --git a/api/src/main/java/org/semanticweb/owlapi/io/AbstractOWLParser.java b/api/src/main/java/org/semanticweb/owlapi/io/AbstractOWLParser.java new file mode 100644 index 0000000000..aaf59623c2 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/AbstractOWLParser.java @@ -0,0 +1,43 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import java.io.Reader; +import java.io.Serializable; +import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration; +import org.xml.sax.InputSource; + +/** + * A convenience base class for parsers, which provides a mechanism to manage + * the setting and getting of the {@code OWLOntologyManager} that should be + * associated with the parser. Note: all current parser implementations are + * stateless. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public abstract class AbstractOWLParser implements OWLParser, Serializable { + + protected AbstractOWLParser() { + } + + @SuppressWarnings("resource") + protected InputSource getInputSource(OWLOntologyDocumentSource source, + OWLOntologyLoaderConfiguration config) + throws OWLOntologyInputSourceException { + Reader in = DocumentSources.wrapInputAsReader(source, config); + InputSource is = new InputSource(in); + is.setSystemId(source.getDocumentIRI().toString()); + return is; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/AbstractOWLRenderer.java b/api/src/main/java/org/semanticweb/owlapi/io/AbstractOWLRenderer.java new file mode 100644 index 0000000000..de4067ddc9 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/AbstractOWLRenderer.java @@ -0,0 +1,55 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import java.io.BufferedWriter; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLRuntimeException; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public abstract class AbstractOWLRenderer implements OWLRenderer { + + protected AbstractOWLRenderer() { + } + + @Override + public void render(OWLOntology ontology, OutputStream os) throws OWLRendererException { + try { + PrintWriter writer = new PrintWriter( + new BufferedWriter(new OutputStreamWriter(os, StandardCharsets.UTF_8))); + render(ontology, writer); + writer.flush(); + } catch (OWLRuntimeException e) { + throw new OWLRendererIOException(e); + } + } + + /** + * Renders the specified ontology using the specified writer. + * + * @param ontology the ontology to render + * @param writer The writer that should be used to write the ontology. Note that this writer + * need not be wrapped with a {@code BufferedWriter} because this is taken care of by this + * abstract implementation. + * @throws OWLRendererException if exceptions arise + */ + public abstract void render(OWLOntology ontology, PrintWriter writer) + throws OWLRendererException; +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/DocumentSources.java b/api/src/main/java/org/semanticweb/owlapi/io/DocumentSources.java new file mode 100644 index 0000000000..a42eb0fb75 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/DocumentSources.java @@ -0,0 +1,388 @@ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.HttpURLConnection; +import java.net.JarURLConnection; +import java.net.MalformedURLException; +import java.net.SocketTimeoutException; +import java.net.URL; +import java.net.URLConnection; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.HashSet; +import java.util.Locale; +import java.util.Optional; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.zip.GZIPInputStream; +import java.util.zip.Inflater; +import java.util.zip.InflaterInputStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +import javax.annotation.Nullable; + +import org.apache.commons.io.ByteOrderMark; +import org.apache.commons.io.input.BOMInputStream; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.tukaani.xz.XZInputStream; + +/** + * Static methods from AbstractOWLParser. Mostly used by OWLOntologyDocumentSource implementations. + */ +public class DocumentSources { + + private static final Logger LOGGER = LoggerFactory.getLogger(DocumentSources.class); + private static final String ZIP_FILE_EXTENSION = ".zip"; + private static final String GZ_FILE_EXTENSION = ".gz"; + private static final String XZ_FILE_EXTENSION = ".xz"; + private static final String CONTENT_DISPOSITION_HEADER = "Content-Disposition"; + private static final Pattern CONTENT_DISPOSITION_FILE_NAME_PATTERN = + Pattern.compile(".*filename=\"([^\\s;]*)\".*"); + private static final int CONTENT_DISPOSITION_FILE_NAME_PATTERN_GROUP = 1; + private static final Pattern ZIP_ENTRY_ONTOLOGY_NAME_PATTERN = + Pattern.compile(".*owl|rdf|xml|mos"); + private static final String ACCEPTABLE_CONTENT_ENCODING = "xz,gzip,deflate"; + private static final String TEXTPLAIN_REQUEST_TYPE = ", text/plain; q=0.1"; + private static final String LAST_REQUEST_TYPE = ", */*; q=0.09"; + private static final String DEFAULT_REQUEST = + "application/rdf+xml, application/xml; q=0.7, text/xml; q=0.6" + TEXTPLAIN_REQUEST_TYPE + + LAST_REQUEST_TYPE; + + private DocumentSources() {} + + /** + * Select the available input source and, if it is not already a Reader, wrap it in a Reader. + * This method removes the duplication of code required for each caller to figure out if a + * reader or an inputstream is available. The returned Reader will be buffered. + * + * @param source ontology source + * @param configuration loader configuration to use of the reader must be built form the input + * IRI + * @param encoding character encoding if a new Reader needs to be created. + * @return A Reader for the input; if no Reader can be obtained, an + * OWLOntologyInputSourceException is thrown. + * @throws OWLOntologyInputSourceException if an IO related exception is thrown. + */ + public static Reader wrapInputAsReader(OWLOntologyDocumentSource source, + OWLOntologyLoaderConfiguration configuration, Charset encoding) + throws OWLOntologyInputSourceException { + Optional reader = source.getReader(); + if (reader.isPresent()) { + return new BufferedReader(reader.get()); + } + return new BufferedReader( + new InputStreamReader(wrap(wrapInput(source, configuration)), encoding)); + } + + /** + * Call #wrapwrapInputAsReader(OWLOntologyLoaderConfiguration, String) with UTF-* as default + * encoding. + * + * @param source ontology source + * @param configuration loader configuration to use of the reader must be built form the input + * IRI + * @return A Reader wrapped in an Optional; if no Reader can be obtained, the result is + * Optional.empty. @throws OWLOntologyInputSourceException if an IO related exception is + * thrown. + * @throws OWLOntologyInputSourceException if an IO related exception is thrown. + */ + public static Reader wrapInputAsReader(OWLOntologyDocumentSource source, + OWLOntologyLoaderConfiguration configuration) throws OWLOntologyInputSourceException { + return wrapInputAsReader(source, configuration, StandardCharsets.UTF_8); + } + + /** + * Select the available input source as an input stream. The input stream will be buffered. + * + * @param source ontology source + * @param configuration loader configuration to use of the reader must be built form the input + * IRI + * @return A Reader for the input; if no Reader can be obtained, an + * OWLOntologyInputSourceException is thrown. + * @throws OWLOntologyInputSourceException if an IO related exception is thrown. + */ + public static InputStream wrapInput(OWLOntologyDocumentSource source, + OWLOntologyLoaderConfiguration configuration) throws OWLOntologyInputSourceException { + Optional input = source.getInputStream(); + if (!input.isPresent() && !source.hasAlredyFailedOnIRIResolution()) { + if (source.getDocumentIRI().getNamespace().startsWith("jar:")) { + if (source.getDocumentIRI().getNamespace().startsWith("jar:!")) { + String name = source.getDocumentIRI().toString().substring(5); + if (!name.startsWith("/")) { + name = "/" + name; + } + return DocumentSources.class.getResourceAsStream(name); + } else { + try { + return streamFromJar(source.getDocumentIRI()).getInputStream(); + } catch (IOException e) { + source.setIRIResolutionFailed(true); + throw new OWLParserException(e); + } + } + } + + Optional headers = source.getAcceptHeaders(); + if (headers.isPresent()) { + input = getInputStream(source.getDocumentIRI(), configuration, headers.get()); + } else { + input = getInputStream(source.getDocumentIRI(), configuration, DEFAULT_REQUEST); + } + } + if (input.isPresent()) { + return new BufferedInputStream(input.get()); + } + throw new OWLOntologyInputSourceException("No input reader can be found"); + } + + protected static JarURLConnection streamFromJar(IRI documentIRI) + throws IOException, MalformedURLException { + return (JarURLConnection) new URL(documentIRI.toString()).openConnection(); + } + + /** + * A convenience method that obtains an input stream from a URI. This method sets up the correct + * request type and wraps the input stream within a buffered input stream. + * + * @param documentIRI The URI from which the input stream should be returned + * @param config the load configuration + * @return The input stream obtained from the URI + * @throws OWLOntologyInputSourceException if there was an {@code IOException} in obtaining the + * input stream from the URI. + * @deprecated use {@link #getInputStream(IRI, OWLOntologyLoaderConfiguration, String)} instead + */ + @Deprecated + public static Optional getInputStream(IRI documentIRI, + OWLOntologyLoaderConfiguration config) throws OWLOntologyInputSourceException { + return getInputStream(documentIRI, config, DEFAULT_REQUEST); + } + + /** + * A convenience method that obtains an input stream from a URI. This method sets up the correct + * request type and wraps the input stream within a buffered input stream. + * + * @param documentIRI The URI from which the input stream should be returned + * @param config the load configuration + * @param acceptHeaders accept headers for the connection + * @return The input stream obtained from the URI + * @throws OWLOntologyInputSourceException if there was an {@code IOException} in obtaining the + * input stream from the URI. + */ + @SuppressWarnings("resource") + public static Optional getInputStream(IRI documentIRI, + OWLOntologyLoaderConfiguration config, String acceptHeaders) + throws OWLOntologyInputSourceException { + try { + URL originalURL = documentIRI.toURI().toURL(); + URLConnection conn = originalURL.openConnection(); + String actualAcceptHeaders = acceptHeaders; + if (!acceptHeaders.contains("text/plain")) { + actualAcceptHeaders += TEXTPLAIN_REQUEST_TYPE; + } + if (!acceptHeaders.contains("*/*")) { + actualAcceptHeaders += LAST_REQUEST_TYPE; + } + conn.addRequestProperty("Accept", actualAcceptHeaders); + if (config.getAuthorizationValue() != null + && !config.getAuthorizationValue().isEmpty()) { + conn.setRequestProperty("Authorization", config.getAuthorizationValue()); + } + if (config.isAcceptingHTTPCompression()) { + conn.setRequestProperty("Accept-Encoding", ACCEPTABLE_CONTENT_ENCODING); + } + int connectionTimeout = config.getConnectionTimeout(); + conn.setConnectTimeout(connectionTimeout); + conn = connect(config, conn, connectionTimeout, actualAcceptHeaders, new HashSet<>()); + String contentEncoding = conn.getContentEncoding(); + InputStream is = connectWithFiveRetries(documentIRI, config, conn, connectionTimeout, + contentEncoding); + if (is == null) { + return emptyOptional(); + } + return optional(is); + } catch (IOException e) { + throw new OWLOntologyInputSourceException(e); + } + } + + protected static URLConnection connect(OWLOntologyLoaderConfiguration config, + URLConnection conn, int connectionTimeout, String acceptHeaders, Set visited) + throws IOException { + if (conn instanceof HttpURLConnection && config.isFollowRedirects()) { + // follow redirects to HTTPS + HttpURLConnection con = (HttpURLConnection) conn; + con.connect(); + int responseCode = con.getResponseCode(); + // redirect + if (responseCode == HttpURLConnection.HTTP_MOVED_TEMP + || responseCode == HttpURLConnection.HTTP_MOVED_PERM + || responseCode == HttpURLConnection.HTTP_SEE_OTHER + // no constants for temporary and permanent redirect in HttpURLConnection + || responseCode == 307 || responseCode == 308) { + String location = con.getHeaderField("Location"); + if (visited.add(location)) { + URL newURL = new URL(location); + return connect(config, + rebuildConnection(config, connectionTimeout, newURL, acceptHeaders), + connectionTimeout, acceptHeaders, visited); + } else { + throw new IllegalStateException( + "Infinite loop: redirect cycle detected. " + visited); + } + } + } + return conn; + } + + protected static URLConnection rebuildConnection(OWLOntologyLoaderConfiguration config, + int connectionTimeout, URL newURL, String acceptHeaders) throws IOException { + URLConnection conn; + conn = newURL.openConnection(); + conn.addRequestProperty("Accept", acceptHeaders); + if (config.isAcceptingHTTPCompression()) { + conn.setRequestProperty("Accept-Encoding", ACCEPTABLE_CONTENT_ENCODING); + } + conn.setConnectTimeout(connectionTimeout); + return conn; + } + + @Nullable + protected static InputStream connectWithFiveRetries(IRI documentIRI, + OWLOntologyLoaderConfiguration config, URLConnection conn, int connectionTimeout, + String contentEncoding) throws IOException, OWLOntologyInputSourceException { + InputStream is = null; + int count = 0; + while (count < config.getRetriesToAttempt() && is == null) { + try { + is = getInputStreamFromContentEncoding(documentIRI, conn, contentEncoding); + } catch (SocketTimeoutException e) { + count++; + if (count == 5) { + throw new OWLOntologyInputSourceException( + "cannot connect to " + documentIRI + "; retry limit exhausted", e); + } + conn.setConnectTimeout(connectionTimeout + connectionTimeout * count); + } + } + return is; + } + + /** + * Wrap an input stream to strip the BOM. + * + * @param delegate delegate to wrap + * @return wrapped input stream + */ + public static InputStream wrap(InputStream delegate) { + checkNotNull(delegate, "delegate cannot be null"); + return new BOMInputStream(delegate, ByteOrderMark.UTF_8, ByteOrderMark.UTF_16BE, + ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_32BE, ByteOrderMark.UTF_32LE); + } + + private static boolean couldBeOntology(@Nullable ZipEntry zipEntry) { + if (zipEntry == null) { + return false; + } + return ZIP_ENTRY_ONTOLOGY_NAME_PATTERN.matcher(zipEntry.getName()).matches(); + } + + private static InputStream getInputStreamFromContentEncoding(@Nullable IRI documentIRI, + URLConnection conn, @Nullable String contentEncoding) throws IOException { + String fileName = getFileNameFromContentDisposition(conn); + if (fileName == null) { + fileName = documentIRI == null ? "" : documentIRI.toString(); + } + InputStream in = conn.getInputStream(); + if (contentEncoding != null) { + InputStream toReturn = handleKnownContentEncodings(contentEncoding, in, fileName); + if (toReturn != null) { + return toReturn; + } + } + return wrap(checkFileName(in, fileName)); + } + + private static InputStream checkFileName(InputStream in, String fileName) throws IOException { + if (isGzFileName(fileName)) { + LOGGER.info("URL connection has no content encoding but name ends with .gz"); + return new BufferedInputStream(new GZIPInputStream(in)); + } + if (isXzFileName(fileName)) { + LOGGER.info("URL connection has no content encoding but name ends with .xz"); + return new BufferedInputStream(new XZInputStream(in)); + } + if (isZipFileName(fileName)) { + ZipInputStream zis = new ZipInputStream(in); + ZipEntry entry = null; + ZipEntry nextEntry = zis.getNextEntry(); + // XXX is this a bug? + while (entry != null && nextEntry != null) { + if (couldBeOntology(nextEntry)) { + entry = nextEntry; + } + nextEntry = zis.getNextEntry(); + } + return zis; + } + return in; + + } + + @Nullable + protected static InputStream handleKnownContentEncodings(String contentEncoding, InputStream in, + String fileName) throws IOException { + if ("xz".equals(contentEncoding)) { + LOGGER.info("URL connection input stream is compressed using xz"); + return new BufferedInputStream(checkFileName(new XZInputStream(in), fileName)); + } + if ("gzip".equals(contentEncoding)) { + LOGGER.info("URL connection input stream is compressed using gzip"); + return new BufferedInputStream(checkFileName(new GZIPInputStream(in), fileName)); + } + if ("deflate".equals(contentEncoding)) { + LOGGER.info("URL connection input stream is compressed using deflate"); + return checkFileName(new InflaterInputStream(in, new Inflater(true)), fileName); + } + return null; + } + + @Nullable + private static String getFileNameFromContentDisposition(URLConnection connection) { + String contentDispositionHeaderValue = + connection.getHeaderField(CONTENT_DISPOSITION_HEADER); + if (contentDispositionHeaderValue != null) { + Matcher matcher = + CONTENT_DISPOSITION_FILE_NAME_PATTERN.matcher(contentDispositionHeaderValue); + if (matcher.matches()) { + return matcher.group(CONTENT_DISPOSITION_FILE_NAME_PATTERN_GROUP); + } + } + return null; + } + + private static boolean isZipFileName(String fileName) { + return fileName.toLowerCase(Locale.getDefault()).endsWith(ZIP_FILE_EXTENSION); + } + + private static boolean isGzFileName(String fileName) { + return fileName.toLowerCase(Locale.getDefault()).endsWith(GZ_FILE_EXTENSION); + } + + private static boolean isXzFileName(String fileName) { + return fileName.toLowerCase(Locale.getDefault()).endsWith(XZ_FILE_EXTENSION); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/FileDocumentSource.java b/api/src/main/java/org/semanticweb/owlapi/io/FileDocumentSource.java new file mode 100644 index 0000000000..6078d9b9d6 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/FileDocumentSource.java @@ -0,0 +1,83 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A convenience class which will prepare an input source from a file. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class FileDocumentSource extends OWLOntologyDocumentSourceBase { + + private static final Logger LOGGER = LoggerFactory.getLogger(FileDocumentSource.class); + private final File file; + + /** + * Constructs an ontology input source using the specified file. + * + * @param file The file from which a concrete representation of an ontology will be obtained. + */ + public FileDocumentSource(File file) { + this(file, null, null); + } + + /** + * Constructs an ontology input source using the specified file. + * + * @param file The file from which a concrete representation of an ontology will be obtained. + * @param format ontology format. Can be null. + */ + public FileDocumentSource(File file, OWLDocumentFormat format) { + this(file, format, null); + } + + /** + * Constructs an ontology input source using the specified file. + * + * @param file The file from which a concrete representation of an ontology will be obtained. + * @param format ontology format. Can be null. + * @param mime mime type + */ + public FileDocumentSource(File file, @Nullable OWLDocumentFormat format, + @Nullable String mime) { + super(IRI.create(file), format, mime); + this.file = checkNotNull(file, "file cannot be null"); + } + + @Override + public Optional getInputStream() { + try { + return optional(new FileInputStream(file)); + } catch (FileNotFoundException e) { + LOGGER.error("File cannot be found", e); + failedOnStreams.set(true); + return emptyOptional(); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/FileDocumentTarget.java b/api/src/main/java/org/semanticweb/owlapi/io/FileDocumentTarget.java new file mode 100644 index 0000000000..92e69cbc07 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/FileDocumentTarget.java @@ -0,0 +1,77 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.BufferedOutputStream; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.OutputStream; +import java.io.Writer; +import java.util.Optional; +import org.semanticweb.owlapi.model.IRI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * An {@code OWLOntologyDocumentTarget} that supports writing out to a + * {@code File}. + * + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.2.0 + */ +public class FileDocumentTarget implements OWLOntologyDocumentTarget { + + private static final Logger LOGGER = LoggerFactory.getLogger(FileDocumentTarget.class); + private final File file; + + /** + * Constructs the document target, with the target being the specified file. + * + * @param file The file that is the target. + */ + public FileDocumentTarget(File file) { + this.file = checkNotNull(file, "file cannot be null"); + } + + @Override + public Optional getWriter() { + try { + return optional(new BufferedWriter(new FileWriter(file))); + } catch (IOException e) { + LOGGER.error("Writer cannot be created", e); + return emptyOptional(); + } + } + + @Override + public Optional getOutputStream() { + try { + return optional(new BufferedOutputStream(new FileOutputStream(file))); + } catch (IOException e) { + LOGGER.error("Input stream cannot be created", e); + return emptyOptional(); + } + } + + @Override + public Optional getDocumentIRI() { + return optional(IRI.create(file)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/GZipFileDocumentSource.java b/api/src/main/java/org/semanticweb/owlapi/io/GZipFileDocumentSource.java new file mode 100644 index 0000000000..e36edc1b42 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/GZipFileDocumentSource.java @@ -0,0 +1,77 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Optional; +import java.util.zip.GZIPInputStream; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * An ontology document source which can read from a GZIP File. + * + * @author ignazio + * @since 3.4.8 + */ +public class GZipFileDocumentSource extends OWLOntologyDocumentSourceBase { + + private static final Logger LOGGER = LoggerFactory.getLogger(GZipFileDocumentSource.class); + private final File file; + + /** + * Constructs an input source which will read an ontology from a + * representation from the specified file. + * + * @param is The file that the ontology representation will be read from. + */ + public GZipFileDocumentSource(File is) { + super("file:ontology", null, null); + file = is; + } + + /** + * Constructs an input source which will read an ontology from a + * representation from the specified file. + * + * @param stream The file that the ontology representation will be read from. + * @param documentIRI The document IRI + * @param format ontology format + * @param mime mime type + */ + public GZipFileDocumentSource(File stream, IRI documentIRI, @Nullable OWLDocumentFormat format, + @Nullable String mime) { + super(documentIRI, format, mime); + file = stream; + } + + @Override + public Optional getInputStream() { + try { + return optional(new GZIPInputStream(new FileInputStream(file))); + } catch (IOException e) { + LOGGER.error("File cannot be found or opened", e); + failedOnStreams.set(true); + return emptyOptional(); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/GZipFileDocumentTarget.java b/api/src/main/java/org/semanticweb/owlapi/io/GZipFileDocumentTarget.java new file mode 100644 index 0000000000..cfaaa44b52 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/GZipFileDocumentTarget.java @@ -0,0 +1,62 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Optional; +import java.util.zip.GZIPOutputStream; +import org.semanticweb.owlapi.model.IRI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * An ontology document target which can write to a GZIP File. Notice that this + * works best when the output stream is closed explicitly in the client code. + * + * @author ignazio + * @since 3.4.8 + */ +public class GZipFileDocumentTarget implements OWLOntologyDocumentTarget { + + private static final Logger LOGGER = LoggerFactory.getLogger(GZipFileDocumentTarget.class); + private final File out; + + /** + * @param os the actual file + */ + public GZipFileDocumentTarget(File os) { + out = checkNotNull(os, "os cannot be null"); + } + + @Override + public Optional getOutputStream() { + try { + return optional(new GZIPOutputStream(new FileOutputStream(out))); + } catch (IOException e) { + LOGGER.error("Cannot create output stream", e); + return emptyOptional(); + } + } + + @Override + public Optional getDocumentIRI() { + return optional(IRI.create(out)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/GZipStreamDocumentSource.java b/api/src/main/java/org/semanticweb/owlapi/io/GZipStreamDocumentSource.java new file mode 100644 index 0000000000..077c0c8e04 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/GZipStreamDocumentSource.java @@ -0,0 +1,91 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Optional; +import java.util.zip.GZIPInputStream; +import javax.annotation.Nullable; +import org.apache.commons.io.IOUtils; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * An ontology document source which can read from a GZIP stream. + * + * @author ignazio + * @since 3.4.8 + */ +public class GZipStreamDocumentSource extends OWLOntologyDocumentSourceBase { + + private static final Logger LOGGER = LoggerFactory.getLogger(GZipStreamDocumentSource.class); + @Nullable + private byte[] buffer; + + /** + * Constructs an input source which will read an ontology from a + * representation from the specified file. + * + * @param is The stream that the ontology representation will be read from. + */ + public GZipStreamDocumentSource(InputStream is) { + super("gzipinputstream:ontology", null, null); + readIntoBuffer(is); + } + + /** + * Constructs an input source which will read an ontology from a + * representation from the specified stream. + * + * @param stream The stream that the ontology representation will be read from. + * @param documentIRI The document IRI + * @param format ontology format + * @param mime mime type + */ + public GZipStreamDocumentSource(InputStream stream, IRI documentIRI, + @Nullable OWLDocumentFormat format, + @Nullable String mime) { + super(documentIRI, format, mime); + readIntoBuffer(stream); + } + + private void readIntoBuffer(InputStream reader) { + try { + buffer = IOUtils.toByteArray(reader); + } catch (IOException e) { + throw new OWLRuntimeException(e); + } + } + + @Override + public Optional getInputStream() { + if (buffer == null) { + return emptyOptional(); + } + try { + return optional(new GZIPInputStream(new ByteArrayInputStream(buffer))); + } catch (IOException e) { + LOGGER.error("Buffer cannot be opened", e); + failedOnStreams.set(true); + return emptyOptional(); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/GZipStreamDocumentTarget.java b/api/src/main/java/org/semanticweb/owlapi/io/GZipStreamDocumentTarget.java new file mode 100644 index 0000000000..c12c399c0c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/GZipStreamDocumentTarget.java @@ -0,0 +1,55 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.Optional; +import java.util.zip.GZIPOutputStream; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * An ontology document target which can write to a GZIP stream. Notice that + * this works best when the output stream is closed explicitly in the client + * code. + * + * @author ignazio + * @since 3.4.8 + */ +public class GZipStreamDocumentTarget implements OWLOntologyDocumentTarget { + + private static final Logger LOGGER = LoggerFactory + .getLogger(GZipFileDocumentTarget.class); + private final OutputStream outputStream; + + /** + * @param os the actual file + */ + public GZipStreamDocumentTarget(OutputStream os) { + outputStream = os; + } + + @Override + public Optional getOutputStream() { + try { + return optional(new GZIPOutputStream(outputStream)); + } catch (IOException e) { + LOGGER.error("Fille cannot be found or opened", e); + return emptyOptional(); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/IRIDocumentSource.java b/api/src/main/java/org/semanticweb/owlapi/io/IRIDocumentSource.java new file mode 100644 index 0000000000..4482fdb140 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/IRIDocumentSource.java @@ -0,0 +1,42 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDocumentFormat; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class IRIDocumentSource extends OWLOntologyDocumentSourceBase { + + /** + * @param documentIRI the source document IRI + */ + public IRIDocumentSource(IRI documentIRI) { + this(documentIRI, null, null); + } + + /** + * @param documentIRI the source document IRI + * @param format ontology format + * @param mime mime type + */ + public IRIDocumentSource(IRI documentIRI, @Nullable OWLDocumentFormat format, + @Nullable String mime) { + super(documentIRI, format, mime); + failedOnStreams.set(true); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/OWLObjectRenderer.java b/api/src/main/java/org/semanticweb/owlapi/io/OWLObjectRenderer.java new file mode 100644 index 0000000000..b50d61d43a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/OWLObjectRenderer.java @@ -0,0 +1,43 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.util.ShortFormProvider; + +/** + * A general purpose interface, implementations of which can be used to renderer OWL objects (e.g. + * class expressions, axioms etc.) for presentation in user interfaces, console writing etc. etc. + * Many ontology renderers may also choose to implement this interface. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public interface OWLObjectRenderer { + + /** + * Sets the short form provider, which determines the short form that should be used for + * entities. + * + * @param shortFormProvider The short form provider to be used. + */ + void setShortFormProvider(ShortFormProvider shortFormProvider); + + /** + * Renders the specified object. + * + * @param object The object to be rendered. + * @return A string that represents the rendering of the object. + */ + String render(OWLObject object); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyCreationIOException.java b/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyCreationIOException.java new file mode 100644 index 0000000000..ba01e0c622 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyCreationIOException.java @@ -0,0 +1,32 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import org.semanticweb.owlapi.model.OWLOntologyCreationException; + +/** + * Indicates an {@link java.io.IOException} happened during ontology creation. + * The cause of this exception will be an {@link java.io.IOException}. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class OWLOntologyCreationIOException extends OWLOntologyCreationException { + + /** + * @param ioException the cause + */ + public OWLOntologyCreationIOException(Throwable ioException) { + super("OWLOntologyCreationIOException: " + ioException.getMessage(), ioException); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyDocumentSource.java b/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyDocumentSource.java new file mode 100644 index 0000000000..8aa4aa3b5d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyDocumentSource.java @@ -0,0 +1,120 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; + +import java.io.InputStream; +import java.io.Reader; +import java.util.Optional; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDocumentFormat; + +/** + * A document source provides a point for loading an ontology. A document source may provide three + * ways of obtaining an ontology document: + *
    + *
  1. From a {@link java.io.Reader} + *
  2. From an {@link java.io.InputStream} + *
  3. From an ontology document {@link org.semanticweb.owlapi.model.IRI} + *
+ * Consumers that use a document source will attempt to obtain a concrete representation of an + * ontology in the above order.
+ * Note that while an ontology document source may appear similar to a SAX input source, an + * important difference is that the getReader and getInputStream methods return new instances each + * time the method is called. This allows multiple attempts at loading an ontology. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLOntologyDocumentSource { + + /** + * Gets a reader which an ontology document can be read from. This method may be called multiple + * times. Each invocation will return a new {@code Reader}. If there is no reader stream + * available, returns Optional.absent. + * + * @return A new {@code Reader} which the ontology can be read from, wrapped in an Optional. + */ + default Optional getReader() { + return emptyOptional(); + } + + /** + * If an input stream can be obtained from this document source then this method creates it. + * This method may be called multiple times. Each invocation will return a new input stream. If + * there is no input stream available, returns Optional.absent. . + * + * @return A new input stream which the ontology can be read from, wrapped in an Optional. + */ + default Optional getInputStream() { + return emptyOptional(); + } + + /** + * Gets the IRI of the ontology document. + * + * @return An IRI which represents the ontology document IRI + */ + IRI getDocumentIRI(); + + /** + * @return format for the ontology. If none is known, return Optional.absent. + */ + default Optional getFormat() { + return emptyOptional(); + } + + /** + * @return MIME type for this source, if one is specified. If none is known, return + * Optional.absent. + */ + default Optional getMIMEType() { + return emptyOptional(); + } + + /** + * @param headers accept headers; if not set, the mime type will be used; if that is also + * missing, the available parsers will contribute the headers + */ + default void setAcceptHeaders(@SuppressWarnings("unused") String headers) {} + + /** @return currently set accept headers */ + default Optional getAcceptHeaders() { + return emptyOptional(); + } + + /** + * @return true if there is no reader or input stream available for this source, or reading from + * them has already been attempted in a previous call and has failed. This leaves + * attempting to resolve the document IRI as input. No attempt is made to verify that + * the document IRI is resolvable. + */ + boolean hasAlredyFailedOnStreams(); + + /** + * @return true if resolving the document IRI has been attempted by a previous call and has + * failed, false if resolution has not been attempted yet or it has happened + * successfully. + */ + boolean hasAlredyFailedOnIRIResolution(); + + /** + * IRI resolution does not happen inside this class. This method allows the resolver to mark the + * document IRI as unresolvable, so that the information is tracked with the source. + * + * @param value new value for the flag + */ + void setIRIResolutionFailed(boolean value); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyDocumentSourceBase.java b/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyDocumentSourceBase.java new file mode 100644 index 0000000000..6db3eeb5c6 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyDocumentSourceBase.java @@ -0,0 +1,94 @@ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.util.Optional; +import java.util.concurrent.atomic.AtomicBoolean; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDocumentFormat; + +/** + * Base class for OWLOntologyDocumentSource. + * + * @author ignazio + * @since 4.0.0 + */ +public abstract class OWLOntologyDocumentSourceBase implements OWLOntologyDocumentSource { + + protected final AtomicBoolean failedOnStreams = new AtomicBoolean(false); + protected final AtomicBoolean failedOnIRI = new AtomicBoolean(false); + private final IRI documentIRI; + private final Optional format; + private final Optional mimeType; + private String acceptHeaders = null; + + /** + * Constructs an ontology input source using the specified file. + * + * @param iri document IRI + * @param format ontology format. If null, it is considered unspecified + * @param mime mime type. If null or empty, it is considered unspecified. + */ + public OWLOntologyDocumentSourceBase(IRI iri, @Nullable OWLDocumentFormat format, + @Nullable String mime) { + this.format = optional(format); + mimeType = optional(mime); + documentIRI = checkNotNull(iri, "document iri cannot be null"); + } + + /** + * Constructs an ontology input source using the specified file. + * + * @param iriPrefix document IRI prefix - used to generate a new IRI + * @param format ontology format. If null, it is considered unspecified + * @param mime mime type. If null or empty, it is considered unspecified. + */ + public OWLOntologyDocumentSourceBase(String iriPrefix, @Nullable OWLDocumentFormat format, + @Nullable String mime) { + this(IRI.getNextDocumentIRI(iriPrefix), format, mime); + } + + @Override + public Optional getAcceptHeaders() { + return Optional.ofNullable(acceptHeaders); + } + + @Override + public void setAcceptHeaders(String headers) { + acceptHeaders = headers; + } + + @Override + public final IRI getDocumentIRI() { + return documentIRI; + } + + @Override + public boolean hasAlredyFailedOnStreams() { + return failedOnStreams.get(); + } + + @Override + public boolean hasAlredyFailedOnIRIResolution() { + return failedOnIRI.get(); + } + + @Override + public void setIRIResolutionFailed(boolean value) { + failedOnIRI.set(value); + } + + @Override + public Optional getFormat() { + return format; + } + + @Override + public Optional getMIMEType() { + return mimeType; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyDocumentTarget.java b/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyDocumentTarget.java new file mode 100644 index 0000000000..d9f7c403df --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyDocumentTarget.java @@ -0,0 +1,69 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; + +import java.io.OutputStream; +import java.io.Writer; +import java.util.Optional; +import org.semanticweb.owlapi.model.IRI; + +/** + * Specifies an interface that provides a pointer to an ontology document where + * an ontology can be stored.
+ * Any client that writes an ontology to a "stream" will first try to obtain a + * writer, followed by an OutputStream , followed by trying to open a stream + * from a document IRI.
+ * A client that writes an ontology to a database or some similar storage will + * simply try to use the {@link IRI} returned by {@link #getDocumentIRI()}. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public interface OWLOntologyDocumentTarget { + + /** + * Gets a {@link java.io.Writer} that can be used to write an ontology to an + * ontology document. If none is available, return Optional.absent. Do not + * call multiple times for the same file: the output file will be opened for + * write multiple times. + * + * @return The writer + */ + default Optional getWriter() { + return emptyOptional(); + } + + /** + * Gets an {@link java.io.OutputStream} that can be used to write an + * ontology to an ontology document. If none is available, return + * Optional.absent. Do not call multiple times for the same file: the output + * file will be opened for write multiple times. + * + * @return The output stream + */ + default Optional getOutputStream() { + return emptyOptional(); + } + + /** + * Gets an IRI that points to an ontology document. If none is available, + * return Optional.absent. + * + * @return The IRI + */ + default Optional getDocumentIRI() { + return emptyOptional(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyInputSourceException.java b/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyInputSourceException.java new file mode 100644 index 0000000000..e2db6cd87b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyInputSourceException.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import org.semanticweb.owlapi.model.OWLException; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class OWLOntologyInputSourceException extends OWLException { + + /** + * Default constructor. + */ + public OWLOntologyInputSourceException() { + super(); + } + + /** + * @param cause the cause + */ + public OWLOntologyInputSourceException(Throwable cause) { + super(cause); + } + + /** + * @param message the message + */ + public OWLOntologyInputSourceException(String message) { + super(message); + } + + /** + * @param message the message + * @param cause the cause + */ + public OWLOntologyInputSourceException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyLoaderMetaData.java b/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyLoaderMetaData.java new file mode 100644 index 0000000000..57fe85b973 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyLoaderMetaData.java @@ -0,0 +1,47 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import com.google.common.collect.Multimap; +import java.io.Serializable; +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.IRI; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +public interface OWLOntologyLoaderMetaData extends Serializable { + + /** + * Gets a count of the triples process during loading. + * + * @return The number of triples process during loading. + */ + int getTripleCount(); + + /** + * @return the header status + */ + RDFOntologyHeaderStatus getHeaderState(); + + /** + * @return the set of unparsed triples, as a copy + */ + Stream getUnparsedTriples(); + + /** + * @return the guessed declarations, i.e., those not parsed from explicit declaration axioms + */ + Multimap> getGuessedDeclarations(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyStorageIOException.java b/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyStorageIOException.java new file mode 100644 index 0000000000..e341901c41 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/OWLOntologyStorageIOException.java @@ -0,0 +1,43 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import java.io.IOException; + +import org.semanticweb.owlapi.model.OWLOntologyStorageException; + +/** + * An {@code OWLOntologyStorageException} that was caused by an {@code IOException}. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class OWLOntologyStorageIOException extends OWLOntologyStorageException { + + private final IOException ioException; + + /** + * @param ioException the cause + */ + public OWLOntologyStorageIOException(IOException ioException) { + super(ioException); + this.ioException = ioException; + } + + /** + * @return the {@code IOException} that this exception wraps. + */ + public IOException getIOException() { + return ioException; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/OWLParser.java b/api/src/main/java/org/semanticweb/owlapi/io/OWLParser.java new file mode 100644 index 0000000000..b87851c210 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/OWLParser.java @@ -0,0 +1,97 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import java.io.Serializable; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLDocumentFormatFactory; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChangeException; +import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.UnloadableImportException; + +/** + * An {@code OWLParser} parses an ontology document and adds the axioms of the parsed ontology to + * the {@code OWLOntology} object passed to the {@code parse} methods.
+ * {@code OWLParser} implementations are supposed to be stateless, and therefore immutable. By + * default, implementation factories are injected in OWLOntologyManager instances at creation. This + * is not mandatory, and a specific manager can have different implementations injected at any time + * after creation.
+ * OWLParsers are typically used by {@link OWLOntologyManager} to populate empty + * {@link OWLOntology}, but can be used to add axioms to an {@code OWLOntology} that + * already contains axioms.
+ * One such case is parsing {@code owl:imports} which point to documents that are not ontologies. In + * this case, any axioms parsed from the imported document are added to the existing ontology, which + * already contains axioms parsed from a different document. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLParser extends Serializable { + + /** + * Parses the ontology with a concrete representation available at {@code documentIRI} and adds + * its axioms to {@code ontology}. Implementors of this method should load imported ontologies + * through + * {@link OWLOntologyManager#makeLoadImportRequest(org.semanticweb.owlapi.model.OWLImportsDeclaration, OWLOntologyLoaderConfiguration) + * makeLoadImportRequest()}. + * + * @param documentIRI the IRI of the document to parse + * @param ontology the ontology to which the parsed axioms are added + * @return the format of the parsed ontology + * @throws OWLParserException if there was a parsing problem parsing the ontology. + * @throws OWLOntologyChangeException if there was a problem updating {@code ontology}. + * Typically this depends on the document being parsed containing an ontology with an + * ontology IRI clashing with one already loaded. + * @throws UnloadableImportException if one or more imports could not be loaded. + */ + default OWLDocumentFormat parse(IRI documentIRI, OWLOntology ontology) { + return parse(new IRIDocumentSource(documentIRI, null, null), ontology, + ontology.getOWLOntologyManager().getOntologyLoaderConfiguration()); + } + + /** + * Parses the ontology with a concrete representation in {@code documentSource} and adds its + * axioms to {@code ontology}. Implementors of this method should load imported ontologies + * through + * {@link OWLOntologyManager#makeLoadImportRequest(org.semanticweb.owlapi.model.OWLImportsDeclaration, OWLOntologyLoaderConfiguration) + * makeLoadImportRequest()}. + * + * @param documentSource the source of a concrete representation of the document to parse + * @param ontology the ontology to which the parsed axioms are added + * @param configuration parsing options for the parser + * @return the format of the parsed ontology + * @throws OWLParserException if there was a parsing problem parsing the ontology. @throws + * OWLOntologyChangeException if there was a problem updating {@code ontology}. + * Typically this depends on the document being parsed containing an ontology with an + * ontology IRI clashing with one already loaded. + * @throws UnloadableImportException if one or more imports could not be loaded. + */ + OWLDocumentFormat parse(OWLOntologyDocumentSource documentSource, OWLOntology ontology, + OWLOntologyLoaderConfiguration configuration); + + /** + * @return a unique name for the parser, typically the simple class name + */ + default String getName() { + return getClass().getSimpleName(); + } + + /** + * @return The supported format for this parser. + */ + OWLDocumentFormatFactory getSupportedFormat(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/OWLParserException.java b/api/src/main/java/org/semanticweb/owlapi/io/OWLParserException.java new file mode 100644 index 0000000000..43cecca2b4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/OWLParserException.java @@ -0,0 +1,124 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import org.semanticweb.owlapi.model.OWLRuntimeException; + +/** + * Indicates that a parse error happened when trying to parse an ontology. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLParserException extends OWLRuntimeException { + + private final int lineNumber; + private final int columnNumber; + + /** + * Default constructor. + */ + public OWLParserException() { + lineNumber = -1; + columnNumber = -1; + } + + /** + * @param message the message + */ + public OWLParserException(String message) { + super(message); + lineNumber = -1; + columnNumber = -1; + } + + /** + * @param message the message + * @param cause the cause + */ + public OWLParserException(String message, Throwable cause) { + super(message, cause); + lineNumber = -1; + columnNumber = -1; + } + + /** + * @param cause the cause + */ + public OWLParserException(Throwable cause) { + super(cause); + lineNumber = -1; + columnNumber = -1; + } + + /** + * @param message the message + * @param lineNumber the line number + * @param columnNumber the column number + */ + public OWLParserException(String message, int lineNumber, int columnNumber) { + super(message); + this.lineNumber = lineNumber; + this.columnNumber = columnNumber; + } + + /** + * @param cause the cause + * @param lineNumber the line number + * @param columnNumber the column number + */ + public OWLParserException(Throwable cause, int lineNumber, int columnNumber) { + super(cause); + this.lineNumber = lineNumber; + this.columnNumber = columnNumber; + } + + /** + * @param cause the cause + * @param message the message + * @param lineNumber the line number + * @param columnNumber the column number + */ + public OWLParserException(String message, Throwable cause, int lineNumber, + int columnNumber) { + super(message, cause); + this.lineNumber = lineNumber; + this.columnNumber = columnNumber; + } + + /** + * Gets the line number of the line that the parser was parsing when the + * error occurred. + * + * @return A positive integer which represents the line number, or -1 if the line number could + * not be determined. + */ + public int getLineNumber() { + return lineNumber; + } + + /** + * @return the column number + */ + public int getColumnNumber() { + return columnNumber; + } + + @Override + public String getMessage() { + if (lineNumber != -1) { + return super.getMessage() + " (Line " + lineNumber + ')'; + } + return super.getMessage(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/OWLParserFactory.java b/api/src/main/java/org/semanticweb/owlapi/io/OWLParserFactory.java new file mode 100644 index 0000000000..eac2cf8ee7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/OWLParserFactory.java @@ -0,0 +1,40 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import java.io.Serializable; +import java.util.function.Supplier; + +import org.semanticweb.owlapi.model.MIMETypeAware; +import org.semanticweb.owlapi.model.OWLDocumentFormatFactory; + +/** + * An object that can create an {@code OWLParser}. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLParserFactory extends Serializable, Supplier, MIMETypeAware { + + /** + * Creates a parser. + * + * @return The parser created by this parser factory. + */ + OWLParser createParser(); + + /** + * @return The supported format for this parser. + */ + OWLDocumentFormatFactory getSupportedFormat(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/OWLParserFactoryImpl.java b/api/src/main/java/org/semanticweb/owlapi/io/OWLParserFactoryImpl.java new file mode 100644 index 0000000000..b84f09048b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/OWLParserFactoryImpl.java @@ -0,0 +1,45 @@ +package org.semanticweb.owlapi.io; + +import java.util.List; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLDocumentFormatFactory; + +/** + * Generic parser factory. + * + * @author ignazio + */ +public abstract class OWLParserFactoryImpl implements OWLParserFactory { + + private final OWLDocumentFormatFactory format; + + protected OWLParserFactoryImpl(OWLDocumentFormatFactory format) { + this.format = format; + } + + @Override + public OWLDocumentFormatFactory getSupportedFormat() { + return format; + } + + @Override + public final OWLParser get() { + return createParser(); + } + + @Override + @Nullable + public final String getDefaultMIMEType() { + return format.getDefaultMIMEType(); + } + + @Override + public final List getMIMETypes() { + return format.getMIMETypes(); + } + + @Override + public final boolean handlesMimeType(String mimeType) { + return format.handlesMimeType(mimeType); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/OWLRenderer.java b/api/src/main/java/org/semanticweb/owlapi/io/OWLRenderer.java new file mode 100644 index 0000000000..f3be9046fa --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/OWLRenderer.java @@ -0,0 +1,36 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import java.io.OutputStream; + +import org.semanticweb.owlapi.model.OWLException; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +@FunctionalInterface +public interface OWLRenderer { + + /** + * Renders the specified ontology to a concrete representation which should be written to the + * specified output stream. + * + * @param ontology the ontology + * @param os the output stream + * @throws OWLException for any exception raised + */ + void render(OWLOntology ontology, OutputStream os) throws OWLException; +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/OWLRendererException.java b/api/src/main/java/org/semanticweb/owlapi/io/OWLRendererException.java new file mode 100644 index 0000000000..3339d0efd3 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/OWLRendererException.java @@ -0,0 +1,44 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import org.semanticweb.owlapi.model.OWLOntologyStorageException; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLRendererException extends OWLOntologyStorageException { + + /** + * @param message the message + */ + public OWLRendererException(String message) { + super(message); + } + + /** + * @param message the message + * @param cause the cause + */ + public OWLRendererException(String message, Throwable cause) { + super(message, cause); + } + + /** + * @param cause the cause + */ + public OWLRendererException(Throwable cause) { + super(cause); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/OWLRendererIOException.java b/api/src/main/java/org/semanticweb/owlapi/io/OWLRendererIOException.java new file mode 100644 index 0000000000..a03ffe72f5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/OWLRendererIOException.java @@ -0,0 +1,28 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLRendererIOException extends OWLRendererException { + + /** + * @param cause the cause + */ + public OWLRendererIOException(Exception cause) { + super(cause); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/OntologyIRIMappingNotFoundException.java b/api/src/main/java/org/semanticweb/owlapi/io/OntologyIRIMappingNotFoundException.java new file mode 100644 index 0000000000..8c6ae05a73 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/OntologyIRIMappingNotFoundException.java @@ -0,0 +1,41 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class OntologyIRIMappingNotFoundException extends + OWLOntologyCreationException { + + private final IRI ontologyIRI; + + /** + * @param ontologyIRI the ontology not found + */ + public OntologyIRIMappingNotFoundException(IRI ontologyIRI) { + super("Document IRI mapping not found for " + ontologyIRI); + this.ontologyIRI = ontologyIRI; + } + + /** + * @return the ontology IRI + */ + public IRI getOntologyIRI() { + return ontologyIRI; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/RDFLiteral.java b/api/src/main/java/org/semanticweb/owlapi/io/RDFLiteral.java new file mode 100644 index 0000000000..11f56b70af --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/RDFLiteral.java @@ -0,0 +1,213 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.Locale; +import java.util.Optional; + +import javax.annotation.Nullable; + +import org.apache.commons.rdf.api.Literal; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.util.EscapeUtils; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.2 + */ +public class RDFLiteral extends RDFNode implements Literal { + + private final String lexicalValue; + private final String lang; + private final IRI datatype; + private int hashCode; + + /** + * Constructor for plain literal wrappers. + * + * @param literal lexical form + * @param lang language tag + * @param datatype datatype IRI + */ + public RDFLiteral(String literal, @Nullable String lang, @Nullable IRI datatype) { + lexicalValue = checkNotNull(literal, "literal cannot be null"); + this.lang = lang == null ? "" : lang.toLowerCase(Locale.ROOT); + OWL2Datatype defaultType = + this.lang.isEmpty() ? OWL2Datatype.RDF_PLAIN_LITERAL : OWL2Datatype.RDF_LANG_STRING; + this.datatype = datatype == null ? defaultType.getIRI() : datatype; + } + + /** + * @param literal the wrapped literal + */ + public RDFLiteral(OWLLiteral literal) { + this(literal.getLiteral(), literal.getLang(), literal.getDatatype().getIRI()); + } + + @Override + public boolean isLiteral() { + return true; + } + + @Override + public int hashCode() { + if (hashCode == 0) { + hashCode = 37; + hashCode = hashCode * 37 + lexicalValue.hashCode(); + hashCode = hashCode * 37 + lang.hashCode(); + hashCode = hashCode * 37 + datatype.hashCode(); + } + return hashCode; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof RDFLiteral) { + RDFLiteral other = (RDFLiteral) obj; + if (!lexicalValue.equals(other.lexicalValue)) { + return false; + } + if (!lang.equals(other.lang)) { + return false; + } + return datatype.equals(other.datatype); + } + if (obj instanceof RDFLiteral) { + RDFLiteral literal = (RDFLiteral) obj; + if (!getLexicalForm().equals(literal.getLexicalForm())) { + return false; + } + if (!getLanguageTag().equals(literal.getLanguageTag())) { + return false; + } + return getDatatype().equals(literal.getDatatype()); + } + if (obj instanceof Literal) { + // Note: This also works on RDFLiteral + // but is slightly more expensive as it must call the + // getter methods when accessing obj. + // + // To ensure future compatibility, the Commons RDF getter + // methods are also called on this rather than using the fields. + Literal literal = (Literal) obj; + if (!getLexicalForm().equals(literal.getLexicalForm())) { + return false; + } + if (!getLanguageTag() + .equals(literal.getLanguageTag().map(s -> s.toLowerCase(Locale.ROOT)))) { + return false; + } + return getDatatype().equals(literal.getDatatype()); + } + return false; + } + + @Override + public String toString() { + return lexicalValue; + } + + @Override + public IRI getIRI() { + throw new UnsupportedOperationException("RDF Literals do not have IRIs"); + } + + /** + * @return the lexical form for this literal + */ + public String getLexicalValue() { + return lexicalValue; + } + + @Override + public String getLexicalForm() { + return getLexicalValue(); + } + + /** + * @return the language tag for this literal + */ + public String getLang() { + return lang; + } + + @Override + public Optional getLanguageTag() { + if (hasLang()) { + return Optional.of(lang); + } + return Optional.empty(); + } + + @Override + public IRI getDatatype() { + return datatype; + } + + /** + * @return true if this literal has a non empty lang tag + */ + public boolean hasLang() { + return !lang.isEmpty(); + } + + /** + * @return true if the datatype of this literal is plain literal + */ + public boolean isPlainLiteral() { + return OWL2Datatype.RDF_PLAIN_LITERAL.getIRI().equals(datatype); + } + + @Override + public int compareTo(@Nullable RDFNode o) { + checkNotNull(o); + assert o != null; + if (!o.isLiteral()) { + return -1; + } + if (equals(o)) { + return 0; + } + RDFLiteral lit2 = (RDFLiteral) o; + int diff = lexicalValue.compareTo(lit2.lexicalValue); + if (diff == 0) { + diff = getDatatype().compareTo(lit2.getDatatype()); + } + if (diff == 0) { + diff = getLang().compareTo(lit2.getLang()); + } + return diff; + } + + @Override + public String ntriplesString() { + String escaped = '"' + + EscapeUtils.escapeString(getLexicalValue()).replace("\n", "\\n").replace("\r", "\\r") + + '"'; + if (datatype.equals(OWL2Datatype.RDF_PLAIN_LITERAL.getIRI()) + || datatype.equals(OWL2Datatype.XSD_STRING.getIRI())) { + return escaped; + } else if (hasLang()) { + return escaped + "@" + getLang(); + } else { + return escaped + "^^" + getDatatype().ntriplesString(); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/RDFNode.java b/api/src/main/java/org/semanticweb/owlapi/io/RDFNode.java new file mode 100644 index 0000000000..65d6d42f92 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/RDFNode.java @@ -0,0 +1,76 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import java.io.Serializable; + +import org.semanticweb.owlapi.model.HasIRI; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.2 + */ +public abstract class RDFNode + implements Serializable, Comparable, HasIRI, org.apache.commons.rdf.api.RDFTerm { + + /** + * Determines if this node is a literal node. + * + * @return {@code true} if this node is a literal, otherwise {@code false}. + */ + public boolean isLiteral() { + return false; + } + + /** + * Determines if this node is an axiom. + * + * @return {@code true} if this node is a literal, otherwise {@code false}. + */ + public boolean isAxiom() { + return false; + } + + /** + * Determines if this node is a resource and is anonymous. + * + * @return {@code true} if this is a resource node (i.e. {@link #isLiteral()} returns {@code + * false}) and the node is anonymous, or {@code false} if this is a resource node and is not + * anonymous. + */ + public boolean isAnonymous() { + return false; + } + + /** + * @return true if this is an anonymous individual + */ + public boolean isIndividual() { + return false; + } + + /** + * @return true if blank node id is mandatory for this resource + */ + public boolean shouldOutputId() { + return false; + } + + /** + * @return true if an id is required for this node - only if this is an individual or an axiom + * and id is required + */ + public boolean idRequired() { + return isAnonymous() && shouldOutputId(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/RDFOntologyHeaderStatus.java b/api/src/main/java/org/semanticweb/owlapi/io/RDFOntologyHeaderStatus.java new file mode 100644 index 0000000000..5c58b5b925 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/RDFOntologyHeaderStatus.java @@ -0,0 +1,35 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.2 + */ +public enum RDFOntologyHeaderStatus { + /** + * Specifies that during parsing, the ontology document did not contain any + * ontology headers. + */ + PARSED_ZERO_HEADERS, + /** + * Specifies that during parsing, the ontology document that the ontology + * was created from contained one header. + */ + PARSED_ONE_HEADER, + /** + * Specifies that during parsing, the ontology document that the ontology + * was created from contained multiple headers. + */ + PARSED_MULTIPLE_HEADERS +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/RDFParserMetaData.java b/api/src/main/java/org/semanticweb/owlapi/io/RDFParserMetaData.java new file mode 100644 index 0000000000..ff5ae749ae --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/RDFParserMetaData.java @@ -0,0 +1,71 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; +import com.google.common.collect.Multimaps; +import java.io.Serializable; +import java.util.Set; +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.IRI; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.2 + */ +public class RDFParserMetaData implements OWLOntologyLoaderMetaData, Serializable { + + private final int tripleCount; + private final RDFOntologyHeaderStatus headerStatus; + private final Set unparsedTriples; + private final ArrayListMultimap> guessedDeclarations; + + /** + * @param headerStatus the header status + * @param tripleCount the triple count + * @param unparsedTriples the set of triples not parsed + * @param guessedDeclarations guessed declarations map + */ + public RDFParserMetaData(RDFOntologyHeaderStatus headerStatus, int tripleCount, + Set unparsedTriples, + ArrayListMultimap> guessedDeclarations) { + this.tripleCount = tripleCount; + this.headerStatus = checkNotNull(headerStatus, "headerStatus cannot be null"); + this.unparsedTriples = checkNotNull(unparsedTriples, "unparsedTriples cannot be null"); + this.guessedDeclarations = checkNotNull(guessedDeclarations, + "guessedDeclarations cannot be null"); + } + + @Override + public int getTripleCount() { + return tripleCount; + } + + @Override + public RDFOntologyHeaderStatus getHeaderState() { + return headerStatus; + } + + @Override + public Stream getUnparsedTriples() { + return unparsedTriples.stream(); + } + + @Override + public Multimap> getGuessedDeclarations() { + return Multimaps.unmodifiableMultimap(guessedDeclarations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/RDFResource.java b/api/src/main/java/org/semanticweb/owlapi/io/RDFResource.java new file mode 100644 index 0000000000..d0a3422dbb --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/RDFResource.java @@ -0,0 +1,73 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.IRI; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.2 + */ +public abstract class RDFResource extends RDFNode + implements org.apache.commons.rdf.api.BlankNodeOrIRI { + + // XXX implement equals() + + /** + * @return the resource IRI + */ + public abstract IRI getResource(); + + /** + * For blank nodes, return a valid value for the RDF/XML nodeId attribute. For non blank nodes, + * an exception should be thrown. The method must only be called on blank nodes. + * + * @return a valid value for thE RDF/XML nodeId attribute + */ + public abstract String getNodeIDValue(); + + @Override + public int compareTo(@Nullable RDFNode o) { + checkNotNull(o); + assert o != null; + if (o.isLiteral()) { + return 1; + } + if (equals(o)) { + return 0; + } + boolean anonA = isAnonymous(); + boolean anonB = o.isAnonymous(); + if (anonA == anonB) { + // if both are anonymous or both are not anonymous, + // comparing the id() values corresponds to comparing IRIs or + // comparing bnode ids + return getIRI().compareTo(o.getIRI()); + } + // if one is anonymous and the other is not, + // named nodes come first + if (!anonA) { + return -1; + } + return 1; + } + + @Override + public String ntriplesString() { + return getResource().ntriplesString(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/RDFResourceBlankNode.java b/api/src/main/java/org/semanticweb/owlapi/io/RDFResourceBlankNode.java new file mode 100644 index 0000000000..8455e9c878 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/RDFResourceBlankNode.java @@ -0,0 +1,158 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.UUID; + +import javax.annotation.Nullable; + +import org.apache.commons.rdf.api.BlankNode; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.NodeID; + +/** + * Anonymous node implementation. + */ +public class RDFResourceBlankNode extends RDFResource implements BlankNode { + + /** + * Random UUID, used by {@link #uniqueReference()} + */ + private static final UUID UNIQUE_BASE = UUID.randomUUID(); + private final IRI resource; + private final boolean isIndividual; + private final boolean isAxiom; + private boolean forceIdOutput; + + /** + * Create an RDFResource that is anonymous. + * + * @param resource The IRI of the resource + * @param isIndividual true if the node represents an individual + * @param forceId true if id should be output + * @param isAxiom true if axiom + */ + public RDFResourceBlankNode(IRI resource, boolean isIndividual, boolean forceId, + boolean isAxiom) { + this.resource = checkNotNull(resource, "resource cannot be null"); + this.isIndividual = isIndividual; + this.isAxiom = isAxiom; + forceIdOutput = forceId; + } + + /** + * Create an RDFResource that is anonymous. + * + * @param anonId the number at the end of the anon IRI + * @param isIndividual true if the node represents an individual + * @param forceId true if id should be output + * @param isAxiom true if axiom + */ + public RDFResourceBlankNode(Integer anonId, boolean isIndividual, boolean forceId, + boolean isAxiom) { + this(NodeID.nodeId(anonId), isIndividual, forceId, isAxiom); + } + + /** + * Create an RDFResource that is anonymous + * + * @param isIndividual true if this is an individual + * @param forceId true if the id should be output + * @param isAxiom true if axiom + */ + public RDFResourceBlankNode(boolean isIndividual, boolean forceId, boolean isAxiom) { + this(NodeID.nextFreshNodeId(), isIndividual, forceId, isAxiom); + } + + @Override + public boolean isIndividual() { + return isIndividual; + } + + @Override + public boolean isAxiom() { + return isAxiom; + } + + @Override + public boolean shouldOutputId() { + return forceIdOutput; + } + + /** + * @param b change the value of the id required flag + */ + public void setIdRequired(boolean b) { + forceIdOutput = b; + } + + @Override + public boolean isLiteral() { + return false; + } + + @Override + public boolean isAnonymous() { + return true; + } + + @Override + public int hashCode() { + return resource.hashCode(); + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof RDFResourceBlankNode) { + RDFResourceBlankNode other = (RDFResourceBlankNode) obj; + return resource.equals(other.resource); + } + // Commons RDF BlankNode.equals() contract + if (obj instanceof BlankNode) { + BlankNode blankNode = (BlankNode) obj; + return uniqueReference().equals(blankNode.uniqueReference()); + } + return false; + } + + @Override + public String toString() { + return resource.toString(); + } + + @Override + public IRI getIRI() { + return resource; + } + + @Override + public IRI getResource() { + return resource; + } + + @Override + public String uniqueReference() { + String nodeId = resource.getIRIString().replace("_:", ""); + return UNIQUE_BASE + ":" + nodeId; + } + + @Override + public String getNodeIDValue() { + return NodeID.stripArtifacts(resource); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/RDFResourceIRI.java b/api/src/main/java/org/semanticweb/owlapi/io/RDFResourceIRI.java new file mode 100644 index 0000000000..dd30c4c115 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/RDFResourceIRI.java @@ -0,0 +1,81 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.IRI; + +/** + * IRI node implementation. + */ +public class RDFResourceIRI extends RDFResource implements org.apache.commons.rdf.api.IRI { + + private final IRI resource; + + /** + * @param resource the resource + */ + public RDFResourceIRI(IRI resource) { + this.resource = checkNotNull(resource, "resource cannot be null"); + } + + @Override + public IRI getIRI() { + return resource; + } + + @Override + public IRI getResource() { + return resource; + } + + @Override + public int hashCode() { + return resource.hashCode(); + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof RDFResourceIRI) { + RDFResourceIRI other = (RDFResourceIRI) obj; + return resource.equals(other.resource); + } + // Commons RDF IRI equals() contract + if (obj instanceof org.apache.commons.rdf.api.IRI) { + org.apache.commons.rdf.api.IRI iri = (org.apache.commons.rdf.api.IRI) obj; + return ntriplesString().equals(iri.ntriplesString()); + } + return false; + } + + @Override + public String toString() { + return resource.toQuotedString(); + } + + @Override + public String getIRIString() { + return resource.getIRIString(); + } + + @Override + public String getNodeIDValue() { + throw new UnsupportedOperationException( + "RDFResource " + toString() + " is not a blank node; nodeId not defined."); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/RDFResourceParseError.java b/api/src/main/java/org/semanticweb/owlapi/io/RDFResourceParseError.java new file mode 100644 index 0000000000..af99c9b7dc --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/RDFResourceParseError.java @@ -0,0 +1,70 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.util.CollectionFactory; + +/** + * Describes why an RDF resource could not be parsed into an {@code OWLObject}. + * For example, why an RDF resource could not be parsed into an + * {@code OWLClassExpression}.
+ * When these errors occur, the RDF parser generates an {@code OWLEntity} that + * represents the error and inserts this where appropriate into the + * corresponding complete OWLObject (OWLAxiom) that could not be parsed. + * + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.2 + */ +public class RDFResourceParseError implements Serializable { + + private final OWLEntity parserGeneratedErrorEntity; + private final RDFNode mainNode; + private final Set mainNodeTriples = new HashSet<>(); + + /** + * @param parserGeneratedErrorEntity the error entity + * @param mainNode the main node + * @param mainNodeTriples the main node triples + */ + public RDFResourceParseError(OWLEntity parserGeneratedErrorEntity, RDFNode mainNode, + Set mainNodeTriples) { + this.parserGeneratedErrorEntity = parserGeneratedErrorEntity; + this.mainNode = mainNode; + this.mainNodeTriples.addAll(mainNodeTriples); + } + + /** + * @return the error entity + */ + public OWLEntity getParserGeneratedErrorEntity() { + return parserGeneratedErrorEntity; + } + + /** + * @return the main node + */ + public RDFNode getMainNode() { + return mainNode; + } + + /** + * @return the main node triples + */ + public Set getMainNodeTriples() { + return CollectionFactory.copyMutable(mainNodeTriples); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/RDFTriple.java b/api/src/main/java/org/semanticweb/owlapi/io/RDFTriple.java new file mode 100644 index 0000000000..afe2985b8c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/RDFTriple.java @@ -0,0 +1,216 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.OWL_ANNOTATED_PROPERTY; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.OWL_ANNOTATED_SOURCE; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.OWL_ANNOTATED_TARGET; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.OWL_DATA_RANGE; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.OWL_DEPRECATED; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.OWL_DISJOINT_WITH; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.OWL_EQUIVALENT_CLASS; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.OWL_EQUIVALENT_PROPERTY; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.OWL_ON_CLASS; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.OWL_ON_PROPERTY; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.RDFS_COMMENT; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.RDFS_DOMAIN; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.RDFS_IS_DEFINED_BY; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.RDFS_LABEL; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.RDFS_RANGE; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.RDFS_SUBCLASS_OF; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.RDFS_SUB_PROPERTY_OF; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.RDF_FIRST; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.RDF_REST; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.RDF_TYPE; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.apache.commons.rdf.api.Triple; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; + +import com.carrotsearch.hppcrt.maps.ObjectIntHashMap; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.2 + */ +public class RDFTriple implements Serializable, Comparable, Triple { + + static final ObjectIntHashMap specialPredicateRanks = initMap(); + private final RDFResource subject; + private final RDFResourceIRI predicate; + private final RDFNode object; + + /** + * @param subject the subject + * @param predicate the predicate + * @param object the object + */ + public RDFTriple(RDFResource subject, RDFResourceIRI predicate, RDFNode object) { + this.subject = checkNotNull(subject, "subject cannot be null"); + this.predicate = checkNotNull(predicate, "predicate cannot be null"); + this.object = checkNotNull(object, "object cannot be null"); + } + + /** + * @param subject the subject + * @param subjectAnon whether the subject is anonymous + * @param subjectAxiom true if axiom + * @param predicate the predicate + * @param object the object + * @param objectAnon whether the object is anonymous + * @param objectAxiom true if axiom + */ + public RDFTriple(IRI subject, boolean subjectAnon, boolean subjectAxiom, IRI predicate, + IRI object, boolean objectAnon, boolean objectAxiom) { + this(getResource(subject, subjectAnon, subjectAxiom), + // Predicate is not allowed to be anonymous + new RDFResourceIRI(predicate), getResource(object, objectAnon, objectAxiom)); + } + + /** + * @param subject the subject + * @param subjectAnon whether the subject is anonymous + * @param axiom true if axiom + * @param predicate the predicate + * @param object the object + */ + public RDFTriple(IRI subject, boolean subjectAnon, boolean axiom, IRI predicate, + OWLLiteral object) { + this(getResource(subject, subjectAnon, axiom), new RDFResourceIRI(predicate), + new RDFLiteral(object)); + } + + private static RDFResource getResource(IRI iri, boolean anon, boolean axiom) { + if (anon) { + return new RDFResourceBlankNode(iri, true, true, axiom); + } + return new RDFResourceIRI(iri); + } + + static ObjectIntHashMap initMap() { + ObjectIntHashMap predicates = new ObjectIntHashMap<>(); + AtomicInteger nextId = new AtomicInteger(1); + List ORDERED_URIS = Arrays.asList(RDF_TYPE, RDFS_LABEL, OWL_DEPRECATED, + RDFS_COMMENT, RDFS_IS_DEFINED_BY, RDF_FIRST, RDF_REST, OWL_EQUIVALENT_CLASS, + OWL_EQUIVALENT_PROPERTY, RDFS_SUBCLASS_OF, RDFS_SUB_PROPERTY_OF, RDFS_DOMAIN, + RDFS_RANGE, OWL_DISJOINT_WITH, OWL_ON_PROPERTY, OWL_DATA_RANGE, OWL_ON_CLASS, + OWL_ANNOTATED_SOURCE, OWL_ANNOTATED_PROPERTY, OWL_ANNOTATED_TARGET); + ORDERED_URIS.forEach(iri -> predicates.put(iri.getIRI(), nextId.getAndIncrement())); + Stream.of(OWLRDFVocabulary.values()) + .forEach(iri -> predicates.putIfAbsent(iri.getIRI(), nextId.getAndIncrement())); + return predicates; + } + + private static int comparePredicates(RDFResourceIRI predicate, RDFResourceIRI otherPredicate) { + IRI predicateIRI = predicate.getIRI(); + int specialPredicateRank = specialPredicateRanks.get(predicateIRI); + IRI otherPredicateIRI = otherPredicate.getIRI(); + int otherSpecialPredicateRank = specialPredicateRanks.get(otherPredicateIRI); + if (specialPredicateRank != specialPredicateRanks.getDefaultValue()) { + if (otherSpecialPredicateRank != specialPredicateRanks.getDefaultValue()) { + return Integer.compare(specialPredicateRank, otherSpecialPredicateRank); + } else { + return -1; + } + } else { + if (otherSpecialPredicateRank != specialPredicateRanks.getDefaultValue()) { + return +1; + } else { + return predicateIRI.compareTo(otherPredicateIRI); + } + } + } + + /** + * @return true if subject and object are the same + */ + public boolean isSubjectSameAsObject() { + return subject.equals(object); + } + + @Override + public RDFResource getSubject() { + return subject; + } + + @Override + public RDFResourceIRI getPredicate() { + return predicate; + } + + @Override + public RDFNode getObject() { + return object; + } + + @Override + public int hashCode() { + return subject.hashCode() * 37 + predicate.hashCode() * 17 + object.hashCode(); + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof RDFTriple) { + RDFTriple other = (RDFTriple) obj; + return subject.equals(other.subject) && predicate.equals(other.predicate) + && object.equals(other.object); + } + // Commons RDF Triple.equals() contract + if (obj instanceof Triple) { + // Note: This also works on RDFLiteral + // but is slightly more expensive as it must call the + // getter methods when accessing obj. + // + // To ensure future compatibility, the Commons RDF getter + // methods are also called on this rather than using the fields. + Triple triple = (Triple) obj; + return getSubject().equals(triple.getSubject()) + && getPredicate().equals(triple.getPredicate()) + && getObject().equals(triple.getObject()); + } + return false; + } + + @Override + public String toString() { + return String.format("%s %s %s.", subject, predicate, object); + } + + @Override + public int compareTo(@Nullable RDFTriple o) { + checkNotNull(o); + assert o != null; + // compare by predicate, then subject, then object + int diff = comparePredicates(predicate, o.predicate); + if (diff == 0) { + diff = subject.compareTo(o.subject); + } + if (diff == 0) { + diff = object.compareTo(o.object); + } + return diff; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/ReaderDocumentSource.java b/api/src/main/java/org/semanticweb/owlapi/io/ReaderDocumentSource.java new file mode 100644 index 0000000000..5a814ce4be --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/ReaderDocumentSource.java @@ -0,0 +1,64 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import java.io.Reader; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDocumentFormat; + +/** + * An ontology document source which reads an ontology from a reader. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class ReaderDocumentSource extends StreamDocumentSourceBase { + + /** + * Constructs and ontology input source which will read an ontology from a + * reader. + * + * @param reader The reader that will be used to read an ontology. + */ + public ReaderDocumentSource(Reader reader) { + super(reader, "reader:ontology", null, null); + } + + /** + * Constructs and ontology input source which will read an ontology from a + * reader. + * + * @param reader The reader that will be used to read an ontology. + * @param iri The ontology document IRI which will be used as the base of the document if + * needed. + */ + public ReaderDocumentSource(Reader reader, IRI iri) { + super(reader, iri, null, null); + } + + /** + * Constructs and ontology input source which will read an ontology from a + * reader. + * + * @param reader The reader that will be used to read an ontology. + * @param iri The ontology document IRI which will be used as the base of the document if + * needed. + * @param f ontology format + * @param mime mime type + */ + public ReaderDocumentSource(Reader reader, IRI iri, @Nullable OWLDocumentFormat f, + @Nullable String mime) { + super(reader, iri, f, mime); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/StreamDocumentSource.java b/api/src/main/java/org/semanticweb/owlapi/io/StreamDocumentSource.java new file mode 100644 index 0000000000..b251757ebe --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/StreamDocumentSource.java @@ -0,0 +1,76 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import java.io.InputStream; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDocumentFormat; + +/** + * An ontology document source which can read from a stream. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class StreamDocumentSource extends StreamDocumentSourceBase { + + /** + * Constructs an input source which will read an ontology from a + * representation from the specified stream. + * + * @param is The stream that the ontology representation will be read from. + */ + public StreamDocumentSource(InputStream is) { + super(is, "inputstream:ontology", null, null); + } + + /** + * Constructs an input source which will read an ontology from a + * representation from the specified stream. + * + * @param is The stream that the ontology representation will be read from. + * @param iri The document IRI + */ + public StreamDocumentSource(InputStream is, IRI iri) { + super(is, iri, null, null); + } + + /** + * Constructs an input source which will read an ontology from a + * representation from the specified stream. + * + * @param stream The stream that the ontology representation will be read from. + * @param documentIRI The document IRI + * @param f ontology format + * @param mime mime type + */ + public StreamDocumentSource(InputStream stream, IRI documentIRI, @Nullable OWLDocumentFormat f, + @Nullable String mime) { + super(stream, documentIRI, f, mime); + } + + /** + * Constructs an input source which will read an ontology from a + * representation from the specified stream. + * + * @param stream The stream that the ontology representation will be read from. + * @param prefix The document IRI prefix + * @param f ontology format + * @param mime mime type + */ + public StreamDocumentSource(InputStream stream, String prefix, @Nullable OWLDocumentFormat f, + @Nullable String mime) { + super(stream, prefix, f, mime); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/StreamDocumentSourceBase.java b/api/src/main/java/org/semanticweb/owlapi/io/StreamDocumentSourceBase.java new file mode 100644 index 0000000000..8c95f737aa --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/StreamDocumentSourceBase.java @@ -0,0 +1,195 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.Reader; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.Optional; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; +import javax.annotation.Nullable; +import org.apache.commons.io.IOUtils; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Base class for common utilities among stream, reader and file input sources. + * + * @since 4.0.0 TODO both stream and reader sources copy the input in memory in case reloading is + * needed. This can be bad for memory. Remote loading will download the ontologies multiple + * times too, until parsing fails. Both issues could be addressed with a local file copy. + */ +public abstract class StreamDocumentSourceBase extends OWLOntologyDocumentSourceBase { + + private static final String STREAM_CANNOT_BE_NULL = "stream cannot be null"; + private static final Logger LOGGER = LoggerFactory.getLogger(StreamDocumentSourceBase.class); + @Nullable + protected byte[] byteBuffer; + private Charset encoding = StandardCharsets.UTF_8; + private final boolean streamAvailable; + + /** + * Constructs an input source which will read an ontology from a representation from the + * specified stream. + * + * @param stream The stream that the ontology representation will be read from. + * @param documentIRI The document IRI + * @param format ontology format + * @param mime mime type + */ + public StreamDocumentSourceBase(InputStream stream, IRI documentIRI, + @Nullable OWLDocumentFormat format, @Nullable String mime) { + super(documentIRI, format, mime); + readIntoBuffer(checkNotNull(stream, STREAM_CANNOT_BE_NULL)); + streamAvailable = true; + } + + /** + * Constructs an input source which will read an ontology from a representation from the + * specified stream. + * + * @param stream The stream that the ontology representation will be read from. + * @param documentIRI The document IRI + * @param format ontology format + * @param mime mime type + */ + public StreamDocumentSourceBase(Reader stream, IRI documentIRI, + @Nullable OWLDocumentFormat format, @Nullable String mime) { + super(documentIRI, format, mime); + checkNotNull(stream, STREAM_CANNOT_BE_NULL); + // if the input stream carries encoding information, use it; else leave + // the default as UTF-8 + if (stream instanceof InputStreamReader) { + encoding = Charset.forName(((InputStreamReader) stream).getEncoding()); + } + readIntoBuffer(stream); + streamAvailable = false; + } + + /** + * Constructs an input source which will read an ontology from a representation from the + * specified stream. + * + * @param stream The stream that the ontology representation will be read from. + * @param prefix The document IRI prefix + * @param format ontology format + * @param mime mime type + */ + protected StreamDocumentSourceBase(InputStream stream, String prefix, + @Nullable OWLDocumentFormat format, @Nullable String mime) { + super(prefix, format, mime); + readIntoBuffer(checkNotNull(stream, STREAM_CANNOT_BE_NULL)); + streamAvailable = true; + } + + /** + * Constructs an input source which will read an ontology from a representation from the + * specified stream. + * + * @param stream The stream that the ontology representation will be read from. + * @param prefix The document IRI prefix + * @param format ontology format + * @param mime mime type + */ + protected StreamDocumentSourceBase(Reader stream, String prefix, + @Nullable OWLDocumentFormat format, @Nullable String mime) { + super(prefix, format, mime); + checkNotNull(stream, STREAM_CANNOT_BE_NULL); + // if the input stream carries encoding information, use it; else leave + // the default as UTF-8 + if (stream instanceof InputStreamReader) { + encoding = Charset.forName(((InputStreamReader) stream).getEncoding()); + } + readIntoBuffer(stream); + streamAvailable = false; + } + + /** + * Reads all the bytes from the specified stream into a temporary buffer, which is necessary + * because we may need to access the input stream more than once. In other words, this method + * caches the input stream. + * + * @param reader The stream to be "cached" + */ + private void readIntoBuffer(InputStream reader) { + try { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + GZIPOutputStream out = new GZIPOutputStream(bos); + IOUtils.copy(reader, out); + out.finish(); + out.flush(); + byteBuffer = bos.toByteArray(); + } catch (IOException e) { + throw new OWLRuntimeException(e); + } + } + + private void readIntoBuffer(Reader reader) { + try { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + GZIPOutputStream out = new GZIPOutputStream(bos); + OutputStreamWriter writer = new OutputStreamWriter(out); + IOUtils.copy(reader, writer); + writer.flush(); + out.finish(); + out.flush(); + byteBuffer = bos.toByteArray(); + } catch (IOException e) { + throw new OWLRuntimeException(e); + } + } + + @Override + public Optional getInputStream() { + if (!streamAvailable) { + return emptyOptional(); + } + try { + return optional(new GZIPInputStream(new ByteArrayInputStream(byteBuffer))); + } catch (IOException e) { + LOGGER.error("Buffer cannot be opened", e); + failedOnStreams.set(true); + return emptyOptional(); + } + } + + @Override + public Optional getReader() { + if (streamAvailable) { + return emptyOptional(); + } + try { + return optional(new InputStreamReader( + DocumentSources.wrap(new GZIPInputStream(new ByteArrayInputStream(byteBuffer))), + encoding)); + } catch (IOException e) { + LOGGER.error("Buffer cannot be opened", e); + failedOnStreams.set(true); + return emptyOptional(); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/StreamDocumentTarget.java b/api/src/main/java/org/semanticweb/owlapi/io/StreamDocumentTarget.java new file mode 100644 index 0000000000..066d37bc04 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/StreamDocumentTarget.java @@ -0,0 +1,40 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.OutputStream; +import java.util.Optional; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class StreamDocumentTarget implements OWLOntologyDocumentTarget { + + private final Optional os; + + /** + * @param os the actual output stream + */ + public StreamDocumentTarget(OutputStream os) { + this.os = optional(checkNotNull(os, "os cannot be null")); + } + + @Override + public Optional getOutputStream() { + return os; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/StringDocumentSource.java b/api/src/main/java/org/semanticweb/owlapi/io/StringDocumentSource.java new file mode 100644 index 0000000000..9b018139ae --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/StringDocumentSource.java @@ -0,0 +1,94 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.Reader; +import java.io.StringReader; +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDocumentFormat; + +/** + * An ontology input source that wraps a string. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class StringDocumentSource extends OWLOntologyDocumentSourceBase { + + private final String string; + + /** + * @param string the source string + */ + public StringDocumentSource(String string) { + super("string:ontology", null, null); + this.string = checkNotNull(string, "string cannot be null"); + // avoid attempting IRI resolution if it is known to be failed + // a String document source needs not have an IRI and should not resolve + // it anyway + failedOnIRI.set(true); + } + + /** + * @param string the source string + * @param iri The document IRI + */ + public StringDocumentSource(String string, IRI iri) { + this(string, iri, null, null); + } + + /** + * @param target a document target + */ + public StringDocumentSource(StringDocumentTarget target) { + this(target.toString()); + } + + /** + * Specifies a string as an ontology document. + * + * @param string The string + * @param documentIRI The document IRI + * @param f ontology format + * @param mime mime type + */ + public StringDocumentSource(String string, IRI documentIRI, @Nullable OWLDocumentFormat f, + @Nullable String mime) { + super(documentIRI, f, mime); + this.string = checkNotNull(string, "string cannot be null"); + } + + /** + * Specifies a string as an ontology document. + * + * @param string The string + * @param prefix The document IRI prefix + * @param f ontology format + * @param mime mime type + */ + public StringDocumentSource(String string, String prefix, @Nullable OWLDocumentFormat f, + @Nullable String mime) { + super(prefix, f, mime); + this.string = checkNotNull(string, "string cannot be null"); + } + + @Override + public Optional getReader() { + return optional(new StringReader(string)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/StringDocumentTarget.java b/api/src/main/java/org/semanticweb/owlapi/io/StringDocumentTarget.java new file mode 100644 index 0000000000..43a7c7563b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/StringDocumentTarget.java @@ -0,0 +1,38 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.StringWriter; +import java.io.Writer; +import java.util.Optional; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class StringDocumentTarget implements OWLOntologyDocumentTarget { + + private final Optional writer = optional(new StringWriter()); + + @Override + public String toString() { + return writer.get().toString(); + } + + @Override + public Optional getWriter() { + return writer; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/SystemOutDocumentTarget.java b/api/src/main/java/org/semanticweb/owlapi/io/SystemOutDocumentTarget.java new file mode 100644 index 0000000000..3cec5a1f32 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/SystemOutDocumentTarget.java @@ -0,0 +1,43 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.OutputStream; +import java.util.Optional; + +/** + * An output target that will output an ontology to {@code System.out}. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class SystemOutDocumentTarget implements OWLOntologyDocumentTarget { + + @Override + public Optional getOutputStream() { + return optional(new OutputStream() { + + @Override + public void write(int b) { + System.out.write(b); + } + + @Override + public void close() { + // Do nothing + } + }); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/ToStringRenderer.java b/api/src/main/java/org/semanticweb/owlapi/io/ToStringRenderer.java new file mode 100644 index 0000000000..cf591cc9ef --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/ToStringRenderer.java @@ -0,0 +1,59 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.concurrent.atomic.AtomicReference; + +import javax.inject.Provider; + +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.util.SimpleRenderer; + +/** + * A utility class which can be used by implementations to provide a toString rendering of OWL API + * objects. The idea is that this is pluggable. TODO this does not allow for independent rendering; + * in a multithreaded situation, the renderer may change mid execution because of the static + * singleton instance + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public final class ToStringRenderer { + + private static final AtomicReference> rendererProvider = + new AtomicReference<>(SimpleRenderer::new); + + /** + * @return the singleton instance + */ + public static OWLObjectRenderer getInstance() { + return rendererProvider.get().get(); + } + + /** + * @param renderer the new renderer to use + */ + public static void setRenderer(Provider renderer) { + rendererProvider.set(checkNotNull(renderer, "renderer cannot be null")); + } + + /** + * @param object the object to render + * @return the rendering for the object + */ + public static String getRendering(OWLObject object) { + return getInstance().render(checkNotNull(object, "object cannot be null")); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/UnparsableOntologyException.java b/api/src/main/java/org/semanticweb/owlapi/io/UnparsableOntologyException.java new file mode 100644 index 0000000000..c09d226309 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/UnparsableOntologyException.java @@ -0,0 +1,111 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import java.util.Collections; +import java.util.Map; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration; + +/** + * A class that describes how ontology parsing failed. This class collects parse errors and the + * parsers that generated the errors. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class UnparsableOntologyException extends OWLOntologyCreationException { + + private final boolean includeStackTraceInMessage; + private final IRI documentIRI; + private final Map exceptions; + + /** + * @param documentIRI the document IRI + * @param exceptions the map parser->exceptions + * @param config the configuration object + */ + public UnparsableOntologyException(IRI documentIRI, + Map exceptions, OWLOntologyLoaderConfiguration config) { + super("Could not parse ontology from document IRI: " + documentIRI.toQuotedString()); + includeStackTraceInMessage = config.isReportStackTrace(); + this.documentIRI = documentIRI; + this.exceptions = exceptions; + } + + @Override + public String getMessage() { + StringBuilder msg = + new StringBuilder(1000).append("Problem parsing ").append(documentIRI).append( + "\nCould not parse ontology. Either a suitable parser could not be found, or parsing failed. See parser logs below for explanation.\nThe following parsers were tried:\n"); + int counter = 1; + for (OWLParser parser : exceptions.keySet()) { + msg.append(counter).append(") ").append(parser).append('\n'); + counter++; + } + msg.append("\n\nDetailed logs:\n"); + for (Map.Entry nextException : exceptions.entrySet()) { + Throwable exception = nextException.getValue(); + msg.append( + "--------------------------------------------------------------------------------\nParser: ") + .append(nextException.getKey()).append('\n'); + if (!includeStackTraceInMessage) { + msg.append(exception.getMessage()).append("\n\n"); + } else { + msg.append(" Stack trace:\n"); + Throwable current = exception; + // print up to five nested causes + for (int i = 0; i < 5 && current != null; i++) { + current = addFrame(msg, current); + } + msg.append("\n\n"); + } + } + return msg.toString(); + } + + @Nullable + protected Throwable addFrame(StringBuilder msg, Throwable current) { + msg.append(current.getMessage()); + StackTraceElement[] stackTrace = current.getStackTrace(); + for (int stackDepth = 0; stackDepth < 10 && stackDepth < stackTrace.length; stackDepth++) { + StackTraceElement element = stackTrace[stackDepth]; + msg.append(" ").append(element).append('\n'); + } + if (current.getCause() != null && current.getCause() != current) { + return current.getCause(); + } + return null; + } + + /** + * Gets the ontology document IRI from which there was an attempt to parse an ontology. + * + * @return The ontology document IRI + */ + public IRI getDocumentIRI() { + return documentIRI; + } + + /** + * Gets a map that lists the parsers (that were used to parse an ontology) and the errors that + * they generated. + * + * @return The map of parsers and their errors. + */ + public Map getExceptions() { + return Collections.unmodifiableMap(exceptions); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/WriterDocumentTarget.java b/api/src/main/java/org/semanticweb/owlapi/io/WriterDocumentTarget.java new file mode 100644 index 0000000000..b214d7619a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/WriterDocumentTarget.java @@ -0,0 +1,40 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.Writer; +import java.util.Optional; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class WriterDocumentTarget implements OWLOntologyDocumentTarget { + + private final Optional writer; + + /** + * @param writer the writer to use + */ + public WriterDocumentTarget(Writer writer) { + this.writer = optional(checkNotNull(writer, "writer cannot be null")); + } + + @Override + public Optional getWriter() { + return writer; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/XMLUtils.java b/api/src/main/java/org/semanticweb/owlapi/io/XMLUtils.java new file mode 100644 index 0000000000..598b9fc718 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/XMLUtils.java @@ -0,0 +1,432 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import javax.annotation.Nullable; + +/** + * This class contains various methods for checking QNames, NCNames etc. The implementation is based + * on the W3C namespaces in XML specification. + * + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.3.0 + */ +public final class XMLUtils { + + /** + * &lt; shortcut. + */ + public static final String LT = "<"; + /** + * &gt; shortcut. + */ + public static final String GT = ">"; + /** + * &quot; shortcut. + */ + public static final String QUOT = """; + /** + * &amp; shortcut. + */ + public static final String AMP = "&"; + /** + * &apos; shortcut. + */ + public static final String APOS = "'"; + // For some point in the future + /** + * OWL processing instruction. + */ + public static final String OWL_PROCESSING_INSTRUCTION_NAME = "owl"; + + private XMLUtils() {} + + /** + * Determines if a character is an XML name start character. + * + * @param codePoint The code point of the character to be tested. For UTF-16 characters the code + * point corresponds to the value of the char that represents the character. + * @return {@code true} if {@code codePoint} is an XML name start character, otherwise + * {@code false} + */ + public static boolean isXMLNameStartCharacter(int codePoint) { + return codePoint == ':' || codePoint >= 'A' && codePoint <= 'Z' || codePoint == '_' + || codePoint >= 'a' && codePoint <= 'z' || codePoint >= 0xC0 && codePoint <= 0xD6 + || codePoint >= 0xD8 && codePoint <= 0xF6 || codePoint >= 0xF8 && codePoint <= 0x2FF + || codePoint >= 0x370 && codePoint <= 0x37D || codePoint >= 0x37F && codePoint <= 0x1FFF + || codePoint >= 0x200C && codePoint <= 0x200D + || codePoint >= 0x2070 && codePoint <= 0x218F + || codePoint >= 0x2C00 && codePoint <= 0x2FEF + || codePoint >= 0x3001 && codePoint <= 0xD7FF + || codePoint >= 0xF900 && codePoint <= 0xFDCF + || codePoint >= 0xFDF0 && codePoint <= 0xFFFD + || codePoint >= 0x10000 && codePoint <= 0xEFFFF; + } + + /** + * Determines if a character is an XML name character. + * + * @param codePoint The code point of the character to be tested. For UTF-8 and UTF-16 + * characters the code point corresponds to the value of the char that represents the + * character. + * @return {@code true} if {@code codePoint} is an XML name start character, otherwise + * {@code false} + */ + public static boolean isXMLNameChar(int codePoint) { + return isXMLNameStartCharacter(codePoint) || codePoint == '-' || codePoint == '.' + || codePoint >= '0' && codePoint <= '9' || codePoint == 0xB7 + || codePoint >= 0x0300 && codePoint <= 0x036F + || codePoint >= 0x203F && codePoint <= 0x2040; + } + + /** + * Determines if a character is an NCName (Non-Colonised Name) start character. + * + * @param codePoint The code point of the character to be tested. For UTF-8 and UTF-16 + * characters the code point corresponds to the value of the char that represents the + * character. + * @return {@code true} if {@code codePoint} is a NCName start character, otherwise + * {@code false}. + */ + public static boolean isNCNameStartChar(int codePoint) { + return codePoint != ':' && isXMLNameStartCharacter(codePoint); + } + + /** + * Determines if a character is an NCName (Non-Colonised Name) character. + * + * @param codePoint The code point of the character to be tested. For UTF-8 and UTF-16 + * characters the code point corresponds to the value of the char that represents the + * character. + * @return {@code true} if {@code codePoint} is a NCName character, otherwise {@code false}. + */ + public static boolean isNCNameChar(int codePoint) { + return codePoint != ':' && isXMLNameChar(codePoint); + } + + /** + * Determines if a character sequence is an NCName (Non-Colonised Name). An NCName is a string + * which starts with an NCName start character and is followed by zero or more NCName + * characters. + * + * @param s The character sequence to be tested. + * @return {@code true} if {@code s} is an NCName, otherwise {@code false}. + */ + public static boolean isNCName(@Nullable CharSequence s) { + if (isNullOrEmpty(s)) { + return false; + } + assert s != null; + int firstCodePoint = Character.codePointAt(s, 0); + if (!isNCNameStartChar(firstCodePoint)) { + return false; + } + for (int i = Character.charCount(firstCodePoint); i < s.length();) { + int codePoint = Character.codePointAt(s, i); + if (!isNCNameChar(codePoint)) { + return false; + } + i += Character.charCount(codePoint); + } + return true; + } + + /** + * Determines if a character sequence is a QName. A QName is either an NCName (LocalName), or an + * NCName followed by a colon followed by another NCName (where the first NCName is referred to + * as the 'Prefix Name' and the second NCName is referred to as the 'Local Name' - i.e. + * PrefixName:LocalName). + * + * @param s The character sequence to be tested. + * @return {@code true} if {@code s} is a QName, otherwise {@code false}. + */ + public static boolean isQName(CharSequence s) { + return isQName(s, 0); + } + + /** + * Determines if a character sequence is a QName. A QName is either an NCName (LocalName), or an + * NCName followed by a colon followed by another NCName (where the first NCName is referred to + * as the 'Prefix Name' and the second NCName is referred to as the 'Local Name' - i.e. + * PrefixName:LocalName). + * + * @param s The character sequence to be tested. + * @param start start index to check + * @return {@code true} if {@code s} is a QName, otherwise {@code false}. + */ + public static boolean isQName(CharSequence s, int start) { + if (isNullOrEmpty(s) || start >= s.length()) { + return false; + } + boolean foundColon = false; + boolean inNCName = false; + for (int i = start; i < s.length();) { + int codePoint = Character.codePointAt(s, i); + if (codePoint == ':') { + if (foundColon) { + return false; + } + foundColon = true; + if (!inNCName) { + return false; + } + inNCName = false; + } else { + if (!inNCName) { + if (!isXMLNameStartCharacter(codePoint)) { + return false; + } + inNCName = true; + } else { + if (!isXMLNameChar(codePoint)) { + return false; + } + } + } + i += Character.charCount(codePoint); + } + return true; + } + + /** + * Determines if a character sequence has a suffix that is an NCName. + * + * @param s The character sequence. + * @return {@code true} if the character sequence {@code s} has a suffix that is an NCName. + */ + public static boolean hasNCNameSuffix(CharSequence s) { + return getNCNameSuffixIndex(s) != -1; + } + + /** + * Gets the index of the longest NCName that is the suffix of a character sequence. + * + * @param s The character sequence. + * @return The index of the longest suffix of the specified character sequence {@code s} that is + * an NCName, or -1 if the character sequence {@code s} does not have a suffix that is + * an NCName. + */ + public static int getNCNameSuffixIndex(CharSequence s) { + // identify bnode labels and do not try to split them + if (s.length() > 1 && s.charAt(0) == '_' && s.charAt(1) == ':') { + return -1; + } + int index = -1; + for (int i = s.length() - 1; i > -1; i--) { + if (!Character.isLowSurrogate(s.charAt(i))) { + int codePoint = Character.codePointAt(s, i); + if (isNCNameStartChar(codePoint)) { + index = i; + } + if (!isNCNameChar(codePoint)) { + break; + } + } + } + return index; + } + + /** + * Get the longest NCName that is a suffix of a character sequence. + * + * @param s The character sequence. + * @return The String which is the longest suffix of the character sequence {@code s} that is an + * NCName, or {@code null} if the character sequence {@code s} does not have a suffix + * that is an NCName. + */ + @Nullable + public static String getNCNameSuffix(CharSequence s) { + if (s.length() > 1 && s.charAt(0) == '_' && s.charAt(1) == ':') { + return null; + } + int localPartStartIndex = getNCNameSuffixIndex(s); + if (localPartStartIndex > -1) { + return s.toString().substring(localPartStartIndex); + } else { + return null; + } + } + + /** + * @param s string + * @return true if the input is null, empty or blank, i.e., only containing whitespace + * characters + */ + public static boolean isEmpty(@Nullable CharSequence s) { + if (s == null || s.length() == 0) { + return true; + } + return s.chars().allMatch(Character::isWhitespace); + } + + /** + * utility to get the part of a char sequence that is not the NCName fragment. + * + * @param s the char sequence to split + * @return the prefix split at the last non-ncname character, or the whole input if no ncname is + * found + */ + public static String getNCNamePrefix(CharSequence s) { + if (isEmpty(s)) { + return ""; + } + if (s.length() > 1 && s.charAt(0) == '_' && s.charAt(1) == ':') { + return s.toString(); + } + int localPartStartIndex = getNCNameSuffixIndex(s); + int firstNonBlank = 0; + while (Character.isWhitespace(s.charAt(firstNonBlank))) { + firstNonBlank++; + } + if (localPartStartIndex > -1) { + return s.toString().substring(firstNonBlank, localPartStartIndex); + } else { + return s.toString().substring(firstNonBlank); + } + } + + /** + * Escapes a character sequence so that it is valid XML. + * + * @param s The character sequence. + * @return The escaped version of the character sequence. + */ + public static String escapeXML(CharSequence s) { + // double quote -- quot + // ampersand -- amp + // less than -- lt + // greater than -- gt + // apostrophe -- apos + StringBuilder sb = new StringBuilder(s.length() * 2); + for (int i = 0; i < s.length();) { + int codePoint = Character.codePointAt(s, i); + if (codePoint == '<') { + sb.append(LT); + } else if (codePoint == '>') { + sb.append(GT); + } else if (codePoint == '\"') { + sb.append(QUOT); + } else if (codePoint == '&') { + sb.append(AMP); + } else if (codePoint == '\'') { + sb.append(APOS); + } else { + sb.appendCodePoint(codePoint); + } + i += Character.charCount(codePoint); + } + return sb.toString(); + } + + /** + * Escapes a subset of a char sequence so that it is valid XML. Escaped or unchanged characters + * are added to destination. + * + * @param chars chars to check + * @param start start index (inclusive) + * @param count number of characters + * @param destination destination for escaped chars + * @return The modified destination. + */ + public static StringBuilder escapeXML(char[] chars, int start, int count, + StringBuilder destination) { + // double quote -- quot + // ampersand -- amp + // less than -- lt + // greater than -- gt + // apostrophe -- apos + for (int i = 0; i < count; i++) { + char codePoint = chars[start + i]; + if (codePoint == '<') { + destination.append(LT); + } else if (codePoint == '>') { + destination.append(GT); + } else if (codePoint == '\"') { + destination.append(QUOT); + } else if (codePoint == '&') { + destination.append(AMP); + } else if (codePoint == '\'') { + destination.append(APOS); + } else { + destination.append(codePoint); + } + } + return destination; + } + + /** + * Escapes a string builder so that it is valid XML. + * + * @param sb The string builder to escape. + */ + public static void escapeXML(StringBuilder sb) { + // double quote -- quot + // ampersand -- amp + // less than -- lt + // greater than -- gt + // apostrophe -- apos + for (int i = 0; i < sb.length();) { + int codePoint = Character.codePointAt(sb, i); + int length = Character.charCount(codePoint); + if (codePoint == '<') { + sb.replace(i, i + length, LT); + i += LT.length(); + } else if (codePoint == '>') { + sb.replace(i, i + length, GT); + i += GT.length(); + } else if (codePoint == '\"') { + sb.replace(i, i + length, QUOT); + i += QUOT.length(); + } else if (codePoint == '&') { + sb.replace(i, i + length, AMP); + i += AMP.length(); + } else if (codePoint == '\'') { + sb.replace(i, i + length, APOS); + i += APOS.length(); + } else { + i += length; + } + } + } + + /** + * Determines if a character sequence is {@code null} or empty. + * + * @param s The character sequence. + * @return {@code true} if the character sequence is {@code null}, {@code true} if the character + * sequence is empty, otherwise {@code false}. + */ + public static boolean isNullOrEmpty(@Nullable CharSequence s) { + return s == null || s.length() == 0; + } + + /** + * @param iri input to check and terminate with a hash + * @return input plus a hash if the input does not terminate with hash or slash; if the input + * contains a hash in a position aside from the last character, it is returned + * unchanged. If null is received, return {@code "#"}. + */ + public static String iriWithTerminatingHash(@Nullable String iri) { + if (iri == null) { + return "#"; + } + char c = iri.charAt(iri.length() - 1); + if (c == '/' || c == '#') { + return iri; + } + if (iri.indexOf('#') > -1) { + return iri; + } + return iri + '#'; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/XZFileDocumentSource.java b/api/src/main/java/org/semanticweb/owlapi/io/XZFileDocumentSource.java new file mode 100644 index 0000000000..94de0cb289 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/XZFileDocumentSource.java @@ -0,0 +1,78 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.tukaani.xz.XZInputStream; + +/** + * An ontology document source which can read from a XZ (LZMA) compressed File. + * + * @author ses + * @since 4.0.2 + */ +public class XZFileDocumentSource extends OWLOntologyDocumentSourceBase { + + private static final Logger LOGGER = LoggerFactory.getLogger(XZFileDocumentSource.class); + private final File file; + + /** + * Constructs an input source which will read an ontology from a + * representation from the specified file. + * + * @param is The file that the ontology representation will be read from. + */ + public XZFileDocumentSource(File is) { + super("file:ontology", null, null); + file = is; + } + + /** + * Constructs an input source which will read an ontology from a + * representation from the specified file. + * + * @param stream The file that the ontology representation will be read from. + * @param documentIRI The document IRI + * @param format ontology format + * @param mime mime type + */ + public XZFileDocumentSource(File stream, IRI documentIRI, @Nullable OWLDocumentFormat format, + @Nullable String mime) { + super(documentIRI, format, mime); + file = stream; + } + + @Override + public Optional getInputStream() { + try { + return optional(new XZInputStream(new BufferedInputStream(new FileInputStream(file)))); + } catch (IOException e) { + LOGGER.error("File cannot be found or opened", e); + failedOnStreams.set(true); + return emptyOptional(); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/XZFileDocumentTarget.java b/api/src/main/java/org/semanticweb/owlapi/io/XZFileDocumentTarget.java new file mode 100644 index 0000000000..c3d7b6ba98 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/XZFileDocumentTarget.java @@ -0,0 +1,103 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.IRI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.tukaani.xz.FilterOptions; +import org.tukaani.xz.LZMA2Options; +import org.tukaani.xz.UnsupportedOptionsException; +import org.tukaani.xz.XZOutputStream; + +/** + * An ontology document target which can write to a XZ File. Notice that this + * works best when the output stream is closed explicitly in the client code. + * + * @author ses + * @since 4.0.2 + */ +public class XZFileDocumentTarget implements OWLOntologyDocumentTarget, AutoCloseable { + + private static final Logger LOGGER = LoggerFactory.getLogger(XZFileDocumentTarget.class); + private final File out; + private final FilterOptions[] filterOptions; + @Nullable + private OutputStream outputStream; + + /** + * @param os the actual file + * @param filterOptions Settings for XZ compression + */ + public XZFileDocumentTarget(File os, FilterOptions... filterOptions) { + out = os; + this.filterOptions = filterOptions; + } + + /** + * Construct an XZ document target using the selected compression preset + * + * @param os target File + * @param presetLevel LZMA2 Compression preset level + * @throws UnsupportedOptionsException if the options selected are not acceptable + */ + public XZFileDocumentTarget(File os, int presetLevel) throws UnsupportedOptionsException { + this(os, new LZMA2Options(presetLevel)); + } + + /** + * Construct an XZ document target + * + * @param file target File + */ + public XZFileDocumentTarget(File file) { + this(file, new LZMA2Options()); + } + + @Override + public Optional getOutputStream() { + try { + BufferedOutputStream bufferedOutputStream = + new BufferedOutputStream(new FileOutputStream(out)); + outputStream = new XZOutputStream(bufferedOutputStream, filterOptions); + } catch (IOException e) { + LOGGER.error("Cannot create output stream", e); + return emptyOptional(); + } + return optional(outputStream); + } + + @Override + public Optional getDocumentIRI() { + return optional(IRI.create(out)); + } + + @Override + public void close() throws Exception { + OutputStream toReturn = outputStream; + outputStream = null; + if (toReturn != null) { + toReturn.close(); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/XZStreamDocumentSource.java b/api/src/main/java/org/semanticweb/owlapi/io/XZStreamDocumentSource.java new file mode 100644 index 0000000000..613cebde0c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/XZStreamDocumentSource.java @@ -0,0 +1,109 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.UnsupportedEncodingException; +import java.util.Optional; +import javax.annotation.Nullable; +import org.apache.commons.io.IOUtils; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.tukaani.xz.XZInputStream; + +/** + * An ontology document source which can read from a XZ stream. + * + * @author ses + * @since 4.0.2 + */ +public class XZStreamDocumentSource extends OWLOntologyDocumentSourceBase { + + private static final Logger LOGGER = LoggerFactory.getLogger(XZStreamDocumentSource.class); + @Nullable + private byte[] buffer; + + /** + * Constructs an input source which will read an ontology from a + * representation from the specified file. + * + * @param is The stream that the ontology representation will be read from. + */ + public XZStreamDocumentSource(InputStream is) { + super("xzinputstream:ontology", null, null); + readIntoBuffer(is); + } + + /** + * Constructs an input source which will read an ontology from a + * representation from the specified stream. + * + * @param stream The stream that the ontology representation will be read from. + * @param documentIRI The document IRI + * @param format ontology format + * @param mime mime type + */ + public XZStreamDocumentSource(InputStream stream, IRI documentIRI, + @Nullable OWLDocumentFormat format, + @Nullable String mime) { + super(documentIRI, format, mime); + readIntoBuffer(stream); + } + + private void readIntoBuffer(InputStream reader) { + try { + buffer = IOUtils.toByteArray(reader); + } catch (IOException e) { + throw new OWLRuntimeException(e); + } + } + + @Override + public Optional getInputStream() { + if (buffer == null) { + return emptyOptional(); + } + try { + return optional(new XZInputStream(new ByteArrayInputStream(buffer))); + } catch (IOException e) { + LOGGER.error("Buffer cannot be opened", e); + failedOnStreams.set(true); + return emptyOptional(); + } + } + + @Override + public Optional getReader() { + try { + Optional inputStream = getInputStream(); + if (!inputStream.isPresent()) { + return emptyOptional(); + } + return optional(new InputStreamReader(inputStream.get(), "UTF-8")); + } catch (UnsupportedEncodingException e) { + LOGGER.error("Buffer cannot be opened", e); + failedOnStreams.set(true); + return emptyOptional(); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/XZStreamDocumentTarget.java b/api/src/main/java/org/semanticweb/owlapi/io/XZStreamDocumentTarget.java new file mode 100644 index 0000000000..abc35a34cf --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/XZStreamDocumentTarget.java @@ -0,0 +1,90 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.Optional; +import javax.annotation.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.tukaani.xz.FilterOptions; +import org.tukaani.xz.LZMA2Options; +import org.tukaani.xz.UnsupportedOptionsException; +import org.tukaani.xz.XZOutputStream; + +/** + * An ontology document target which can write to a XZ stream. Notice that this + * works best when the output stream is closed explicitly in the client code. + * + * @author ses + * @since 4.0.2 + */ +public class XZStreamDocumentTarget implements OWLOntologyDocumentTarget, AutoCloseable { + + private static final Logger LOGGER = LoggerFactory.getLogger(XZStreamDocumentTarget.class); + private final OutputStream outputStream; + @Nullable + private XZOutputStream xzOutputStream; + private FilterOptions[] filterOptions; + + /** + * @param os the actual output stream + * @param filterOptions XZ filter options to use. If no options are supplied use default LZMA2 + * Options. + */ + public XZStreamDocumentTarget(OutputStream os, FilterOptions... filterOptions) { + outputStream = os; + if (filterOptions.length == 0) { + this.filterOptions = new FilterOptions[] {new LZMA2Options()}; + } else { + this.filterOptions = filterOptions; + } + } + + /** + * @param os output stream to wrap + * @param presetLevel LZMA2 Preset Level to use + * @throws UnsupportedOptionsException if an unsupported preset level is supplied + */ + public XZStreamDocumentTarget(OutputStream os, int presetLevel) + throws UnsupportedOptionsException { + this(os, new LZMA2Options(presetLevel)); + } + + @Override + public Optional getOutputStream() { + if (xzOutputStream == null) { + try { + xzOutputStream = new XZOutputStream(outputStream, filterOptions); + } catch (IOException e) { + LOGGER.error("Fille cannot be found or opened", e); + return emptyOptional(); + } + } + return optional(verifyNotNull(xzOutputStream)); + } + + @Override + public void close() throws Exception { + XZOutputStream toReturn = xzOutputStream; + xzOutputStream = null; + if (toReturn != null) { + toReturn.close(); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/ZipDocumentTarget.java b/api/src/main/java/org/semanticweb/owlapi/io/ZipDocumentTarget.java new file mode 100644 index 0000000000..d3d44c4c5f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/ZipDocumentTarget.java @@ -0,0 +1,64 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Optional; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class ZipDocumentTarget implements OWLOntologyDocumentTarget { + + private static final Logger LOGGER = LoggerFactory.getLogger(ZipDocumentTarget.class); + private final File file; + + /** + * @param file the file to use + */ + public ZipDocumentTarget(File file) { + this.file = checkNotNull(file, "file cannot be null"); + } + + @SuppressWarnings("resource") + @Override + public Optional getOutputStream() { + File parentFile = file.getAbsoluteFile().getParentFile(); + if (parentFile.exists() || parentFile.mkdirs()) { + ZipOutputStream os; + try { + os = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(file))); + os.putNextEntry(new ZipEntry("ontology.txt")); + return optional(os); + } catch (IOException e) { + LOGGER.error("Cannot create or find file", e); + return emptyOptional(); + } + } + LOGGER.error("Could not create directories: {}", parentFile); + return emptyOptional(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/io/package-info.java b/api/src/main/java/org/semanticweb/owlapi/io/package-info.java new file mode 100644 index 0000000000..dc4164600a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Ontology parsing and saving classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.io; diff --git a/api/src/main/java/org/semanticweb/owlapi/io/packageinfo b/api/src/main/java/org/semanticweb/owlapi/io/packageinfo new file mode 100644 index 0000000000..dc4ac9fa8d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/io/packageinfo @@ -0,0 +1 @@ +version 5.2.2 diff --git a/api/src/main/java/org/semanticweb/owlapi/model/AddAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/AddAxiom.java new file mode 100644 index 0000000000..d3d1b298c3 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/AddAxiom.java @@ -0,0 +1,80 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import javax.annotation.Nullable; +import org.semanticweb.owlapi.change.AddAxiomData; + +/** + * Represents an ontology change where axioms should be added to an ontology. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class AddAxiom extends OWLAxiomChange { + + /** + * @param ont the ontology to which the change is to be applied + * @param axiom the axiom to be added + */ + public AddAxiom(OWLOntology ont, OWLAxiom axiom) { + super(ont, axiom); + } + + @Override + public AddAxiomData getChangeData() { + return new AddAxiomData(getAxiom()); + } + + @Override + public boolean isAddAxiom() { + return true; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof AddAxiom)) { + return false; + } + AddAxiom other = (AddAxiom) obj; + return other.getOntology().equals(getOntology()) && other.getAxiom().equals(getAxiom()); + } + + @Override + public int hashCode() { + return 17 + getOntology().hashCode() * 13 + getAxiom().hashCode() * 13; + } + + @Override + public void accept(OWLOntologyChangeVisitor visitor) { + visitor.visit(this); + } + + @Override + public O accept(OWLOntologyChangeVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return "AddAxiom(" + getAxiom() + " OntologyID(" + getOntology().getOntologyID() + "))"; + } + + @Override + public OWLOntologyChange reverseChange() { + return new RemoveAxiom(getOntology(), getAxiom()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/AddImport.java b/api/src/main/java/org/semanticweb/owlapi/model/AddImport.java new file mode 100644 index 0000000000..180f956d13 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/AddImport.java @@ -0,0 +1,77 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import javax.annotation.Nullable; +import org.semanticweb.owlapi.change.AddImportData; + +/** + * Represents an ontology change where an import statement is added to an + * ontology. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class AddImport extends ImportChange { + + /** + * @param ont the ontology to which the change is to be applied + * @param importDeclaration the import declaration + */ + public AddImport(OWLOntology ont, OWLImportsDeclaration importDeclaration) { + super(ont, importDeclaration); + } + + @Override + public AddImportData getChangeData() { + return new AddImportData(getImportDeclaration()); + } + + @Override + public int hashCode() { + return getOntology().hashCode() * 37 + getImportDeclaration().hashCode(); + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof AddImport)) { + return false; + } + AddImport other = (AddImport) obj; + return getImportDeclaration().equals(other.getImportDeclaration()); + } + + @Override + public String toString() { + return "AddImport(" + getImportDeclaration() + " OntologyID(" + getOntology() + .getOntologyID() + "))"; + } + + @Override + public void accept(OWLOntologyChangeVisitor visitor) { + visitor.visit(this); + } + + @Override + public O accept(OWLOntologyChangeVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public OWLOntologyChange reverseChange() { + return new RemoveImport(getOntology(), getImportDeclaration()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/AddOntologyAnnotation.java b/api/src/main/java/org/semanticweb/owlapi/model/AddOntologyAnnotation.java new file mode 100644 index 0000000000..08807ac303 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/AddOntologyAnnotation.java @@ -0,0 +1,77 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import javax.annotation.Nullable; +import org.semanticweb.owlapi.change.AddOntologyAnnotationData; + +/** + * Represents an ontology change where an annotation is added to an ontology. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class AddOntologyAnnotation extends AnnotationChange { + + /** + * @param ont the ontology to which the change is to be applied + * @param annotation the annotation + */ + public AddOntologyAnnotation(OWLOntology ont, OWLAnnotation annotation) { + super(ont, annotation); + } + + @Override + public AddOntologyAnnotationData getChangeData() { + return new AddOntologyAnnotationData(getAnnotation()); + } + + @Override + public void accept(OWLOntologyChangeVisitor visitor) { + visitor.visit(this); + } + + @Override + public O accept(OWLOntologyChangeVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public int hashCode() { + return getAnnotation().hashCode() + getOntology().hashCode() + 317; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof AddOntologyAnnotation)) { + return false; + } + AddOntologyAnnotation other = (AddOntologyAnnotation) obj; + return getAnnotation().equals(other.getAnnotation()) && getOntology() + .equals(other.getOntology()); + } + + @Override + public String toString() { + return "AddOntologyAnnotation(" + getAnnotation() + " OntologyID(" + getOntology() + .getOntologyID() + "))"; + } + + @Override + public OWLOntologyChange reverseChange() { + return new RemoveOntologyAnnotation(getOntology(), getAnnotation()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/AnnotationChange.java b/api/src/main/java/org/semanticweb/owlapi/model/AnnotationChange.java new file mode 100644 index 0000000000..b1f2a8bfef --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/AnnotationChange.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public abstract class AnnotationChange extends OWLOntologyChange { + + private final OWLAnnotation annotation; + + /** + * @param ont the ontology to which the change is to be applied + * @param annotation the annotation + */ + public AnnotationChange(OWLOntology ont, OWLAnnotation annotation) { + super(ont); + this.annotation = checkNotNull(annotation, "annotation cannot be null"); + } + + @Override + public Stream signature() { + return annotation.signature(); + } + + /** + * Gets the annotation that was added to an ontology. + * + * @return The annotation that was added + */ + public OWLAnnotation getAnnotation() { + return annotation; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/AsOWLAnnotationProperty.java b/api/src/main/java/org/semanticweb/owlapi/model/AsOWLAnnotationProperty.java new file mode 100644 index 0000000000..9f95496b00 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/AsOWLAnnotationProperty.java @@ -0,0 +1,31 @@ +package org.semanticweb.owlapi.model; + +/** + * Convert to OWLAnnotationProperty interface. + */ +public interface AsOWLAnnotationProperty { + + /** + * A convenience method that determines if this entity is an + * OWLAnnotationProperty. + * + * @return {@code true} if this entity is an OWLAnnotationProperty, otherwise {@code false} + */ + default boolean isOWLAnnotationProperty() { + return false; + } + + /** + * A convenience method that obtains this entity as an OWLAnnotationProperty + * (in order to avoid explicit casting). + * + * @return The entity as an OWLAnnotationProperty. + * @throws OWLRuntimeException if this entity is not an OWLAnnotationProperty + */ + default OWLAnnotationProperty asOWLAnnotationProperty() { + if (isOWLAnnotationProperty()) { + return (OWLAnnotationProperty) this; + } + throw new ClassCastException(getClass().getName() + "is not an OWLAnnotationProperty"); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/AsOWLClass.java b/api/src/main/java/org/semanticweb/owlapi/model/AsOWLClass.java new file mode 100644 index 0000000000..d89eeaecfe --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/AsOWLClass.java @@ -0,0 +1,31 @@ +package org.semanticweb.owlapi.model; + +/** + * Convert to OWLClass interface. + */ +public interface AsOWLClass { + + /** + * A convenience method that determines if this entity is an OWLClass. + * + * @return {@code true} if this entity is an OWLClass, otherwise {@code false} + */ + default boolean isOWLClass() { + return false; + } + + /** + * A convenience method that obtains this entity as an OWLClass (in order to avoid explicit + * casting). + * + * @return The entity as an OWLClass. + * @throws OWLRuntimeException if this entity is not an OWLClass (check with + * {@link #isOWLClass()} first). + */ + default OWLClass asOWLClass() { + if (isOWLClass()) { + return (OWLClass) this; + } + throw new ClassCastException(getClass().getName() + "is not an OWLClass"); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/AsOWLDataProperty.java b/api/src/main/java/org/semanticweb/owlapi/model/AsOWLDataProperty.java new file mode 100644 index 0000000000..733cd9beea --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/AsOWLDataProperty.java @@ -0,0 +1,31 @@ +package org.semanticweb.owlapi.model; + +/** + * Convert to OWLDataProperty interface. + */ +public interface AsOWLDataProperty { + + /** + * A convenience method that determines if this entity is an OWLDataProperty. + * + * @return {@code true} if this entity is an OWLDataProperty, otherwise {@code false} + */ + default boolean isOWLDataProperty() { + return false; + } + + /** + * A convenience method that obtains this entity as an OWLDataProperty (in order to avoid + * explicit casting). + * + * @return The entity as an OWLDataProperty. + * @throws OWLRuntimeException if this entity is not an OWLDataProperty (check with the + * {@link #isOWLDataProperty()} method first). + */ + default OWLDataProperty asOWLDataProperty() { + if (isOWLDataProperty()) { + return (OWLDataProperty) this; + } + throw new ClassCastException(getClass().getName() + "is not an OWLDataProperty"); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/AsOWLDatatype.java b/api/src/main/java/org/semanticweb/owlapi/model/AsOWLDatatype.java new file mode 100644 index 0000000000..4a3d38b000 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/AsOWLDatatype.java @@ -0,0 +1,31 @@ +package org.semanticweb.owlapi.model; + +/** + * Convert to OWLDatatype interface. + */ +public interface AsOWLDatatype { + + /** + * A convenience method that determines if this entity is an OWLDatatype. + * + * @return {@code true} if this entity is an OWLDatatype, otherwise {@code false} + */ + default boolean isOWLDatatype() { + return false; + } + + /** + * A convenience method that obtains this entity as an OWLDatatype (in order to avoid explicit + * casting). + * + * @return The entity as an OWLDatatype. + * @throws OWLRuntimeException if this entity is not an OWLDatatype (check with the + * {@link #isOWLDatatype()} method first). + */ + default OWLDatatype asOWLDatatype() { + if (isOWLDatatype()) { + return (OWLDatatype) this; + } + throw new ClassCastException(getClass().getName() + "is not an OWLDatatype"); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/AsOWLNamedIndividual.java b/api/src/main/java/org/semanticweb/owlapi/model/AsOWLNamedIndividual.java new file mode 100644 index 0000000000..1f9f2cb57b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/AsOWLNamedIndividual.java @@ -0,0 +1,31 @@ +package org.semanticweb.owlapi.model; + +/** + * Convert to OWLNamedIndividual interface. + */ +public interface AsOWLNamedIndividual { + + /** + * A convenience method that determines if this entity is an OWLNamedIndividual. + * + * @return {@code true} if this entity is an OWLNamedIndividual, otherwise {@code false} + */ + default boolean isOWLNamedIndividual() { + return false; + } + + /** + * A convenience method that obtains this entity as an OWLNamedIndividual (in order to avoid + * explicit casting). + * + * @return The entity as an OWLNamedIndividual. + * @throws OWLRuntimeException if this entity is not an OWLIndividual (check with the + * {@link #isOWLNamedIndividual()} method first). + */ + default OWLNamedIndividual asOWLNamedIndividual() { + if (isOWLNamedIndividual()) { + return (OWLNamedIndividual) this; + } + throw new ClassCastException(getClass().getName() + "is not an OWLNamedIndividual"); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/AsOWLObjectProperty.java b/api/src/main/java/org/semanticweb/owlapi/model/AsOWLObjectProperty.java new file mode 100644 index 0000000000..d53402f993 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/AsOWLObjectProperty.java @@ -0,0 +1,31 @@ +package org.semanticweb.owlapi.model; + +/** + * Convert to OWLObjectProperty interface. + */ +public interface AsOWLObjectProperty { + + /** + * A convenience method that determines if this entity is an OWLObjectProperty. + * + * @return {@code true} if this entity is an OWLObjectProperty, otherwise {@code false} + */ + default boolean isOWLObjectProperty() { + return false; + } + + /** + * A convenience method that obtains this entity as an OWLObjectProperty (in order to avoid + * explicit casting). + * + * @return The entity as an OWLObjectProperty. + * @throws OWLRuntimeException if this entity is not an OWLObjectProperty (check with the + * {@link #isOWLObjectProperty()} method first). + */ + default OWLObjectProperty asOWLObjectProperty() { + if (isOWLObjectProperty()) { + return (OWLObjectProperty) this; + } + throw new ClassCastException(getClass().getName() + "is not an OWLObjectProperty"); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/AxiomType.java b/api/src/main/java/org/semanticweb/owlapi/model/AxiomType.java new file mode 100644 index 0000000000..964ecd5436 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/AxiomType.java @@ -0,0 +1,270 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.util.CollectionFactory; + +/** + * Represents the type of axioms which can belong to ontologies. Axioms can be retrieved from + * ontologies by their {@code AxiomType}. For example, see + * {@link org.semanticweb.owlapi.model.OWLOntology#axioms(AxiomType)} and + * {@link org.semanticweb.owlapi.model.OWLOntology#getAxiomCount(AxiomType, org.semanticweb.owlapi.model.parameters.Imports)} + * . + * + * @param axiom type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +@SuppressWarnings({"unchecked"}) +public final class AxiomType implements Serializable, Comparable> { + +//@formatter:off + /** Declaration. */ public static final AxiomType DECLARATION = getInstance(OWLDeclarationAxiom.class, 0, "Declaration", true, true, false); + /** EquivalentClasses. */ public static final AxiomType EQUIVALENT_CLASSES = getInstance(OWLEquivalentClassesAxiom.class, 1, "EquivalentClasses", false, false, true); + /** SubClassOf. */ public static final AxiomType SUBCLASS_OF = getInstance(OWLSubClassOfAxiom.class, 2, "SubClassOf", false, false, true); + /** DisjointClasses. */ public static final AxiomType DISJOINT_CLASSES = getInstance(OWLDisjointClassesAxiom.class, 3, "DisjointClasses", false, false, true); + /** DisjointUnion. */ public static final AxiomType DISJOINT_UNION = getInstance(OWLDisjointUnionAxiom.class, 4, "DisjointUnion", true, false, true); + /** ClassAssertion. */ public static final AxiomType CLASS_ASSERTION = getInstance(OWLClassAssertionAxiom.class, 5, "ClassAssertion", false, false, true); + /** SameIndividual. */ public static final AxiomType SAME_INDIVIDUAL = getInstance(OWLSameIndividualAxiom.class, 6, "SameIndividual", false, false, true); + /** DifferentIndividuals. */ public static final AxiomType DIFFERENT_INDIVIDUALS = getInstance(OWLDifferentIndividualsAxiom.class, 7, "DifferentIndividuals", false, false, true); + /** ObjectPropertyAssertion. */ public static final AxiomType OBJECT_PROPERTY_ASSERTION = getInstance(OWLObjectPropertyAssertionAxiom.class, 8, "ObjectPropertyAssertion", false, false, true); + /** NegativeObjectPropertyAssertion. */ public static final AxiomType NEGATIVE_OBJECT_PROPERTY_ASSERTION = getInstance(OWLNegativeObjectPropertyAssertionAxiom.class, 9, "NegativeObjectPropertyAssertion", true,false, true); + /** DataPropertyAssertion. */ public static final AxiomType DATA_PROPERTY_ASSERTION = getInstance(OWLDataPropertyAssertionAxiom.class, 10, "DataPropertyAssertion", false, false, true); + /** NegativeDataPropertyAssertion. */ public static final AxiomType NEGATIVE_DATA_PROPERTY_ASSERTION = getInstance(OWLNegativeDataPropertyAssertionAxiom.class, 11, "NegativeDataPropertyAssertion", true,false, true); + /** EquivalentObjectProperties. */ public static final AxiomType EQUIVALENT_OBJECT_PROPERTIES = getInstance(OWLEquivalentObjectPropertiesAxiom.class, 12, "EquivalentObjectProperties", false, false,true); + /** SubObjectPropertyOf. */ public static final AxiomType SUB_OBJECT_PROPERTY = getInstance(OWLSubObjectPropertyOfAxiom.class, 13, "SubObjectPropertyOf", false, false, true); + /** InverseObjectProperties. */ public static final AxiomType INVERSE_OBJECT_PROPERTIES = getInstance(OWLInverseObjectPropertiesAxiom.class, 14, "InverseObjectProperties", false, false, true); + /** FunctionalObjectProperty. */ public static final AxiomType FUNCTIONAL_OBJECT_PROPERTY = getInstance(OWLFunctionalObjectPropertyAxiom.class, 15, "FunctionalObjectProperty", false, false, true); + /** InverseFunctionalObjectProperty. */ public static final AxiomType INVERSE_FUNCTIONAL_OBJECT_PROPERTY = getInstance(OWLInverseFunctionalObjectPropertyAxiom.class, 16, "InverseFunctionalObjectProperty", false,false, true); + /** SymmetricObjectProperty. */ public static final AxiomType SYMMETRIC_OBJECT_PROPERTY = getInstance(OWLSymmetricObjectPropertyAxiom.class, 17, "SymmetricObjectProperty", false, false, true); + /** AsymmetricObjectProperty. */ public static final AxiomType ASYMMETRIC_OBJECT_PROPERTY = getInstance(OWLAsymmetricObjectPropertyAxiom.class, 18, "AsymmetricObjectProperty", true, true, true); + /** TransitiveObjectProperty. */ public static final AxiomType TRANSITIVE_OBJECT_PROPERTY = getInstance(OWLTransitiveObjectPropertyAxiom.class, 19, "TransitiveObjectProperty", false, false, true); + /** ReflexiveObjectProperty. */ public static final AxiomType REFLEXIVE_OBJECT_PROPERTY = getInstance(OWLReflexiveObjectPropertyAxiom.class, 20, "ReflexiveObjectProperty", true, true, true); + /** IrreflexiveObjectProperty. */ public static final AxiomType IRREFLEXIVE_OBJECT_PROPERTY = getInstance(OWLIrreflexiveObjectPropertyAxiom.class, 21, "IrrefexiveObjectProperty", true, true, true); + /** ObjectPropertyDomain. */ public static final AxiomType OBJECT_PROPERTY_DOMAIN = getInstance(OWLObjectPropertyDomainAxiom.class, 22, "ObjectPropertyDomain", false, false, true); + /** ObjectPropertyRange. */ public static final AxiomType OBJECT_PROPERTY_RANGE = getInstance(OWLObjectPropertyRangeAxiom.class, 23, "ObjectPropertyRange", false, false, true); + /** DisjointObjectProperties. */ public static final AxiomType DISJOINT_OBJECT_PROPERTIES = getInstance(OWLDisjointObjectPropertiesAxiom.class, 24, "DisjointObjectProperties", true, true, true); + /** SubPropertyChainOf. */ public static final AxiomType SUB_PROPERTY_CHAIN_OF = getInstance(OWLSubPropertyChainOfAxiom.class, 25, "SubPropertyChainOf", true, true, true); + /** EquivalentDataProperties. */ public static final AxiomType EQUIVALENT_DATA_PROPERTIES = getInstance(OWLEquivalentDataPropertiesAxiom.class, 26, "EquivalentDataProperties", false, false, true); + /** SubDataPropertyOf. */ public static final AxiomType SUB_DATA_PROPERTY = getInstance(OWLSubDataPropertyOfAxiom.class, 27, "SubDataPropertyOf", false, false, true); + /** FunctionalDataProperty. */ public static final AxiomType FUNCTIONAL_DATA_PROPERTY = getInstance(OWLFunctionalDataPropertyAxiom.class, 28, "FunctionalDataProperty", false, false, true); + /** DataPropertyDomain. */ public static final AxiomType DATA_PROPERTY_DOMAIN = getInstance(OWLDataPropertyDomainAxiom.class, 29, "DataPropertyDomain", false, false, true); + /** DataPropertyRange. */ public static final AxiomType DATA_PROPERTY_RANGE = getInstance(OWLDataPropertyRangeAxiom.class, 30, "DataPropertyRange", false, false, true); + /** DisjointDataProperties. */ public static final AxiomType DISJOINT_DATA_PROPERTIES = getInstance(OWLDisjointDataPropertiesAxiom.class, 31, "DisjointDataProperties", true, true, true); + /** DatatypeDefinition. */ public static final AxiomType DATATYPE_DEFINITION = getInstance(OWLDatatypeDefinitionAxiom.class, 38, "DatatypeDefinition", true, true, true); + /** HasKey. */ public static final AxiomType HAS_KEY = getInstance(OWLHasKeyAxiom.class, 32, "HasKey", true, true, true); + /** Rule. */ public static final AxiomType SWRL_RULE = getInstance(SWRLRule.class, 33, "Rule", false, false, true); + /** AnnotationAssertion. */ public static final AxiomType ANNOTATION_ASSERTION = getInstance(OWLAnnotationAssertionAxiom.class, 34, "AnnotationAssertion", false, false, false); + /** SubAnnotationPropertyOf. */ public static final AxiomType SUB_ANNOTATION_PROPERTY_OF = getInstance(OWLSubAnnotationPropertyOfAxiom.class, 35, "SubAnnotationPropertyOf", true, true, false); + /** AnnotationPropertyRangeOf. */ public static final AxiomType ANNOTATION_PROPERTY_RANGE = getInstance(OWLAnnotationPropertyRangeAxiom.class, 36, "AnnotationPropertyRangeOf", true, true, false); + /** AnnotationPropertyDomain. */ public static final AxiomType ANNOTATION_PROPERTY_DOMAIN = getInstance(OWLAnnotationPropertyDomainAxiom.class, 37, "AnnotationPropertyDomain", true, true, false); + /** Axiom types. */ public static final Set> AXIOM_TYPES = CollectionFactory.createSet(SUBCLASS_OF, EQUIVALENT_CLASSES, DISJOINT_CLASSES, CLASS_ASSERTION, SAME_INDIVIDUAL, DIFFERENT_INDIVIDUALS, OBJECT_PROPERTY_ASSERTION, NEGATIVE_OBJECT_PROPERTY_ASSERTION, DATA_PROPERTY_ASSERTION, NEGATIVE_DATA_PROPERTY_ASSERTION, OBJECT_PROPERTY_DOMAIN, OBJECT_PROPERTY_RANGE, DISJOINT_OBJECT_PROPERTIES, SUB_OBJECT_PROPERTY, EQUIVALENT_OBJECT_PROPERTIES, INVERSE_OBJECT_PROPERTIES, SUB_PROPERTY_CHAIN_OF, FUNCTIONAL_OBJECT_PROPERTY, INVERSE_FUNCTIONAL_OBJECT_PROPERTY, SYMMETRIC_OBJECT_PROPERTY, ASYMMETRIC_OBJECT_PROPERTY, TRANSITIVE_OBJECT_PROPERTY, REFLEXIVE_OBJECT_PROPERTY, IRREFLEXIVE_OBJECT_PROPERTY, DATA_PROPERTY_DOMAIN, DATA_PROPERTY_RANGE, DISJOINT_DATA_PROPERTIES, SUB_DATA_PROPERTY, EQUIVALENT_DATA_PROPERTIES, FUNCTIONAL_DATA_PROPERTY, DATATYPE_DEFINITION, DISJOINT_UNION, DECLARATION, SWRL_RULE, ANNOTATION_ASSERTION, SUB_ANNOTATION_PROPERTY_OF, ANNOTATION_PROPERTY_DOMAIN, ANNOTATION_PROPERTY_RANGE, HAS_KEY); + /** Axiom types. */ public static final Set> LOGICAL_AXIOM_TYPES = asSet(AXIOM_TYPES.stream().filter(AxiomType::isLogical)); + /** Logical axioms and declarations */ public static final Set> LOGICAL_AXIOMS_AND_DECLARATIONS_TYPES = asSet(Stream.concat(LOGICAL_AXIOM_TYPES.stream(), Stream.of(DECLARATION))); + /** Set of tbox axiom types. */ public static final Set> TBoxAxiomTypes = CollectionFactory.createSet((AxiomType) SUBCLASS_OF, EQUIVALENT_CLASSES, DISJOINT_CLASSES, OBJECT_PROPERTY_DOMAIN, OBJECT_PROPERTY_RANGE, FUNCTIONAL_OBJECT_PROPERTY, INVERSE_FUNCTIONAL_OBJECT_PROPERTY, DATA_PROPERTY_DOMAIN, DATA_PROPERTY_RANGE, FUNCTIONAL_DATA_PROPERTY, DATATYPE_DEFINITION, DISJOINT_UNION, HAS_KEY); + /** Set of abox axiom types. */ public static final Set> ABoxAxiomTypes = CollectionFactory.createSet((AxiomType) CLASS_ASSERTION, SAME_INDIVIDUAL, DIFFERENT_INDIVIDUALS, OBJECT_PROPERTY_ASSERTION, NEGATIVE_OBJECT_PROPERTY_ASSERTION, DATA_PROPERTY_ASSERTION, NEGATIVE_DATA_PROPERTY_ASSERTION); + /** Set of rbox axiom types. */ public static final Set> RBoxAxiomTypes = CollectionFactory.createSet((AxiomType) TRANSITIVE_OBJECT_PROPERTY, DISJOINT_DATA_PROPERTIES, SUB_DATA_PROPERTY, EQUIVALENT_DATA_PROPERTIES, DISJOINT_OBJECT_PROPERTIES, SUB_OBJECT_PROPERTY, EQUIVALENT_OBJECT_PROPERTIES, SUB_PROPERTY_CHAIN_OF, INVERSE_OBJECT_PROPERTIES, SYMMETRIC_OBJECT_PROPERTY, ASYMMETRIC_OBJECT_PROPERTY, REFLEXIVE_OBJECT_PROPERTY, IRREFLEXIVE_OBJECT_PROPERTY); + /** Set of tbox and rbox axiom types. */public static final Set> TBoxAndRBoxAxiomTypes = Collections.unmodifiableSet(Stream.concat(TBoxAxiomTypes.stream(), RBoxAxiomTypes.stream()).collect(Collectors.toSet())); + + private static final Map> NAME_TYPE_MAP = Collections.unmodifiableMap(AXIOM_TYPES.stream().collect(Collectors.toMap(AxiomType::getName, Function.identity()))); + private static final Map, AxiomType> CLASS_TYPE_MAP = Collections.unmodifiableMap(AXIOM_TYPES.stream().collect(Collectors.toMap(AxiomType::getActualClass, Function.identity()))); + private final String name; + private final boolean owl2Axiom; + private final boolean nonSyntacticOWL2Axiom; + private final boolean isLogical; + private final int index; + private final Class actualClass; +//@formatter:on + + private AxiomType(Class actualClass, int ind, String name, boolean owl2Axiom, + boolean nonSyntacticOWL2Axiom, boolean isLogical) { + this.actualClass = actualClass; + this.name = name; + this.owl2Axiom = owl2Axiom; + this.nonSyntacticOWL2Axiom = nonSyntacticOWL2Axiom; + this.isLogical = isLogical; + index = ind; + } + + private static AxiomType getInstance(Class c, int i, String name, + boolean owl2Axiom, boolean nonSyntacticOWL2Axiom, boolean isLogical) { + return new AxiomType<>(c, i, name, owl2Axiom, nonSyntacticOWL2Axiom, isLogical); + } + + /** + * @return axiom types minus declarations + */ + public static Stream> skipDeclarations() { + return AXIOM_TYPES.stream().filter(t -> t != DECLARATION); + } + + /** + * @param t axiom class to match + * @param axiom type + * @return axiom type for axiom class + */ + public static AxiomType getTypeForClass(Class t) { + AxiomType axiomType = CLASS_TYPE_MAP.get(t); + if (axiomType == null) { + throw new OWLRuntimeException("No known axiom type for " + t); + } + return (AxiomType) axiomType; + } + + /** + * Gets the set of axioms from a source set of axioms that are not of the specified type. + * + * @param sourceAxioms The source set of axioms + * @param axiomTypes The types that will be filtered out of the source set + * @return A set of axioms that represents the source axioms without the specified types. Note + * that source axioms will not be modified. The returned set is a copy. + */ + public static Set getAxiomsWithoutTypes(Collection sourceAxioms, + AxiomType... axiomTypes) { + Set> disallowed = new HashSet<>(Arrays.asList(axiomTypes)); + return asSet(sourceAxioms.stream().filter(a -> !disallowed.contains(a.getAxiomType()))); + } + + /** + * Gets the set of axioms from a source set of axioms that have a specified type. + * + * @param sourceAxioms The source set of axioms + * @param axiomTypes The types of axioms that will be returned + * @return A set of axioms that represents the source axioms that have the specified types. Note + * that source axioms will not be modified. The returned set is a copy. + */ + public static Set getAxiomsOfTypes(Collection sourceAxioms, + AxiomType... axiomTypes) { + Set> allowed = new HashSet<>(Arrays.asList(axiomTypes)); + return asSet(sourceAxioms.stream().filter(a -> allowed.contains(a.getAxiomType()))); + } + + /** + * Gets an axiom type by its name. + * + * @param name The name of the axiom type + * @return The axiom type with the specified name, or {@code null} if there is no such axiom + * type with the specified name + */ + public static AxiomType getAxiomType(String name) { + return NAME_TYPE_MAP.get(name); + } + + /** + * Determines if there is an axiom type with the specified name. + * + * @param _name The name to test for + * @return {@code true} if there is an axiom type with the specified name, or {@code false} if + * there is no axiom type with the specified name. + */ + public static boolean isAxiomType(String _name) { + return NAME_TYPE_MAP.containsKey(_name); + } + + @Override + public int hashCode() { + return name.hashCode(); + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == null) { + return false; + } + if (this == obj) { + return true; + } + if (obj instanceof AxiomType) { + return name.equals(((AxiomType) obj).name); + } + return false; + } + + @Override + public String toString() { + return name; + } + + /** + * @return the axiom interface corresponding to this type + */ + public Class getActualClass() { + return actualClass; + } + + /** + * Determines if this axiom is structurally an OWL 2 axiom. + * + * @return {@code true} if this axiom is an OWL 2 axiom, {@code false} if this axiom is not an + * OWL 2 axiom and it can be represented using OWL 1. + */ + public boolean isOWL2Axiom() { + return owl2Axiom; + } + + /** + * Some OWL 2 axioms, for example, + * {@link org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom} axioms are + * structurally OWL 2 axioms, but can be represented using OWL 1 syntax. This method determines + * if this axiom type is a pure OWL 2 axiom and cannot be represented using OWL 1 syntax. + * + * @return {@code true} if this axiom is a pure OWL 2 axiom and cannot be represented using OWL + * 1 syntax, otherwise {@code false}. + */ + public boolean isNonSyntacticOWL2Axiom() { + return nonSyntacticOWL2Axiom; + } + + /** + * @return index in the axiom type list + */ + public int getIndex() { + return index; + } + + /** + * @return axiom type name + */ + public String getName() { + return name; + } + + /** + * Determines if this axiom type is a logical axiom type. + * + * @return {@code true} if this axiom type is a logical axiom type, otherwise false; + */ + public boolean isLogical() { + return isLogical; + } + + @Override + public int compareTo(@SuppressWarnings("null") AxiomType o) { + return Integer.compare(index, o.index); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/ByName.java b/api/src/main/java/org/semanticweb/owlapi/model/ByName.java new file mode 100644 index 0000000000..dddf32d13c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/ByName.java @@ -0,0 +1,17 @@ +package org.semanticweb.owlapi.model; + +/** + * An interface for things that have an exact mapping by name. This interface + * exists to allow enumerations to be used easily in ConfigurationOptions. + * + * @param type for the interface + */ +@FunctionalInterface +public interface ByName { + + /** + * @param name the name to map to an object + * @return the object associated with name + */ + T byName(CharSequence name); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/ChangeDetails.java b/api/src/main/java/org/semanticweb/owlapi/model/ChangeDetails.java new file mode 100644 index 0000000000..1aef68fb9a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/ChangeDetails.java @@ -0,0 +1,43 @@ +package org.semanticweb.owlapi.model; + +import java.util.List; + +import org.semanticweb.owlapi.model.parameters.ChangeApplied; + +/** + * A class to hold detailed results on a set of changes. {@code changeEffect} has the overall result + * of the transaction (changes can have been applied successfully, they can have failed and been + * rolled back, or all changes might have been no-operation). {@code enactedChanges} has all the + * changes that have been applied successfully. + * + * @author ignazio + */ +public class ChangeDetails { + + private final ChangeApplied changeEffect; + private final List enactedChanges; + + /** + * @param changeEffect the result of a change + * @param enactedChanges the list of changes applied successfully + */ + public ChangeDetails(ChangeApplied changeEffect, + List enactedChanges) { + this.changeEffect = changeEffect; + this.enactedChanges = enactedChanges; + } + + /** + * @return the change effect + */ + public ChangeApplied getChangeEffect() { + return changeEffect; + } + + /** + * @return the enacted changes + */ + public List getEnactedChanges() { + return enactedChanges; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/ClassExpressionType.java b/api/src/main/java/org/semanticweb/owlapi/model/ClassExpressionType.java new file mode 100644 index 0000000000..52b84ee53b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/ClassExpressionType.java @@ -0,0 +1,81 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; +import org.semanticweb.owlapi.vocab.Namespaces; + +/** + * Represents the different types of OWL 2 class expressions. + * + * @author Matthew Horridge, The University Of Manchester, Information Management Group + * @since 2.2.0 + */ +public enum ClassExpressionType implements Serializable, HasShortForm, HasPrefixedName, HasIRI { + //@formatter:off + /** Represents {@link OWLClass}. */ OWL_CLASS ("Class"), + /** Represents {@link OWLObjectSomeValuesFrom}. */ OBJECT_SOME_VALUES_FROM ("ObjectSomeValuesFrom" ), + /** Represents {@link OWLObjectAllValuesFrom}. */ OBJECT_ALL_VALUES_FROM ("ObjectAllValuesFrom" ), + /** Represents {@link OWLObjectMinCardinality}. */ OBJECT_MIN_CARDINALITY ("ObjectMinCardinality" ), + /** Represents {@link OWLObjectMaxCardinality}. */ OBJECT_MAX_CARDINALITY ("ObjectMaxCardinality" ), + /** Represents {@link OWLObjectExactCardinality}. */ OBJECT_EXACT_CARDINALITY("ObjectExactCardinality"), + /** Represents {@link OWLObjectHasValue}. */ OBJECT_HAS_VALUE ("ObjectHasValue" ), + /** Represents {@link OWLObjectHasSelf}. */ OBJECT_HAS_SELF ("ObjectHasSelf" ), + /** Represents {@link OWLDataSomeValuesFrom}. */ DATA_SOME_VALUES_FROM ("DataSomeValuesFrom" ), + /** Represents {@link OWLDataAllValuesFrom}. */ DATA_ALL_VALUES_FROM ("DataAllValuesFrom" ), + /** Represents {@link OWLDataMinCardinality}. */ DATA_MIN_CARDINALITY ("DataMinCardinality" ), + /** Represents {@link OWLDataMaxCardinality}. */ DATA_MAX_CARDINALITY ("DataMaxCardinality" ), + /** Represents {@link OWLDataExactCardinality}. */ DATA_EXACT_CARDINALITY ("DataExactCardinality" ), + /** Represents {@link OWLDataHasValue}. */ DATA_HAS_VALUE ("DataHasValue" ), + /** Represents {@link OWLObjectIntersectionOf}. */ OBJECT_INTERSECTION_OF ("ObjectIntersectionOf" ), + /** Represents {@link OWLObjectUnionOf}. */ OBJECT_UNION_OF ("ObjectUnionOf" ), + /** Represents {@link OWLObjectComplementOf}. */ OBJECT_COMPLEMENT_OF ("ObjectComplementOf" ), + /** Represents {@link OWLObjectComplementOf}. */ OBJECT_ONE_OF ("ObjectOneOf" ); + //@formatter:on + private final String name; + private final String prefixedName; + private final IRI iri; + + ClassExpressionType(String name) { + this.name = name; + prefixedName = Namespaces.OWL.getPrefixName() + ':' + name; + iri = IRI.create(Namespaces.OWL.getPrefixIRI(), name); + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + @Override + public String toString() { + return name; + } + + @Override + public String getShortForm() { + return name; + } + + @Override + public IRI getIRI() { + return iri; + } + + @Override + public String getPrefixedName() { + return prefixedName; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/DataRangeType.java b/api/src/main/java/org/semanticweb/owlapi/model/DataRangeType.java new file mode 100644 index 0000000000..b698bc3204 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/DataRangeType.java @@ -0,0 +1,63 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; +import org.semanticweb.owlapi.vocab.Namespaces; + +/** + * Represents the different types of OWL 2 data ranges. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public enum DataRangeType implements Serializable, HasShortForm, HasPrefixedName, HasIRI { + //@formatter:off + /** Represents {@link OWLDatatype}. */ DATATYPE ("Datatype" ), + /** Represents {@link OWLDataOneOf}. */ DATA_ONE_OF ("DataOneOf" ), + /** Represents {@link OWLDatatypeRestriction}. */ DATATYPE_RESTRICTION ("DatatypeRestriction" ), + /** Represents {@link OWLDataComplementOf}. */ DATA_COMPLEMENT_OF ("DataComplementOf" ), + /** Represents {@link OWLDataUnionOf}. */ DATA_UNION_OF ("DataUnionOf" ), + /** Represents {@link OWLDataIntersectionOf}. */ DATA_INTERSECTION_OF ("DataIntersectionOf" ); + //@formatter:on + private final String name; + private final String prefixedName; + private final IRI iri; + + DataRangeType(String name) { + this.name = name; + prefixedName = Namespaces.OWL.getPrefixName() + ':' + name; + iri = IRI.create(Namespaces.OWL.getPrefixIRI(), name); + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + @Override + public String getShortForm() { + return name; + } + + @Override + public IRI getIRI() { + return iri; + } + + @Override + public String getPrefixedName() { + return prefixedName; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/DefaultChangeBroadcastStrategy.java b/api/src/main/java/org/semanticweb/owlapi/model/DefaultChangeBroadcastStrategy.java new file mode 100644 index 0000000000..0dedea5378 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/DefaultChangeBroadcastStrategy.java @@ -0,0 +1,34 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; +import java.util.List; + +/** + * A change broadcast strategy that simple broadcasts all changes made to all + * ontologies. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class DefaultChangeBroadcastStrategy implements OWLOntologyChangeBroadcastStrategy, + Serializable { + + @Override + public void broadcastChanges(OWLOntologyChangeListener listener, + List changes) { + // Just broadcast all changes + listener.ontologiesChanged(changes); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/DefaultImpendingChangeBroadcastStrategy.java b/api/src/main/java/org/semanticweb/owlapi/model/DefaultImpendingChangeBroadcastStrategy.java new file mode 100644 index 0000000000..222c024569 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/DefaultImpendingChangeBroadcastStrategy.java @@ -0,0 +1,30 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; +import java.util.List; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +public class DefaultImpendingChangeBroadcastStrategy + implements ImpendingOWLOntologyChangeBroadcastStrategy, Serializable { + + @Override + public void broadcastChanges(ImpendingOWLOntologyChangeListener listener, + List changes) { + listener.handleImpendingOntologyChanges(changes); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/EDTChangeBroadcastStrategy.java b/api/src/main/java/org/semanticweb/owlapi/model/EDTChangeBroadcastStrategy.java new file mode 100644 index 0000000000..99b16e4b17 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/EDTChangeBroadcastStrategy.java @@ -0,0 +1,40 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.List; +import javax.swing.SwingUtilities; + +/** + * A change broadcast strategy which broadcasts all ontology changes in the + * Swing Even Dispatch Thread (EDT). + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class EDTChangeBroadcastStrategy implements OWLOntologyChangeBroadcastStrategy { + + @Override + public void broadcastChanges(OWLOntologyChangeListener l, + List changes) + throws OWLException { + try { + SwingUtilities.invokeLater(() -> l.ontologiesChanged(changes)); + } catch (OWLRuntimeException e) { + if (e.getCause() instanceof OWLException) { + throw (OWLException) e.getCause(); + } + throw new OWLException(e); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/EntityType.java b/api/src/main/java/org/semanticweb/owlapi/model/EntityType.java new file mode 100644 index 0000000000..51f8ecfa3b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/EntityType.java @@ -0,0 +1,147 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.OWL_ANNOTATION_PROPERTY; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.OWL_CLASS; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.OWL_DATA_PROPERTY; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.OWL_NAMED_INDIVIDUAL; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.OWL_OBJECT_PROPERTY; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.RDFS_DATATYPE; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +import org.semanticweb.owlapi.model.providers.EntityProvider; +import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; + +/** + * Represents the different types of OWL 2 Entities. + * + * @param entity type + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class EntityType + implements Serializable, HasShortForm, HasPrefixedName, HasIRI { + +//@formatter:off + /** Class entity. */ public static final EntityType CLASS = new EntityType<>("Class", "Class", "Classes", OWL_CLASS, (i, p) -> p.getOWLClass(i)); + /** Object property entity. */ public static final EntityType OBJECT_PROPERTY = new EntityType<>("ObjectProperty", "Object property", "Object properties", OWL_OBJECT_PROPERTY, (i, p) -> p.getOWLObjectProperty(i)); + /** Data property entity. */ public static final EntityType DATA_PROPERTY = new EntityType<>("DataProperty", "Data property", "Data properties", OWL_DATA_PROPERTY, (i, p) -> p.getOWLDataProperty(i)); + /** Annotation property entity. */ public static final EntityType ANNOTATION_PROPERTY = new EntityType<>("AnnotationProperty", "Annotation property", "Annotation properties", OWL_ANNOTATION_PROPERTY,(i, p) -> p.getOWLAnnotationProperty(i)); + /** Named individual entity. */ public static final EntityType NAMED_INDIVIDUAL = new EntityType<>("NamedIndividual", "Named individual", "Named individuals", OWL_NAMED_INDIVIDUAL, (i, p) -> p.getOWLNamedIndividual(i)); + /** Datatype entity. */ public static final EntityType DATATYPE = new EntityType<>("Datatype", "Datatype", "Datatypes", RDFS_DATATYPE, (i, p) -> p.getOWLDatatype(i)); + //@formatter:on + private static final List> VALUES = + Collections.>unmodifiableList(Arrays.asList(CLASS, OBJECT_PROPERTY, + DATA_PROPERTY, ANNOTATION_PROPERTY, NAMED_INDIVIDUAL, DATATYPE)); + private final String name; + private final OWLRDFVocabulary vocabulary; + private final String printName; + private final String pluralPrintName; + private final Builder builder; + + protected EntityType(String name, String print, String pluralPrint, OWLRDFVocabulary vocabulary, + Builder builder) { + this.name = name; + this.vocabulary = vocabulary; + printName = print; + pluralPrintName = pluralPrint; + this.builder = builder; + } + + /** + * @return the list of known entity types + */ + public static List> values() { + return VALUES; + } + + /** + * @return toe vocabulary enum corresponding to this entity + */ + public OWLRDFVocabulary getVocabulary() { + return vocabulary; + } + + /** + * @return this entity type name + */ + public String getName() { + return name; + } + + @Override + public String toString() { + return name; + } + + /** + * @return printable name + */ + public String getPrintName() { + return printName; + } + + /** + * @return plural printable name + */ + public String getPluralPrintName() { + return pluralPrintName; + } + + @Override + public String getShortForm() { + return name; + } + + @Override + public String getPrefixedName() { + return vocabulary.getPrefixedName(); + } + + @Override + public IRI getIRI() { + return vocabulary.getIRI(); + } + + /** + * @param visitor visitor to accept + * @param return type + * @return visitor return value + */ + public Optional accept(EntityTypeVisitorEx visitor) { + return visitor.visit(this); + } + + /** + * Build an entity of this type, using the factory passed in as df. + * + * @param i iri + * @param df data factory + * @return entity + */ + public E buildEntity(IRI i, EntityProvider df) { + return builder.buildEntity(i, df); + } + + @FunctionalInterface + private static interface Builder { + + T buildEntity(IRI i, EntityProvider p); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/EntityTypeVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/model/EntityTypeVisitorEx.java new file mode 100644 index 0000000000..6ee41fac52 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/EntityTypeVisitorEx.java @@ -0,0 +1,77 @@ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; + +import java.util.Optional; + +/** + * Value visitor for EntityType + * + * @param type to return + * @author ignazio + */ +public interface EntityTypeVisitorEx { + + /** + * @param entity entity to visit + * @return return value + */ + default Optional visit(EntityType entity) { + if (entity.equals(EntityType.CLASS)) { + return visitCLASS(); + } + if (entity.equals(EntityType.OBJECT_PROPERTY)) { + return visitOBJECT_PROPERTY(); + } + if (entity.equals(EntityType.DATA_PROPERTY)) { + return visitDATA_PROPERTY(); + } + if (entity.equals(EntityType.ANNOTATION_PROPERTY)) { + return visitANNOTATION_PROPERTY(); + } + if (entity.equals(EntityType.NAMED_INDIVIDUAL)) { + return visitNAMED_INDIVIDUAL(); + } + if (entity.equals(EntityType.DATATYPE)) { + return visitDATATYPE(); + } + return doDefault(); + } + + /** + * @return default value if no values are matched + */ + default Optional doDefault() { + return emptyOptional(); + } + + /** + * @return value for class + */ + Optional visitCLASS(); + + /** + * @return value for object property + */ + Optional visitOBJECT_PROPERTY(); + + /** + * @return value for data property + */ + Optional visitDATA_PROPERTY(); + + /** + * @return value for annotation property + */ + Optional visitANNOTATION_PROPERTY(); + + /** + * @return value for individual + */ + Optional visitNAMED_INDIVIDUAL(); + + /** + * @return value for datatype + */ + Optional visitDATATYPE(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasAddAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/HasAddAxiom.java new file mode 100644 index 0000000000..938d63adf4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasAddAxiom.java @@ -0,0 +1,35 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.model.parameters.ChangeApplied; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 4.0.0 + */ +@FunctionalInterface +public interface HasAddAxiom { + + /** + * A convenience method that adds a single axiom to an ontology. The + * appropriate AddAxiom change object is automatically generated. + * + * @param ont The ontology to add the axiom to. + * @param axiom The axiom to be added + * @return ChangeApplied.SUCCESSFULLY if the axiom is added, ChangeApplied.UNSUCCESSFULLY + * otherwise. + * @throws OWLOntologyChangeException if there was a problem adding the axiom + */ + ChangeApplied addAxiom(OWLOntology ont, OWLAxiom axiom); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasAddAxioms.java b/api/src/main/java/org/semanticweb/owlapi/model/HasAddAxioms.java new file mode 100644 index 0000000000..9e166414d7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasAddAxioms.java @@ -0,0 +1,52 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Collection; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.parameters.ChangeApplied; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5 + */ +@FunctionalInterface +public interface HasAddAxioms { + + /** + * A convenience method that adds a collection of axioms to an ontology. The appropriate + * AddAxiom change objects are automatically generated. + * + * @param ont The ontology to which the axioms should be added. + * @param axioms The axioms to be added. + * @return ChangeApplied.SUCCESSFULLY if the axioms are added, ChangeApplied.UNSUCCESSFULLY + * otherwise. For more detailed results see + * {@link HasApplyChanges#applyChangesAndGetDetails(java.util.List)} + */ + default ChangeApplied addAxioms(OWLOntology ont, Collection axioms) { + return addAxioms(ont, axioms.stream()); + } + + /** + * A convenience method that adds a stream of axioms to an ontology. The appropriate AddAxiom + * change objects are automatically generated. + * + * @param ont The ontology to which the axioms should be added. + * @param axioms The axioms to be added. + * @return ChangeApplied.SUCCESSFULLY if the axioms are added, ChangeApplied.UNSUCCESSFULLY + * otherwise. For more detailed results see + * {@link HasApplyChanges#applyChangesAndGetDetails(java.util.List)} + */ + ChangeApplied addAxioms(OWLOntology ont, Stream axioms); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasAnnotationPropertiesInSignature.java b/api/src/main/java/org/semanticweb/owlapi/model/HasAnnotationPropertiesInSignature.java new file mode 100644 index 0000000000..892d21c096 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasAnnotationPropertiesInSignature.java @@ -0,0 +1,42 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.empty; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +public interface HasAnnotationPropertiesInSignature { + + /** + * @return The annotation properties that are in the signature of this object. The set is a + * subset of the signature, and is not backed by the signature; it is a modifiable + * collection and changes are not reflected by the signature. + */ + default Set getAnnotationPropertiesInSignature() { + return asSet(annotationPropertiesInSignature()); + } + + /** + * @return the annotation properties that are in the signature of this object. + */ + default Stream annotationPropertiesInSignature() { + return empty(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasAnnotationValue.java b/api/src/main/java/org/semanticweb/owlapi/model/HasAnnotationValue.java new file mode 100644 index 0000000000..98f25994d5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasAnnotationValue.java @@ -0,0 +1,363 @@ +package org.semanticweb.owlapi.model; + +import java.util.Optional; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.function.Supplier; + +/** + * Convenience interface for classes that have an annotation value referred - i.e., annotation + * assertion axioms, annotations and annotation values. The annotation value referred is the main + * annotation value, nested annotations or annotations on axioms are excluded. + * + * The purpose of these methods is providing stream friendly shortcuts to operate on literals, iris + * and anonymous individuals used as values for annotations. + */ +public interface HasAnnotationValue { + + /** + * @return for IRI values, the IRI, else an empty Optional + */ + default Optional iriValue() { + return annotationValue().asIRI(); + } + + /** + * @return for literal values, the literal, else an empty Optional + */ + default Optional literalValue() { + return annotationValue().asLiteral(); + } + + /** + * @return for anonymous individual values, the individual, else an empty Optional + */ + default Optional anonymousIndividualValue() { + return annotationValue().asAnonymousIndividual(); + } + + /** + * @return the annotation value itself; this method allows OWLAnnotationAssertionAxiom and + * OWLAnnotation to use the default methods rather than replicate the methods. For + * OWLAnnotationValue instances, the value returned is the object itself. + */ + OWLAnnotationValue annotationValue(); + + /** + * Execute the consumer if and only if the annotation value is of the specified type and the + * predicate evaluates to true; the alternative runnable is executed if the predicate does not + * match or the type does not match (only once if both conditions do not match). + * + * @param witness class for which predicate and consumer should be executed + * @param p predicate to test + * @param c consumer to apply + * @param r runnable to execute if the predicate does not match or the annotation type does not + * match + * @param type + */ + default void when(Class witness, Predicate p, + Consumer c, Runnable r) { + OWLAnnotationValue t = annotationValue(); + if (witness.isInstance(t)) { + T av = witness.cast(t); + if (p.test(av)) { + c.accept(av); + } else { + r.run(); + } + } else { + r.run(); + } + } + + /** + * Apply the function if and only if the annotation value is of the specified type and the + * predicate evaluates to true; the alternative supplier is executed if the predicate does not + * match or the type does not match (only once if both conditions do not match). + * + * @param type to match + * @param return type + * @param witness class for which predicate and function should be executed + * @param p predicate to test + * @param f function to apply + * @param s supplier to execute if the predicate does not match or the annotation type does not + * match + * @return function result or supplier result, depending on predicate evaluation + */ + default O map(Class witness, Predicate p, + Function f, Supplier s) { + OWLAnnotationValue t = annotationValue(); + if (witness.isInstance(t)) { + T av = witness.cast(t); + if (p.test(av)) { + return f.apply(av); + } else { + return s.get(); + } + } + return s.get(); + } + + /** + * Apply the function if and only if the annotation value is of the specified type and the + * predicate evaluates to true; the default value is returned if the predicate does not match or + * the type does not match. + * + * @param type to match + * @param return type + * @param witness class for which predicate and function should be executed + * @param p predicate to test + * @param f function to apply + * @param defaultValue default value to return if the predicate does not match or the annotation + * type does not match + * @return function result or default value, depending on predicate evaluation + */ + default O map(Class witness, Predicate p, + Function f, O defaultValue) { + OWLAnnotationValue t = annotationValue(); + if (witness.isInstance(t)) { + T av = witness.cast(t); + if (p.test(av)) { + return f.apply(av); + } else { + return defaultValue; + } + } + return defaultValue; + } + + /** + * @param literalConsumer consumer to run if the value is a literal + */ + default void ifLiteral(Consumer literalConsumer) { + OWLAnnotationValue value = annotationValue(); + if (value.isLiteral()) { + literalConsumer.accept((OWLLiteral) value); + } + } + + + /** + * @param literalConsumer consumer to run if the value is a literal + * @param elseAction runnable to run if the value iS not a literal + */ + default void ifLiteralOrElse(Consumer literalConsumer, Runnable elseAction) { + OWLAnnotationValue value = annotationValue(); + if (value.isLiteral()) { + literalConsumer.accept((OWLLiteral) value); + } else { + elseAction.run(); + } + } + + /** + * @param iriConsumer consumer to run if the value is an IRI + */ + default void ifIri(Consumer iriConsumer) { + OWLAnnotationValue value = annotationValue(); + if (value.isIRI()) { + iriConsumer.accept((IRI) value); + } + } + + /** + * @param iriConsumer consumer to run if the value is an IRI + * @param elseAction runnable to run if the value is not an IRI + */ + default void ifIriOrElse(Consumer iriConsumer, Runnable elseAction) { + OWLAnnotationValue value = annotationValue(); + if (value.isIRI()) { + iriConsumer.accept((IRI) value); + } else { + elseAction.run(); + } + } + + /** + * @param anonConsumer consumer to run if the value is an anonymous individual + */ + default void ifAnonymousIndividual(Consumer anonConsumer) { + OWLAnnotationValue value = annotationValue(); + if (value.isIndividual()) { + anonConsumer.accept((OWLAnonymousIndividual) value); + } + } + + /** + * @param anonConsumer consumer to run if the value is an anonymous individual + * @param elseAction runnable to run if the value is not an anonymous individual + */ + default void ifAnonymousIndividualOrElse(Consumer anonConsumer, + Runnable elseAction) { + OWLAnnotationValue value = annotationValue(); + if (value.isIndividual()) { + anonConsumer.accept((OWLAnonymousIndividual) value); + } else { + elseAction.run(); + } + } + + /** + * @param function function to run if the value is a literal + * @param returned type + * @return mapped value for literals, empty otherwise + */ + default Optional mapLiteral(Function function) { + OWLAnnotationValue value = annotationValue(); + if (value.isLiteral()) { + return Optional.ofNullable(function.apply((OWLLiteral) value)); + } + return Optional.empty(); + } + + /** + * @param function function to run if the value is a literal + * @param defaultValue value returned if the value if not a literal + * @param returned type + * @return mapped value for literals, default value for non literals + */ + default T mapLiteralOrElse(Function function, T defaultValue) { + OWLAnnotationValue value = annotationValue(); + if (value.isLiteral()) { + return function.apply((OWLLiteral) value); + } + return defaultValue; + } + + /** + * @param function function to run if the value is a literal + * @param defaultValue supplier to run if the value is not a literal + * @param returned type + * @return mapped value for literals, supplier result for non literals + */ + default T mapLiteralOrElseGet(Function function, Supplier defaultValue) { + OWLAnnotationValue value = annotationValue(); + if (value.isLiteral()) { + return function.apply((OWLLiteral) value); + } + return defaultValue.get(); + } + + /** + * @param function function to run if the value is an IRI + * @param returned type + * @return mapped value for IRIs, empty for non IRIs + */ + default Optional mapIri(Function function) { + OWLAnnotationValue value = annotationValue(); + if (value.isIRI()) { + return Optional.ofNullable(function.apply((IRI) value)); + } + return Optional.empty(); + } + + /** + * @param function function to run if the value is an IRI + * @param defaultValue default value to return if the value is not an IRI + * @param return type + * @return mapped value for IRIs, default value for non IRIs + */ + default T mapIriOrElse(Function function, T defaultValue) { + OWLAnnotationValue value = annotationValue(); + if (value.isIRI()) { + return function.apply((IRI) value); + } + return defaultValue; + } + + /** + * @param function function to run if the value is an IRI + * @param defaultValue supplier to run if the value is not an IRI + * @param returned type + * @return mapped value for IRIs, supplier result for non IRIs + */ + default T mapIriOrElseGet(Function function, Supplier defaultValue) { + OWLAnnotationValue value = annotationValue(); + if (value.isIRI()) { + return function.apply((IRI) value); + } + return defaultValue.get(); + } + + /** + * @param function function to run if the value is an anonymous individual + * @param returned type + * @return mapped value for anonymous individuals, empty for non individuals + */ + default Optional mapAnonymousIndividual(Function function) { + OWLAnnotationValue value = annotationValue(); + if (value.isIRI()) { + return Optional.ofNullable(function.apply((OWLAnonymousIndividual) value)); + } + return Optional.empty(); + } + + /** + * @param function function to run if the value is an anonymous individual + * @param defaultValue default value to if the value is not an anonymous individual + * @param returned type + * @return mapped value for anonymous individuals, default value for non individuals + */ + default T mapAnonymousIndividualOrElse(Function function, + T defaultValue) { + OWLAnnotationValue value = annotationValue(); + if (value.isAnonymous()) { + return function.apply((OWLAnonymousIndividual) value); + } + return defaultValue; + } + + /** + * @param function function to run if the value is an anonymous individual + * @param defaultValue supplier to run if the value is not an anonymous individual + * @param returned type + * @return mapped value for anonymous individuals, supplier result for non individuals + */ + default T mapAnonymousIndividualOrElseGet(Function function, + Supplier defaultValue) { + OWLAnnotationValue value = annotationValue(); + if (value.isAnonymous()) { + return function.apply((OWLAnonymousIndividual) value); + } + return defaultValue.get(); + } + + /** + * @param literalConsumer consumer to run for literals + * @param iriConsumer consumer to run for IRIs + * @param anonConsumer consumer to run for anonymous individuals + */ + default void ifValue(Consumer literalConsumer, Consumer iriConsumer, + Consumer anonConsumer) { + OWLAnnotationValue value = annotationValue(); + if (value.isLiteral()) { + ifLiteral(literalConsumer); + } else if (value.isIRI()) { + ifIri(iriConsumer); + } else { + ifAnonymousIndividual(anonConsumer); + } + } + + /** + * @param literalFunction function to run for literals + * @param iriFunction function to run for IRIs + * @param anonFunction function to run for anonymous individuals + * @param returned type + * @return mapped value, or empty if none matches (currently there will be always one matching + * function, but the creation of a new OWLAnnotationValue subinterface would change + * that) + */ + default Optional mapValue(Function literalFunction, + Function iriFunction, Function anonFunction) { + OWLAnnotationValue value = annotationValue(); + if (value.isLiteral()) { + return mapLiteral(literalFunction); + } else if (value.isIRI()) { + return mapIri(iriFunction); + } else { + return mapAnonymousIndividual(anonFunction); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasAnnotations.java b/api/src/main/java/org/semanticweb/owlapi/model/HasAnnotations.java new file mode 100644 index 0000000000..4643abbbe0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasAnnotations.java @@ -0,0 +1,98 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.empty; + +import java.util.List; +import java.util.Set; +import java.util.function.Predicate; +import java.util.stream.Stream; + +/** + * An interface to an object that has annotation. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +public interface HasAnnotations { + + /** + * @return a sorted stream of OWLAnnotation instances on this object. This will only include the + * annotations contained in this object, not the value of annotation assertion axioms in + * an ontology or in other ontologies. Use the EntitySearcher methods for that purpose. + */ + default Stream annotations() { + return empty(); + } + + /** @return annotation collection s list */ + default List annotationsAsList() { + return asList(annotations()); + } + + /** + * @param p filter predicate for annotations. Can be used to match the annotation property or + * the annotation value + * @return a stream of OWLAnnotation instances on this object, with filter applied. This will + * only include the annotations contained in this object, not the value of annotation + * assertion axioms in an ontology or in other ontologies. Use the EntitySearcher + * methods for that purpose. + */ + default Stream annotations(Predicate p) { + // Default implementation returns a sorted stream already. + return annotations().filter(p).sorted(); + } + + /** + * @param p annotation property to filter on + * @return a stream of OWLAnnotation instances on this object, with filter applied. This will + * only include the annotations contained in this object, not the value of annotation + * assertion axioms in an ontology or in other ontologies. Use the EntitySearcher + * methods for that purpose. + */ + default Stream annotations(OWLAnnotationProperty p) { + // Default implementation returns a sorted stream already. + return annotations().filter(a -> a.getProperty().equals(p)).sorted(); + } + + /** + * Gets the annotations on this object. + * + * @return A set of annotations on this object. For an OWLOntology, these are the ontology + * annotations, not the annotations attached to axioms or annotation axioms contained in + * the ontology. For an OWLAnnotation, these are the annotations on the annotation; the + * annotation itself is not included. The set returned will be a copy - modifying the + * set will have no effect on the annotations in this object, similarly, any changes + * that affect the annotations on this object will not change the returned set. Note: + * for iterating over this set of annotations, using the annotations() stream is more + * efficient. + */ + default Set getAnnotations() { + return asSet(annotations()); + } + + /** + * Gets the annotations whose annotation property is equal to {@code annotationProperty}. + * + * @param annotationProperty The annotation property that will be equal to the annotation + * property of each returned annotation. + * @return A set of annotations whose annotation properties is equals to {@code + * annotationProperty}. + */ + default Set getAnnotations(OWLAnnotationProperty annotationProperty) { + return asSet(annotations(a -> a.getProperty().equals(annotationProperty))); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasAnonymousIndividuals.java b/api/src/main/java/org/semanticweb/owlapi/model/HasAnonymousIndividuals.java new file mode 100644 index 0000000000..234a27ce91 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasAnonymousIndividuals.java @@ -0,0 +1,42 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.empty; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +public interface HasAnonymousIndividuals { + + /** + * @return The anonymous individuals occurring in this object. The set is a copy, changes are + * not reflected back. The default implementation of this method returns a modifiable, + * empty set. + */ + default Set getAnonymousIndividuals() { + return asSet(anonymousIndividuals()); + } + + /** + * @return A stream of anonymous individuals occurring in this object. + */ + default Stream anonymousIndividuals() { + return empty(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasApplyChange.java b/api/src/main/java/org/semanticweb/owlapi/model/HasApplyChange.java new file mode 100644 index 0000000000..0a2188badb --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasApplyChange.java @@ -0,0 +1,46 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.model.parameters.ChangeApplied; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5 + */ +@FunctionalInterface +public interface HasApplyChange { + + /** + * A convenience method that applies just one change to an ontology. When this method is used + * through an {@code OWLOntologyManager} implementation, the instance used should be the one + * that the ontology returns through the {@code getOWLOntologyManager()} call. The reason is + * that some changes, e.g., change of ontology id and change of imports directives, affect data + * that only that manager instance knows about, such as the imports closure; changes of ontology + * id through the wrong manager will make the ontology unreachable through its new id in the + * manager associated with the ontology. Configuration for loading and saving parameters is also + * held by the manager, if not explicitly specified for the ontology. While the change might be + * successful, other bugs might be made apparent later. + * + * @param change The change to be applied + * @return ChangeApplied.SUCCESSFULLY if the change is applied with success, + * ChangeApplied.UNSUCCESSFULLY otherwise. + * @throws OWLOntologyChangeException If the change could not be applied. See subclasses of + * ontology change exception for more specific details. + * @throws OWLOntologyRenameException If one or more of the changes is an instance of + * {@link org.semanticweb.owlapi.model.SetOntologyID} where the new + * {@link org.semanticweb.owlapi.model.OWLOntologyID} already belongs to an ontology + * managed by this manager. + */ + ChangeApplied applyChange(OWLOntologyChange change); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasApplyChanges.java b/api/src/main/java/org/semanticweb/owlapi/model/HasApplyChanges.java new file mode 100644 index 0000000000..3f76c21616 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasApplyChanges.java @@ -0,0 +1,103 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Arrays; +import java.util.List; + +import org.semanticweb.owlapi.model.parameters.ChangeApplied; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5 + */ +public interface HasApplyChanges { + + /** + * Applies a list ontology changes to a collection of ontologies. When this method is used + * through an {@code OWLOntologyManager} implementation, the instance used should be the one + * that the ontology returns through the {@code getOWLOntologyManager()} call. The reason is + * that some changes, e.g., change of ontology id and change of imports directives, affect data + * that only that manager instance knows about, such as the imports closure; changes of ontology + * id through the wrong manager will make the ontology unreachable through its new id in the + * manager associated with the ontology. Configuration for loading and saving parameters is also + * held by the manager, if not explicitly specified for the ontology. While the change might be + * successful, other bugs might be made apparent later. + * + * @param changes The changes to be applied. + * @return ChangeApplied.SUCCESSFULLY if the axiom is added, ChangeApplied.UNSUCCESSFULLY + * otherwise. + * @throws OWLOntologyChangeException If one or more of the changes could not be applied. + */ + default ChangeApplied applyChanges(List changes) { + return applyChangesAndGetDetails(changes).getChangeEffect(); + } + + /** + * Applies a list ontology changes to a collection of ontologies. When this method is used + * through an {@code OWLOntologyManager} implementation, the instance used should be the one + * that the ontology returns through the {@code getOWLOntologyManager()} call. The reason is + * that some changes, e.g., change of ontology id and change of imports directives, affect data + * that only that manager instance knows about, such as the imports closure; changes of ontology + * id through the wrong manager will make the ontology unreachable through its new id in the + * manager associated with the ontology. Configuration for loading and saving parameters is also + * held by the manager, if not explicitly specified for the ontology. While the change might be + * successful, other bugs might be made apparent later. + * + * @param changes The changes to be applied. + * @return ChangeApplied.SUCCESSFULLY if the axiom is added, ChangeApplied.UNSUCCESSFULLY + * otherwise. + * @throws OWLOntologyChangeException If one or more of the changes could not be applied. + */ + default ChangeApplied applyChanges(OWLOntologyChange... changes) { + return applyChanges(Arrays.asList(changes)); + } + + /** + * Applies a list ontology changes to a collection of ontologies. When this method is used + * through an {@code OWLOntologyManager} implementation, the instance used should be the one + * that the ontology returns through the {@code getOWLOntologyManager()} call. The reason is + * that some changes, e.g., change of ontology id and change of imports directives, affect data + * that only that manager instance knows about, such as the imports closure; changes of ontology + * id through the wrong manager will make the ontology unreachable through its new id in the + * manager associated with the ontology. Configuration for loading and saving parameters is also + * held by the manager, if not explicitly specified for the ontology. While the change might be + * successful, other bugs might be made apparent later. + * + * @param changes The changes to be applied. + * @return ChangeApplied.SUCCESSFULLY if the axiom is added, ChangeApplied.UNSUCCESSFULLY + * otherwise. + * @throws OWLOntologyChangeException If one or more of the changes could not be applied. + */ + ChangeDetails applyChangesAndGetDetails(List changes); + + /** + * Applies a list ontology changes to a collection of ontologies. When this method is used + * through an {@code OWLOntologyManager} implementation, the instance used should be the one + * that the ontology returns through the {@code getOWLOntologyManager()} call. The reason is + * that some changes, e.g., change of ontology id and change of imports directives, affect data + * that only that manager instance knows about, such as the imports closure; changes of ontology + * id through the wrong manager will make the ontology unreachable through its new id in the + * manager associated with the ontology. Configuration for loading and saving parameters is also + * held by the manager, if not explicitly specified for the ontology. While the change might be + * successful, other bugs might be made apparent later. + * + * @param changes The changes to be applied. + * @return ChangeApplied.SUCCESSFULLY if the axiom is added, ChangeApplied.UNSUCCESSFULLY + * otherwise. + * @throws OWLOntologyChangeException If one or more of the changes could not be applied. + */ + default ChangeDetails applyChangesAndGetDetails(OWLOntologyChange... changes) { + return applyChangesAndGetDetails(Arrays.asList(changes)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasApplyDirectChange.java b/api/src/main/java/org/semanticweb/owlapi/model/HasApplyDirectChange.java new file mode 100644 index 0000000000..605dc4e754 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasApplyDirectChange.java @@ -0,0 +1,41 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.model.parameters.ChangeApplied; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5 + */ +@FunctionalInterface +public interface HasApplyDirectChange { + + /** + * A convenience method that applies just one change to this ontology. Note: + * ontology ID changes should not be passed directly to this method but + * applied through OWLOntologyManager. This is because the manager needs to + * update its internal structures for id changes. + * + * @param change The change to be applied + * @return ChangeApplied.SUCCESSFULLY if the change is applied with success, + * ChangeApplied.UNSUCCESSFULLY otherwise. + * @throws OWLOntologyChangeException If the change could not be applied. See subclasses of + * ontology change exception for more specific details. + * @throws OWLOntologyRenameException If one or more of the changes is an instance of {@link + * org.semanticweb.owlapi.model.SetOntologyID} where the new {@link + * org.semanticweb.owlapi.model.OWLOntologyID} already belongs to an ontology managed by this + * manager. + */ + ChangeApplied applyDirectChange(OWLOntologyChange change); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasAxioms.java b/api/src/main/java/org/semanticweb/owlapi/model/HasAxioms.java new file mode 100644 index 0000000000..d02c0000a2 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasAxioms.java @@ -0,0 +1,43 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * An interface to an object that contains axioms. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +@FunctionalInterface +public interface HasAxioms { + + /** + * Gets the {@link OWLAxiom}s contained in this object. + * + * @return The set of {@link OWLAxiom}s contained in this object. The set is a copy, changes are + * not reflected back. + */ + default Set getAxioms() { + return asSet(axioms()); + } + + /** + * @return Stream of {@link OWLAxiom}s contained in this object. + */ + Stream axioms(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasAxiomsByType.java b/api/src/main/java/org/semanticweb/owlapi/model/HasAxiomsByType.java new file mode 100644 index 0000000000..604d1b29bc --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasAxiomsByType.java @@ -0,0 +1,66 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static java.util.stream.Collectors.toSet; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * An interface to an object that contains axioms and can provide subsets of these axioms by the + * type of axiom. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +@FunctionalInterface +public interface HasAxiomsByType { + + /** + * Compare the axioms inside this object with the axioms inside the other object, shortcutting + * by type; it will not merge all axioms in a large lump for comparisons only + * + * @param o other object to compare + * @return true if the two objects contain the same axioms + */ + default boolean equalAxioms(HasAxiomsByType o) { + // using collect(toSet()) to avoid ordering issues and avoid + // LinkedHashSet cost + return AxiomType.AXIOM_TYPES.stream() + .allMatch(t -> axioms(t).collect(toSet()).equals(o.axioms(t).collect(toSet()))); + } + + /** + * Gets the axioms which are of the specified type. + * + * @param axiomType The type of axioms to be retrieved. + * @param axiom type + * @return A set containing the axioms which are of the specified type. The set that is returned + * is a copy of the axioms in this object. Modifications to the returned set will not be + * reflected in this object. + */ + default Set getAxioms(AxiomType axiomType) { + return asSet(axioms(axiomType)); + } + + /** + * Gets the axioms which are of the specified type. + * + * @param axiomType The type of axioms to be retrieved. + * @param axiom type + * @return Stream of axioms of the specified type. + */ + Stream axioms(AxiomType axiomType); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasCardinality.java b/api/src/main/java/org/semanticweb/owlapi/model/HasCardinality.java new file mode 100644 index 0000000000..7c445595c3 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasCardinality.java @@ -0,0 +1,30 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface to objects that have a cardinality. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5.0 + */ +@FunctionalInterface +public interface HasCardinality { + + /** + * Gets the cardinality of a restriction. + * + * @return The cardinality. A non-negative integer. + */ + int getCardinality(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasClassesInSignature.java b/api/src/main/java/org/semanticweb/owlapi/model/HasClassesInSignature.java new file mode 100644 index 0000000000..707551ccc6 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasClassesInSignature.java @@ -0,0 +1,47 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.empty; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * An interface to an object that has a signature and can provide the classes that are contained in + * its signature. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +public interface HasClassesInSignature { + + /** + * Gets the classes in the signature of this object. + * + * @return A set containing the classes that are in the signature of this object. The set is a + * subset of the signature, and is not backed by the signature; it is a modifiable + * collection and changes are not reflected by the signature. + */ + default Set getClassesInSignature() { + return asSet(classesInSignature()); + } + + /** + * @return Stream of classes in the signature of this object. + */ + default Stream classesInSignature() { + return empty(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasComponents.java b/api/src/main/java/org/semanticweb/owlapi/model/HasComponents.java new file mode 100644 index 0000000000..2c2e5aea24 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasComponents.java @@ -0,0 +1,40 @@ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * An interface for objects that have a set of components - this is useful for + * all those situations where a generic action has to be performed on all + * components of an object, such as hashcode and equals computations, or + * rendering in a syntax. + */ +public interface HasComponents { + + /** + * @return components as a stream. + * The stream is ordered (by visit order) but not sorted. Implementations that override + * components() must ensure the order is compatible with equals() and hashCode(). + */ + Stream components(); + + /** + * @return components as a stream; for objects that can have annotations on them, annotation + * streams appear first. This is useful in renderers. + * The stream is ordered (by visit order) but not sorted. Implementations that override + * components() must ensure the order is compatible with equals() and hashCode(). + */ + default Stream componentsAnnotationsFirst() { + return components(); + } + + /** + * @return components as a stream; for objects that can have annotations on them, these are + * skipped. This is useful for comparing axioms without taking annotations into account. Note: + * annotations on nested objects are not affected. + * The stream is ordered (by visit order) but not sorted. Implementations that override + * components() must ensure the order is compatible with equals() and hashCode(). + */ + default Stream componentsWithoutAnnotations() { + return components(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasContainsAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/HasContainsAxiom.java new file mode 100644 index 0000000000..fbcd344ff8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasContainsAxiom.java @@ -0,0 +1,32 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface to an object that contains axioms. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +@FunctionalInterface +public interface HasContainsAxiom { + + /** + * Determines whether or not this object contains a particular + * {@link OWLAxiom}. + * + * @param axiom The {@link OWLAxiom} to test for. + * @return {@code true} if this object contains {@code axiom}, otherwise {@code false}. + */ + boolean containsAxiom(OWLAxiom axiom); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasContainsEntityInSignature.java b/api/src/main/java/org/semanticweb/owlapi/model/HasContainsEntityInSignature.java new file mode 100644 index 0000000000..f9e9bf9796 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasContainsEntityInSignature.java @@ -0,0 +1,33 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface to an object that has a signature. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +public interface HasContainsEntityInSignature { + + /** + * Determines if the signature of this object contains the specified entity. + * + * @param owlEntity The entity + * @return {@code true} if the signature of this object contains {@code owlEntity}, otherwise + * {@code false} + */ + default boolean containsEntityInSignature(@SuppressWarnings("unused") OWLEntity owlEntity) { + return false; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasContainsOntology.java b/api/src/main/java/org/semanticweb/owlapi/model/HasContainsOntology.java new file mode 100644 index 0000000000..403e740e6a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasContainsOntology.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5 + */ +@FunctionalInterface +public interface HasContainsOntology { + + /** + * Determines if this object contains an ontology that has the specified + * {@link org.semanticweb.owlapi.model.OWLOntologyID}. + * + * @param id The {@link OWLOntologyID} to test for. + * @return {@code true} if this object contains an ontology that has the specified Id, + * otherwise, {@code false}. + */ + boolean contains(OWLOntologyID id); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasDataFactory.java b/api/src/main/java/org/semanticweb/owlapi/model/HasDataFactory.java new file mode 100644 index 0000000000..2111cf2116 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasDataFactory.java @@ -0,0 +1,29 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5 + */ +@FunctionalInterface +public interface HasDataFactory { + + /** + * Gets a data factory which can be used to create OWL API objects such as + * classes, properties, individuals, axioms etc. + * + * @return A reference to a data factory for creating OWL API objects. + */ + OWLDataFactory getOWLDataFactory(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasDataPropertiesInSignature.java b/api/src/main/java/org/semanticweb/owlapi/model/HasDataPropertiesInSignature.java new file mode 100644 index 0000000000..6f195a9acc --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasDataPropertiesInSignature.java @@ -0,0 +1,45 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.empty; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +public interface HasDataPropertiesInSignature { + + /** + * Get the data properties that are in the signature of this object. The default implementation + * of this method returns an empty, modifiable set. + * + * @return A set containing the data properties that are in the signature of this object. The + * set is a subset of the signature, and is not backed by the signature; it is a + * modifiable collection and changes are not reflected by the signature. + */ + default Set getDataPropertiesInSignature() { + return asSet(dataPropertiesInSignature()); + } + + /** + * @return Stream of data properties that are in the signature of this object. + */ + default Stream dataPropertiesInSignature() { + return empty(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasDatatypesInSignature.java b/api/src/main/java/org/semanticweb/owlapi/model/HasDatatypesInSignature.java new file mode 100644 index 0000000000..126fb572e3 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasDatatypesInSignature.java @@ -0,0 +1,44 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.empty; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +public interface HasDatatypesInSignature { + + /** + * Gets the datatypes that are in the signature of this object. + * + * @return A set containing the datatypes that are in the signature of this object. The set is a + * subset of the signature, and is not backed by the signature; it is a modifiable + * collection and changes are not reflected by the signature. + */ + default Set getDatatypesInSignature() { + return asSet(datatypesInSignature()); + } + + /** + * @return A stream of the datatypes that are in the signature of this object. + */ + default Stream datatypesInSignature() { + return empty(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasDirectAddAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/HasDirectAddAxiom.java new file mode 100644 index 0000000000..1ad5d2a323 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasDirectAddAxiom.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.model.parameters.ChangeApplied; + +/** + * Interface for an object that accepts axiom additions (typically, an OWLOntology). + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 4.0.0 + */ +@FunctionalInterface +public interface HasDirectAddAxiom { + + /** + * A convenience method that adds a single axiom to an ontology. The appropriate AddAxiom change + * object is automatically generated. + * + * @param axiom The axiom to be added + * @return ChangeApplied.SUCCESSFULLY if the axiom is added, ChangeApplied.UNSUCCESSFULLY + * otherwise. + * @throws OWLOntologyChangeException if there was a problem adding the axiom + */ + ChangeApplied addAxiom(OWLAxiom axiom); + + /** + * A convenience method that adds a single axiom to an ontology. The appropriate AddAxiom change + * object is automatically generated. + * + * @param axiom The axiom to be added + * @return ChangeApplied.SUCCESSFULLY if the axiom is added, ChangeApplied.UNSUCCESSFULLY + * otherwise. + * @throws OWLOntologyChangeException if there was a problem adding the axiom + */ + default ChangeApplied add(OWLAxiom axiom) { + return addAxiom(axiom); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasDirectAddAxioms.java b/api/src/main/java/org/semanticweb/owlapi/model/HasDirectAddAxioms.java new file mode 100644 index 0000000000..19e9018df7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasDirectAddAxioms.java @@ -0,0 +1,81 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Collection; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.parameters.ChangeApplied; + +/** + * Interface for an object that accepts axiom additions (typically, an OWLOntology). + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5 + */ +public interface HasDirectAddAxioms { + + /** + * A convenience method that adds a set of axioms to an ontology. The appropriate AddAxiom + * change objects are automatically generated. + * + * @param axioms The axioms to be added. Not {@code null}. + * @return ChangeApplied.SUCCESSFULLY if the axiom is added, ChangeApplied.UNSUCCESSFULLY + * otherwise. + */ + ChangeApplied addAxioms(Collection axioms); + + /** + * A convenience method that adds a set of axioms to an ontology. The appropriate AddAxiom + * change objects are automatically generated. + * + * @param axioms The axioms to be added. Not {@code null}. + * @return ChangeApplied.SUCCESSFULLY if the axiom is added, ChangeApplied.UNSUCCESSFULLY + * otherwise. + */ + ChangeApplied addAxioms(OWLAxiom... axioms); + + /** + * A convenience method that adds a set of axioms to an ontology. The appropriate AddAxiom + * change objects are automatically generated. + * + * @param axioms The axioms to be added. Not {@code null}. + * @return ChangeApplied.SUCCESSFULLY if the axiom is added, ChangeApplied.UNSUCCESSFULLY + * otherwise. + */ + default ChangeApplied add(Collection axioms) { + return addAxioms(axioms); + } + + /** + * A convenience method that adds a set of axioms to an ontology. The appropriate AddAxiom + * change objects are automatically generated. + * + * @param axioms The axioms to be added. Not {@code null}. + * @return ChangeApplied.SUCCESSFULLY if the axiom is added, ChangeApplied.UNSUCCESSFULLY + * otherwise. + */ + ChangeApplied addAxioms(Stream axioms); + + /** + * A convenience method that adds a set of axioms to an ontology. The appropriate AddAxiom + * change objects are automatically generated. + * + * @param axioms The axioms to be added. Not {@code null}. + * @return ChangeApplied.SUCCESSFULLY if the axiom is added, ChangeApplied.UNSUCCESSFULLY + * otherwise. + */ + default ChangeApplied add(OWLAxiom... axioms) { + return addAxioms(axioms); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasDirectImports.java b/api/src/main/java/org/semanticweb/owlapi/model/HasDirectImports.java new file mode 100644 index 0000000000..3366a374a1 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasDirectImports.java @@ -0,0 +1,87 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * An interface to objects that have a direct set of imports. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5.0 + */ +public interface HasDirectImports { + + /** + * Gets the set of document IRIs that are directly imported by this ontology. This corresponds + * to the IRIs defined by the directlyImportsDocument association as discussed in Section 3.4 of + * the OWL 2 Structural specification. + * + * @return The set of directly imported document IRIs. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + * @throws UnknownOWLOntologyException If this ontology is no longer managed by its manager + * because it was removed from the manager. + */ + default Set getDirectImportsDocuments() { + return asSet(directImportsDocuments()); + } + + /** + * The stream of document IRIs that are directly imported by this ontology. This corresponds to + * the IRIs defined by the directlyImportsDocument association as discussed in Section 3.4 of + * the OWL 2 Structural specification. + * + * @return The stream of directly imported document IRIs. + * @throws UnknownOWLOntologyException If this ontology is no longer managed by its manager + * because it was removed from the manager. + */ + Stream directImportsDocuments(); + + /** + * Gets the set of loaded ontologies that this ontology is related to via the + * directlyImports relation. See Section 3.4 of the OWL 2 specification for the definition of + * the directlyImports relation.
+ * Note that there may be fewer ontologies in the set returned by this method than there are + * IRIs in the set returned by the {@link #getDirectImportsDocuments()} method. This will be the + * case if some of the ontologies that are directly imported by this ontology are not loaded for + * what ever reason. + * + * @return A set of ontologies such that for this ontology O, and each ontology O' in the set, + * (O, O') is in the directlyImports relation. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + * @throws UnknownOWLOntologyException If this ontology is no longer managed by its manager + * because it was removed from the manager. + */ + default Set getDirectImports() { + return asSet(directImports()); + } + + /** + * Stream of loaded ontologies that this ontology is related to via the directlyImports + * relation. See Section 3.4 of the OWL 2 specification for the definition of the + * directlyImports relation.
+ * Note that there may be fewer ontologies in the set returned by this method than there are + * IRIs in the set returned by the {@link #getDirectImportsDocuments()} method. This will be the + * case if some of the ontologies that are directly imported by this ontology are not loaded for + * what ever reason. + * + * @return Stream of ontologies such that for this ontology O, and each ontology O' in the set, + * (O, O') is in the directlyImports relation. + * @throws UnknownOWLOntologyException If this ontology is no longer managed by its manager + * because it was removed from the manager. + */ + Stream directImports(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasDirectRemoveAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/HasDirectRemoveAxiom.java new file mode 100644 index 0000000000..b2ef5bf271 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasDirectRemoveAxiom.java @@ -0,0 +1,45 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.model.parameters.ChangeApplied; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5 + */ +@FunctionalInterface +public interface HasDirectRemoveAxiom { + + /** + * A convenience method that removes a single axiom from this object. The + * appropriate RemoveAxiom change object is automatically generated. + * + * @param axiom The axiom to be removed + * @return A list of ontology changes that represent the changes that actually took place. + * @throws OWLOntologyChangeException if there was a problem removing the axiom + */ + ChangeApplied removeAxiom(OWLAxiom axiom); + + /** + * A convenience method that removes a single axiom from this object. The + * appropriate RemoveAxiom change object is automatically generated. + * + * @param axiom The axiom to be removed + * @return A list of ontology changes that represent the changes that actually took place. + * @throws OWLOntologyChangeException if there was a problem removing the axiom + */ + default ChangeApplied remove(OWLAxiom axiom) { + return removeAxiom(axiom); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasDirectRemoveAxioms.java b/api/src/main/java/org/semanticweb/owlapi/model/HasDirectRemoveAxioms.java new file mode 100644 index 0000000000..d62b3f967c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasDirectRemoveAxioms.java @@ -0,0 +1,96 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Collection; +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.parameters.ChangeApplied; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5 + */ +public interface HasDirectRemoveAxioms { + + /** + * A convenience method that removes a set of axioms from this object. The + * appropriate RemoveAxiom change objects are automatically generated. + * + * @param axioms The axioms to be removed. + * @return A list of ontology changes that represent the changes which took place in order to + * remove the axioms. + * @throws OWLOntologyChangeException if there was a problem removing the axioms + */ + ChangeApplied removeAxioms(Collection axioms); + + /** + * A convenience method that removes a set of axioms from this object. The + * appropriate RemoveAxiom change objects are automatically generated. + * + * @param axioms The axioms to be removed. + * @return A list of ontology changes that represent the changes which took place in order to + * remove the axioms. + * @throws OWLOntologyChangeException if there was a problem removing the axioms + */ + ChangeApplied removeAxioms(Stream axioms); + + /** + * A convenience method that removes a set of axioms from this object. The + * appropriate RemoveAxiom change objects are automatically generated. + * + * @param axioms The axioms to be removed. + * @return A list of ontology changes that represent the changes which took place in order to + * remove the axioms. + * @throws OWLOntologyChangeException if there was a problem removing the axioms + */ + ChangeApplied removeAxioms(OWLAxiom... axioms); + + /** + * A convenience method that removes a set of axioms from this object. The + * appropriate RemoveAxiom change objects are automatically generated. + * + * @param axioms The axioms to be removed. + * @return A list of ontology changes that represent the changes which took place in order to + * remove the axioms. + * @throws OWLOntologyChangeException if there was a problem removing the axioms + */ + default ChangeApplied remove(Collection axioms) { + return removeAxioms(axioms); + } + + /** + * A convenience method that removes a set of axioms from this object. The + * appropriate RemoveAxiom change objects are automatically generated. + * + * @param axioms The axioms to be removed. + * @return A list of ontology changes that represent the changes which took place in order to + * remove the axioms. + * @throws OWLOntologyChangeException if there was a problem removing the axioms + */ + default ChangeApplied remove(Stream axioms) { + return removeAxioms(axioms); + } + + /** + * A convenience method that removes a set of axioms from this object. The + * appropriate RemoveAxiom change objects are automatically generated. + * + * @param axioms The axioms to be removed. + * @return A list of ontology changes that represent the changes which took place in order to + * remove the axioms. + * @throws OWLOntologyChangeException if there was a problem removing the axioms + */ + default ChangeApplied remove(OWLAxiom... axioms) { + return removeAxioms(axioms); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasDomain.java b/api/src/main/java/org/semanticweb/owlapi/model/HasDomain.java new file mode 100644 index 0000000000..257d827a8a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasDomain.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface to objects that have a domain. + * + * @param domain type + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5.0 + */ +@FunctionalInterface +public interface HasDomain { + + /** + * Gets the domain. + * + * @return The domain. + */ + D getDomain(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasFiller.java b/api/src/main/java/org/semanticweb/owlapi/model/HasFiller.java new file mode 100644 index 0000000000..f4be202267 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasFiller.java @@ -0,0 +1,34 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface to objects that have a filler. + * + * @param filler type + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +@FunctionalInterface +public interface HasFiller { + + /** + * Gets the filler for this restriction. In the case of an object + * restriction this will be an individual, in the case of a data restriction + * this will be a constant (data value). For quantified restriction this + * will be a class expression or a data range. + * + * @return the value + */ + T getFiller(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasGetEntitiesInSignature.java b/api/src/main/java/org/semanticweb/owlapi/model/HasGetEntitiesInSignature.java new file mode 100644 index 0000000000..804da3fe5f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasGetEntitiesInSignature.java @@ -0,0 +1,41 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5.0 + */ +@FunctionalInterface +public interface HasGetEntitiesInSignature { + + /** + * @param entityIRI IRI for all entities to retrieve + * @return entities with IRI equal to entity IRI. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + */ + default Set getEntitiesInSignature(IRI entityIRI) { + return asSet(entitiesInSignature(entityIRI)); + } + + /** + * @param entityIRI IRI for all entities to retrieve + * @return stream of entities with IRI equal to entity IRI + */ + Stream entitiesInSignature(IRI entityIRI); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasGetOntologies.java b/api/src/main/java/org/semanticweb/owlapi/model/HasGetOntologies.java new file mode 100644 index 0000000000..38585f9864 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasGetOntologies.java @@ -0,0 +1,39 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5 + */ +@FunctionalInterface +public interface HasGetOntologies { + + /** + * @return The set of ontologies contained within this object. The set that is returned is a + * copy; modifications to the returned set will not be reflected in this object. + */ + default Set getOntologies() { + return asSet(ontologies()); + } + + /** + * @return stream of ontologies contained within this object + */ + Stream ontologies(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasGetOntologyById.java b/api/src/main/java/org/semanticweb/owlapi/model/HasGetOntologyById.java new file mode 100644 index 0000000000..449e6fcde7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasGetOntologyById.java @@ -0,0 +1,34 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import javax.annotation.Nullable; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5 + */ +@FunctionalInterface +public interface HasGetOntologyById { + + /** + * Get a previously loaded/created ontology that has the specified ontology ID. For anonymous + * ids, this method tries to locate the ontology by document IRI. + * + * @param ontologyID The ID of the ontology to retrieve. + * @return The ontology with the specified ID, or {@code null} if there is no ontology with the + * specified ID. + */ + @Nullable + OWLOntology getOntology(OWLOntologyID ontologyID); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasHashIndex.java b/api/src/main/java/org/semanticweb/owlapi/model/HasHashIndex.java new file mode 100644 index 0000000000..88ab647384 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasHashIndex.java @@ -0,0 +1,18 @@ +package org.semanticweb.owlapi.model; + +/** + * Interface for types with a hash index; this is used to seed the hashcode + * computation for instances, so that the hashcodes of objects with different + * types are /more/ different than the hashcodes of objects with the same type. + * One application is ensuring that punned entities do not have clashing + * hashcodes. + */ +@FunctionalInterface +public interface HasHashIndex { + + /** + * @return index for this type. This is not a hashcode for instances, rather a hashcode for the + * types. + */ + int hashIndex(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasIRI.java b/api/src/main/java/org/semanticweb/owlapi/model/HasIRI.java new file mode 100644 index 0000000000..01629f5c51 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasIRI.java @@ -0,0 +1,28 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +@FunctionalInterface +public interface HasIRI { + + /** + * Gets the IRI of this object. + * + * @return The IRI of this object + */ + IRI getIRI(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasImportsClosure.java b/api/src/main/java/org/semanticweb/owlapi/model/HasImportsClosure.java new file mode 100644 index 0000000000..f0a8b08d94 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasImportsClosure.java @@ -0,0 +1,53 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * An interface to objects that provide an imports closure of themselves. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5.0 + */ +@FunctionalInterface +public interface HasImportsClosure { + + /** + * Gets the set of loaded ontologies that this ontology is related to via the + * reflexive transitive closure of the directlyImports relation as defined in Section + * 3.4 of the OWL 2 Structural Specification. For example, if this ontology imports ontology B, + * and ontology B imports ontology C, then this method will return the set consisting of this + * ontology, ontology B and ontology C. + * + * @return The set of ontologies in the reflexive transitive closure of the directlyImports + * relation. The set that is returned is a copy; modifications to the returned set will + * not be reflected in this object. + * @throws UnknownOWLOntologyException If this ontology is no longer managed by its manager + * because it was removed from the manager. + */ + default Set getImportsClosure() { + return asSet(importsClosure()); + } + + /** + * Gets the imports closure, including the root object. + * + * @return Stream of ontologies representing the imports closure of this object (includes this + * object). + */ + Stream importsClosure(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasIndex.java b/api/src/main/java/org/semanticweb/owlapi/model/HasIndex.java new file mode 100644 index 0000000000..c95d78cba4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasIndex.java @@ -0,0 +1,15 @@ +package org.semanticweb.owlapi.model; + +/** + * Interface for types with an index; this is used to group objects by type when + * sorting. + */ +@FunctionalInterface +public interface HasIndex { + + /** + * @return index for this type. This is not a hashcode for instances, rather a sorting index for + * the types. + */ + int typeIndex(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasIndividualsInSignature.java b/api/src/main/java/org/semanticweb/owlapi/model/HasIndividualsInSignature.java new file mode 100644 index 0000000000..bc45e606f1 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasIndividualsInSignature.java @@ -0,0 +1,45 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.empty; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +public interface HasIndividualsInSignature { + + /** + * A convenience method that obtains the individuals that are in the signature of this object. + * The default implementation of this method returns an empty, modifiable set. + * + * @return A set containing the individuals that are in the signature of this object. The set is + * a subset of the signature, and is not backed by the signature; it is a modifiable + * collection and changes are not reflected by the signature. + */ + default Set getIndividualsInSignature() { + return asSet(individualsInSignature()); + } + + /** + * @return Stream containing the individuals that are in the signature of this object. + */ + default Stream individualsInSignature() { + return empty(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasLang.java b/api/src/main/java/org/semanticweb/owlapi/model/HasLang.java new file mode 100644 index 0000000000..69bd23f327 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasLang.java @@ -0,0 +1,30 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group Date: + * 18/02/2014 + */ +@FunctionalInterface +public interface HasLang { + + /** + * Gets the language tag of the literal. + * + * @return A string representing the language tag of a literal. If the literal does not have a + * language tag, because it is not of the type {@code rdf:PlainLiteral}, or because its language + * tag is empty, then the empty string will be returned. + */ + String getLang(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasLogicalAxioms.java b/api/src/main/java/org/semanticweb/owlapi/model/HasLogicalAxioms.java new file mode 100644 index 0000000000..590fc5da10 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasLogicalAxioms.java @@ -0,0 +1,44 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * An interface to an object that contains a set of logical axioms. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +@FunctionalInterface +public interface HasLogicalAxioms { + + /** + * Gets the set of {@link OWLLogicalAxiom}s contained within this object. + * + * @return A set of {@link OWLLogicalAxiom}s that are contained within this object. The set that + * is returned is a copy; modifications to the returned set will not be reflected in + * this object. + */ + default Set getLogicalAxioms() { + return asSet(logicalAxioms()); + } + + /** + * @return Stream of {@link OWLLogicalAxiom}s that are contained within this object. + */ + Stream logicalAxioms(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasObject.java b/api/src/main/java/org/semanticweb/owlapi/model/HasObject.java new file mode 100644 index 0000000000..9d3369c082 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasObject.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface to objects that have objects (e.g. property assertion axioms). + * + * @param object type + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5.0 + */ +@FunctionalInterface +public interface HasObject { + + /** + * Gets the object. + * + * @return The object. + */ + O getObject(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasObjectPropertiesInSignature.java b/api/src/main/java/org/semanticweb/owlapi/model/HasObjectPropertiesInSignature.java new file mode 100644 index 0000000000..b608923220 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasObjectPropertiesInSignature.java @@ -0,0 +1,48 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.empty; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * An interface to an object that has a signature and can provide the object properties that are + * contained in its signature. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +public interface HasObjectPropertiesInSignature { + + /** + * A convenience method that obtains the object properties that are in the signature of this + * object. The default implementation of this method returns an empty, modifiable set. + * + * @return A set containing the object properties that are in the signature of this object. The + * set is a subset of the signature, and is not backed by the signature; it is a + * modifiable collection and changes are not reflected by the signature. + */ + default Set getObjectPropertiesInSignature() { + return asSet(objectPropertiesInSignature()); + } + + /** + * @return Stream of object properties that are in the signature of this object. + */ + default Stream objectPropertiesInSignature() { + return empty(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasOntologyChangeListeners.java b/api/src/main/java/org/semanticweb/owlapi/model/HasOntologyChangeListeners.java new file mode 100644 index 0000000000..474ea4087b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasOntologyChangeListeners.java @@ -0,0 +1,37 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 4.0.0 + */ +public interface HasOntologyChangeListeners { + + /** + * Removes a previously added listener. + * + * @param listener The listener to be removed. + */ + void removeOntologyChangeListener(OWLOntologyChangeListener listener); + + /** + * Adds an ontology change listener, which listens to all changes for all + * ontologies. To customise the changes/ontologies that are listened to, the + * {@code addOntologyChangeListener} method which takes a broadcast strategy + * as an argument should be used. + * + * @param listener The listener to be added. + */ + void addOntologyChangeListener(OWLOntologyChangeListener listener); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasOntologyConfigurator.java b/api/src/main/java/org/semanticweb/owlapi/model/HasOntologyConfigurator.java new file mode 100644 index 0000000000..11d87ef291 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasOntologyConfigurator.java @@ -0,0 +1,32 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface for objects that allow a loader configuration provider to be + * set. + * + * @since 4.0.0 + */ +public interface HasOntologyConfigurator { + + /** + * @return the configurator. + */ + OntologyConfigurator getOntologyConfigurator(); + + /** + * @param configurator the configurator. + */ + void setOntologyConfigurator(OntologyConfigurator configurator); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasOntologyID.java b/api/src/main/java/org/semanticweb/owlapi/model/HasOntologyID.java new file mode 100644 index 0000000000..1e3987de5e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasOntologyID.java @@ -0,0 +1,30 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface to objects that have an {@link OWLOntologyID}. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +@FunctionalInterface +public interface HasOntologyID { + + /** + * Gets the {@link OWLOntologyID} belonging to this object. + * + * @return The {@link OWLOntologyID} + */ + OWLOntologyID getOntologyID(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasOntologyLoaderConfiguration.java b/api/src/main/java/org/semanticweb/owlapi/model/HasOntologyLoaderConfiguration.java new file mode 100644 index 0000000000..766b07a738 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasOntologyLoaderConfiguration.java @@ -0,0 +1,35 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface for objects that allow a loader configuration to be set. + * + * @since 4.0.0 + */ +public interface HasOntologyLoaderConfiguration { + + /** + * @return the configuration for this object. This is a read only accessor, since the + * configuration is an immutable object. To change the configuration, use the setter in this + * interface to set a modified configuration. + */ + OWLOntologyLoaderConfiguration getOntologyLoaderConfiguration(); + + /** + * Sets the configuration. + * + * @param config configuration to be used + */ + void setOntologyLoaderConfiguration(OWLOntologyLoaderConfiguration config); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasOntologyWriterConfiguration.java b/api/src/main/java/org/semanticweb/owlapi/model/HasOntologyWriterConfiguration.java new file mode 100644 index 0000000000..22c4dfe3bd --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasOntologyWriterConfiguration.java @@ -0,0 +1,35 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface for objects that allow a writer configuration to be set. + * + * @since 5.0.0 + */ +public interface HasOntologyWriterConfiguration { + + /** + * @return the configuration for this object. This is a read only accessor, since the + * configuration is an immutable object. To change the configuration, use the setter in this + * interface to set a modified configuration. + */ + OWLOntologyWriterConfiguration getOntologyWriterConfiguration(); + + /** + * Sets the configuration. + * + * @param config configuration to be used + */ + void setOntologyWriterConfiguration(OWLOntologyWriterConfiguration config); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasOperands.java b/api/src/main/java/org/semanticweb/owlapi/model/HasOperands.java new file mode 100644 index 0000000000..851c4ba218 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasOperands.java @@ -0,0 +1,46 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.List; +import java.util.stream.Stream; + +/** + * An interface to objects that have a collection of operands. + * + * @param operand type + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 5.0.0 + */ +@FunctionalInterface +public interface HasOperands { + + /** + * Gets the operands - e.g., the individuals in a sameAs axiom, or the classes in an equivalent + * classes axiom. + * + * @return The operands. + */ + Stream operands(); + + /** + * Gets the operands as a list. + * + * @return The operands. + */ + default List getOperandsAsList() { + return asList(operands()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasPrefixedName.java b/api/src/main/java/org/semanticweb/owlapi/model/HasPrefixedName.java new file mode 100644 index 0000000000..80e41488e8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasPrefixedName.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group, Date: + * 18/02/2014

An interface to objects that have a prefixed name (a name composing of a + * prefix name e.g. "owl:" plus a local name e.g. "Thing").

+ * @since 3.5 + */ +@FunctionalInterface +public interface HasPrefixedName { + + /** + * Gets the prefixed name. + * + * @return The prefixed name. + * @since 3.5 + */ + String getPrefixedName(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasProperty.java b/api/src/main/java/org/semanticweb/owlapi/model/HasProperty.java new file mode 100644 index 0000000000..65c55d5b24 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasProperty.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface to objects which have a property. + * + * @param

property type + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5.0 + */ +@FunctionalInterface +public interface HasProperty

{ + + /** + * Gets the property. + * + * @return The property. + */ + P getProperty(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasRange.java b/api/src/main/java/org/semanticweb/owlapi/model/HasRange.java new file mode 100644 index 0000000000..fd7e01e63f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasRange.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface to objects that have a range. + * + * @param range type + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5.0 + */ +@FunctionalInterface +public interface HasRange { + + /** + * Gets the range. + * + * @return The range. + */ + R getRange(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasRemoveAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/HasRemoveAxiom.java new file mode 100644 index 0000000000..96e0f54cb4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasRemoveAxiom.java @@ -0,0 +1,37 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.model.parameters.ChangeApplied; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5 + */ +@FunctionalInterface +public interface HasRemoveAxiom { + + /** + * A convenience method that removes a single axiom from an ontology. The + * appropriate RemoveAxiom change object is automatically generated. + * + * @param ont The ontology to remove the axiom from. + * @param axiom The axiom to be removed + * @return ChangeApplied.SUCCESSFULLY if the axiom is added, ChangeApplied.UNSUCCESSFULLY + * otherwise. + * @throws OWLOntologyChangeException if there was a problem removing the axiom + * @deprecated use {@link OWLOntology#removeAxiom(OWLAxiom)} + */ + @Deprecated + ChangeApplied removeAxiom(OWLOntology ont, OWLAxiom axiom); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasRemoveAxioms.java b/api/src/main/java/org/semanticweb/owlapi/model/HasRemoveAxioms.java new file mode 100644 index 0000000000..44111ccc1c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasRemoveAxioms.java @@ -0,0 +1,52 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Collection; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.parameters.ChangeApplied; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5 + */ +@FunctionalInterface +public interface HasRemoveAxioms { + + /** + * A convenience method that removes a set of axioms from an ontology. The appropriate + * RemoveAxiom change objects are automatically generated. + * + * @param ont The ontology from which the axioms should be removed. + * @param axioms The axioms to be removed. + * @return ChangeApplied.SUCCESSFULLY if the axiom is added, ChangeApplied.UNSUCCESSFULLY + * otherwise. + * @throws OWLOntologyChangeException if there was a problem removing the axioms + */ + default ChangeApplied removeAxioms(OWLOntology ont, Collection axioms) { + return removeAxioms(ont, axioms.stream()); + } + + /** + * A convenience method that removes a set of axioms from an ontology. The appropriate + * RemoveAxiom change objects are automatically generated. + * + * @param ont The ontology from which the axioms should be removed. + * @param axioms The axioms to be removed. + * @return ChangeApplied.SUCCESSFULLY if the axiom is added, ChangeApplied.UNSUCCESSFULLY + * otherwise. + * @throws OWLOntologyChangeException if there was a problem removing the axioms + */ + ChangeApplied removeAxioms(OWLOntology ont, Stream axioms); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasShortForm.java b/api/src/main/java/org/semanticweb/owlapi/model/HasShortForm.java new file mode 100644 index 0000000000..94d41c9d3e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasShortForm.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface to an object that has a short form (human readable short name + * e.g. owl:Class as opposed to the complete IRI). + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5.0 + */ +@FunctionalInterface +public interface HasShortForm { + + /** + * Gets the short form. + * + * @return A string that represents the short form. + */ + String getShortForm(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasSignature.java b/api/src/main/java/org/semanticweb/owlapi/model/HasSignature.java new file mode 100644 index 0000000000..eb0fa2de11 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasSignature.java @@ -0,0 +1,63 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.empty; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * An interface to an object which has a signature + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +public interface HasSignature { + + /** + * Gets the signature of this object. The default implementation is an empty, modifiable set. + *

+ * For ontologies, the signature of an ontology is the set of entities that are used to build + * axioms and annotations in the ontology. (See The + * OWL 2 Structural Specification) + *

+ * For ontology changes, this is the signature of the axiom being added/removed or the + * annotation being added/removed, or empty. + * + * @return A set of entities that represents the signature of this object. The set that is + * returned is a copy; modifications to the returned set will not be reflected in this + * object. + */ + default Set getSignature() { + return asSet(unsortedSignature()); + } + + /** + * @return Stream of the signature of this object. + */ + default Stream signature() { + return empty(); + } + + /** + * @return signature without sorting requirement. For immutable objects, this does not + * necessarily differ from the signature. Mutable objects, such as OWLOntology + * instances, can provide an unsorted signature faster. + */ + default Stream unsortedSignature() { + return signature(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/HasSubject.java b/api/src/main/java/org/semanticweb/owlapi/model/HasSubject.java new file mode 100644 index 0000000000..84bdcdab9d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/HasSubject.java @@ -0,0 +1,29 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param subject type + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +@FunctionalInterface +public interface HasSubject { + + /** + * Gets the subject of this object. + * + * @return The subject + */ + T getSubject(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/IRI.java b/api/src/main/java/org/semanticweb/owlapi/model/IRI.java new file mode 100644 index 0000000000..f5cc62b54e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/IRI.java @@ -0,0 +1,517 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import java.io.File; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.Collections; +import java.util.Optional; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.io.XMLUtils; +import org.semanticweb.owlapi.model.parameters.ConfigurationOptions; +import org.semanticweb.owlapi.vocab.Namespaces; +import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; + +import com.github.benmanes.caffeine.cache.Caffeine; +import com.github.benmanes.caffeine.cache.LoadingCache; + +/** + * Represents International Resource Identifiers. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class IRI implements OWLAnnotationSubject, OWLAnnotationValue, SWRLPredicate, CharSequence, + OWLPrimitive, HasShortForm, org.apache.commons.rdf.api.IRI { + + // Cache prefixes for memory gains. + private static final LoadingCache CACHE = + Caffeine.newBuilder().weakKeys().maximumSize(size()).build(k -> k); + + protected static long size() { + return ConfigurationOptions.CACHE_SIZE.getValue(Integer.class, Collections.emptyMap()) + .longValue(); + } + + private static final AtomicLong COUNTER = new AtomicLong(System.nanoTime()); + // Impl - All constructors are private - factory methods are used for + // public creation + private final String remainder; + private final String namespace; + + /** + * Constructs an IRI which is built from the concatenation of the specified prefix and suffix. + * + * @param prefix The prefix. + * @param suffix The suffix. + */ + protected IRI(String prefix, @Nullable String suffix) { + namespace = CACHE.get(XMLUtils.getNCNamePrefix(prefix)); + remainder = suffix == null ? "" : suffix; + } + + protected IRI(String s) { + this(XMLUtils.getNCNamePrefix(s), XMLUtils.getNCNameSuffix(s)); + } + + protected IRI(URI uri) { + this(checkNotNull(uri, "uri cannot be null").toString()); + } + + /** + * Creates an IRI from the specified String. + * + * @param str The String that specifies the IRI + * @return The IRI that has the specified string representation. + */ + public static IRI create(String str) { + checkNotNull(str, "str cannot be null"); + int index = XMLUtils.getNCNameSuffixIndex(str); + if (index < 0) { + // no ncname + return new IRI(str, ""); + } + return new IRI(str.substring(0, index), str.substring(index)); + } + + /** + * Creates an IRI by concatenating two strings. The full IRI is an IRI that contains the + * characters in prefix + suffix. + * + * @param prefix The first string + * @param suffix The second string + * @return An IRI whose characters consist of prefix + suffix. + * @since 3.3 + */ + public static IRI create(@Nullable String prefix, @Nullable String suffix) { + if (prefix == null && suffix == null) { + throw new IllegalArgumentException("prefix and suffix cannot both be null"); + } + if (prefix == null) { + return create(verifyNotNull(suffix)); + } + if (suffix == null) { + // suffix set deliberately to null is used only in blank node + // management + // this is not great but blank nodes should be changed to not refer + // to IRIs at all + // XXX address blank node issues with iris + return create(prefix); + } + int index = XMLUtils.getNCNameSuffixIndex(prefix); + int test = XMLUtils.getNCNameSuffixIndex(suffix); + if (index == -1 && test == 0) { + // the prefix does not contain an ncname character and there is + // no illegal character in the suffix + // the split is therefore correct + return new IRI(prefix, suffix); + } + // otherwise the split is wrong; we could obtain the right split by + // using index and test, but it's just as easy to use the other + // constructor + return create(prefix + suffix); + } + + /** + * @param file the file to create the IRI from + * @return file.toURI() IRI + */ + public static IRI create(File file) { + checkNotNull(file, "file cannot be null"); + return new IRI(file.toURI()); + } + + /** + * @param uri the URI to create the IRI from + * @return the IRI wrapping the URI + */ + public static IRI create(URI uri) { + checkNotNull(uri, "uri cannot be null"); + return new IRI(uri); + } + + /** + * @param url the URL to create the IRI from + * @return an IRI wrapping url.toURI() + * @throws OWLRuntimeException if the URL is ill formed + */ + public static IRI create(URL url) { + checkNotNull(url, "url cannot be null"); + try { + return new IRI(url.toURI()); + } catch (URISyntaxException e) { + throw new OWLRuntimeException(e); + } + } + + /** + * Gets an auto-generated ontology document IRI. + * + * @return An auto-generated ontology document IRI. The IRI has the form {@code + * owlapi:ontologyNNNNNNNNNNN} + */ + public static IRI generateDocumentIRI() { + return getNextDocumentIRI("owlapi:ontology"); + } + + /** + * @param prefix prefix for result + * @return a fresh IRI + */ + public static IRI getNextDocumentIRI(String prefix) { + return IRI.create(prefix + COUNTER.incrementAndGet()); + } + + @Override + public int typeIndex() { + return 0; + } + + @Override + public boolean isIRI() { + return true; + } + + /** + * Obtains this IRI as a URI. Note that Java URIs handle unicode characters, so there is no loss + * during this translation. + * + * @return The URI + */ + public URI toURI() { + return URI.create(namespace + remainder); + } + + /** + * Determines if this IRI is absolute. + * + * @return {@code true} if this IRI is absolute or {@code false} if this IRI is not absolute + */ + public boolean isAbsolute() { + int colonIndex = namespace.indexOf(':'); + if (colonIndex == -1) { + return false; + } + for (int i = 0; i < colonIndex; i++) { + char ch = namespace.charAt(i); + if (disallowed(ch)) { + return false; + } + } + return true; + } + + protected boolean disallowed(char ch) { + return !Character.isLetter(ch) && !Character.isDigit(ch) && ch != '.' && ch != '+' + && ch != '-'; + } + + /** + * @return the IRI scheme, e.g., {@code http}, {@code urn} + */ + @Nullable + public String getScheme() { + int colonIndex = namespace.indexOf(':'); + if (colonIndex == -1) { + return null; + } + return namespace.substring(0, colonIndex); + } + + /** + * @return the prefix + */ + public String getNamespace() { + return namespace; + } + + /** + * @param s the IRI string to be resolved + * @return s resolved against this IRI (with the URI::resolve() method, unless this IRI is + * opaque) + */ + public IRI resolve(String s) { + // shortcut: checking absolute and opaque here saves the creation of an + // extra URI object + URI uri = URI.create(s); + if (uri.isAbsolute() || uri.isOpaque()) { + return create(uri); + } + return create(toURI().resolve(uri)); + } + + /** + * Determines if this IRI is in the reserved vocabulary. An IRI is in the reserved vocabulary if + * it starts with <http://www.w3.org/1999/02/22-rdf-syntax-ns#> or + * <http://www.w3.org/2000/01/rdf-schema#> or <http://www.w3.org/2001/XMLSchema#> or + * <http://www.w3.org/2002/07/owl#> + * + * @return {@code true} if the IRI is in the reserved vocabulary, otherwise {@code false}. + */ + public boolean isReservedVocabulary() { + return Namespaces.OWL.inNamespace(namespace) || Namespaces.RDF.inNamespace(namespace) + || Namespaces.RDFS.inNamespace(namespace) || Namespaces.XSD.inNamespace(namespace); + } + + /** + * Built in annotation properties do not need declarations. Adding this method to IRIs so during + * parsing any undeclared properties can easily be disambiguated between builtin annotation + * properties and properties that are guessed to be annotation properties because of missing + * declarations. + * + * @return true if this IRI equals one of the vocabulary annotation properties + */ + public boolean isBuiltinAnnotationProperty() { + return OWLRDFVocabulary.BUILT_IN_AP_IRIS.contains(this); + } + + /** + * Determines if this IRI is equal to the IRI that {@code owl:Thing} is named with. + * + * @return {@code true} if this IRI is equal to <http://www.w3.org/2002/07/owl#Thing> and + * otherwise {@code false} + */ + public boolean isThing() { + return equals(OWLRDFVocabulary.OWL_THING.getIRI()); + } + + /** + * Determines if this IRI is equal to the IRI that {@code owl:Nothing} is named with. + * + * @return {@code true} if this IRI is equal to <http://www.w3.org/2002/07/owl#Nothing> + * and otherwise {@code false} + */ + public boolean isNothing() { + return equals(OWLRDFVocabulary.OWL_NOTHING.getIRI()); + } + + /** + * Determines if this IRI is equal to the IRI that is named {@code rdf:PlainLiteral}. + * + * @return {@code true} if this IRI is equal to + * <http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral>, otherwise + * {@code false} + */ + public boolean isPlainLiteral() { + return "PlainLiteral".equals(remainder) && Namespaces.RDF.inNamespace(namespace); + } + + /** + * Gets the last part of the IRI that is a valid NCName; note that for some IRIs this can be + * empty. + * + * @return The IRI fragment, or empty string if the IRI does not have a fragment + */ + public String getFragment() { + return remainder; + } + + /** + * @return the remainder (coincident with NCName usually) for this IRI. + */ + public Optional getRemainder() { + if (remainder.isEmpty()) { + return emptyOptional(); + } + return optional(remainder); + } + + /** + * Obtained this IRI surrounded by angled brackets. + * + * @return This IRI surrounded by < and > + */ + public String toQuotedString() { + return ntriplesString(); + } + + /** + * @param suffix suffix to turn to optional. Empty string is the same as null + * @return optional value for remainder + */ + protected Optional asOptional(@Nullable String suffix) { + if (suffix == null || suffix.isEmpty()) { + return emptyOptional(); + } + return optional(suffix); + } + + @Override + public int length() { + return namespace.length() + remainder.length(); + } + + @Override + public char charAt(int index) { + if (index < 0) { + throw new IndexOutOfBoundsException(Integer.toString(index)); + } + if (index < namespace.length()) { + return namespace.charAt(index); + } + return remainder.charAt(index - namespace.length()); + } + + @Override + public CharSequence subSequence(int start, int end) { + StringBuilder sb = new StringBuilder(namespace); + sb.append(remainder); + return sb.subSequence(start, end); + } + + /** + * @param prefix prefix to use for replacing the IRI namespace + * @return prefix plus IRI ncname + */ + public String prefixedBy(String prefix) { + checkNotNull(prefix, "prefix cannot be null"); + if (remainder.isEmpty()) { + return prefix; + } + return prefix + remainder; + } + + @Override + public String getShortForm() { + if (!remainder.isEmpty()) { + return remainder; + } + int lastSlashIndex = namespace.lastIndexOf('/'); + if (lastSlashIndex != -1 && lastSlashIndex != namespace.length() - 1) { + return namespace.substring(lastSlashIndex + 1); + } + return toQuotedString(); + } + + @Override + public void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + public O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public void accept(OWLAnnotationSubjectVisitor visitor) { + visitor.visit(this); + } + + @Override + public E accept(OWLAnnotationSubjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public int compareTo(@Nullable OWLObject o) { + checkNotNull(o); + assert o != null; + if (o == this || equals(o)) { + return 0; + } + if (!o.isIRI()) { + return -1; + } + IRI other = (IRI) o; + int diff = namespace.compareTo(other.namespace); + if (diff != 0) { + return diff; + } + return remainder.compareTo(other.remainder); + } + + @Override + public String toString() { + return getIRIString(); + } + + @Override + public int hashCode() { + return namespace.hashCode() + remainder.hashCode(); + } + + @Override + public int initHashCode() { + return hashCode(); + } + + @Override + public void accept(OWLAnnotationValueVisitor visitor) { + visitor.visit(this); + } + + @Override + public O accept(OWLAnnotationValueVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public Optional asIRI() { + return optional(this); + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (obj instanceof IRI) { + IRI other = (IRI) obj; + return remainder.equals(other.remainder) && other.namespace.equals(namespace); + } + // Commons RDF IRI equals() contract + if (obj instanceof org.apache.commons.rdf.api.IRI) { + org.apache.commons.rdf.api.IRI iri = (org.apache.commons.rdf.api.IRI) obj; + return ntriplesString().equals(iri.ntriplesString()); + } + return false; + } + + @Override + public String ntriplesString() { + return '<' + namespace + remainder + '>'; + } + + @Override + public String getIRIString() { + if (remainder.isEmpty()) { + return namespace; + } + return namespace + remainder; + } + + @Override + public Stream components() { + return Stream.empty(); + } + + @Override + public int hashIndex() { + return 863; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/ImmutableOWLOntologyChangeException.java b/api/src/main/java/org/semanticweb/owlapi/model/ImmutableOWLOntologyChangeException.java new file mode 100644 index 0000000000..f57732af2d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/ImmutableOWLOntologyChangeException.java @@ -0,0 +1,35 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.change.OWLOntologyChangeData; + +/** + * An exception to describe a situation where there was an attempt to apply a + * change to an immutable ontology. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class ImmutableOWLOntologyChangeException extends OWLOntologyChangeException { + + /** + * Constructs an exception which describes the attempted change. + * + * @param change The change. + * @param o the ontology. + */ + public ImmutableOWLOntologyChangeException(OWLOntologyChangeData change, String o) { + super(change, "Cannot apply changes to immutable ontology: " + o); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/ImpendingOWLOntologyChangeBroadcastStrategy.java b/api/src/main/java/org/semanticweb/owlapi/model/ImpendingOWLOntologyChangeBroadcastStrategy.java new file mode 100644 index 0000000000..80e2e83bf9 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/ImpendingOWLOntologyChangeBroadcastStrategy.java @@ -0,0 +1,33 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; +import java.util.List; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +@FunctionalInterface +public interface ImpendingOWLOntologyChangeBroadcastStrategy extends Serializable { + + /** + * Broadcasts the list of changes to the specified listeners. + * + * @param changes The changes to be broadcast. + * @param listener The listeners that the changes should be broadcast to + */ + void broadcastChanges(ImpendingOWLOntologyChangeListener listener, + List changes); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/ImpendingOWLOntologyChangeListener.java b/api/src/main/java/org/semanticweb/owlapi/model/ImpendingOWLOntologyChangeListener.java new file mode 100644 index 0000000000..87d6776020 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/ImpendingOWLOntologyChangeListener.java @@ -0,0 +1,37 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; +import java.util.List; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +@FunctionalInterface +public interface ImpendingOWLOntologyChangeListener extends Serializable { + + /** + * Called when a list of ontology changes is about to be applied. Note that + * not all of the changes in the list may be applied. This is due to the + * fact that change objects that would not cause any change to the + * associated ontology are typically not enacted. + * + * @param impendingChanges A list of ontology changes that will be applied to an ontology. Note + * that the list of changes represents the requested changes. Not all change might be applied. + * @throws OWLOntologyChangeVetoException The listener may throw a change veto exception, which + * will prevent all of the changes being applied. + */ + void handleImpendingOntologyChanges(List impendingChanges); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/ImportChange.java b/api/src/main/java/org/semanticweb/owlapi/model/ImportChange.java new file mode 100644 index 0000000000..597e4639b8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/ImportChange.java @@ -0,0 +1,47 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public abstract class ImportChange extends OWLOntologyChange { + + private final OWLImportsDeclaration declaration; + + /** + * @param ont the ontology to which the change is to be applied + * @param importDeclaration the import declaration + */ + public ImportChange(OWLOntology ont, OWLImportsDeclaration importDeclaration) { + super(ont); + declaration = checkNotNull(importDeclaration, "importDeclaration cannot be null"); + } + + /** + * Gets the import declaration that the change pertains to. + * + * @return The import declaration + */ + public OWLImportsDeclaration getImportDeclaration() { + return declaration; + } + + @Override + public boolean isImportChange() { + return true; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/IsAnonymous.java b/api/src/main/java/org/semanticweb/owlapi/model/IsAnonymous.java new file mode 100644 index 0000000000..a5e5028270 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/IsAnonymous.java @@ -0,0 +1,33 @@ +package org.semanticweb.owlapi.model; + +/** + * Anonymous or named object interface. Named {@code OWLObject} instances have an IRI; this includes + * {@code OWLClass}, {@code OWLDataProperty}, {@code OWLObjectProperty}, {@code OWLDatatype}, + * {@code OWLAnnotationProperty} and {@code OWLNamedIndividual} instances. {@code OWLOntology} + * instances also have an IRI or can be anonymous, depending on the contents of their ontology id. + * Ontologies are mutable and therefore can switch from anonymous to named, when their id is + * changed; all other objects are immutable, and therefore will not change from anonymous to named. + */ +public interface IsAnonymous { + + /** + * @return {@code true} if this object is anonymous, {@code false} otherwise. For example, class + * expressions are anonymous while class entities are not (they have an IRI); + * {@code OWLNamedIndividual} instances are named, {@code OWLAnonymousIndividual} + * instances are anonymous. An ontology is anonymous if it does not have an ontology + * IRI. In this case, getOntologyID().getOntologyIRI() will return an empty optional. + */ + default boolean isAnonymous() { + return true; + } + + /** + * @return {@code true} if this object is named, {@code false} otherwise. For example, class + * entities are named (they have an IRI) while class expressions are anonymous; + * {@code OWLNamedIndividual} instances are named, {@code OWLAnonymousIndividual} + * instances are anonymous. + */ + default boolean isNamed() { + return !isAnonymous(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/MIMETypeAware.java b/api/src/main/java/org/semanticweb/owlapi/model/MIMETypeAware.java new file mode 100644 index 0000000000..a78490cd70 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/MIMETypeAware.java @@ -0,0 +1,68 @@ +package org.semanticweb.owlapi.model; + +import java.util.Collections; +import java.util.List; + +import javax.annotation.Nullable; + +/** + * Interface for MIME type aware objects. These can be instances of format, parser or storer + * factories. Formats can use annotations for the same purpose, but generic factories cannot use + * type annotations to change behaviour. + * + * @author ignazio + * @since 4.0.0 + */ +public interface MIMETypeAware { + + /** + * Returns the default MIME Type for the OWLDocumentFormat that this class is a factory for. + * + * @return The default MIME Type for the OWLDocumentFormat that this class is a factory for or + * null if no MIME Types are specified. + */ + @Nullable + String getDefaultMIMEType(); + + /** + * Returns a sorted list of MIME types for the OWLDocumentFormat that this class is a factory + * for. If this list is not empty, the first element in the returned list must be the default + * MIME type. + * + * @return A list of strings containing the known MIME types for this format. + */ + default List getMIMETypes() { + String defaultMIMEType = getDefaultMIMEType(); + if (defaultMIMEType == null || defaultMIMEType.isEmpty()) { + return Collections.emptyList(); + } + return Collections.singletonList(getDefaultMIMEType()); + } + + /** + * Determines whether either {@link #getDefaultMIMEType()} equals the given mime type or + * {@link #getMIMETypes()} contains the given mime type. + * + * @param mimeType The MIME type to match against. + * @return True if the given MIME type matches this format. + */ + default boolean handlesMimeType(String mimeType) { + String type = stripWeight(mimeType); + return getMIMETypes().stream().map(MIMETypeAware::stripWeight) + .anyMatch(m -> m.equals(type)); + } + + /** + * Utility to reduce a mime format like "text/plain; q=0.1" to "text/plain" + * + * @param mime input + * @return mime type without weight + */ + static String stripWeight(String mime) { + int semiColon = mime.indexOf(';'); + if (semiColon > -1) { + return mime.substring(0, semiColon).trim(); + } + return mime.trim(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/MissingImportEvent.java b/api/src/main/java/org/semanticweb/owlapi/model/MissingImportEvent.java new file mode 100644 index 0000000000..b2136b4bb6 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/MissingImportEvent.java @@ -0,0 +1,55 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +/** + * An event that gets posted to objects that listen for missing imports when silent missing import + * handling is set to {@code true} in an ontology manager. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @see org.semanticweb.owlapi.model.MissingImportListener + * @see org.semanticweb.owlapi.model.OWLOntologyManager#addMissingImportListener(MissingImportListener) + * @see org.semanticweb.owlapi.model.OWLOntologyManager#removeMissingImportListener(MissingImportListener) + * @since 2.2.0 + */ +public class MissingImportEvent { + + private final IRI ontologyIRI; + private final OWLOntologyCreationException creationException; + + /** + * @param ontologyIRI the ontology IRI + * @param creationException the creation exception + */ + public MissingImportEvent(IRI ontologyIRI, OWLOntologyCreationException creationException) { + this.ontologyIRI = checkNotNull(ontologyIRI, "ontologyIRI cannot be null"); + this.creationException = + checkNotNull(creationException, "creationException cannot be null"); + } + + /** + * @return the IRI + */ + public IRI getImportedOntologyURI() { + return ontologyIRI; + } + + /** + * @return the exception + */ + public OWLOntologyCreationException getCreationException() { + return creationException; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/MissingImportHandlingStrategy.java b/api/src/main/java/org/semanticweb/owlapi/model/MissingImportHandlingStrategy.java new file mode 100644 index 0000000000..40ce6352a5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/MissingImportHandlingStrategy.java @@ -0,0 +1,41 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Specifies how missing imports should be treated during loading. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.3 + */ +public enum MissingImportHandlingStrategy implements ByName { + /** + * Specifies that an {@link org.semanticweb.owlapi.model.UnloadableImportException} will NOT be + * thrown during ontology loading if an import cannot be loaded (for what ever reason). Instead, + * any registered {@link org.semanticweb.owlapi.model.MissingImportListener}s will be informed + * of the problem via their {@link org.semanticweb.owlapi.model.MissingImportListener#importMissing(org.semanticweb.owlapi.model.MissingImportEvent)} + * method. + */ + SILENT, /** + * Specifies that an + * {@link org.semanticweb.owlapi.model.UnloadableImportException} + * WILL be thrown during ontology loading if an import cannot be + * loaded. + */ + THROW_EXCEPTION; + + @Override + public MissingImportHandlingStrategy byName(CharSequence name) { + return valueOf(name.toString()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/MissingImportListener.java b/api/src/main/java/org/semanticweb/owlapi/model/MissingImportListener.java new file mode 100644 index 0000000000..9c6ae6fc19 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/MissingImportListener.java @@ -0,0 +1,33 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; + +/** + * An interface for objects that listen to missing imports events. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @see MissingImportEvent + * @see org.semanticweb.owlapi.model.OWLOntologyManager#addMissingImportListener(MissingImportListener) + * @see org.semanticweb.owlapi.model.OWLOntologyManager#removeMissingImportListener(MissingImportListener) + * @since 2.2.0 + */ +@FunctionalInterface +public interface MissingImportListener extends Serializable { + + /** + * @param event the missing import event + */ + void importMissing(MissingImportEvent event); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/MissingOntologyHeaderStrategy.java b/api/src/main/java/org/semanticweb/owlapi/model/MissingOntologyHeaderStrategy.java new file mode 100644 index 0000000000..9ed3061fe4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/MissingOntologyHeaderStrategy.java @@ -0,0 +1,15 @@ +package org.semanticweb.owlapi.model; + +/** + * what action to take if the ontology header is missing. + */ +public enum MissingOntologyHeaderStrategy implements ByName { + //@formatter:off + /** Include triples. */ INCLUDE_GRAPH, + /** Keep import structure. */ IMPORT_GRAPH; + //@formatter:on + @Override + public MissingOntologyHeaderStrategy byName(CharSequence name) { + return valueOf(name.toString()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/NodeID.java b/api/src/main/java/org/semanticweb/owlapi/model/NodeID.java new file mode 100644 index 0000000000..69ae8c665d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/NodeID.java @@ -0,0 +1,211 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.io.Serializable; +import java.util.concurrent.atomic.AtomicLong; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.io.XMLUtils; + +/** + * Represents the Node ID for anonymous individuals. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public final class NodeID implements Comparable, Serializable { + + private static final AtomicLong COUNTER = new AtomicLong(Integer.MAX_VALUE); + private static final String NODE_ID_PREFIX = "genid"; + private static final String SHARED_NODE_ID_PREFIX = "genid-nodeid-"; + private static final String PREFIX = "_:"; + private static final String PREFIX_NODE = PREFIX + NODE_ID_PREFIX; + private static final String PREFIX_SHARED_NODE = PREFIX + SHARED_NODE_ID_PREFIX; + private final String id; + + private NodeID(String id) { + if (id.startsWith(PREFIX)) { + this.id = id; + } else { + this.id = PREFIX + id; + } + } + + /** + * @param id the node id + * @return string version of id + */ + public static String nodeString(int id) { + return PREFIX_NODE + Integer.toString(id); + } + + /** + * @param id id + * @return IRI with full node id + */ + public static IRI nodeId(Integer id) { + return IRI.create(PREFIX_NODE + id); + } + + /** + * Returns an absolute IRI from a nodeID attribute. + * + * @param nodeID the node id + * @return absolute IRI + */ + public static String getIRIFromNodeID(String nodeID) { + if (nodeID.startsWith(PREFIX_SHARED_NODE)) { + return nodeID; + } + return PREFIX_SHARED_NODE + nodeID.replace(NODE_ID_PREFIX, ""); + } + + /** + * Generates next anonymous IRI. + * + * @return absolute IRI + */ + public static String nextAnonymousIRI() { + return PREFIX_NODE + COUNTER.incrementAndGet(); + } + + /** + * @return IRI with fresh node id + */ + public static IRI nextFreshNodeId() { + return IRI.create(PREFIX_NODE + COUNTER.incrementAndGet()); + } + + /** + * Tests whether supplied IRI was generated by this parser in order to label an anonymous node. + * + * @param iri the IRI + * @return {@code true} if the IRI was generated by this parser to label an anonymous node + */ + public static boolean isAnonymousNodeIRI(@Nullable String iri) { + return iri != null && iri.startsWith(PREFIX) && iri.contains(NODE_ID_PREFIX); + } + + /** + * Tests whether supplied IRI was generated by this parser in order to label an anonymous node. + * + * @param iri the IRI + * @return {@code true} if the IRI was generated by this parser to label an anonymous node + */ + public static boolean isAnonymousNodeIRI(@Nullable IRI iri) { + return iri != null && iri.getNamespace().startsWith(PREFIX) + && iri.getNamespace().contains(NODE_ID_PREFIX); + } + + /** + * @param iri the iri or node id + * @return true if the iri is an anonymous label + */ + public static boolean isAnonymousNodeID(@Nullable String iri) { + return iri != null && iri.contains(PREFIX_SHARED_NODE); + } + + /** + * Gets a NodeID with a specific identifier string. + * + * @param id The String that identifies the node. If the String doesn't start with "_:" then + * this will be concatenated to the front of the specified id String; if the string is + * empty or null, an autogenerated id will be used. + * @return A NodeID + */ + public static NodeID getNodeID(@Nullable String id) { + String nonBlankId = id == null || id.isEmpty() ? nextAnonymousIRI() : id; + return new NodeID(nonBlankId); + } + + /** + * @return get a new node id with an autogenerated, sequential id + */ + public static NodeID getNodeID() { + return getNodeID(nextAnonymousIRI()); + } + + @Override + public String toString() { + return id; + } + + @Override + public int compareTo(@Nullable NodeID o) { + return id.compareTo(checkNotNull(o).id); + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (!(obj instanceof NodeID)) { + return false; + } + NodeID other = (NodeID) obj; + return id.equals(other.id); + } + + @Override + public int hashCode() { + return id.hashCode(); + } + + /** + * Gets the string representation of the node ID. This will begin with _: + * + * @return The string representation of the node ID. + */ + public String getID() { + return id; + } + + /** + * @param resource nodeid IRI to strip of prefixes + * @return id string compatible with RDF/XML + */ + public static String stripArtifacts(CharSequence resource) { + StringBuilder b = new StringBuilder(resource); + int toDelete = b.indexOf(SHARED_NODE_ID_PREFIX); + if (toDelete > -1) { + b.delete(toDelete, toDelete + SHARED_NODE_ID_PREFIX.length()); + } + toDelete = b.indexOf(NODE_ID_PREFIX); + if (toDelete > -1) { + b.delete(toDelete, toDelete + NODE_ID_PREFIX.length()); + } + toDelete = b.indexOf(PREFIX); + if (toDelete > -1) { + b.delete(toDelete, toDelete + PREFIX.length()); + } + for (int i = b.length() - 1; i > -1; i--) { + if (!XMLUtils.isNCNameChar(b.charAt(i))) { + b.deleteCharAt(i); + } + } + if (!XMLUtils.isNCNameStartChar(b.charAt(0))) { + // if the first character is not suitable as the start of an NCName, prefix it with the + // mildest of the prefixes + b.insert(0, NODE_ID_PREFIX); + } + return b.toString(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotation.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotation.java new file mode 100644 index 0000000000..c1d4fd1a24 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotation.java @@ -0,0 +1,141 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Collection; +import java.util.stream.Stream; + +/** + * Annotations are used in the various types of annotation axioms, which bind annotations to their + * subjects (i.e. axioms or declarations).
+ * An annotation is equal to another annotation if both objects have equal annotation URIs and have + * equal annotation values. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLAnnotation + extends OWLObject, HasAnnotations, HasProperty, HasAnnotationValue { + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getProperty(), getValue()); + } + + @Override + default Stream components() { + return Stream.of(getProperty(), getValue(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getProperty().hashCode()); + hash = OWLObject.hashIteration(hash, getValue().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getProperty(), getValue()); + } + + @Override + default int hashIndex() { + return 877; + } + + @Override + default int typeIndex() { + return 5001; + } + + /** + * Gets the property that this annotation acts along. + * + * @return The annotation property + */ + @Override + OWLAnnotationProperty getProperty(); + + /** + * Gets the annotation value. The type of value will depend upon the type of the annotation e.g. + * whether the annotation is an {@link org.semanticweb.owlapi.model.OWLLiteral}, an + * {@link org.semanticweb.owlapi.model.IRI} or an + * {@link org.semanticweb.owlapi.model.OWLAnonymousIndividual}. + * + * @return The annotation value. + * @see org.semanticweb.owlapi.model.OWLAnnotationValueVisitor + * @see org.semanticweb.owlapi.model.OWLAnnotationValueVisitorEx + */ + OWLAnnotationValue getValue(); + + /** + * Determines if this annotation is an annotation used to deprecate an IRI. This is the case if + * the annotation property has an IRI of {@code owl:deprecated} and the value of the annotation + * is {@code "true"^^xsd:boolean} + * + * @return {@code true} if this annotation is an annotation that can be used to deprecate an + * IRI, otherwise {@code false}. + */ + boolean isDeprecatedIRIAnnotation(); + + /** + * Gets an OWLAnnotation which is a copy of this annotation but which has the specified + * annotations. + * + * @param annotations The annotations + * @return A copy of this annotation with the specified annotations annotating it + */ + OWLAnnotation getAnnotatedAnnotation(Collection annotations); + + /** + * Gets an OWLAnnotation which is a copy of this annotation but which has the specified + * annotations. + * + * @param annotations The annotations + * @return A copy of this annotation with the specified annotations annotating it + */ + OWLAnnotation getAnnotatedAnnotation(Stream annotations); + + /** + * @param visitor visitor to accept + */ + default void accept(OWLAnnotationObjectVisitor visitor) { + visitor.visit(this); + } + + /** + * @param visitor visitor to accept + * @param visitor return type + * @return visitor value + */ + default O accept(OWLAnnotationObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default OWLAnnotationValue annotationValue() { + return getValue(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationAssertionAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationAssertionAxiom.java new file mode 100644 index 0000000000..7af7fc14fa --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationAssertionAxiom.java @@ -0,0 +1,119 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * Represents + * AnnotationAssertion axioms in the OWL 2 specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLAnnotationAssertionAxiom extends OWLAnnotationAxiom, + HasSubject, HasProperty, HasAnnotationValue { + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getSubject(), getProperty(), getValue()); + } + + @Override + default Stream components() { + return Stream.of(getSubject(), getProperty(), getValue(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getSubject().hashCode()); + hash = OWLObject.hashIteration(hash, getProperty().hashCode()); + hash = OWLObject.hashIteration(hash, getValue().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getSubject(), getProperty(), getValue()); + } + + @Override + default int hashIndex() { + return 47; + } + + /** + * Gets the annotation value. This is either an {@link org.semanticweb.owlapi.model.IRI}, an + * {@link org.semanticweb.owlapi.model.OWLAnonymousIndividual} or an {@link OWLLiteral}. + * Annotation values can be visited with an + * {@link org.semanticweb.owlapi.model.OWLAnnotationValueVisitor}. + * + * @return The annotation value. + * @see org.semanticweb.owlapi.model.OWLAnnotationValueVisitor + * @see org.semanticweb.owlapi.model.OWLAnnotationValueVisitorEx + */ + OWLAnnotationValue getValue(); + + /** + * Gets the combination of the annotation property and the annotation value as an + * {@link org.semanticweb.owlapi.model.OWLAnnotation} object. + * + * @return The annotation object that combines the property and value of this annotation. + */ + OWLAnnotation getAnnotation(); + + /** + * Determines if this annotation assertion deprecates the IRI that is the subject of the + * annotation. + * + * @return {@code true} if this annotation assertion deprecates the subject IRI of the + * assertion, otherwise {@code false}. + * @see org.semanticweb.owlapi.model.OWLAnnotation#isDeprecatedIRIAnnotation() + */ + boolean isDeprecatedIRIAssertion(); + + @Override + @SuppressWarnings("unchecked") + OWLAnnotationAssertionAxiom getAxiomWithoutAnnotations(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.ANNOTATION_ASSERTION; + } + + @Override + default OWLAnnotationValue annotationValue() { + return getAnnotation().getValue(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationAxiom.java new file mode 100644 index 0000000000..648f081fb1 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationAxiom.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * A super interface for annotation axioms. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLAnnotationAxiom extends OWLAxiom, OWLAnnotationObject { + + @Override + public default boolean isAnnotationAxiom() { + return true; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationAxiomVisitor.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationAxiomVisitor.java new file mode 100644 index 0000000000..f6896146ba --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationAxiomVisitor.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * A visitor which visits the different kinds of annotation axioms. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLAnnotationAxiomVisitor extends OWLVisitorBase { + + /** + * visit OWLAnnotationAssertionAxiom type + * + * @param axiom object to visit + */ + default void visit(OWLAnnotationAssertionAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLSubAnnotationPropertyOfAxiom type + * + * @param axiom object to visit + */ + default void visit(OWLSubAnnotationPropertyOfAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLAnnotationPropertyDomainAxiom type + * + * @param axiom object to visit + */ + default void visit(OWLAnnotationPropertyDomainAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLAnnotationPropertyRangeAxiom type + * + * @param axiom object to visit + */ + default void visit(OWLAnnotationPropertyRangeAxiom axiom) { + doDefault(axiom); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationAxiomVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationAxiomVisitorEx.java new file mode 100644 index 0000000000..1a3f440bd5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationAxiomVisitorEx.java @@ -0,0 +1,61 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param visitor type + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLAnnotationAxiomVisitorEx extends OWLVisitorExBase { + + /** + * visit OWLAnnotationAssertionAxiom type + * + * @param axiom object to visit + * @return visitor value + */ + default O visit(OWLAnnotationAssertionAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLSubAnnotationPropertyOfAxiom type + * + * @param axiom object to visit + * @return visitor value + */ + default O visit(OWLSubAnnotationPropertyOfAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLAnnotationPropertyDomainAxiom type + * + * @param axiom object to visit + * @return visitor value + */ + default O visit(OWLAnnotationPropertyDomainAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLAnnotationPropertyRangeAxiom type + * + * @param axiom object to visit + * @return visitor value + */ + default O visit(OWLAnnotationPropertyRangeAxiom axiom) { + return doDefault(axiom); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationObject.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationObject.java new file mode 100644 index 0000000000..2067d6f7c9 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationObject.java @@ -0,0 +1,42 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; + +import java.util.Optional; + +/** + * A marker interface for the values (objects) of annotations. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLAnnotationObject extends OWLObject { + + /** + * @return if the value is an IRI, return an optional containing it. Return Optional.absent + * otherwise. + */ + default Optional asIRI() { + return emptyOptional(); + } + + /** + * @return if the value is an anonymous, return an optional containing it. Return + * Optional.absent otherwise. + */ + default Optional asAnonymousIndividual() { + return emptyOptional(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationObjectVisitor.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationObjectVisitor.java new file mode 100644 index 0000000000..1185fab397 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationObjectVisitor.java @@ -0,0 +1,30 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLAnnotationObjectVisitor extends OWLAnnotationAxiomVisitor, + OWLAnnotationValueVisitor { + + /** + * visit OWLAnnotation type + * + * @param node object to visit + */ + default void visit(OWLAnnotation node) { + doDefault(node); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationObjectVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationObjectVisitorEx.java new file mode 100644 index 0000000000..3713b8c163 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationObjectVisitorEx.java @@ -0,0 +1,32 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param visitor type + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLAnnotationObjectVisitorEx + extends OWLAnnotationAxiomVisitorEx, OWLAnnotationValueVisitorEx { + + /** + * visit OWLAnnotation type + * + * @param node object to visit + * @return visitor value + */ + default O visit(OWLAnnotation node) { + return doDefault(node); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationProperty.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationProperty.java new file mode 100644 index 0000000000..4541c47272 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationProperty.java @@ -0,0 +1,124 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import javax.annotation.Nonnull; +import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; + +/** + * Represents an + * + * AnnotationProperty in the OWL 2 specification. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLAnnotationProperty extends OWLProperty { + + @Override + default int hashIndex() { + return 857; + } + + @Override + default int typeIndex() { + return 1006; + } + + @Override + default EntityType getEntityType() { + return EntityType.ANNOTATION_PROPERTY; + } + + /** + * Determines if this annotation property has an IRI corresponding to + * {@code rdfs:comment}. + * + * @return {@code true} if the IRI of this annotation property is {@code rdfs:comment}, where + * {@code rdfs:} expands to the usual prefix, otherwise {@code false}. + */ + default boolean isComment() { + return getIRI().equals(OWLRDFVocabulary.RDFS_COMMENT.getIRI()); + } + + /** + * Determines if this annotation property has an IRI corresponding to + * {@code rdfs:label}. + * + * @return {@code true} if the IRI of this annotation property is {@code rdfs:label}, where + * {@code rdfs:} expands to the usual prefix, otherwise {@code false}. + */ + default boolean isLabel() { + return getIRI().equals(OWLRDFVocabulary.RDFS_LABEL.getIRI()); + } + + /** + * Determines if this annotation property has an IRI corresponding to + * {@code owl:deprecated}. An annotation along the {@code owl:deprecated} + * property which has a value of {@code "true"^^xsd:boolean} can be used to + * deprecate IRIs. (See + * + * Section 5.5 of the OWL 2 specification. + * + * @return {@code true} if the IRI of this annotation property is {@code owl:deprecated}, where + * {@code owl:} expands to the usual prefix, otherwise {@code false}. + */ + default boolean isDeprecated() { + return getIRI().equals(OWLRDFVocabulary.OWL_DEPRECATED.getIRI()); + } + + @Override + default boolean isOWLAnnotationProperty() { + return true; + } + + @Override + default void accept(@Nonnull OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(@Nonnull OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(@Nonnull OWLPropertyExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(@Nonnull OWLPropertyExpressionVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(@Nonnull OWLEntityVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(@Nonnull OWLEntityVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(@Nonnull OWLNamedObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(@Nonnull OWLNamedObjectVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationPropertyDomainAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationPropertyDomainAxiom.java new file mode 100644 index 0000000000..b8bc9413c4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationPropertyDomainAxiom.java @@ -0,0 +1,83 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * Represents an + * AnnotationPropertyDomain axiom in the OWL 2 specification. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLAnnotationPropertyDomainAxiom + extends OWLAnnotationAxiom, HasProperty, HasDomain { + + @Override + @SuppressWarnings("unchecked") + OWLAnnotationPropertyDomainAxiom getAxiomWithoutAnnotations(); + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getProperty(), getDomain()); + } + + @Override + default Stream components() { + return Stream.of(getProperty(), getDomain(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getProperty().hashCode()); + hash = OWLObject.hashIteration(hash, getDomain().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getProperty(), getDomain()); + } + + @Override + default int hashIndex() { + return 823; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.ANNOTATION_PROPERTY_DOMAIN; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationPropertyRangeAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationPropertyRangeAxiom.java new file mode 100644 index 0000000000..fa279766ba --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationPropertyRangeAxiom.java @@ -0,0 +1,85 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +import javax.annotation.Nonnull; + +/** + * Represents an + * AnnotationPropertyRange axiom in the OWL 2 specification. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLAnnotationPropertyRangeAxiom + extends OWLAnnotationAxiom, HasProperty, HasRange { + + @Override + @SuppressWarnings("unchecked") + OWLAnnotationPropertyRangeAxiom getAxiomWithoutAnnotations(); + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getProperty(), getRange()); + } + + @Override + default Stream components() { + return Stream.of(getProperty(), getRange(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getProperty().hashCode()); + hash = OWLObject.hashIteration(hash, getRange().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getProperty(), getRange()); + } + + @Override + default int hashIndex() { + return 827; + } + + @Override + default void accept(@Nonnull OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(@Nonnull OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(@Nonnull OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(@Nonnull OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.ANNOTATION_PROPERTY_RANGE; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationSubject.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationSubject.java new file mode 100644 index 0000000000..e53bbf0fa1 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationSubject.java @@ -0,0 +1,35 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * A marker interface for annotation subjects, which can either be IRIs or + * anonymous individuals, with visitor methods. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLAnnotationSubject extends OWLAnnotationObject, OWLPrimitive { + + /** + * @param visitor visitor to accept + */ + void accept(OWLAnnotationSubjectVisitor visitor); + + /** + * @param visitor visitor to accept + * @param visitor return type + * @return visitor value + */ + O accept(OWLAnnotationSubjectVisitorEx visitor); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationSubjectVisitor.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationSubjectVisitor.java new file mode 100644 index 0000000000..d3c9f5ace2 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationSubjectVisitor.java @@ -0,0 +1,34 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLAnnotationSubjectVisitor { + + /** + * Visit IRI type. + * + * @param iri object to visit + */ + void visit(IRI iri); + + /** + * Visit OWLAnonymousIndividual type. + * + * @param individual object to visit + */ + void visit(OWLAnonymousIndividual individual); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationSubjectVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationSubjectVisitorEx.java new file mode 100644 index 0000000000..4b93fb7c87 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationSubjectVisitorEx.java @@ -0,0 +1,37 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param visitor type + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLAnnotationSubjectVisitorEx { + + /** + * Visit IRI type. + * + * @param iri object to visit + * @return visitor value + */ + O visit(IRI iri); + + /** + * Visit OWLAnonymousIndividual type. + * + * @param individual object to visit + * @return visitor value + */ + O visit(OWLAnonymousIndividual individual); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationValue.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationValue.java new file mode 100644 index 0000000000..e09b6f4b1b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationValue.java @@ -0,0 +1,62 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; + +import java.util.Optional; + +/** + * A marker interface for annotation values, which can either be an IRI (URI), Literal or Anonymous + * Individual, with visitor methods. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @see org.semanticweb.owlapi.model.IRI + * @see org.semanticweb.owlapi.model.OWLLiteral + * @see org.semanticweb.owlapi.model.OWLAnonymousIndividual + * @since 3.0.0 + */ +public interface OWLAnnotationValue extends OWLAnnotationObject, OWLPrimitive, HasAnnotationValue { + + /** + * @param visitor visitor to accept + */ + void accept(OWLAnnotationValueVisitor visitor); + + /** + * @param visitor visitor to accept + * @param visitor return type + * @return visitor value + */ + O accept(OWLAnnotationValueVisitorEx visitor); + + /** + * @return if the value is a literal, return an optional containing it. Return Optional.absent + * otherwise. + */ + default Optional asLiteral() { + return emptyOptional(); + } + + /** + * @return true if the annotation value is a literal + */ + default boolean isLiteral() { + return false; + } + + @Override + default OWLAnnotationValue annotationValue() { + return this; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationValueVisitor.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationValueVisitor.java new file mode 100644 index 0000000000..6d1606fa28 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationValueVisitor.java @@ -0,0 +1,33 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * A visitor that visits values of {@link OWLAnnotation}s and + * {@link org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom}s. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLAnnotationValueVisitor extends OWLAnonymousIndividualVisitorBase, + OWLLiteralVisitorBase { + + /** + * visit IRI type + * + * @param iri object to visit + */ + default void visit(IRI iri) { + doDefault(iri); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationValueVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationValueVisitorEx.java new file mode 100644 index 0000000000..0bd3476ace --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationValueVisitorEx.java @@ -0,0 +1,32 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param visitor type + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLAnnotationValueVisitorEx + extends OWLAnonymousIndividualVisitorExBase, OWLLiteralVisitorExBase { + + /** + * visit IRI type + * + * @param iri object to visit + * @return visitor value + */ + default O visit(IRI iri) { + return doDefault(iri); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnonymousClassExpression.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnonymousClassExpression.java new file mode 100644 index 0000000000..2d24d26c7e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnonymousClassExpression.java @@ -0,0 +1,28 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * The super interface for all class expressions which are not named class expressions (i.e. all + * class expressions which are not {@code OWLClass}). This interface represents + * class expressions in the OWL 2 + * Specification. + * + * Note: This is a marker interface because the default implementation of the method already returns + * true. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLAnonymousClassExpression extends OWLClassExpression { +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnonymousIndividual.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnonymousIndividual.java new file mode 100644 index 0000000000..db72343f9a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnonymousIndividual.java @@ -0,0 +1,93 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * Represents Anonymous + * Individuals in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLAnonymousIndividual + extends OWLIndividual, OWLAnnotationValue, OWLAnnotationSubject, OWLPrimitive { + + @Override + default Stream components() { + return Stream.of(getID()); + } + + @Override + default int initHashCode() { + return OWLObject.hashIteration(hashIndex(), getID().hashCode()); + } + + @Override + default int hashIndex() { + return 859; + } + + @Override + default int typeIndex() { + return 1007; + } + + /** + * Gets the ID of this individual. + * + * @return The node ID of this individual. + */ + NodeID getID(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLIndividualVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLIndividualVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAnnotationValueVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAnnotationValueVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAnnotationSubjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default E accept(OWLAnnotationSubjectVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnonymousIndividualVisitorBase.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnonymousIndividualVisitorBase.java new file mode 100644 index 0000000000..a5ff57ae0a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnonymousIndividualVisitorBase.java @@ -0,0 +1,29 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLAnonymousIndividualVisitorBase extends OWLVisitorBase { + + /** + * visit OWLAnonymousIndividual type + * + * @param individual object to visit + */ + default void visit(OWLAnonymousIndividual individual) { + doDefault(individual); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAnonymousIndividualVisitorExBase.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnonymousIndividualVisitorExBase.java new file mode 100644 index 0000000000..df0ddbaf62 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAnonymousIndividualVisitorExBase.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param visitor type + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLAnonymousIndividualVisitorExBase extends OWLVisitorExBase { + + /** + * visit OWLAnonymousIndividual type + * + * @param individual object to visit + * @return visitor value + */ + default O visit(OWLAnonymousIndividual individual) { + return doDefault(individual); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAsymmetricObjectPropertyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAsymmetricObjectPropertyAxiom.java new file mode 100644 index 0000000000..5bf2ce2c5c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAsymmetricObjectPropertyAxiom.java @@ -0,0 +1,81 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * Represents + * AsymmetricObjectProperty axioms in the OWL 2 specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLAsymmetricObjectPropertyAxiom extends OWLObjectPropertyCharacteristicAxiom { + + @Override + default Stream components() { + return Stream.of(getProperty(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getProperty().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getProperty()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getProperty()); + } + + @Override + default int hashIndex() { + return 3; + } + + @Override + @SuppressWarnings("unchecked") + OWLAsymmetricObjectPropertyAxiom getAxiomWithoutAnnotations(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.ASYMMETRIC_OBJECT_PROPERTY; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiom.java new file mode 100644 index 0000000000..7fc4cf3e4f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiom.java @@ -0,0 +1,282 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.equalStreams; + +import java.util.Arrays; +import java.util.Collection; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +/** + * Represents Axioms in the OWL 2 + * Specification.
+ * An OWL ontology contains a set of axioms. These axioms can be annotation axioms, declaration + * axioms, imports axioms or logical axioms + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLAxiom extends OWLObject, HasAnnotations { + + /** + * Gets an axiom that is structurally equivalent to the input axiom without annotations. This + * essentially returns a version of the axiom stripped of any annotations. + * + * @param type + * @param axiom axiom to divest of annotations + * @return The axiom without annotations + */ + @SuppressWarnings("unchecked") + static T getAxiomWithoutAnnotations(T axiom) { + return axiom.getAxiomWithoutAnnotations((Class) axiom.getClass()); + } + + /** + * Gets a copy of the input axiom that is annotated with the specified annotations. If the axiom + * has any annotations on it they will be merged with the specified set of annotations. Note + * that the input axiom will not be modified (or removed from any ontologies). + * + * @param axiom axiom to be copied + * @param annotations The annotations that will be added to existing annotations to annotate the + * copy of this axiom + * @param type of axiom returned + * @return A copy of this axiom that has the specified annotations plus any existing annotations + * returned by the {@code OWLAxiom#getAnnotations()} method. + */ + @SuppressWarnings("unchecked") + static T getAnnotatedAxiom(Stream annotations, T axiom) { + return axiom.getAnnotatedAxiom((Class) axiom.getClass(), annotations); + } + + /** + * Gets a copy of the input axiom that is annotated with the specified annotations. If the axiom + * has any annotations on it they will be merged with the specified set of annotations. Note + * that the input axiom will not be modified (or removed from any ontologies). + * + * @param axiom axiom to be copied + * @param annotations The annotations that will be added to existing annotations to annotate the + * copy of this axiom + * @param type of axiom returned + * @return A copy of this axiom that has the specified annotations plus any existing annotations + * returned by the {@code OWLAxiom#getAnnotations()} method. + */ + static T getAnnotatedAxiom(Collection annotations, + T axiom) { + return getAnnotatedAxiom(annotations.stream(), axiom); + } + + @Override + default int typeIndex() { + return 2000 + getAxiomType().getIndex(); + } + + @Override + default boolean isIndividual() { + return false; + } + + @Override + default boolean isAxiom() { + return true; + } + + /** + * @param visitor visitor to accept + */ + void accept(OWLAxiomVisitor visitor); + + /** + * @param visitor visitor to accept + * @param visitor return type + * @return visitor value + */ + O accept(OWLAxiomVisitorEx visitor); + + /** + * Gets an axiom that is structurally equivalent to this axiom without annotations. This + * essentially returns a version of this axiom stripped of any annotations. + * + * @param type + * @return The axiom without annotations + */ + T getAxiomWithoutAnnotations(); + + /** + * Gets an axiom that is structurally equivalent to this axiom without annotations. This + * essentially returns a version of this axiom stripped of any annotations.
+ *
+ * Calling {@code axiom.getAxiomWithoutAnnotations(axiom.getClass())} is equivalent to + * {@code axiom.getAxiomWithoutAnnotations()}, but it provides compile time type safety - there + * will be no attempt to cast to an incompatible type. + * + * @param type + * @param witness Variable to ground the generic return type + * @return The axiom without annotations + */ + @SuppressWarnings("unchecked") + default T getAxiomWithoutAnnotations( + @SuppressWarnings("unused") Class witness) { + return (T) getAxiomWithoutAnnotations(); + } + + /** + * Gets a copy of this axiom that is annotated with the specified annotations. If this axiom has + * any annotations on it they will be merged with the specified set of annotations. Note that + * this axiom will not be modified (or removed from any ontologies).
+ *
+ * Calling {@code axiom.getAnnotatedAxiom(axiom.getClass(), annotations)} is equivalent to + * {@code axiom.getAnnotatedAxiom(annotations)}, but it provides compile time type safety - + * there will be no attempt to cast to an incompatible type. + * + * @param type + * @param witness Variable to ground the generic return type + * @param annotations The annotations that will be added to existing annotations to annotate the + * copy of this axiom + * @return A copy of this axiom that has the specified annotations plus any existing annotations + * returned by the {@code OWLAxiom#getAnnotations()} method. + */ + @SuppressWarnings("unchecked") + default T getAnnotatedAxiom(@SuppressWarnings("unused") Class witness, + Stream annotations) { + return (T) getAnnotatedAxiom(annotations); + } + + /** + * Gets a copy of this axiom that is annotated with the specified annotations. If this axiom has + * any annotations on it they will be merged with the specified set of annotations. Note that + * this axiom will not be modified (or removed from any ontologies). + * + * @param type + * @param annotations The annotations that will be added to existing annotations to annotate the + * copy of this axiom + * @return A copy of this axiom that has the specified annotations plus any existing annotations + * returned by the {@code OWLAxiom#getAnnotations()} method. + */ + T getAnnotatedAxiom(Stream annotations); + + /** + * Gets a copy of this axiom that is annotated with the specified annotations. If this axiom has + * any annotations on it they will be merged with the specified set of annotations. Note that + * this axiom will not be modified (or removed from any ontologies). + * + * @param type + * @param annotations The annotations that will be added to existing annotations to annotate the + * copy of this axiom + * @return A copy of this axiom that has the specified annotations plus any existing annotations + * returned by the {@code OWLAxiom#getAnnotations()} method. + */ + default T getAnnotatedAxiom(Collection annotations) { + return getAnnotatedAxiom(annotations.stream()); + } + + /** + * Determines if another axiom is equal to this axiom not taking into consideration the + * annotations on the axiom + * + * @param axiom The axiom to test if equal + * @return {@code true} if {@code axiom} without annotations is equal to this axiom without + * annotations otherwise {@code false}. + */ + default boolean equalsIgnoreAnnotations(@Nullable OWLAxiom axiom) { + if (axiom == null) { + return false; + } + if (this == axiom) { + return true; + } + if (typeIndex() != axiom.typeIndex()) { + return false; + } + return equalStreams(componentsWithoutAnnotations(), axiom.componentsWithoutAnnotations()); + } + + /** + * Determines if this axiom is a logical axiom. Logical axioms are defined to be axioms other + * than both declaration axioms (including imports declarations) and annotation axioms. + * + * @return {@code true} if the axiom is a logical axiom, {@code false} if the axiom is not a + * logical axiom. + */ + default boolean isLogicalAxiom() { + return false; + } + + /** + * Determines if this axioms in an annotation axiom (an instance of {@code OWLAnnotationAxiom}) + * + * @return {@code true} if this axiom is an instance of {@code OWLAnnotationAxiom}, otherwise + * {@code false}. + * @since 3.2 + */ + default boolean isAnnotationAxiom() { + return false; + } + + /** + * Determines if this axiom has any annotations on it + * + * @return {@code true} if this axiom has annotations on it, otherwise {@code false} + */ + boolean isAnnotated(); + + /** + * Gets the axiom type for this axiom. + * + * @return The axiom type that corresponds to the type of this axiom. + */ + AxiomType getAxiomType(); + + /** + * Determines if this axiom is one of the specified types + * + * @param axiomTypes The axiom types to check for + * @return {@code true} if this axiom is one of the specified types, otherwise {@code false} + * @since 3.0 + */ + default boolean isOfType(AxiomType... axiomTypes) { + return isOfType(Arrays.stream(axiomTypes)); + } + + /** + * Determines if this axiom is one of the specified types + * + * @param types The axiom types to check for + * @return {@code true} if this axioms is one of the specified types, otherwise {@code false} + * @since 3.0 + */ + default boolean isOfType(Collection> types) { + return types.contains(getAxiomType()); + } + + /** + * Determines if this axiom is one of the specified types + * + * @param types The axiom types to check for + * @return {@code true} if this axioms is one of the specified types, otherwise {@code false} + * @since 3.0 + */ + default boolean isOfType(Stream> types) { + return types.anyMatch(getAxiomType()::equals); + } + + /** + * Gets this axioms in negation normal form. i.e. any class expressions involved in this axiom + * are converted into negation normal form. + * + * @return The axiom in negation normal form. + */ + OWLAxiom getNNF(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiomChange.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiomChange.java new file mode 100644 index 0000000000..e3382b51ba --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiomChange.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public abstract class OWLAxiomChange extends OWLOntologyChange { + + private final OWLAxiom axiom; + + /** + * @param ont the ontology to which the change is to be applied + * @param axiom the axiom to be changed + */ + public OWLAxiomChange(OWLOntology ont, OWLAxiom axiom) { + super(ont); + this.axiom = checkNotNull(axiom, "axiom cannot be null"); + } + + @Override + public Stream signature() { + return axiom.signature(); + } + + @Override + public boolean isAxiomChange() { + return true; + } + + @Override + public OWLAxiom getAxiom() { + return axiom; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiomCollection.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiomCollection.java new file mode 100644 index 0000000000..3a2b8bf45a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiomCollection.java @@ -0,0 +1,772 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.parameters.AxiomAnnotations; +import org.semanticweb.owlapi.model.parameters.Imports; + +/** + * Ontology methods related to it being a collection of axioms. + * + * @author ignazio + * @since 4.0.0 + */ +public interface OWLAxiomCollection + extends HasAxioms, HasLogicalAxioms, HasAxiomsByType, HasContainsAxiom, HasImportsClosure { + + /** + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return All of the axioms in this collection, and optionally in the import closure. The set + * that is returned is a copy; modifications to the returned set will not be reflected + * in this object. + */ + default Set getAxioms(Imports includeImportsClosure) { + return asSet(axioms(includeImportsClosure)); + } + + /** + * @param imports if INCLUDED, include imports closure. + * @return stream of all of the axioms in this collection, and optionally in the import closure. + */ + default Stream axioms(Imports imports) { + return imports.stream(this).flatMap(OWLOntology::axioms); + } + + /** + * @return The number of axioms in this ontology. + */ + int getAxiomCount(); + + /** + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return The number of axioms in this ontology, and optionally in the imports closure. + */ + int getAxiomCount(Imports includeImportsClosure); + + /** + * Gets all axioms semantically relevant, i.e., all axioms that are not annotation axioms or + * declaration axioms. + * + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return A set of axioms which are of type {@code OWLLogicalAxiom}, optionally including the + * imports closure. The set that is returned is a copy; modifications to the returned + * set will not be reflected in this object. + */ + default Set getLogicalAxioms(Imports includeImportsClosure) { + return asSet(logicalAxioms(includeImportsClosure)); + } + + /** + * Gets all axioms semantically relevant, i.e., all axioms that are not annotation axioms or + * declaration axioms. + * + * @param imports if INCLUDED, include imports closure. + * @return A stream of axioms which are of type {@code OWLLogicalAxiom}, optionally including + * the imports closure. + */ + default Stream logicalAxioms(Imports imports) { + return imports.stream(this).flatMap(OWLOntology::logicalAxioms); + } + + /** + * Gets the number of logical axioms in this collection. + * + * @return The number of axioms in this collection. + */ + int getLogicalAxiomCount(); + + /** + * Gets the number of logical axioms in this collection, optionally including the imports + * closure. + * + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return The number of axioms in this collection, optionally including the imports closure. + */ + int getLogicalAxiomCount(Imports includeImportsClosure); + + /** + * Gets all axioms of the specified type. + * + * @param axiomType The type of axioms to be retrieved. + * @param includeImportsClosure if INCLUDED, include imports closure. + * @param axiom type + * @return all axioms of the specified type. The set that is returned is a copy; modifications + * to the returned set will not be reflected in this object. + */ + default Set getAxioms(AxiomType axiomType, + Imports includeImportsClosure) { + return asSet(axioms(axiomType, includeImportsClosure)); + } + + /** + * Gets all axioms of the specified type. + * + * @param axiomType The type of axioms to be retrieved. + * @param imports if INCLUDED, include imports closure. + * @param axiom type + * @return stream of all axioms of the specified type. + */ + default Stream axioms(AxiomType axiomType, Imports imports) { + return imports.stream(this).flatMap(o -> o.axioms(axiomType)); + } + + /** + * Gets the axiom count of a specific type of axiom. + * + * @param axiomType The type of axiom to count + * @param axiom type class + * @return The number of the specified types of axioms in this collection + */ + int getAxiomCount(AxiomType axiomType); + + /** + * Gets the axiom count of a specific type of axiom, optionally including the imports closure. + * + * @param axiomType The type of axiom to count + * @param includeImportsClosure if INCLUDED, include imports closure. + * @param axiom type + * @return The number of the specified types of axioms in this collection + */ + int getAxiomCount(AxiomType axiomType, Imports includeImportsClosure); + + /** + * Determines if this ontology contains the specified axiom, optionally including the imports + * closure. + * + * @param axiom The axiom to search. + * @param includeImportsClosure if INCLUDED, include imports closure. + * @param ignoreAnnotations if IGNORE_ANNOTATIONS, annotations are ignored when searching for + * the axiom. For example, if the collection contains + * {@code SubClassOf(Annotation(p V) A B)} then this method will return {@code true} if + * the ontology contains {@code SubClassOf(A B)} or + * {@code SubClassOf(Annotation(q S) A B)} for any annotation property {@code q} and any + * annotation value {@code S}. + * @return {@code true} if the ontology contains the specified axiom. + */ + boolean containsAxiom(OWLAxiom axiom, Imports includeImportsClosure, + AxiomAnnotations ignoreAnnotations); + + /** + * Determines if this ontology contains the specified axiom. + * + * @param axiom The axiom to search. + * @return {@code true} if the ontology contains the specified axiom. + */ + boolean containsAxiomIgnoreAnnotations(OWLAxiom axiom); + + /** + * Gets the set of axioms contained in this collection that have the same "logical structure" as + * the specified axiom; i.e., all axioms that equal the specified axiom, when ignoring + * annotations. Optionally the imports closure is included. + * + * @param axiom The axiom that the returned axioms must equal, ignoring annotations. + * @return The set of axioms such that for any two axioms, {@code axiomA} and {@code axiomB} in + * the set, {@code axiomA.getAxiomWithoutAnnotations()} is equal to {@code + * axiomB.getAxiomWithoutAnnotations()}. The specified axiom will be contained in the set. The + * set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + */ + default Set getAxiomsIgnoreAnnotations(OWLAxiom axiom) { + return asSet(axiomsIgnoreAnnotations(axiom)); + } + + /** + * Gets the set of axioms contained in this collection that have the same "logical structure" as + * the specified axiom; i.e., all axioms that equal the specified axiom, when ignoring + * annotations. Optionally the imports closure is included. + * + * @param axiom The axiom that the returned axioms must equal, ignoring annotations. + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return The set of axioms such that for any two axioms, {@code axiomA} and {@code axiomB} in + * the set, {@code axiomA.getAxiomWithoutAnnotations()} is equal to {@code + * axiomB.getAxiomWithoutAnnotations()}. The specified axiom will be contained in the set. The + * set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + */ + default Set getAxiomsIgnoreAnnotations(OWLAxiom axiom, + Imports includeImportsClosure) { + return asSet(axiomsIgnoreAnnotations(axiom, includeImportsClosure)); + } + + /** + * Gets the stream of axioms contained in this collection that have the same "logical structure" + * as the specified axiom; i.e., all axioms that equal the specified axiom, when ignoring + * annotations. Optionally the imports closure is included. + * + * @param axiom The axiom that the returned axioms must equal, ignoring annotations. + * @return stream of axioms such that for any two axioms, {@code axiomA} and {@code axiomB}, + * {@code axiomA.getAxiomWithoutAnnotations()} is equal to {@code + * axiomB.getAxiomWithoutAnnotations()}. The specified axiom will be contained in the stream. + */ + Stream axiomsIgnoreAnnotations(OWLAxiom axiom); + + /** + * Gets the stream of axioms contained in this collection that have the same "logical structure" + * as the specified axiom; i.e., all axioms that equal the specified axiom, when ignoring + * annotations. Optionally the imports closure is included. + * + * @param axiom The axiom that the returned axioms must equal, ignoring annotations. + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return stream of axioms such that for any two axioms, {@code axiomA} and {@code axiomB}, + * {@code axiomA.getAxiomWithoutAnnotations()} is equal to {@code + * axiomB.getAxiomWithoutAnnotations()}. The specified axiom will be contained in the stream. + */ + Stream axiomsIgnoreAnnotations(OWLAxiom axiom, Imports includeImportsClosure); + + /** + * Gets the axioms where the specified {@link OWLPrimitive} appears in the signature of the + * axiom.
+ * Note that currently signatures contain {@link OWLEntity} only. This method accepts + * OWLPrimitive so that also anonymous individuals, literals, IRIs and annotation values can be + * passed in, although they are not included in the axioms' signatures. + * + * @param owlEntity The entity that should be directly referred to by all axioms in the results + * set. + * @return All axioms referencing the entity. The set that is returned is a copy; modifications + * to the returned set will not be reflected in this object. + */ + default Set getReferencingAxioms(OWLPrimitive owlEntity) { + return asSet(referencingAxioms(owlEntity)); + } + + /** + * Gets the axioms where the specified {@link OWLPrimitive} appears in the signature of the + * axiom.
+ * Note that currently signatures contain {@link OWLEntity} only. This method accepts + * OWLPrimitive so that also anonymous individuals, literals, IRIs and annotation values can be + * passed in, although they are not included in the axioms' signatures. + * + * @param owlEntity The entity that should be directly referred to by all axioms in the results + * set. + * @return Stream of all axioms referencing the entity. + */ + Stream referencingAxioms(OWLPrimitive owlEntity); + + /** + * Gets the axioms where the specified {@link OWLPrimitive} appears in the signature of the + * axiom.
+ * Note that currently signatures contain {@link OWLEntity} only. This method accepts + * OWLPrimitive so that also anonymous individuals, literals, IRIs and annotation values can be + * passed in, although they are not included in the axioms' signatures. + * + * @param owlEntity The entity that should be directly referred to by all axioms in the results + * set. + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return All axioms referencing the entity. The set that is returned is a copy; modifications + * to the returned set will not be reflected in this object. + */ + default Set getReferencingAxioms(OWLPrimitive owlEntity, + Imports includeImportsClosure) { + return asSet(referencingAxioms(owlEntity, includeImportsClosure)); + } + + /** + * Gets the axioms where the specified {@link OWLPrimitive} appears in the signature of the + * axiom.
+ * Note that currently signatures contain {@link OWLEntity} only. This method accepts + * OWLPrimitive so that also anonymous individuals, literals, IRIs and annotation values can be + * passed in, although they are not included in the axioms' signatures. + * + * @param owlEntity The entity that should be directly referred to by all axioms in the results + * set. + * @param imports if INCLUDED, include imports closure. + * @return stream of all axioms referencing the entity. + */ + default Stream referencingAxioms(OWLPrimitive owlEntity, Imports imports) { + return imports.stream(this).flatMap(o -> o.referencingAxioms(owlEntity)); + } + + // Axioms that form part of a description of a named entity + + /** + * Gets the axioms that form the definition/description of a class. + * + * @param cls The class whose describing axioms are to be retrieved. + * @return A set of class axioms that describe the class. This set includes + *

    + *
  • Subclass axioms where the subclass is equal to the specified class
  • + *
  • Equivalent class axioms where the specified class is an operand in the equivalent + * class axiom
  • + *
  • Disjoint class axioms where the specified class is an operand in the disjoint + * class axiom
  • + *
  • Disjoint union axioms, where the specified class is the named class that is + * equivalent to the disjoint union
  • + *
+ * The set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + */ + default Set getAxioms(OWLClass cls) { + return asSet(axioms(cls)); + } + + /** + * Gets the axioms that form the definition/description of a class. + * + * @param cls The class whose describing axioms are to be retrieved. + * @return A stream of class axioms that describe the class. This set includes + *
    + *
  • Subclass axioms where the subclass is equal to the specified class
  • + *
  • Equivalent class axioms where the specified class is an operand in the equivalent + * class axiom
  • + *
  • Disjoint class axioms where the specified class is an operand in the disjoint + * class axiom
  • + *
  • Disjoint union axioms, where the specified class is the named class that is + * equivalent to the disjoint union
  • + *
+ */ + Stream axioms(OWLClass cls); + + /** + * Gets the axioms that form the definition/description of a class. + * + * @param cls The class whose describing axioms are to be retrieved. + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return A set of class axioms that describe the class. This set includes + *
    + *
  • Subclass axioms where the subclass is equal to the specified class
  • + *
  • Equivalent class axioms where the specified class is an operand in the equivalent + * class axiom
  • + *
  • Disjoint class axioms where the specified class is an operand in the disjoint + * class axiom
  • + *
  • Disjoint union axioms, where the specified class is the named class that is + * equivalent to the disjoint union
  • + *
+ * The set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + */ + default Set getAxioms(OWLClass cls, Imports includeImportsClosure) { + return asSet(axioms(cls, includeImportsClosure)); + } + + // Axioms that form part of a description of a named entity + + /** + * Gets the axioms that form the definition/description of a class. + * + * @param cls The class whose describing axioms are to be retrieved. + * @param imports if INCLUDED, include imports closure. + * @return A stream of class axioms that describe the class. This includes + *
    + *
  • Subclass axioms where the subclass is equal to the specified class
  • + *
  • Equivalent class axioms where the specified class is an operand in the equivalent + * class axiom
  • + *
  • Disjoint class axioms where the specified class is an operand in the disjoint + * class axiom
  • + *
  • Disjoint union axioms, where the specified class is the named class that is + * equivalent to the disjoint union
  • + *
+ */ + default Stream axioms(OWLClass cls, Imports imports) { + return imports.stream(this).flatMap(o -> o.axioms(cls)); + } + + /** + * Gets the axioms that form the definition/description of an object property. + * + * @param property The property whose defining axioms are to be retrieved. + * @return A set of object property axioms that includes + *
    + *
  • Sub-property axioms where the sub property is the specified property
  • + *
  • Equivalent property axioms where the axiom contains the specified property
  • + *
  • Equivalent property axioms that contain the inverse of the specified + * property
  • + *
  • Disjoint property axioms that contain the specified property
  • + *
  • Domain axioms that specify a domain of the specified property
  • + *
  • Range axioms that specify a range of the specified property
  • + *
  • Any property characteristic axiom (i.e. Functional, Symmetric, Reflexive etc.) + * whose subject is the specified property
  • + *
  • Inverse properties axioms that contain the specified property
  • + *
+ * The set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + */ + default Set getAxioms(OWLObjectPropertyExpression property) { + return asSet(axioms(property)); + } + + /** + * Gets the axioms that form the definition/description of an object property. + * + * @param property The property whose defining axioms are to be retrieved. + * @return A stream of object property axioms that includes + *
    + *
  • Sub-property axioms where the sub property is the specified property
  • + *
  • Equivalent property axioms where the axiom contains the specified property
  • + *
  • Equivalent property axioms that contain the inverse of the specified + * property
  • + *
  • Disjoint property axioms that contain the specified property
  • + *
  • Domain axioms that specify a domain of the specified property
  • + *
  • Range axioms that specify a range of the specified property
  • + *
  • Any property characteristic axiom (i.e. Functional, Symmetric, Reflexive etc.) + * whose subject is the specified property
  • + *
  • Inverse properties axioms that contain the specified property
  • + *
+ */ + Stream axioms(OWLObjectPropertyExpression property); + + /** + * Gets the axioms that form the definition/description of an object property. + * + * @param property The property whose defining axioms are to be retrieved. + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return A set of object property axioms that includes + *
    + *
  • Sub-property axioms where the sub property is the specified property
  • + *
  • Equivalent property axioms where the axiom contains the specified property
  • + *
  • Equivalent property axioms that contain the inverse of the specified + * property
  • + *
  • Disjoint property axioms that contain the specified property
  • + *
  • Domain axioms that specify a domain of the specified property
  • + *
  • Range axioms that specify a range of the specified property
  • + *
  • Any property characteristic axiom (i.e. Functional, Symmetric, Reflexive etc.) + * whose subject is the specified property
  • + *
  • Inverse properties axioms that contain the specified property
  • + *
+ * The set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + */ + default Set getAxioms(OWLObjectPropertyExpression property, + Imports includeImportsClosure) { + return asSet(axioms(property, includeImportsClosure)); + } + + /** + * Gets the axioms that form the definition/description of an object property. + * + * @param property The property whose defining axioms are to be retrieved. + * @param imports if INCLUDED, include imports closure. + * @return A stream of object property axioms that includes + *
    + *
  • Sub-property axioms where the sub property is the specified property
  • + *
  • Equivalent property axioms where the axiom contains the specified property
  • + *
  • Equivalent property axioms that contain the inverse of the specified + * property
  • + *
  • Disjoint property axioms that contain the specified property
  • + *
  • Domain axioms that specify a domain of the specified property
  • + *
  • Range axioms that specify a range of the specified property
  • + *
  • Any property characteristic axiom (i.e. Functional, Symmetric, Reflexive etc.) + * whose subject is the specified property
  • + *
  • Inverse properties axioms that contain the specified property
  • + *
+ */ + default Stream axioms(OWLObjectPropertyExpression property, + Imports imports) { + return imports.stream(this).flatMap(o -> o.axioms(property)); + } + + /** + * Gets the axioms that form the definition/description of a data property. + * + * @param property The property whose defining axioms are to be retrieved. + * @return A set of data property axioms that includes + *
    + *
  • Sub-property axioms where the sub property is the specified property
  • + *
  • Equivalent property axioms where the axiom contains the specified property
  • + *
  • Disjoint property axioms that contain the specified property
  • + *
  • Domain axioms that specify a domain of the specified property
  • + *
  • Range axioms that specify a range of the specified property
  • + *
  • Any property characteristic axiom (i.e. Functional, Symmetric, Reflexive etc.) + * whose subject is the specified property
  • + *
+ * The set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + */ + default Set getAxioms(OWLDataProperty property) { + return asSet(axioms(property)); + } + + /** + * Gets the axioms that form the definition/description of a data property. + * + * @param property The property whose defining axioms are to be retrieved. + * @return A stream of data property axioms that includes + *
    + *
  • Sub-property axioms where the sub property is the specified property
  • + *
  • Equivalent property axioms where the axiom contains the specified property
  • + *
  • Disjoint property axioms that contain the specified property
  • + *
  • Domain axioms that specify a domain of the specified property
  • + *
  • Range axioms that specify a range of the specified property
  • + *
  • Any property characteristic axiom (i.e. Functional, Symmetric, Reflexive etc.) + * whose subject is the specified property
  • + *
+ */ + Stream axioms(OWLDataProperty property); + + /** + * Gets the axioms that form the definition/description of a data property. + * + * @param property The property whose defining axioms are to be retrieved. + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return A set of data property axioms that includes + *
    + *
  • Sub-property axioms where the sub property is the specified property
  • + *
  • Equivalent property axioms where the axiom contains the specified property
  • + *
  • Disjoint property axioms that contain the specified property
  • + *
  • Domain axioms that specify a domain of the specified property
  • + *
  • Range axioms that specify a range of the specified property
  • + *
  • Any property characteristic axiom (i.e. Functional, Symmetric, Reflexive etc.) + * whose subject is the specified property
  • + *
+ * The set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + */ + default Set getAxioms(OWLDataProperty property, + Imports includeImportsClosure) { + return asSet(axioms(property, includeImportsClosure)); + } + + /** + * Gets the axioms that form the definition/description of a data property. + * + * @param property The property whose defining axioms are to be retrieved. + * @param imports if INCLUDED, include imports closure. + * @return A stream of data property axioms that includes + *
    + *
  • Sub-property axioms where the sub property is the specified property
  • + *
  • Equivalent property axioms where the axiom contains the specified property
  • + *
  • Disjoint property axioms that contain the specified property
  • + *
  • Domain axioms that specify a domain of the specified property
  • + *
  • Range axioms that specify a range of the specified property
  • + *
  • Any property characteristic axiom (i.e. Functional, Symmetric, Reflexive etc.) + * whose subject is the specified property
  • + *
+ */ + default Stream axioms(OWLDataProperty property, Imports imports) { + return imports.stream(this).flatMap(o -> o.axioms(property)); + } + + /** + * Gets the axioms that form the definition/description of an individual. + * + * @param individual The individual whose defining axioms are to be retrieved. + * @return A set of individual axioms that includes + *
    + *
  • Individual type assertions that assert the type of the specified individual
  • + *
  • Same individuals axioms that contain the specified individual
  • + *
  • Different individuals axioms that contain the specified individual
  • + *
  • Object property assertion axioms whose subject is the specified individual
  • + *
  • Data property assertion axioms whose subject is the specified individual
  • + *
  • Negative object property assertion axioms whose subject is the specified + * individual
  • + *
  • Negative data property assertion axioms whose subject is the specified + * individual
  • + *
+ * The set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + */ + default Set getAxioms(OWLIndividual individual) { + return asSet(axioms(individual)); + } + + /** + * Gets the axioms that form the definition/description of an individual. + * + * @param individual The individual whose defining axioms are to be retrieved. + * @return A stream of individual axioms that includes + *
    + *
  • Individual type assertions that assert the type of the specified individual
  • + *
  • Same individuals axioms that contain the specified individual
  • + *
  • Different individuals axioms that contain the specified individual
  • + *
  • Object property assertion axioms whose subject is the specified individual
  • + *
  • Data property assertion axioms whose subject is the specified individual
  • + *
  • Negative object property assertion axioms whose subject is the specified + * individual
  • + *
  • Negative data property assertion axioms whose subject is the specified + * individual
  • + *
+ */ + Stream axioms(OWLIndividual individual); + + /** + * Gets the axioms that form the definition/description of an individual. + * + * @param individual The individual whose defining axioms are to be retrieved. + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return A set of individual axioms that includes + *
    + *
  • Individual type assertions that assert the type of the specified individual
  • + *
  • Same individuals axioms that contain the specified individual
  • + *
  • Different individuals axioms that contain the specified individual
  • + *
  • Object property assertion axioms whose subject is the specified individual
  • + *
  • Data property assertion axioms whose subject is the specified individual
  • + *
  • Negative object property assertion axioms whose subject is the specified + * individual
  • + *
  • Negative data property assertion axioms whose subject is the specified + * individual
  • + *
+ * The set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + */ + default Set getAxioms(OWLIndividual individual, + Imports includeImportsClosure) { + return asSet(axioms(individual, includeImportsClosure)); + } + + /** + * Gets the axioms that form the definition/description of an individual. + * + * @param individual The individual whose defining axioms are to be retrieved. + * @param imports if INCLUDED, include imports closure. + * @return A stream of individual axioms that includes + *
    + *
  • Individual type assertions that assert the type of the specified individual
  • + *
  • Same individuals axioms that contain the specified individual
  • + *
  • Different individuals axioms that contain the specified individual
  • + *
  • Object property assertion axioms whose subject is the specified individual
  • + *
  • Data property assertion axioms whose subject is the specified individual
  • + *
  • Negative object property assertion axioms whose subject is the specified + * individual
  • + *
  • Negative data property assertion axioms whose subject is the specified + * individual
  • + *
+ */ + default Stream axioms(OWLIndividual individual, Imports imports) { + return imports.stream(this).flatMap(o -> o.axioms(individual)); + } + + /** + * Gets the axioms that form the definition/description of an annotation property. + * + * @param property The property whose definition axioms are to be retrieved + * @return A set of axioms that includes + *
    + *
  • Annotation subpropertyOf axioms where the specified property is the sub + * property
  • + *
  • Annotation property domain axioms that specify a domain for the specified + * property
  • + *
  • Annotation property range axioms that specify a range for the specified + * property
  • + *
+ * The set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + */ + default Set getAxioms(OWLAnnotationProperty property) { + return asSet(axioms(property)); + } + + /** + * Gets the axioms that form the definition/description of an annotation property. + * + * @param property The property whose definition axioms are to be retrieved + * @return stream of axioms that includes + *
    + *
  • Annotation subpropertyOf axioms where the specified property is the sub + * property
  • + *
  • Annotation property domain axioms that specify a domain for the specified + * property
  • + *
  • Annotation property range axioms that specify a range for the specified + * property
  • + *
+ */ + default Stream axioms(OWLAnnotationProperty property) { + return Stream.of( + axioms(AxiomType.SUB_ANNOTATION_PROPERTY_OF) + .filter(a -> a.getSubProperty().equals(property)), + axioms(AxiomType.ANNOTATION_PROPERTY_RANGE) + .filter(a -> a.getProperty().equals(property)), + axioms(AxiomType.ANNOTATION_PROPERTY_DOMAIN) + .filter(a -> a.getProperty().equals(property))) + .flatMap(x -> x); + } + + /** + * Gets the axioms that form the definition/description of an annotation property. + * + * @param property The property whose definition axioms are to be retrieved + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return A set of axioms that includes + *
    + *
  • Annotation subpropertyOf axioms where the specified property is the sub + * property
  • + *
  • Annotation property domain axioms that specify a domain for the specified + * property
  • + *
  • Annotation property range axioms that specify a range for the specified + * property
  • + *
+ * The set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + */ + default Set getAxioms(OWLAnnotationProperty property, + Imports includeImportsClosure) { + return asSet(axioms(property, includeImportsClosure)); + } + + /** + * Gets the axioms that form the definition/description of an annotation property. + * + * @param property The property whose definition axioms are to be retrieved + * @param imports if INCLUDED, include imports closure. + * @return A stream of axioms that includes + *
    + *
  • Annotation subpropertyOf axioms where the specified property is the sub + * property
  • + *
  • Annotation property domain axioms that specify a domain for the specified + * property
  • + *
  • Annotation property range axioms that specify a range for the specified + * property
  • + *
+ */ + default Stream axioms(OWLAnnotationProperty property, Imports imports) { + return imports.stream(this).flatMap(o -> o.axioms(property)); + } + + /** + * Gets the datatype definition axioms for the specified datatype. + * + * @param datatype The datatype + * @return The set of datatype definition axioms for the specified datatype. The set that is + * returned is a copy; modifications to the returned set will not be reflected in this + * object. + */ + default Set getAxioms(OWLDatatype datatype) { + return asSet(axioms(datatype)); + } + + /** + * Gets the datatype definition axioms for the specified datatype. + * + * @param datatype The datatype + * @return stream of datatype definition axioms for the specified datatype. + */ + Stream axioms(OWLDatatype datatype); + + /** + * Gets the datatype definition axioms for the specified datatype. + * + * @param datatype The datatype + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return The set of datatype definition axioms for the specified datatype. The set that is + * returned is a copy; modifications to the returned set will not be reflected in this + * object. + */ + default Set getAxioms(OWLDatatype datatype, + Imports includeImportsClosure) { + return asSet(axioms(datatype, includeImportsClosure)); + } + + /** + * Gets the datatype definition axioms for the specified datatype. + * + * @param datatype The datatype + * @param imports if INCLUDED, include imports closure. + * @return stream of datatype definition axioms for the specified datatype. + */ + default Stream axioms(OWLDatatype datatype, Imports imports) { + return imports.stream(this).flatMap(o -> o.datatypeDefinitions(datatype)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiomCollectionBooleanArgs.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiomCollectionBooleanArgs.java new file mode 100644 index 0000000000..f1fadc29c3 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiomCollectionBooleanArgs.java @@ -0,0 +1,329 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Set; + +import org.semanticweb.owlapi.model.parameters.AxiomAnnotations; +import org.semanticweb.owlapi.model.parameters.Imports; + +/** + * Ontology methods related to it being a collection of axioms. This interface differs from + * OWLAxiomCollection because it uses booleans instead of Imports value to determine import closure + * inclusion. + * + * @author ignazio + * @since 4.0.0 + */ +public interface OWLAxiomCollectionBooleanArgs + extends HasAxioms, HasLogicalAxioms, HasAxiomsByType, HasContainsAxiom, OWLAxiomCollection { + + /** + * @param b true if imports are included. + * @return All of the axioms in this collection. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + * @deprecated use {@link #axioms(Imports)} instead + */ + @Deprecated + default Set getAxioms(boolean b) { + return getAxioms(Imports.fromBoolean(b)); + } + + /** + * @param includeImportsClosure if true, include imports closure. + * @return The number of axioms in this ontology, and optionally in the imports closure. + * @deprecated use {@link #getAxiomCount(Imports)} + */ + @Deprecated + default int getAxiomCount(boolean includeImportsClosure) { + return getAxiomCount(Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Gets all axioms semantically relevant, i.e., all axioms that are not annotation axioms or + * declaration axioms. + * + * @param includeImportsClosure if true, include imports closure. + * @return A set of axioms which are of type {@code OWLLogicalAxiom}, optionally including the + * imports closure. The set that is returned is a copy; modifications to the returned + * set will not be reflected in this object. + * @deprecated use {@link #logicalAxioms(Imports)} + */ + @Deprecated + default Set getLogicalAxioms(boolean includeImportsClosure) { + return getLogicalAxioms(Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Gets the number of logical axioms in this collection, optionally including the imports + * closure. + * + * @param includeImportsClosure if true, include imports closure. + * @return The number of axioms in this collection, optionally including the imports closure. + * @deprecated use {@link #getLogicalAxiomCount(Imports)} + */ + @Deprecated + default int getLogicalAxiomCount(boolean includeImportsClosure) { + return getLogicalAxiomCount(Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Gets all axioms of the specified type. + * + * @param axiomType The type of axioms to be retrieved. + * @param includeImportsClosure if true, include imports closure. + * @param axiom type + * @return all axioms of the specified type. The set that is returned is a copy; modifications + * to the returned set will not be reflected in this object. + * @deprecated use {@link #axioms(AxiomType, Imports)} + */ + @Deprecated + default Set getAxioms(AxiomType axiomType, + boolean includeImportsClosure) { + return getAxioms(axiomType, Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Gets the axiom count of a specific type of axiom, optionally including the imports closure. + * + * @param axiomType The type of axiom to count + * @param includeImportsClosure if INCLUDED, include imports closure. + * @param axiom type + * @return The number of the specified types of axioms in this collection + * @deprecated use {@link #getAxiomCount(AxiomType, Imports)} + */ + @Deprecated + default int getAxiomCount(AxiomType axiomType, + boolean includeImportsClosure) { + return getAxiomCount(axiomType, Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Determines if this ontology contains the specified axiom, optionally including the imports + * closure. + * + * @param axiom The axiom to search. + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return {@code true} if the ontology contains the specified axiom. + * @deprecated use {@link #containsAxiom(OWLAxiom, Imports, AxiomAnnotations)} + */ + @Deprecated + default boolean containsAxiom(OWLAxiom axiom, boolean includeImportsClosure) { + return containsAxiom(axiom, Imports.fromBoolean(includeImportsClosure), + AxiomAnnotations.CONSIDER_AXIOM_ANNOTATIONS); + } + + /** + * Determines if this ontology contains the specified axiom, optionally including the imports + * closure. Annotations are ignored when searching for the axiom. For example, if the collection + * contains {@code SubClassOf(Annotation(p V) A B)} then this method will return {@code true} if + * the ontology contains {@code SubClassOf(A B)} or {@code SubClassOf(Annotation(q S) A B)} for + * any annotation property {@code q} and any annotation value {@code S}. + * + * @param axiom The axiom to search. + * @param includeImportsClosure if true, include imports closure. + * @return {@code true} if the ontology contains the specified axiom. + * @deprecated use {@link #containsAxiom(OWLAxiom, Imports, AxiomAnnotations)} + */ + @Deprecated + default boolean containsAxiomIgnoreAnnotations(OWLAxiom axiom, boolean includeImportsClosure) { + return containsAxiom(axiom, Imports.fromBoolean(includeImportsClosure), + AxiomAnnotations.IGNORE_AXIOM_ANNOTATIONS); + } + + /** + * Gets the set of axioms contained in this collection that have the same "logical structure" as + * the specified axiom; i.e., all axioms that equal the specified axiom, when ignoring + * annotations. Optionally the imports closure is included. + * + * @param axiom The axiom that the returned axioms must equal, ignoring annotations. + * @param includeImportsClosure if true, include imports closure. + * @return The set of axioms such that for any two axioms, {@code axiomA} and {@code axiomB} in + * the set, {@code axiomA.getAxiomWithoutAnnotations()} is equal to {@code + * axiomB.getAxiomWithoutAnnotations()}. The specified axiom will be contained in the set. The + * set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + * @deprecated use {@link #axiomsIgnoreAnnotations(OWLAxiom, Imports)} + */ + @Deprecated + default Set getAxiomsIgnoreAnnotations(OWLAxiom axiom, + boolean includeImportsClosure) { + return getAxiomsIgnoreAnnotations(axiom, Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Gets the axioms where the specified {@link OWLPrimitive} appears in the signature of the + * axiom.
+ * Note that currently signatures contain {@link OWLEntity} only. This method accepts + * OWLPrimitive so that also anonymous individuals, literals, IRIs and annotation values can be + * passed in, although they are not included in the axioms' signatures. + * + * @param owlEntity The entity that should be directly referred to by all axioms in the results + * set. + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return All axioms referencing the entity. The set that is returned is a copy; modifications + * to the returned set will not be reflected in this object. + * @deprecated use {@link #referencingAxioms(OWLPrimitive, Imports)} + */ + @Deprecated + default Set getReferencingAxioms(OWLPrimitive owlEntity, + boolean includeImportsClosure) { + return getReferencingAxioms(owlEntity, Imports.fromBoolean(includeImportsClosure)); + } + + // Axioms that form part of a description of a named entity + + /** + * Gets the axioms that form the definition/description of a class. + * + * @param cls The class whose describing axioms are to be retrieved. + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return A set of class axioms that describe the class. This set includes + *
    + *
  • Subclass axioms where the subclass is equal to the specified class
  • + *
  • Equivalent class axioms where the specified class is an operand in the equivalent + * class axiom
  • + *
  • Disjoint class axioms where the specified class is an operand in the disjoint + * class axiom
  • + *
  • Disjoint union axioms, where the specified class is the named class that is + * equivalent to the disjoint union
  • + *
+ * The set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + * @deprecated use {@link #axioms(OWLClass, Imports)} instead + */ + @Deprecated + default Set getAxioms(OWLClass cls, boolean includeImportsClosure) { + return getAxioms(cls, Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Gets the axioms that form the definition/description of an object property. + * + * @param property The property whose defining axioms are to be retrieved. + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return A set of object property axioms that includes + *
    + *
  • Sub-property axioms where the sub property is the specified property
  • + *
  • Equivalent property axioms where the axiom contains the specified property
  • + *
  • Equivalent property axioms that contain the inverse of the specified + * property
  • + *
  • Disjoint property axioms that contain the specified property
  • + *
  • Domain axioms that specify a domain of the specified property
  • + *
  • Range axioms that specify a range of the specified property
  • + *
  • Any property characteristic axiom (i.e. Functional, Symmetric, Reflexive etc.) + * whose subject is the specified property
  • + *
  • Inverse properties axioms that contain the specified property
  • + *
+ * The set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + * @deprecated use {@link #axioms(OWLObjectPropertyExpression, Imports)} instead + */ + @Deprecated + default Set getAxioms(OWLObjectPropertyExpression property, + boolean includeImportsClosure) { + return getAxioms(property, Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Gets the axioms that form the definition/description of a data property. + * + * @param property The property whose defining axioms are to be retrieved. + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return A set of data property axioms that includes + *
    + *
  • Sub-property axioms where the sub property is the specified property
  • + *
  • Equivalent property axioms where the axiom contains the specified property
  • + *
  • Disjoint property axioms that contain the specified property
  • + *
  • Domain axioms that specify a domain of the specified property
  • + *
  • Range axioms that specify a range of the specified property
  • + *
  • Any property characteristic axiom (i.e. Functional, Symmetric, Reflexive etc.) + * whose subject is the specified property
  • + *
+ * The set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + * @deprecated use {@link #axioms(OWLDataProperty, Imports)} instead + */ + @Deprecated + default Set getAxioms(OWLDataProperty property, + boolean includeImportsClosure) { + return getAxioms(property, Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Gets the axioms that form the definition/description of an individual. + * + * @param individual The individual whose defining axioms are to be retrieved. + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return A set of individual axioms that includes + *
    + *
  • Individual type assertions that assert the type of the specified individual
  • + *
  • Same individuals axioms that contain the specified individual
  • + *
  • Different individuals axioms that contain the specified individual
  • + *
  • Object property assertion axioms whose subject is the specified individual
  • + *
  • Data property assertion axioms whose subject is the specified individual
  • + *
  • Negative object property assertion axioms whose subject is the specified + * individual
  • + *
  • Negative data property assertion axioms whose subject is the specified + * individual
  • + *
+ * The set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + * @deprecated use {@link #axioms(OWLIndividual, Imports)} instead + */ + @Deprecated + default Set getAxioms(OWLIndividual individual, + boolean includeImportsClosure) { + return getAxioms(individual, Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Gets the axioms that form the definition/description of an annotation property. + * + * @param property The property whose definition axioms are to be retrieved + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return A set of axioms that includes + *
    + *
  • Annotation subpropertyOf axioms where the specified property is the sub + * property
  • + *
  • Annotation property domain axioms that specify a domain for the specified + * property
  • + *
  • Annotation property range axioms that specify a range for the specified + * property
  • + *
+ * The set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + * @deprecated use {@link #axioms(OWLAnnotationProperty, Imports)} instead + */ + @Deprecated + default Set getAxioms(OWLAnnotationProperty property, + boolean includeImportsClosure) { + return getAxioms(property, Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Gets the datatype definition axioms for the specified datatype. + * + * @param datatype The datatype + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return The set of datatype definition axioms for the specified datatype. The set that is + * returned is a copy; modifications to the returned set will not be reflected in this + * object. + * @deprecated use {@link #axioms(OWLDatatype, Imports)} instead + */ + @Deprecated + default Set getAxioms(OWLDatatype datatype, + boolean includeImportsClosure) { + return getAxioms(datatype, Imports.fromBoolean(includeImportsClosure)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiomIndex.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiomIndex.java new file mode 100644 index 0000000000..2ce92b77f3 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiomIndex.java @@ -0,0 +1,1347 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.model.parameters.Imports.EXCLUDED; +import static org.semanticweb.owlapi.model.parameters.Navigation.IN_SUB_POSITION; +import static org.semanticweb.owlapi.model.parameters.Navigation.IN_SUPER_POSITION; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Collection; +import java.util.Set; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.parameters.Imports; +import org.semanticweb.owlapi.model.parameters.Navigation; +import org.semanticweb.owlapi.util.OWLAxiomSearchFilter; + +/** + * Axiom accessor methods - all OWLOntology methods that return sets (or streams) of axioms of a + * certain type or with a certain entity referred. + * + * @author ignazio + * @since 4.0.0 + */ +public interface OWLAxiomIndex extends HasImportsClosure { + + /** + * Generic search method: returns all axioms which refer entity, are instances of type, + * optionally including the imports closure in the results. + * + * @param type of returned axioms + * @param type type of axioms + * @param entity referred entity (OWLPrimitive or property/class expression) + * @param includeImports if INCLUDED, include imports closure. + * @param forSubPosition for sub axioms (subclass, subproperty), the value specifies whether + * entity should appear as sub or super entity in the axioms returned. For axiom types + * that have no sub/super entities, this parameter is ignored. + * @return set of axioms satisfying the conditions. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + */ + default Set getAxioms(Class type, OWLObject entity, + Imports includeImports, Navigation forSubPosition) { + return asSet(axioms(type, entity, includeImports, forSubPosition)); + } + + /** + * Generic search method: returns all axioms which refer entity, are instances of type, + * optionally including the imports closure in the results. + * + * @param type of returned axioms + * @param type type of axioms + * @param entity referred entity (OWLPrimitive or property/class expression) + * @param imports if INCLUDED, include imports closure. + * @param forSubPosition for sub axioms (subclass, subproperty), the value specifies whether + * entity should appear as sub or super entity in the axioms returned. For axiom types + * that have no sub/super entities, this parameter is ignored. + * @return stream of axioms satisfying the conditions. + */ + default Stream axioms(Class type, OWLObject entity, Imports imports, + Navigation forSubPosition) { + return imports.stream(this) + .flatMap(o -> o.axioms(type, entity.getClass(), entity, forSubPosition)); + } + + /** + * Generic search method: returns all axioms which refer entity, are instances of type, + * optionally including the imports closure in the results. + * + * @param type of returned axioms + * @param type type of axioms + * @param entity referred entity (OWLPrimitive or property/class expression) + * @param forSubPosition for sub axioms (subclass, subproperty), the value specifies whether + * entity should appear as sub or super entity in the axioms returned. For axiom types + * that have no sub/super entities, this parameter is ignored. + * @return set of axioms satisfying the conditions. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + */ + default Set getAxioms(Class type, OWLObject entity, + Navigation forSubPosition) { + return asSet(axioms(type, entity, forSubPosition)); + } + + /** + * Generic search method: returns all axioms which refer entity, are instances of type, + * optionally including the imports closure in the results. + * + * @param type of returned axioms + * @param type type of axioms + * @param entity referred entity (OWLPrimitive or property/class expression) + * @param forSubPosition for sub axioms (subclass, subproperty), the value specifies whether + * entity should appear as sub or super entity in the axioms returned. For axiom types + * that have no sub/super entities, this parameter is ignored. + * @return stream of axioms satisfying the conditions. + */ + default Stream axioms(Class type, OWLObject entity, + Navigation forSubPosition) { + return axioms(type, entity.getClass(), entity, forSubPosition); + } + + /** + * Generic filter type for further refining search by axiom type. The returned axioms are both + * belonging to one of the types listed by the filter and satisfying its pass condition. + * + * @param type of returned axioms + * @param filter the filter to match + * @param key the key. Its type is generic and it is used only by the filter. + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return a collection of axioms matching the request. The axioms are collected from a set, + * therefore the collection contains no duplicates. The collection that is returned is a + * copy; modifications to the returned collection will not be reflected in this object. + */ + default Collection filterAxioms(OWLAxiomSearchFilter filter, Object key, + Imports includeImportsClosure) { + return asSet(axioms(filter, key, includeImportsClosure)); + } + + /** + * Generic filter type for further refining search by axiom type. The returned axioms are both + * belonging to one of the types listed by the filter and satisfying its pass condition. + * + * @param type of returned axioms + * @param filter the filter to match + * @param key the key. Its type is generic and it is used only by the filter. + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return a stream of axioms matching the request. The axioms are collected from a set, + * therefore it contains no duplicates. + */ + Stream axioms(OWLAxiomSearchFilter filter, Object key, + Imports includeImportsClosure); + + /** + * Generic filter type for further refining search by axiom type. The returned axioms are both + * belonging to one of the types listed by the filter and satisfying its pass condition. + * + * @param type of returned axioms + * @param filter the filter to match + * @param key the key. Its type is generic and it is used only by the filter. + * @return a collection of axioms matching the request. The axioms are collected from a set, + * therefore the collection contains no duplicates. The collection that is returned is a + * copy; modifications to the returned collection will not be reflected in this object. + */ + default Collection filterAxioms(OWLAxiomSearchFilter filter, + Object key) { + return asSet(axioms(filter, key)); + } + + /** + * Generic filter type for further refining search by axiom type. The returned axioms are both + * belonging to one of the types listed by the filter and satisfying its pass condition. + * + * @param type of returned axioms + * @param filter the filter to match + * @param key the key. Its type is generic and it is used only by the filter. + * @return a stream of axioms matching the request. The axioms are collected from a set, + * therefore it contains no duplicates. + */ + Stream axioms(OWLAxiomSearchFilter filter, Object key); + + /** + * Generic containment check type for further refining search by axiom type. The method returns + * true if there is at least one result matching the filter. + * + * @param filter the filter to match + * @param key the key. Its type is generic and it is used only by the filter. + * @return true if there is at least one result matching the filter. + */ + boolean contains(OWLAxiomSearchFilter filter, Object key); + + /** + * Generic containment check type for further refining search by axiom type. The method returns + * true if there is at least one result matching the filter. + * + * @param filter the filter to match + * @param key the key. Its type is generic and it is used only by the filter. + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return true if there is at least one result matching the filter. + */ + boolean contains(OWLAxiomSearchFilter filter, Object key, Imports includeImportsClosure); + + /** + * Generic search method: returns all axioms which refer entity, are instances of type, + * optionally including the imports closure in the results. + * + * @param type of returned axioms + * @param type type of axioms + * @param explicitClass for overlapping indexes in the ontology internals, an explicit class + * rather than the entity class might be necessary + * @param entity referred entity (OWLPrimitive or property/class expression) + * @param forSubPosition for sub axioms (subclass, subproperty), the value specifies whether + * entity should appear as sub or super entity in the axioms returned. For axiom types + * that have no sub/super entities, this parameter is ignored. + * @return set of axioms satisfying the conditions. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + */ + default Set getAxioms(Class type, + Class explicitClass, OWLObject entity, Navigation forSubPosition) { + return asSet(axioms(type, explicitClass, entity, forSubPosition)); + } + + /** + * Generic search method: returns all axioms which refer entity, are instances of type, + * optionally including the imports closure in the results. + * + * @param type of returned axioms + * @param type type of axioms + * @param explicitClass for overlapping indexes in the ontology internals, an explicit class + * rather than the entity class might be necessary + * @param entity referred entity (OWLPrimitive or property/class expression) + * @param forSubPosition for sub axioms (subclass, subproperty), the value specifies whether + * entity should appear as sub or super entity in the axioms returned. For axiom types + * that have no sub/super entities, this parameter is ignored. + * @return stream of axioms satisfying the conditions. + */ + Stream axioms(Class type, Class explicitClass, + OWLObject entity, Navigation forSubPosition); + + /** + * Generic search method: returns all axioms which refer entity, are instances of type, + * optionally including the imports closure in the results. + * + * @param type of returned axioms + * @param type type of axioms + * @param explicitClass for overlapping indexes in the ontology internals, an explicit class + * rather than the entity class might be necessary + * @param entity referred entity (OWLPrimitive or property/class expression) + * @param includeImports if INCLUDED, include imports closure. + * @param forSubPosition for sub axioms (subclass, subproperty), the value specifies whether + * entity should appear as sub or super entity in the axioms returned. For axiom types + * that have no sub/super entities, this parameter is ignored. + * @return set of axioms satisfying the conditions. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + */ + default Set getAxioms(Class type, + Class explicitClass, OWLObject entity, Imports includeImports, + Navigation forSubPosition) { + return asSet(axioms(type, explicitClass, entity, includeImports, forSubPosition)); + } + + /** + * Generic search method: returns all axioms which refer entity, are instances of type, + * optionally including the imports closure in the results. + * + * @param type of returned axioms + * @param type type of axioms + * @param explicitClass for overlapping indexes in the ontology internals, an explicit class + * rather than the entity class might be necessary + * @param entity referred entity (OWLPrimitive or property/class expression) + * @param imports if INCLUDED, include imports closure. + * @param forSubPosition for sub axioms (subclass, subproperty), the value specifies whether + * entity should appear as sub or super entity in the axioms returned. For axiom types + * that have no sub/super entities, this parameter is ignored. + * @return stream of axioms satisfying the conditions. + */ + default Stream axioms(Class type, + Class explicitClass, OWLObject entity, Imports imports, + Navigation forSubPosition) { + return imports.stream(this) + .flatMap(o -> o.axioms(type, explicitClass, entity, forSubPosition)); + } + + // Annotation axioms + + /** + * Gets the {@code OWLSubAnnotationPropertyOfAxiom} objects where the specified property is the + * sub-property. + * + * @param subProperty The sub-property of the axioms to be retrieved. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getSubAnnotationPropertyOfAxioms( + OWLAnnotationProperty subProperty) { + return asSet(subAnnotationPropertyOfAxioms(subProperty)); + } + + /** + * Gets the {@code OWLSubAnnotationPropertyOfAxiom} objects where the specified property is the + * sub-property. + * + * @param subProperty The sub-property of the axioms to be retrieved. + * @return the axioms matching the search. + */ + Stream subAnnotationPropertyOfAxioms( + OWLAnnotationProperty subProperty); + + /** + * Gets the {@code OWLAnnotationPropertyDomainAxiom} objects where the specified property is the + * property in the domain axiom. + * + * @param property The property that the axiom specifies a domain for. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getAnnotationPropertyDomainAxioms( + OWLAnnotationProperty property) { + return asSet(annotationPropertyDomainAxioms(property)); + } + + /** + * Gets the {@code OWLAnnotationPropertyDomainAxiom} objects where the specified property is the + * property in the domain axiom. + * + * @param property The property that the axiom specifies a domain for. + * @return the axioms matching the search. + */ + Stream annotationPropertyDomainAxioms( + OWLAnnotationProperty property); + + /** + * Gets the {@code OWLAnnotationPropertyRangeAxiom} objects where the specified property is the + * property in the range axiom. + * + * @param property The property that the axiom specifies a range for. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getAnnotationPropertyRangeAxioms( + OWLAnnotationProperty property) { + return asSet(annotationPropertyRangeAxioms(property)); + } + + /** + * Gets the {@code OWLAnnotationPropertyRangeAxiom} objects where the specified property is the + * property in the range axiom. + * + * @param property The property that the axiom specifies a range for. + * @return the axioms matching the search. + */ + Stream annotationPropertyRangeAxioms( + OWLAnnotationProperty property); + + // Various methods that provide axioms relating to specific entities that + // allow frame style views to be composed for a particular entity. Such + // functionality is useful for ontology editors and browsers. + + /** + * Gets the declaration axioms for specified entity. + * + * @param subject The entity that is the subject of the returned axioms. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getDeclarationAxioms(OWLEntity subject) { + return getAxioms(OWLDeclarationAxiom.class, subject, EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the declaration axioms for specified entity. + * + * @param subject The entity that is the subject of the returned axioms. + * @return the axioms matching the search. + */ + default Stream declarationAxioms(OWLEntity subject) { + return axioms(OWLDeclarationAxiom.class, subject, EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the axioms that annotate the specified entity. + * + * @param entity The entity whose annotations are to be retrieved. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getAnnotationAssertionAxioms( + OWLAnnotationSubject entity) { + return asSet(annotationAssertionAxioms(entity, EXCLUDED)); + } + + /** + * Gets the axioms that annotate the specified entity. + * + * @param entity The entity whose annotations are to be retrieved. + * @param imports imports included or excluded + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getAnnotationAssertionAxioms( + OWLAnnotationSubject entity, Imports imports) { + return asSet(annotationAssertionAxioms(entity, imports)); + } + + /** + * Gets the axioms that annotate the specified entity. + * + * @param entity The entity whose annotations are to be retrieved. + * @return the axioms matching the search. + */ + default Stream annotationAssertionAxioms( + OWLAnnotationSubject entity) { + return annotationAssertionAxioms(entity, EXCLUDED); + } + + /** + * Gets the axioms that annotate the specified entity. + * + * @param entity The entity whose annotations are to be retrieved. + * @param imports imports included or excluded + * @return the axioms matching the search. + */ + default Stream annotationAssertionAxioms( + OWLAnnotationSubject entity, Imports imports) { + return axioms(OWLAnnotationAssertionAxiom.class, OWLAnnotationSubject.class, entity, + imports, IN_SUB_POSITION); + } + + // Classes + + /** + * Gets all of the subclass axioms where the left hand side (the subclass) is equal to the + * specified class. + * + * @param cls The class that is equal to the left hand side of the axiom (subclass). + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getSubClassAxiomsForSubClass(OWLClass cls) { + return asSet(subClassAxiomsForSubClass(cls)); + } + + /** + * Gets all of the subclass axioms where the left hand side (the subclass) is equal to the + * specified class. + * + * @param cls The class that is equal to the left hand side of the axiom (subclass). + * @return the axioms matching the search. + */ + default Stream subClassAxiomsForSubClass(OWLClass cls) { + return axioms(OWLSubClassOfAxiom.class, OWLClass.class, cls, EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets all of the subclass axioms where the right hand side (the superclass) is equal to the + * specified class. + * + * @param cls The class + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getSubClassAxiomsForSuperClass(OWLClass cls) { + return asSet(subClassAxiomsForSuperClass(cls)); + } + + /** + * Gets all of the subclass axioms where the right hand side (the superclass) is equal to the + * specified class. + * + * @param cls The class + * @return the axioms matching the search. + */ + default Stream subClassAxiomsForSuperClass(OWLClass cls) { + return axioms(OWLSubClassOfAxiom.class, OWLClass.class, cls, EXCLUDED, IN_SUPER_POSITION); + } + + /** + * Gets all of the equivalent axioms in this ontology that contain the specified class as an + * operand. + * + * @param cls The class to search + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getEquivalentClassesAxioms(OWLClass cls) { + return asSet(equivalentClassesAxioms(cls)); + } + + /** + * Gets all of the equivalent axioms in this ontology that contain the specified class as an + * operand. + * + * @param cls The class to search + * @return the axioms matching the search. + */ + default Stream equivalentClassesAxioms(OWLClass cls) { + return axioms(OWLEquivalentClassesAxiom.class, OWLClass.class, cls, EXCLUDED, + IN_SUB_POSITION); + } + + /** + * Gets the set of disjoint class axioms that contain the specified class as an operand. + * + * @param cls The class to search + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getDisjointClassesAxioms(OWLClass cls) { + return asSet(disjointClassesAxioms(cls)); + } + + /** + * Gets the stream of disjoint class axioms that contain the specified class as an operand. + * + * @param cls The class to search + * @return the axioms matching the search. + */ + default Stream disjointClassesAxioms(OWLClass cls) { + return axioms(OWLDisjointClassesAxiom.class, OWLClass.class, cls, EXCLUDED, + IN_SUB_POSITION); + } + + /** + * Gets the set of disjoint union axioms that have the specified class as the named class that + * is equivalent to the disjoint union of operands. For example, if the ontology contained the + * axiom DisjointUnion(A, propP some C, D, E) this axiom would be returned for class A (but not + * for D or E). + * + * @param owlClass The class that indexes the axioms to be retrieved. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getDisjointUnionAxioms(OWLClass owlClass) { + return asSet(disjointUnionAxioms(owlClass)); + } + + /** + * Gets the stream of disjoint union axioms that have the specified class as the named class + * that is equivalent to the disjoint union of operands. For example, if the ontology contained + * the axiom DisjointUnion(A, propP some C, D, E) this axiom would be returned for class A (but + * not for D or E). + * + * @param owlClass The class that indexes the axioms to be retrieved. + * @return the axioms matching the search. + */ + default Stream disjointUnionAxioms(OWLClass owlClass) { + return axioms(OWLDisjointUnionAxiom.class, OWLClass.class, owlClass, EXCLUDED, + IN_SUB_POSITION); + } + + /** + * Gets the has key axioms that have the specified class as their subject. + * + * @param cls The subject of the has key axioms + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getHasKeyAxioms(OWLClass cls) { + return asSet(hasKeyAxioms(cls)); + } + + /** + * Gets the has key axioms that have the specified class as their subject. + * + * @param cls The subject of the has key axioms + * @return the axioms matching the search. + */ + default Stream hasKeyAxioms(OWLClass cls) { + return axioms(OWLHasKeyAxiom.class, OWLClass.class, cls, EXCLUDED, IN_SUB_POSITION); + } + + // Object properties + + /** + * Gets the {@link OWLSubObjectPropertyOfAxiom} objects where the sub-property is equal to the + * specified property. + * + * @param subProperty The property which is equal to the sub property of the retrieved axioms. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getObjectSubPropertyAxiomsForSubProperty( + OWLObjectPropertyExpression subProperty) { + return asSet(objectSubPropertyAxiomsForSubProperty(subProperty)); + } + + /** + * Gets the {@link OWLSubObjectPropertyOfAxiom} objects where the sub-property is equal to the + * specified property. + * + * @param subProperty The property which is equal to the sub property of the retrieved axioms. + * @return the axioms matching the search. + */ + default Stream objectSubPropertyAxiomsForSubProperty( + OWLObjectPropertyExpression subProperty) { + return axioms(OWLSubObjectPropertyOfAxiom.class, OWLObjectPropertyExpression.class, + subProperty, EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLSubObjectPropertyOfAxiom} objects where the super-property is equal to the + * specified property. + * + * @param superProperty The property which is equal to the super-property of the retrieved + * axioms. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getObjectSubPropertyAxiomsForSuperProperty( + OWLObjectPropertyExpression superProperty) { + return asSet(objectSubPropertyAxiomsForSuperProperty(superProperty)); + } + + /** + * Gets the {@link OWLSubObjectPropertyOfAxiom} objects where the super-property is equal to the + * specified property. + * + * @param superProperty The property which is equal to the super-property of the retrieved + * axioms. + * @return the axioms matching the search. + */ + default Stream objectSubPropertyAxiomsForSuperProperty( + OWLObjectPropertyExpression superProperty) { + return axioms(OWLSubObjectPropertyOfAxiom.class, OWLObjectPropertyExpression.class, + superProperty, EXCLUDED, IN_SUPER_POSITION); + } + + /** + * Gets the {@link OWLObjectPropertyDomainAxiom} objects where the property is equal to the + * specified property. + * + * @param property The property which is equal to the property of the retrieved axioms. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getObjectPropertyDomainAxioms( + OWLObjectPropertyExpression property) { + return asSet(objectPropertyDomainAxioms(property)); + } + + /** + * Gets the {@link OWLObjectPropertyDomainAxiom} objects where the property is equal to the + * specified property. + * + * @param property The property which is equal to the property of the retrieved axioms. + * @return the axioms matching the search. + */ + default Stream objectPropertyDomainAxioms( + OWLObjectPropertyExpression property) { + return axioms(OWLObjectPropertyDomainAxiom.class, OWLObjectPropertyExpression.class, + property, EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLObjectPropertyRangeAxiom} objects where the property is equal to the + * specified property. + * + * @param property The property which is equal to the property of the retrieved axioms. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getObjectPropertyRangeAxioms( + OWLObjectPropertyExpression property) { + return asSet(objectPropertyRangeAxioms(property)); + } + + /** + * Gets the {@link OWLObjectPropertyRangeAxiom} objects where the property is equal to the + * specified property. + * + * @param property The property which is equal to the property of the retrieved axioms. + * @return the axioms matching the search. + */ + default Stream objectPropertyRangeAxioms( + OWLObjectPropertyExpression property) { + return axioms(OWLObjectPropertyRangeAxiom.class, OWLObjectPropertyExpression.class, + property, EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLInverseObjectPropertiesAxiom} objects where the specified property is + * contained in the set returned by {@link OWLInverseObjectPropertiesAxiom#properties()} . + * + * @param property The property which is equal to the property of the retrieved axioms. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getInverseObjectPropertyAxioms( + OWLObjectPropertyExpression property) { + return asSet(inverseObjectPropertyAxioms(property)); + } + + /** + * Gets the {@link OWLInverseObjectPropertiesAxiom} objects where the specified property is + * contained in the stream returned by {@link OWLInverseObjectPropertiesAxiom#properties()} . + * + * @param property The property which is equal to the property of the retrieved axioms. + * @return the axioms matching the search. + */ + default Stream inverseObjectPropertyAxioms( + OWLObjectPropertyExpression property) { + return axioms(OWLInverseObjectPropertiesAxiom.class, OWLObjectPropertyExpression.class, + property, EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLEquivalentObjectPropertiesAxiom} objects that make the specified property + * equivalent to some other object property expression(s). + * + * @param property The property that the retrieved axioms make equivalent to some other property + * expressions. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getEquivalentObjectPropertiesAxioms( + OWLObjectPropertyExpression property) { + return asSet(equivalentObjectPropertiesAxioms(property)); + } + + /** + * Gets the {@link OWLEquivalentObjectPropertiesAxiom} objects that make the specified property + * equivalent to some other object property expression(s). + * + * @param property The property that the retrieved axioms make equivalent to some other property + * expressions. + * @return the axioms matching the search. + */ + default Stream equivalentObjectPropertiesAxioms( + OWLObjectPropertyExpression property) { + return axioms(OWLEquivalentObjectPropertiesAxiom.class, OWLObjectPropertyExpression.class, + property, EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLDisjointObjectPropertiesAxiom} objects that make the specified property + * disjoint with some other object property expression(s). + * + * @param property The property that the retrieved axioms makes disjoint to some other property + * expressions. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getDisjointObjectPropertiesAxioms( + OWLObjectPropertyExpression property) { + return asSet(disjointObjectPropertiesAxioms(property)); + } + + /** + * Gets the {@link OWLDisjointObjectPropertiesAxiom} objects that make the specified property + * disjoint with some other object property expression(s). + * + * @param property The property that the retrieved axioms makes disjoint to some other property + * expressions. + * @return the axioms matching the search. + */ + default Stream disjointObjectPropertiesAxioms( + OWLObjectPropertyExpression property) { + return axioms(OWLDisjointObjectPropertiesAxiom.class, OWLObjectPropertyExpression.class, + property, EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLFunctionalObjectPropertyAxiom} objects contained in this ontology that + * make the specified object property functional. + * + * @param property The property that is made functional by the axioms. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getFunctionalObjectPropertyAxioms( + OWLObjectPropertyExpression property) { + return asSet(functionalObjectPropertyAxioms(property)); + } + + /** + * Gets the {@link OWLFunctionalObjectPropertyAxiom} objects contained in this ontology that + * make the specified object property functional. + * + * @param property The property that is made functional by the axioms. + * @return the axioms matching the search. + */ + default Stream functionalObjectPropertyAxioms( + OWLObjectPropertyExpression property) { + return axioms(OWLFunctionalObjectPropertyAxiom.class, OWLObjectPropertyExpression.class, + property, EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLInverseFunctionalObjectPropertyAxiom} objects contained in this ontology + * that make the specified object property inverse functional. + * + * @param property The property that is made inverse functional by the axioms. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getInverseFunctionalObjectPropertyAxioms( + OWLObjectPropertyExpression property) { + return asSet(inverseFunctionalObjectPropertyAxioms(property)); + } + + /** + * Gets the {@link OWLInverseFunctionalObjectPropertyAxiom} objects contained in this ontology + * that make the specified object property inverse functional. + * + * @param property The property that is made inverse functional by the axioms. + * @return the axioms matching the search. + */ + default Stream inverseFunctionalObjectPropertyAxioms( + OWLObjectPropertyExpression property) { + return axioms(OWLInverseFunctionalObjectPropertyAxiom.class, + OWLObjectPropertyExpression.class, property, EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLSymmetricObjectPropertyAxiom} objects contained in this ontology that make + * the specified object property symmetric. + * + * @param property The property that is made symmetric by the axioms. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getSymmetricObjectPropertyAxioms( + OWLObjectPropertyExpression property) { + return asSet(symmetricObjectPropertyAxioms(property)); + } + + /** + * Gets the {@link OWLSymmetricObjectPropertyAxiom} objects contained in this ontology that make + * the specified object property symmetric. + * + * @param property The property that is made symmetric by the axioms. + * @return the axioms matching the search. + */ + default Stream symmetricObjectPropertyAxioms( + OWLObjectPropertyExpression property) { + return axioms(OWLSymmetricObjectPropertyAxiom.class, OWLObjectPropertyExpression.class, + property, EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLAsymmetricObjectPropertyAxiom} objects contained in this ontology that + * make the specified object property asymmetric. + * + * @param property The property that is made asymmetric by the axioms. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getAsymmetricObjectPropertyAxioms( + OWLObjectPropertyExpression property) { + return asSet(asymmetricObjectPropertyAxioms(property)); + } + + /** + * Gets the {@link OWLAsymmetricObjectPropertyAxiom} objects contained in this ontology that + * make the specified object property asymmetric. + * + * @param property The property that is made asymmetric by the axioms. + * @return the axioms matching the search. + */ + default Stream asymmetricObjectPropertyAxioms( + OWLObjectPropertyExpression property) { + return axioms(OWLAsymmetricObjectPropertyAxiom.class, OWLObjectPropertyExpression.class, + property, EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLReflexiveObjectPropertyAxiom} objects contained in this ontology that make + * the specified object property reflexive. + * + * @param property The property that is made reflexive by the axioms. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getReflexiveObjectPropertyAxioms( + OWLObjectPropertyExpression property) { + return asSet(reflexiveObjectPropertyAxioms(property)); + } + + /** + * Gets the {@link OWLReflexiveObjectPropertyAxiom} objects contained in this ontology that make + * the specified object property reflexive. + * + * @param property The property that is made reflexive by the axioms. + * @return the axioms matching the search. + */ + default Stream reflexiveObjectPropertyAxioms( + OWLObjectPropertyExpression property) { + return axioms(OWLReflexiveObjectPropertyAxiom.class, OWLObjectPropertyExpression.class, + property, EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLIrreflexiveObjectPropertyAxiom} objects contained in this ontology that + * make the specified object property irreflexive. + * + * @param property The property that is made irreflexive by the axioms. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getIrreflexiveObjectPropertyAxioms( + OWLObjectPropertyExpression property) { + return asSet(irreflexiveObjectPropertyAxioms(property)); + } + + /** + * Gets the {@link OWLIrreflexiveObjectPropertyAxiom} objects contained in this ontology that + * make the specified object property irreflexive. + * + * @param property The property that is made irreflexive by the axioms. + * @return the axioms matching the search. + */ + default Stream irreflexiveObjectPropertyAxioms( + OWLObjectPropertyExpression property) { + return axioms(OWLIrreflexiveObjectPropertyAxiom.class, OWLObjectPropertyExpression.class, + property, EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLTransitiveObjectPropertyAxiom} objects contained in this ontology that + * make the specified object property transitive. + * + * @param property The property that is made transitive by the axioms. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getTransitiveObjectPropertyAxioms( + OWLObjectPropertyExpression property) { + return asSet(transitiveObjectPropertyAxioms(property)); + } + + /** + * Gets the {@link OWLTransitiveObjectPropertyAxiom} objects contained in this ontology that + * make the specified object property transitive. + * + * @param property The property that is made transitive by the axioms. + * @return the axioms matching the search. + */ + default Stream transitiveObjectPropertyAxioms( + OWLObjectPropertyExpression property) { + return axioms(OWLTransitiveObjectPropertyAxiom.class, OWLObjectPropertyExpression.class, + property, EXCLUDED, IN_SUB_POSITION); + } + + // Data properties + + /** + * Gets the {@link OWLSubDataPropertyOfAxiom} objects where the sub-property is equal to the + * specified property. + * + * @param subProperty The property which is equal to the sub property of the retrieved axioms. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getDataSubPropertyAxiomsForSubProperty( + OWLDataProperty subProperty) { + return asSet(dataSubPropertyAxiomsForSubProperty(subProperty)); + } + + /** + * Gets the {@link OWLSubDataPropertyOfAxiom} objects where the sub-property is equal to the + * specified property. + * + * @param subProperty The property which is equal to the sub property of the retrieved axioms. + * @return the axioms matching the search. + */ + default Stream dataSubPropertyAxiomsForSubProperty( + OWLDataProperty subProperty) { + return axioms(OWLSubDataPropertyOfAxiom.class, OWLDataPropertyExpression.class, subProperty, + EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLSubDataPropertyOfAxiom} objects where the super-property is equal to the + * specified property. + * + * @param superProperty The property which is equal to the super-property of the retrieved + * axioms. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getDataSubPropertyAxiomsForSuperProperty( + OWLDataPropertyExpression superProperty) { + return asSet(dataSubPropertyAxiomsForSuperProperty(superProperty)); + } + + /** + * Gets the {@link OWLSubDataPropertyOfAxiom} objects where the super-property is equal to the + * specified property. + * + * @param superProperty The property which is equal to the super-property of the retrieved + * axioms. + * @return the axioms matching the search. + */ + default Stream dataSubPropertyAxiomsForSuperProperty( + OWLDataPropertyExpression superProperty) { + return axioms(OWLSubDataPropertyOfAxiom.class, OWLDataPropertyExpression.class, + superProperty, EXCLUDED, IN_SUPER_POSITION); + } + + /** + * Gets the {@link OWLDataPropertyDomainAxiom} objects where the property is equal to the + * specified property. + * + * @param property The property which is equal to the property of the retrieved axioms. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getDataPropertyDomainAxioms(OWLDataProperty property) { + return asSet(dataPropertyDomainAxioms(property)); + } + + /** + * Gets the {@link OWLDataPropertyDomainAxiom} objects where the property is equal to the + * specified property. + * + * @param property The property which is equal to the property of the retrieved axioms. + * @return the axioms matching the search. + */ + default Stream dataPropertyDomainAxioms(OWLDataProperty property) { + return axioms(OWLDataPropertyDomainAxiom.class, OWLDataPropertyExpression.class, property, + EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLDataPropertyRangeAxiom} objects where the property is equal to the + * specified property. + * + * @param property The property which is equal to the property of the retrieved axioms. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getDataPropertyRangeAxioms(OWLDataProperty property) { + return asSet(dataPropertyRangeAxioms(property)); + } + + /** + * Gets the {@link OWLDataPropertyRangeAxiom} objects where the property is equal to the + * specified property. + * + * @param property The property which is equal to the property of the retrieved axioms. + * @return the axioms matching the search. + */ + default Stream dataPropertyRangeAxioms(OWLDataProperty property) { + return axioms(OWLDataPropertyRangeAxiom.class, OWLDataPropertyExpression.class, property, + EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLEquivalentDataPropertiesAxiom} objects that make the specified property + * equivalent to some other data property expression(s). + * + * @param property The property that the retrieved axioms make equivalent to some other property + * expressions. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getEquivalentDataPropertiesAxioms( + OWLDataProperty property) { + return asSet(equivalentDataPropertiesAxioms(property)); + } + + /** + * Gets the {@link OWLEquivalentDataPropertiesAxiom} objects that make the specified property + * equivalent to some other data property expression(s). + * + * @param property The property that the retrieved axioms make equivalent to some other property + * expressions. + * @return the axioms matching the search. + */ + default Stream equivalentDataPropertiesAxioms( + OWLDataProperty property) { + return axioms(OWLEquivalentDataPropertiesAxiom.class, OWLDataPropertyExpression.class, + property, EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLDisjointDataPropertiesAxiom} objects that make the specified property + * disjoint with some other data property expression(s). + * + * @param property The property that the retrieved axioms makes disjoint to some other property + * expressions. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getDisjointDataPropertiesAxioms( + OWLDataProperty property) { + return asSet(disjointDataPropertiesAxioms(property)); + } + + /** + * Gets the {@link OWLDisjointDataPropertiesAxiom} objects that make the specified property + * disjoint with some other data property expression(s). + * + * @param property The property that the retrieved axioms makes disjoint to some other property + * expressions. + * @return the axioms matching the search. + */ + default Stream disjointDataPropertiesAxioms( + OWLDataProperty property) { + return axioms(OWLDisjointDataPropertiesAxiom.class, OWLDataPropertyExpression.class, + property, EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLFunctionalDataPropertyAxiom} objects contained in this ontology that make + * the specified data property functional. + * + * @param property The property that is made functional by the axioms. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getFunctionalDataPropertyAxioms( + OWLDataPropertyExpression property) { + return asSet(functionalDataPropertyAxioms(property)); + } + + /** + * Gets the {@link OWLFunctionalDataPropertyAxiom} objects contained in this ontology that make + * the specified data property functional. + * + * @param property The property that is made functional by the axioms. + * @return the axioms matching the search. + */ + default Stream functionalDataPropertyAxioms( + OWLDataPropertyExpression property) { + return axioms(OWLFunctionalDataPropertyAxiom.class, OWLDataPropertyExpression.class, + property, EXCLUDED, IN_SUB_POSITION); + } + + // Individuals + + /** + * Gets the {@link OWLClassAssertionAxiom} objects contained in this ontology that make the + * specified {@code individual} an instance of some class expression. + * + * @param individual The individual that the returned axioms make an instance of some class + * expression. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getClassAssertionAxioms(OWLIndividual individual) { + return asSet(classAssertionAxioms(individual)); + } + + /** + * Gets the {@link OWLClassAssertionAxiom} objects contained in this ontology that make the + * specified {@code individual} an instance of some class expression. + * + * @param individual The individual that the returned axioms make an instance of some class + * expression. + * @return the axioms matching the search. + */ + default Stream classAssertionAxioms(OWLIndividual individual) { + return axioms(OWLClassAssertionAxiom.class, OWLIndividual.class, individual, EXCLUDED, + IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLClassAssertionAxiom} objects contained in this ontology that make the + * specified class expression, {@code ce}, a type for some individual. + * + * @param ce The class expression that the returned axioms make a type for some individual. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getClassAssertionAxioms(OWLClassExpression ce) { + return asSet(classAssertionAxioms(ce)); + } + + /** + * Gets the {@link OWLClassAssertionAxiom} objects contained in this ontology that make the + * specified class expression, {@code ce}, a type for some individual. + * + * @param ce The class expression that the returned axioms make a type for some individual. + * @return the axioms matching the search. + */ + default Stream classAssertionAxioms(OWLClassExpression ce) { + return axioms(OWLClassAssertionAxiom.class, OWLClassExpression.class, ce, EXCLUDED, + IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLDataPropertyAssertionAxiom} objects contained in this ontology that have + * the specified {@code individual} as the subject of the axiom. + * + * @param individual The individual that the returned axioms have as a subject. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getDataPropertyAssertionAxioms( + OWLIndividual individual) { + return asSet(dataPropertyAssertionAxioms(individual)); + } + + /** + * Gets the {@link OWLDataPropertyAssertionAxiom} objects contained in this ontology that have + * the specified {@code individual} as the subject of the axiom. + * + * @param individual The individual that the returned axioms have as a subject. + * @return the axioms matching the search. + */ + default Stream dataPropertyAssertionAxioms( + OWLIndividual individual) { + return axioms(OWLDataPropertyAssertionAxiom.class, OWLIndividual.class, individual, + EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLObjectPropertyAssertionAxiom} objects contained in this ontology that have + * the specified {@code individual} as the subject of the axiom. + * + * @param individual The individual that the returned axioms have as a subject. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getObjectPropertyAssertionAxioms( + OWLIndividual individual) { + return asSet(objectPropertyAssertionAxioms(individual)); + } + + /** + * Gets the {@link OWLObjectPropertyAssertionAxiom} objects contained in this ontology that have + * the specified {@code individual} as the subject of the axiom. + * + * @param individual The individual that the returned axioms have as a subject. + * @return the axioms matching the search. + */ + default Stream objectPropertyAssertionAxioms( + OWLIndividual individual) { + return axioms(OWLObjectPropertyAssertionAxiom.class, OWLIndividual.class, individual, + EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLNegativeObjectPropertyAssertionAxiom} objects contained in this ontology + * that have the specified {@code individual} as the subject of the axiom. + * + * @param individual The individual that the returned axioms have as a subject. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getNegativeObjectPropertyAssertionAxioms( + OWLIndividual individual) { + return asSet(negativeObjectPropertyAssertionAxioms(individual)); + } + + /** + * Gets the {@link OWLNegativeObjectPropertyAssertionAxiom} objects contained in this ontology + * that have the specified {@code individual} as the subject of the axiom. + * + * @param individual The individual that the returned axioms have as a subject. + * @return the axioms matching the search. + */ + default Stream negativeObjectPropertyAssertionAxioms( + OWLIndividual individual) { + return axioms(OWLNegativeObjectPropertyAssertionAxiom.class, OWLIndividual.class, + individual, EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLNegativeDataPropertyAssertionAxiom} objects contained in this ontology + * that have the specified {@code individual} as the subject of the axiom. + * + * @param individual The individual that the returned axioms have as a subject. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getNegativeDataPropertyAssertionAxioms( + OWLIndividual individual) { + return asSet(negativeDataPropertyAssertionAxioms(individual)); + } + + /** + * Gets the {@link OWLNegativeDataPropertyAssertionAxiom} objects contained in this ontology + * that have the specified {@code individual} as the subject of the axiom. + * + * @param individual The individual that the returned axioms have as a subject. + * @return the axioms matching the search. + */ + default Stream negativeDataPropertyAssertionAxioms( + OWLIndividual individual) { + return axioms(OWLNegativeDataPropertyAssertionAxiom.class, OWLIndividual.class, individual, + EXCLUDED, IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLSameIndividualAxiom} objects contained in this ontology that make the + * specified {@code individual} the same as some other individual. + * + * @param individual The individual that the returned axioms make the same as some other + * individual. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getSameIndividualAxioms(OWLIndividual individual) { + return asSet(sameIndividualAxioms(individual)); + } + + /** + * Gets the {@link OWLSameIndividualAxiom} objects contained in this ontology that make the + * specified {@code individual} the same as some other individual. + * + * @param individual The individual that the returned axioms make the same as some other + * individual. + * @return the axioms matching the search. + */ + default Stream sameIndividualAxioms(OWLIndividual individual) { + return axioms(OWLSameIndividualAxiom.class, OWLIndividual.class, individual, EXCLUDED, + IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLDifferentIndividualsAxiom} objects contained in this ontology that make + * the specified {@code individual} different to some other individual. + * + * @param individual The individual that the returned axioms make the different as some other + * individual. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getDifferentIndividualAxioms( + OWLIndividual individual) { + return asSet(differentIndividualAxioms(individual)); + } + + /** + * Gets the {@link OWLDifferentIndividualsAxiom} objects contained in this ontology that make + * the specified {@code individual} different to some other individual. + * + * @param individual The individual that the returned axioms make the different as some other + * individual. + * @return the axioms matching the search. + */ + default Stream differentIndividualAxioms( + OWLIndividual individual) { + return axioms(OWLDifferentIndividualsAxiom.class, OWLIndividual.class, individual, EXCLUDED, + IN_SUB_POSITION); + } + + /** + * Gets the {@link OWLDatatypeDefinitionAxiom} objects contained in this ontology that provide a + * definition for the specified datatype. + * + * @param datatype The datatype for which the returned axioms provide a definition. + * @return the axioms matching the search. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + */ + default Set getDatatypeDefinitions(OWLDatatype datatype) { + return asSet(datatypeDefinitions(datatype)); + } + + /** + * Gets the {@link OWLDatatypeDefinitionAxiom} objects contained in this ontology that provide a + * definition for the specified datatype. + * + * @param datatype The datatype for which the returned axioms provide a definition. + * @return the axioms matching the search. + */ + Stream datatypeDefinitions(OWLDatatype datatype); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiomVisitor.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiomVisitor.java new file mode 100644 index 0000000000..a4d9fde8fa --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiomVisitor.java @@ -0,0 +1,37 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface for objects that can accept visits from axioms. (See the + * Visitor Patterns) + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLAxiomVisitor extends OWLAnnotationAxiomVisitor, OWLLogicalAxiomVisitor { + + /** + * @param axiom axiom to visit + */ + default void visit(OWLDeclarationAxiom axiom) { + doDefault(axiom); + } + + /** + * @param axiom axiom to visit + */ + default void visit(OWLDatatypeDefinitionAxiom axiom) { + doDefault(axiom); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiomVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiomVisitorEx.java new file mode 100644 index 0000000000..b78f576b05 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLAxiomVisitorEx.java @@ -0,0 +1,45 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface for objects that can accept visits from axioms. (See the + * Visitor Patterns) + * + * @param visitor return type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public interface OWLAxiomVisitorEx extends OWLAnnotationAxiomVisitorEx, + OWLLogicalAxiomVisitorEx { + + /** + * visit OWLDeclarationAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLDeclarationAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLDatatypeDefinitionAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLDatatypeDefinitionAxiom axiom) { + return doDefault(axiom); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLBooleanClassExpression.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLBooleanClassExpression.java new file mode 100644 index 0000000000..2717a6a9b4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLBooleanClassExpression.java @@ -0,0 +1,21 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLBooleanClassExpression extends OWLAnonymousClassExpression { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLCardinalityRestriction.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLCardinalityRestriction.java new file mode 100644 index 0000000000..a83c6fe07c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLCardinalityRestriction.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * @param value + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLCardinalityRestriction + extends OWLQuantifiedRestriction, HasCardinality { + + @Override + default Stream components() { + return Stream.of(getProperty(), Integer.valueOf(getCardinality()), getFiller()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getProperty().hashCode()); + hash = OWLObject.hashIteration(hash, getCardinality()); + return OWLObject.hashIteration(hash, getFiller().hashCode()); + } + + /** + * Determines if this restriction is qualified. Qualified cardinality restrictions are defined + * to be cardinality restrictions that have fillers which aren't TOP (owl:Thing or + * rdfs:Literal). An object restriction is unqualified if it has a filler that is owl:Thing. A + * data restriction is unqualified if it has a filler which is the top data type (rdfs:Literal). + * + * @return {@code true} if this restriction is qualified, or {@code false} if this restriction + * is unqualified. + */ + default boolean isQualified() { + return !getFiller().isTopEntity(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLClass.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLClass.java new file mode 100644 index 0000000000..2bdfa2b565 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLClass.java @@ -0,0 +1,103 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents a Class in + * the OWL 2 specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLClass extends OWLClassExpression, OWLLogicalEntity, OWLNamedObject { + + @Override + default int hashIndex() { + return 157; + } + + @Override + default int typeIndex() { + return 1001; + } + + @Override + default EntityType getEntityType() { + return EntityType.CLASS; + } + + @Override + default ClassExpressionType getClassExpressionType() { + return ClassExpressionType.OWL_CLASS; + } + + @Override + default boolean isTopEntity() { + return isOWLThing(); + } + + @Override + default boolean isBottomEntity() { + return isOWLNothing(); + } + + @Override + default boolean isClassExpressionLiteral() { + return true; + } + + @Override + default boolean isOWLClass() { + return true; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLClassExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLClassExpressionVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLEntityVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLEntityVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLNamedObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLNamedObjectVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLClassAssertionAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLClassAssertionAxiom.java new file mode 100644 index 0000000000..bd3bf1cb94 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLClassAssertionAxiom.java @@ -0,0 +1,96 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * Represents ClassAssertion + * axioms in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLClassAssertionAxiom extends OWLIndividualAxiom, OWLSubClassOfAxiomShortCut { + + @Override + default Stream components() { + return Stream.of(getIndividual(), getClassExpression(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getIndividual().hashCode()); + hash = OWLObject.hashIteration(hash, getClassExpression().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getIndividual(), getClassExpression()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getIndividual(), getClassExpression()); + } + + @Override + default int hashIndex() { + return 7; + } + + @Override + @SuppressWarnings("unchecked") + OWLClassAssertionAxiom getAxiomWithoutAnnotations(); + + /** + * Gets the individual that is asserted to be an instance of a class expression by this axiom. + * + * @return The individual + */ + OWLIndividual getIndividual(); + + /** + * Gets the class expression that is asserted to be a type for an individual by this axiom. + * + * @return The class expression + */ + OWLClassExpression getClassExpression(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.CLASS_ASSERTION; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLClassAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLClassAxiom.java new file mode 100644 index 0000000000..89aae5dca6 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLClassAxiom.java @@ -0,0 +1,21 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLClassAxiom extends OWLLogicalAxiom { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLClassExpression.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLClassExpression.java new file mode 100644 index 0000000000..8ce52e7af4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLClassExpression.java @@ -0,0 +1,155 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * Represents Class Expressions in + * the OWL 2 specification. This interface covers named and anonymous classes. + * + * @author Matthew Horridge The University Of Manchester Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLClassExpression extends OWLObject, OWLPropertyRange, SWRLPredicate, AsOWLClass { + + /** + * Gets the class expression type for this class expression. + * + * @return The class expression type + */ + ClassExpressionType getClassExpressionType(); + + /** + * Determines if this class is a literal. A literal being either a named class or the negation + * of a named class (i.e. A or not(A)). + * + * @return {@code true} if this is a literal, or false if this is not a literal. + */ + default boolean isClassExpressionLiteral() { + return false; + } + + /** + * Determines if this expression is the built in class owl:Thing. This method does not determine + * if the class is equivalent to owl:Thing. + * + * @return {@code true} if this expression is owl:Thing, or {@code false} if this expression is + * not owl:Thing + */ + boolean isOWLThing(); + + /** + * Determines if this expression is the built in class owl:Nothing. This method does not + * determine if the class is equivalent to owl:Nothing. + * + * @return {@code true} if this expression is owl:Nothing, or {@code false} if this expression + * is not owl:Nothing. + */ + boolean isOWLNothing(); + + /** + * Gets this expression in negation normal form. + * + * @return The expression in negation normal form. + */ + OWLClassExpression getNNF(); + + /** + * Gets the negation normal form of the complement of this expression. + * + * @return A expression that represents the NNF of the complement of this expression. + */ + OWLClassExpression getComplementNNF(); + + /** + * Gets the object complement of this class expression. + * + * @return A class expression that is the complement of this class expression. + */ + OWLClassExpression getObjectComplementOf(); + + /** + * Interprets this expression as a conjunction and returns the conjuncts. This method does not + * normalise the expression (full CNF is not computed). + * + * @return The conjuncts of this expression if it is a conjunction (object intersection of), or + * otherwise a singleton set containing this expression. Note that nested conjunctions + * will be flattened, for example, calling this method on (A and B) and C will return + * the set {A, B, C} + */ + default Stream conjunctSet() { + return asConjunctSet().stream().sorted(); + } + + /** + * Interprets this expression as a conjunction and returns the conjuncts. This method does not + * normalise the expression (full CNF is not computed). + * + * @return The sorted stream of conjuncts of this expression if it is a conjunction (object + * intersection of), or otherwise a singleton set containing this expression. Note that + * nested conjunctions will be flattened, for example, calling this method on (A and B) + * and C will return the set {A, B, C} + */ + Set asConjunctSet(); + + /** + * Determines if this class expression contains a particular conjunct. This method does not do + * any normalisation such as applying DeMorgan's rules. + * + * @param ce The conjunct to test for + * @return {@code true} if this class expression is equal to {@code ce} or if this class + * expression is an {@code ObjectIntersectionOf} (possibly nested within another {@code + * ObjectIntersectionOf}) that contains {@code ce}, otherwise {@code false}. + */ + boolean containsConjunct(OWLClassExpression ce); + + /** + * Interprets this expression as a disjunction and returns the disjuncts. This method does not + * normalise the expression (full DNF is not computed). + * + * @return The sorted stream of disjuncts of this expression if it is a disjunction (object + * union of), or otherwise a singleton set containing this expression. Note that nested + * disjunctions will be flattened, for example, calling this method on (A or B) or C + * will return the set {A, B, C} + */ + default Stream disjunctSet() { + return asDisjunctSet().stream().sorted(); + } + + /** + * Interprets this expression as a disjunction and returns the disjuncts. This method does not + * normalise the expression (full DNF is not computed). + * + * @return The disjuncts of this expression if it is a disjunction (object union of), or + * otherwise a singleton set containing this expression. Note that nested disjunctions + * will be flattened, for example, calling this method on (A or B) or C will return the + * set {A, B, C} + */ + Set asDisjunctSet(); + + /** + * Accepts a visit from an {@code OWLExpressionVisitor}. + * + * @param visitor The visitor that wants to visit + */ + void accept(OWLClassExpressionVisitor visitor); + + /** + * @param visitor visitor + * @param visitor return type + * @return visitor return value + */ + O accept(OWLClassExpressionVisitorEx visitor); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLClassExpressionVisitor.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLClassExpressionVisitor.java new file mode 100644 index 0000000000..6edb208b69 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLClassExpressionVisitor.java @@ -0,0 +1,177 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface to objects that can visit + * {@link org.semanticweb.owlapi.model.OWLClassExpression}s. (See the + * Visitor Patterns) + * + * @author Matthew Horridge, The University Of Manchester Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLClassExpressionVisitor extends OWLClassVisitorBase { + + /** + * visit OWLObjectIntersectionOf type + * + * @param ce ce to visit + */ + default void visit(OWLObjectIntersectionOf ce) { + doDefault(ce); + } + + /** + * visit OWLObjectUnionOf type + * + * @param ce ce to visit + */ + default void visit(OWLObjectUnionOf ce) { + doDefault(ce); + } + + /** + * visit OWLObjectComplementOf type + * + * @param ce ce to visit + */ + default void visit(OWLObjectComplementOf ce) { + doDefault(ce); + } + + /** + * visit OWLObjectSomeValuesFrom type + * + * @param ce ce to visit + */ + default void visit(OWLObjectSomeValuesFrom ce) { + doDefault(ce); + } + + /** + * visit OWLObjectAllValuesFrom type + * + * @param ce ce to visit + */ + default void visit(OWLObjectAllValuesFrom ce) { + doDefault(ce); + } + + /** + * visit OWLObjectHasValue type + * + * @param ce ce to visit + */ + default void visit(OWLObjectHasValue ce) { + doDefault(ce); + } + + /** + * visit OWLObjectMinCardinality type + * + * @param ce ce to visit + */ + default void visit(OWLObjectMinCardinality ce) { + doDefault(ce); + } + + /** + * visit OWLObjectExactCardinality type + * + * @param ce ce to visit + */ + default void visit(OWLObjectExactCardinality ce) { + doDefault(ce); + } + + /** + * visit OWLObjectMaxCardinality type + * + * @param ce ce to visit + */ + default void visit(OWLObjectMaxCardinality ce) { + doDefault(ce); + } + + /** + * visit OWLObjectHasSelf type + * + * @param ce ce to visit + */ + default void visit(OWLObjectHasSelf ce) { + doDefault(ce); + } + + /** + * visit OWLObjectOneOf type + * + * @param ce ce to visit + */ + default void visit(OWLObjectOneOf ce) { + doDefault(ce); + } + + /** + * visit OWLDataSomeValuesFrom type + * + * @param ce ce to visit + */ + default void visit(OWLDataSomeValuesFrom ce) { + doDefault(ce); + } + + /** + * visit OWLDataAllValuesFrom type + * + * @param ce ce to visit + */ + default void visit(OWLDataAllValuesFrom ce) { + doDefault(ce); + } + + /** + * visit OWLDataHasValue type + * + * @param ce ce to visit + */ + default void visit(OWLDataHasValue ce) { + doDefault(ce); + } + + /** + * visit OWLDataMinCardinality type + * + * @param ce ce to visit + */ + default void visit(OWLDataMinCardinality ce) { + doDefault(ce); + } + + /** + * visit OWLDataExactCardinality type + * + * @param ce ce to visit + */ + default void visit(OWLDataExactCardinality ce) { + doDefault(ce); + } + + /** + * visit OWLDataMaxCardinality type + * + * @param ce ce to visit + */ + default void visit(OWLDataMaxCardinality ce) { + doDefault(ce); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLClassExpressionVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLClassExpressionVisitorEx.java new file mode 100644 index 0000000000..a8b8da40f8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLClassExpressionVisitorEx.java @@ -0,0 +1,195 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface to objects that can visit + * {@link org.semanticweb.owlapi.model.OWLClassExpression}s. (See the + * Visitor Patterns) + * + * @param visitor return type + * @author Matthew Horridge, The University Of Manchester Bio-Health Informatics Group + * @since 3.0.0 + */ +public interface OWLClassExpressionVisitorEx extends OWLClassVisitorExBase { + + /** + * visit OWLObjectIntersectionOf type + * + * @param ce ce to visit + * @return visitor value + */ + default O visit(OWLObjectIntersectionOf ce) { + return doDefault(ce); + } + + /** + * visit OWLObjectUnionOf type + * + * @param ce ce to visit + * @return visitor value + */ + default O visit(OWLObjectUnionOf ce) { + return doDefault(ce); + } + + /** + * visit OWLObjectComplementOf type + * + * @param ce ce to visit + * @return visitor value + */ + default O visit(OWLObjectComplementOf ce) { + return doDefault(ce); + } + + /** + * visit OWLObjectSomeValuesFrom type + * + * @param ce ce to visit + * @return visitor value + */ + default O visit(OWLObjectSomeValuesFrom ce) { + return doDefault(ce); + } + + /** + * visit OWLObjectAllValuesFrom type + * + * @param ce ce to visit + * @return visitor value + */ + default O visit(OWLObjectAllValuesFrom ce) { + return doDefault(ce); + } + + /** + * visit OWLObjectHasValue type + * + * @param ce ce to visit + * @return visitor value + */ + default O visit(OWLObjectHasValue ce) { + return doDefault(ce); + } + + /** + * visit OWLObjectMinCardinality type + * + * @param ce ce to visit + * @return visitor value + */ + default O visit(OWLObjectMinCardinality ce) { + return doDefault(ce); + } + + /** + * visit OWLObjectExactCardinality type + * + * @param ce ce to visit + * @return visitor value + */ + default O visit(OWLObjectExactCardinality ce) { + return doDefault(ce); + } + + /** + * visit OWLObjectMaxCardinality type + * + * @param ce ce to visit + * @return visitor value + */ + default O visit(OWLObjectMaxCardinality ce) { + return doDefault(ce); + } + + /** + * visit OWLObjectHasSelf type + * + * @param ce ce to visit + * @return visitor value + */ + default O visit(OWLObjectHasSelf ce) { + return doDefault(ce); + } + + /** + * visit OWLObjectOneOf type + * + * @param ce ce to visit + * @return visitor value + */ + default O visit(OWLObjectOneOf ce) { + return doDefault(ce); + } + + /** + * visit OWLDataSomeValuesFrom type + * + * @param ce ce to visit + * @return visitor value + */ + default O visit(OWLDataSomeValuesFrom ce) { + return doDefault(ce); + } + + /** + * visit OWLDataAllValuesFrom type + * + * @param ce ce to visit + * @return visitor value + */ + default O visit(OWLDataAllValuesFrom ce) { + return doDefault(ce); + } + + /** + * visit OWLDataHasValue type + * + * @param ce ce to visit + * @return visitor value + */ + default O visit(OWLDataHasValue ce) { + return doDefault(ce); + } + + /** + * visit OWLDataMinCardinality type + * + * @param ce ce to visit + * @return visitor value + */ + default O visit(OWLDataMinCardinality ce) { + return doDefault(ce); + } + + /** + * visit OWLDataExactCardinality type + * + * @param ce ce to visit + * @return visitor value + */ + default O visit(OWLDataExactCardinality ce) { + return doDefault(ce); + } + + /** + * visit OWLDataMaxCardinality type + * + * @param ce ce to visit + * @return visitor value + */ + default O visit(OWLDataMaxCardinality ce) { + return doDefault(ce); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLClassVisitorBase.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLClassVisitorBase.java new file mode 100644 index 0000000000..688eed6a42 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLClassVisitorBase.java @@ -0,0 +1,33 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface to objects that can visit + * {@link org.semanticweb.owlapi.model.OWLClassExpression}s. (See the + * Visitor Patterns) + * + * @author Matthew Horridge, The University Of Manchester Bio-Health Informatics Group + * @since 3.0.0 + */ +public interface OWLClassVisitorBase extends OWLVisitorBase { + + /** + * visit OWLClass type + * + * @param ce ce to visit + */ + default void visit(OWLClass ce) { + doDefault(ce); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLClassVisitorExBase.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLClassVisitorExBase.java new file mode 100644 index 0000000000..3a41121de8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLClassVisitorExBase.java @@ -0,0 +1,35 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface to objects that can visit + * {@link org.semanticweb.owlapi.model.OWLClassExpression}s. (See the + * Visitor Patterns) + * + * @param visitor return type + * @author Matthew Horridge, The University Of Manchester Bio-Health Informatics Group + * @since 3.0.0 + */ +public interface OWLClassVisitorExBase extends OWLVisitorExBase { + + /** + * visit OWLClass type + * + * @param ce ce to visit + * @return visitor value + */ + default O visit(OWLClass ce) { + return doDefault(ce); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataAllValuesFrom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataAllValuesFrom.java new file mode 100644 index 0000000000..b30e88fe67 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataAllValuesFrom.java @@ -0,0 +1,59 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents + * + * DataAllValuesFrom class expressions in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataAllValuesFrom extends OWLQuantifiedDataRestriction { + + @Override + default int hashIndex() { + return 163; + } + + @Override + default int typeIndex() { + return 3013; + } + + @Override + default ClassExpressionType getClassExpressionType() { + return ClassExpressionType.DATA_ALL_VALUES_FROM; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLClassExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLClassExpressionVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataCardinalityRestriction.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataCardinalityRestriction.java new file mode 100644 index 0000000000..aa332d106b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataCardinalityRestriction.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents Data Property Cardinality Restrictions in the OWL 2 specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataCardinalityRestriction extends + OWLCardinalityRestriction, OWLQuantifiedDataRestriction, + OWLDataRestriction { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataComplementOf.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataComplementOf.java new file mode 100644 index 0000000000..8baab2a618 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataComplementOf.java @@ -0,0 +1,87 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * Represents + * DataComplementOf in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataComplementOf extends OWLDataRange { + + @Override + default Stream components() { + return Stream.of(getDataRange()); + } + + @Override + default int initHashCode() { + return OWLObject.hashIteration(hashIndex(), getDataRange().hashCode()); + } + + @Override + default int hashIndex() { + return 257; + } + + @Override + default int typeIndex() { + return 4002; + } + + /** + * Gets the data range which this data range is a complement of. + * + * @return The complemented data range. + */ + OWLDataRange getDataRange(); + + @Override + default DataRangeType getDataRangeType() { + return DataRangeType.DATA_COMPLEMENT_OF; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLDataVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLDataVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLDataRangeVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLDataRangeVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataEntityVisitorBase.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataEntityVisitorBase.java new file mode 100644 index 0000000000..1666b398c9 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataEntityVisitorBase.java @@ -0,0 +1,29 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 3.0.0 + */ +public interface OWLDataEntityVisitorBase extends OWLVisitorBase { + + /** + * visit OWLDatatype type + * + * @param node node to visit + */ + default void visit(OWLDatatype node) { + doDefault(node); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataEntityVisitorExBase.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataEntityVisitorExBase.java new file mode 100644 index 0000000000..4e86410d8d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataEntityVisitorExBase.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param return type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 3.0.0 + */ +public interface OWLDataEntityVisitorExBase extends OWLVisitorExBase { + + /** + * visit OWLDatatype type + * + * @param node node to visit + * @return visitor value + */ + default O visit(OWLDatatype node) { + return doDefault(node); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataExactCardinality.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataExactCardinality.java new file mode 100644 index 0000000000..3a231abff6 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataExactCardinality.java @@ -0,0 +1,67 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents + * DataExactCardinality restrictions in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataExactCardinality extends OWLDataCardinalityRestriction { + + @Override + default int hashIndex() { + return 167; + } + + @Override + default int typeIndex() { + return 3016; + } + + @Override + default ClassExpressionType getClassExpressionType() { + return ClassExpressionType.DATA_EXACT_CARDINALITY; + } + + /** + * Obtains an equivalent form that is a conjunction of a min cardinality and max cardinality + * restriction. + * + * @return The semantically equivalent but structurally simpler form simp(= 1 R C) = >= 1 R C + * and <= 1 R C + */ + OWLClassExpression asIntersectionOfMinMax(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLClassExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLClassExpressionVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataFactory.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataFactory.java new file mode 100644 index 0000000000..b861469c7b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataFactory.java @@ -0,0 +1,178 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.axiomproviders.DeclarationAxiomProvider; +import org.semanticweb.owlapi.model.axiomproviders.DisjointAxiomProvider; +import org.semanticweb.owlapi.model.axiomproviders.DisjointUnionAxiomProvider; +import org.semanticweb.owlapi.model.axiomproviders.DomainAxiomProvider; +import org.semanticweb.owlapi.model.axiomproviders.EquivalentAxiomProvider; +import org.semanticweb.owlapi.model.axiomproviders.HasKeyAxiomProvider; +import org.semanticweb.owlapi.model.axiomproviders.InverseAxiomProvider; +import org.semanticweb.owlapi.model.axiomproviders.PropertyChainAxiomProvider; +import org.semanticweb.owlapi.model.axiomproviders.PropertyCharacteristicAxiomProvider; +import org.semanticweb.owlapi.model.axiomproviders.RangeAxiomProvider; +import org.semanticweb.owlapi.model.axiomproviders.SubAxiomProvider; +import org.semanticweb.owlapi.model.providers.AnnotationAssertionProvider; +import org.semanticweb.owlapi.model.providers.AnnotationProvider; +import org.semanticweb.owlapi.model.providers.AnonymousIndividualByIdProvider; +import org.semanticweb.owlapi.model.providers.AnonymousIndividualProvider; +import org.semanticweb.owlapi.model.providers.CardinalityRestrictionProvider; +import org.semanticweb.owlapi.model.providers.ClassAssertionProvider; +import org.semanticweb.owlapi.model.providers.ComplementProvider; +import org.semanticweb.owlapi.model.providers.DataAssertionProvider; +import org.semanticweb.owlapi.model.providers.DatatypeExpressionProvider; +import org.semanticweb.owlapi.model.providers.EntityByTypeProvider; +import org.semanticweb.owlapi.model.providers.EntityProvider; +import org.semanticweb.owlapi.model.providers.ExistentialProvider; +import org.semanticweb.owlapi.model.providers.HasSelfProvider; +import org.semanticweb.owlapi.model.providers.HasValueProvider; +import org.semanticweb.owlapi.model.providers.IndividualAssertionProvider; +import org.semanticweb.owlapi.model.providers.IntersectionProvider; +import org.semanticweb.owlapi.model.providers.InverseProvider; +import org.semanticweb.owlapi.model.providers.LiteralProvider; +import org.semanticweb.owlapi.model.providers.NominalProvider; +import org.semanticweb.owlapi.model.providers.OWLVocabularyProvider; +import org.semanticweb.owlapi.model.providers.ObjectAssertionProvider; +import org.semanticweb.owlapi.model.providers.SWRLProvider; +import org.semanticweb.owlapi.model.providers.UnionProvider; +import org.semanticweb.owlapi.model.providers.UniversalProvider; + +/** + * An interface for creating entities, class expressions and axioms. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataFactory extends SWRLProvider, EntityProvider, EntityByTypeProvider, + AnonymousIndividualProvider, + AnonymousIndividualByIdProvider, OWLVocabularyProvider, LiteralProvider, AnnotationProvider, + AnnotationAssertionProvider, ClassAssertionProvider, DataAssertionProvider, + ObjectAssertionProvider, + IndividualAssertionProvider, CardinalityRestrictionProvider, DisjointAxiomProvider, + EquivalentAxiomProvider, + PropertyCharacteristicAxiomProvider, DatatypeExpressionProvider, DomainAxiomProvider, + RangeAxiomProvider, + IntersectionProvider, UnionProvider, SubAxiomProvider, DeclarationAxiomProvider, + ComplementProvider, + NominalProvider, UniversalProvider, ExistentialProvider, HasKeyAxiomProvider, + InverseAxiomProvider, + HasValueProvider, InverseProvider, HasSelfProvider, DisjointUnionAxiomProvider, + PropertyChainAxiomProvider { + + /** + * @param importedOntologyIRI imported ontology + * @return an imports declaration + */ + OWLImportsDeclaration getOWLImportsDeclaration(IRI importedOntologyIRI); + + /** + * Empty all caches + */ + void purge(); + + /** + * Shorthand for + * {@code getOWLAnnotation(getRDFSLabel(), getOWLLiteral(value))} + * + * @param value The annotation value. + * @return an rdfs:label annotation with provided value + */ + default OWLAnnotation getRDFSLabel(String value) { + return getOWLAnnotation(getRDFSLabel(), getOWLLiteral(value)); + } + + /** + * Shorthand for + * {@code getOWLAnnotation(getRDFSLabel(), getOWLLiteral(value), annotations)} + * + * @param value The annotation value. + * @param annotations annotations + * @return an rdfs:label annotation with provided value + */ + default OWLAnnotation getRDFSLabel(String value, Stream annotations) { + return getOWLAnnotation(getRDFSLabel(), getOWLLiteral(value), annotations); + } + + /** + * Shorthand for + * {@code getOWLAnnotation(getRDFSLabel(), getOWLLiteral(value))} + * + * @param value The annotation value. + * @return an rdfs:label annotation with provided value + */ + default OWLAnnotation getRDFSLabel(OWLAnnotationValue value) { + return getOWLAnnotation(getRDFSLabel(), value); + } + + /** + * Shorthand for + * {@code getOWLAnnotation(getRDFSLabel(), getOWLLiteral(value), annotations)} + * + * @param value The annotation value. + * @param annotations annotations + * @return an rdfs:label annotation with provided value + */ + default OWLAnnotation getRDFSLabel(OWLAnnotationValue value, + Stream annotations) { + return getOWLAnnotation(getRDFSLabel(), value, annotations); + } + + /** + * Shorthand for + * {@code getOWLAnnotation(getRDFSComment(), getOWLLiteral(value))} + * + * @param value The annotation value. + * @return an rdfs:comment annotation with provided value + */ + default OWLAnnotation getRDFSComment(String value) { + return getOWLAnnotation(getRDFSComment(), getOWLLiteral(value)); + } + + /** + * Shorthand for + * {@code getOWLAnnotation(getRDFSComment(), getOWLLiteral(value), annotations)} + * + * @param value The annotation value. + * @param annotations annotations + * @return an rdfs:comment annotation with provided value + */ + default OWLAnnotation getRDFSComment(String value, Stream annotations) { + return getOWLAnnotation(getRDFSComment(), getOWLLiteral(value), annotations); + } + + /** + * Shorthand for + * {@code getOWLAnnotation(getRDFSComment(), getOWLLiteral(value))} + * + * @param value The annotation value. + * @return an rdfs:comment annotation with provided value + */ + default OWLAnnotation getRDFSComment(OWLAnnotationValue value) { + return getOWLAnnotation(getRDFSComment(), value); + } + + /** + * Shorthand for + * {@code getOWLAnnotation(getRDFSComment(), getOWLLiteral(value), annotations)} + * + * @param value The annotation value. + * @param annotations annotations + * @return an rdfs:comment annotation with provided value + */ + default OWLAnnotation getRDFSComment(OWLAnnotationValue value, + Stream annotations) { + return getOWLAnnotation(getRDFSComment(), value, annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataHasValue.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataHasValue.java new file mode 100644 index 0000000000..f32c7a5a45 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataHasValue.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents + * DataHasValue restrictions in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataHasValue extends OWLHasValueRestriction, OWLDataRestriction { + + @Override + default int hashIndex() { + return 191; + } + + @Override + default int typeIndex() { + return 3014; + } + + @Override + default ClassExpressionType getClassExpressionType() { + return ClassExpressionType.DATA_HAS_VALUE; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLClassExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLClassExpressionVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataIntersectionOf.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataIntersectionOf.java new file mode 100644 index 0000000000..83a66b5e6a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataIntersectionOf.java @@ -0,0 +1,69 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents + * + * DataIntersectionOf in the OWL 2 Specification. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLDataIntersectionOf extends OWLNaryDataRange { + + @Override + default int hashIndex() { + return 839; + } + + @Override + default int typeIndex() { + return 4004; + } + + @Override + default DataRangeType getDataRangeType() { + return DataRangeType.DATA_INTERSECTION_OF; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLDataVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLDataVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLDataRangeVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLDataRangeVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataMaxCardinality.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataMaxCardinality.java new file mode 100644 index 0000000000..62cdd90014 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataMaxCardinality.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents + * DataMaxCardinality restrictions in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataMaxCardinality extends OWLDataCardinalityRestriction { + + @Override + default int hashIndex() { + return 173; + } + + @Override + default int typeIndex() { + return 3017; + } + + @Override + default ClassExpressionType getClassExpressionType() { + return ClassExpressionType.DATA_MAX_CARDINALITY; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLClassExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLClassExpressionVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataMinCardinality.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataMinCardinality.java new file mode 100644 index 0000000000..cc8d93053c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataMinCardinality.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents + * DataMinCardinality restrictions in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataMinCardinality extends OWLDataCardinalityRestriction { + + @Override + default int hashIndex() { + return 179; + } + + @Override + default int typeIndex() { + return 3015; + } + + @Override + default ClassExpressionType getClassExpressionType() { + return ClassExpressionType.DATA_MIN_CARDINALITY; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLClassExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLClassExpressionVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataOneOf.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataOneOf.java new file mode 100644 index 0000000000..f52f7f5b8e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataOneOf.java @@ -0,0 +1,100 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * Represents DataOneOf in + * the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataOneOf extends OWLDataRange, HasOperands { + + @Override + default Stream components() { + return Stream.of(values()); + } + + @Override + default int initHashCode() { + return OWLObject.hashIteration(hashIndex(), getOperandsAsList().hashCode()); + } + + @Override + default int hashIndex() { + return 263; + } + + @Override + default int typeIndex() { + return 4003; + } + + @Override + default DataRangeType getDataRangeType() { + return DataRangeType.DATA_ONE_OF; + } + + /** + * Gets the values ({@link OWLLiteral}s) that this data range consists of. + * + * @return The values that this data range consists of. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + */ + default Set getValues() { + return asSet(values()); + } + + /** + * Gets the sorted values ({@link OWLLiteral}s) that this data range consists of. + * + * @return The values that this data range consists of. + */ + Stream values(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLDataVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLDataVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLDataRangeVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLDataRangeVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataProperty.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataProperty.java new file mode 100644 index 0000000000..0719f27f10 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataProperty.java @@ -0,0 +1,110 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; + +/** + * Represents a Data + * Property in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataProperty extends OWLDataPropertyExpression, OWLProperty { + + @Override + default int hashIndex() { + return 283; + } + + @Override + default int typeIndex() { + return 1004; + } + + @Override + default EntityType getEntityType() { + return EntityType.DATA_PROPERTY; + } + + @Override + default boolean isTopEntity() { + return isOWLTopDataProperty(); + } + + @Override + default boolean isBottomEntity() { + return isOWLBottomDataProperty(); + } + + @Override + default boolean isOWLTopDataProperty() { + return getIRI().equals(OWLRDFVocabulary.OWL_TOP_DATA_PROPERTY.getIRI()); + } + + @Override + default boolean isOWLBottomDataProperty() { + return getIRI().equals(OWLRDFVocabulary.OWL_BOTTOM_DATA_PROPERTY.getIRI()); + } + + @Override + default boolean isDataPropertyExpression() { + return true; + } + + @Override + default boolean isOWLDataProperty() { + return true; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLPropertyExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLPropertyExpressionVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLEntityVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLEntityVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLNamedObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLNamedObjectVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyAssertionAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyAssertionAxiom.java new file mode 100644 index 0000000000..c003187a52 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyAssertionAxiom.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents a DataPropertyAssertion in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataPropertyAssertionAxiom extends + OWLPropertyAssertionAxiom, OWLSubClassOfAxiomShortCut { + + @Override + @SuppressWarnings("unchecked") + OWLDataPropertyAssertionAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 11; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.DATA_PROPERTY_ASSERTION; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyAxiom.java new file mode 100644 index 0000000000..ecdfba81de --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyAxiom.java @@ -0,0 +1,23 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * A high level interface which marks data property axioms (e.g. Functional data + * property, data property domain etc.) + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataPropertyAxiom extends OWLPropertyAxiom { +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyCharacteristicAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyCharacteristicAxiom.java new file mode 100644 index 0000000000..c03611976e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyCharacteristicAxiom.java @@ -0,0 +1,22 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataPropertyCharacteristicAxiom extends + OWLDataPropertyAxiom, OWLUnaryPropertyAxiom { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyDomainAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyDomainAxiom.java new file mode 100644 index 0000000000..ac95d3229d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyDomainAxiom.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents a + * DataPropertyDomain axiom in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataPropertyDomainAxiom + extends OWLPropertyDomainAxiom, OWLDataPropertyAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLDataPropertyDomainAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 13; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.DATA_PROPERTY_DOMAIN; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyExpression.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyExpression.java new file mode 100644 index 0000000000..86ff745793 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyExpression.java @@ -0,0 +1,24 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * A high level interface to describe different types of data properties. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataPropertyExpression extends OWLPropertyExpression, + SWRLPredicate { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyRangeAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyRangeAxiom.java new file mode 100644 index 0000000000..8c0ce80170 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyRangeAxiom.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents a + * DataPropertyRange axiom in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataPropertyRangeAxiom + extends OWLPropertyRangeAxiom, OWLDataPropertyAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLDataPropertyRangeAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 17; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.DATA_PROPERTY_RANGE; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataRange.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataRange.java new file mode 100644 index 0000000000..a0aa285461 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataRange.java @@ -0,0 +1,68 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents a + * DataRange in the + * OWL 2 Specification.
+ * A high level interface which represents a data range. Example of data ranges + * are datatypes (e.g. int, float, double, string, ...), complements of data + * ranges (e.g. not(int)), data enumerations (data oneOfs), datatype + * restrictions (e.g. int > 3). + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataRange extends OWLObject, OWLPropertyRange, SWRLPredicate, AsOWLDatatype { + + /** + * Determines if this data range is the top data type. + * + * @return {@code true} if this data range is the top datatype otherwise {@code false} + */ + default boolean isTopDatatype() { + return false; + } + + /** + * Gets the type of this data range. + * + * @return The data range type + */ + DataRangeType getDataRangeType(); + + /** + * @param visitor visitor + */ + void accept(OWLDataVisitor visitor); + + /** + * @param visitor visitor + * @param visitor return type + * @return visitor return value + */ + O accept(OWLDataVisitorEx visitor); + + /** + * @param visitor visitor + */ + void accept(OWLDataRangeVisitor visitor); + + /** + * @param visitor visitor + * @param visitor return type + * @return visitor return value + */ + O accept(OWLDataRangeVisitorEx visitor); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataRangeVisitor.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataRangeVisitor.java new file mode 100644 index 0000000000..7294110437 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataRangeVisitor.java @@ -0,0 +1,68 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface to an object that can accept visits from + * {@link org.semanticweb.owlapi.model.OWLDataRange}s. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLDataRangeVisitor extends OWLDataEntityVisitorBase { + + /** + * visit OWLDataOneOf type + * + * @param node node to visit + */ + default void visit(OWLDataOneOf node) { + doDefault(node); + } + + /** + * visit OWLDataComplementOf type + * + * @param node node to visit + */ + default void visit(OWLDataComplementOf node) { + doDefault(node); + } + + /** + * visit OWLDataIntersectionOf type + * + * @param node node to visit + */ + default void visit(OWLDataIntersectionOf node) { + doDefault(node); + } + + /** + * visit OWLDataUnionOf type + * + * @param node node to visit + */ + default void visit(OWLDataUnionOf node) { + doDefault(node); + } + + /** + * visit OWLDatatypeRestriction type + * + * @param node node to visit + */ + default void visit(OWLDatatypeRestriction node) { + doDefault(node); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataRangeVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataRangeVisitorEx.java new file mode 100644 index 0000000000..7070744314 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataRangeVisitorEx.java @@ -0,0 +1,81 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param visitor return type + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLDataRangeVisitorEx extends OWLVisitorExBase { + + /** + * visit OWLDatatype type + * + * @param node node to visit + * @return visitor value + */ + default O visit(OWLDatatype node) { + return doDefault(node); + } + + /** + * visit OWLDataOneOf type + * + * @param node node to visit + * @return visitor value + */ + default O visit(OWLDataOneOf node) { + return doDefault(node); + } + + /** + * visit OWLDataComplementOf type + * + * @param node node to visit + * @return visitor value + */ + default O visit(OWLDataComplementOf node) { + return doDefault(node); + } + + /** + * visit OWLDataIntersectionOf type + * + * @param node node to visit + * @return visitor value + */ + default O visit(OWLDataIntersectionOf node) { + return doDefault(node); + } + + /** + * visit OWLDataUnionOf type + * + * @param node node to visit + * @return visitor value + */ + default O visit(OWLDataUnionOf node) { + return doDefault(node); + } + + /** + * visit OWLDatatypeRestriction type + * + * @param node node to visit + * @return visitor value + */ + default O visit(OWLDatatypeRestriction node) { + return doDefault(node); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataRestriction.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataRestriction.java new file mode 100644 index 0000000000..7d64d0d508 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataRestriction.java @@ -0,0 +1,40 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents a restriction (Object Property Restriction or Data Property Restriction) in the OWL 2 specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataRestriction extends OWLRestriction, HasProperty { + + /** + * Gets the property/properties that the restriction acts along depending on + * R being a scalar or collection type. + * + * @return The property + */ + @Override + OWLDataPropertyExpression getProperty(); + + @Override + default boolean isDataRestriction() { + return true; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataSomeValuesFrom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataSomeValuesFrom.java new file mode 100644 index 0000000000..fddc65e4a3 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataSomeValuesFrom.java @@ -0,0 +1,59 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents a + * + * DataSomeValuesFrom restriction in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataSomeValuesFrom extends OWLQuantifiedDataRestriction { + + @Override + default int hashIndex() { + return 181; + } + + @Override + default int typeIndex() { + return 3012; + } + + @Override + default ClassExpressionType getClassExpressionType() { + return ClassExpressionType.DATA_SOME_VALUES_FROM; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLClassExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLClassExpressionVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataUnionOf.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataUnionOf.java new file mode 100644 index 0000000000..14a3132941 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataUnionOf.java @@ -0,0 +1,69 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents a + * DataUnionOf + * data range in the OWL 2 Specification. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLDataUnionOf extends OWLNaryDataRange { + + @Override + default int hashIndex() { + return 853; + } + + @Override + default int typeIndex() { + return 4005; + } + + @Override + default DataRangeType getDataRangeType() { + return DataRangeType.DATA_UNION_OF; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLDataVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLDataVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLDataRangeVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLDataRangeVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataVisitor.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataVisitor.java new file mode 100644 index 0000000000..1e446a596b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataVisitor.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * A visitor which can visit various data ranges and constants. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDataVisitor extends OWLDataRangeVisitor, OWLLiteralVisitorBase { + + /** + * visit OWLFacetRestriction type + * + * @param node node to visit + */ + default void visit(OWLFacetRestriction node) { + doDefault(node); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDataVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataVisitorEx.java new file mode 100644 index 0000000000..859c6af683 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDataVisitorEx.java @@ -0,0 +1,82 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param return type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 3.0.0 + */ +public interface OWLDataVisitorEx extends OWLDataEntityVisitorExBase, + OWLLiteralVisitorExBase { + + /** + * visit OWLDataComplementOf type + * + * @param node node to visit + * @return visitor value + */ + default O visit(OWLDataComplementOf node) { + return doDefault(node); + } + + /** + * visit OWLDataOneOf type + * + * @param node node to visit + * @return visitor value + */ + default O visit(OWLDataOneOf node) { + return doDefault(node); + } + + /** + * visit OWLDataIntersectionOf type + * + * @param node node to visit + * @return visitor value + */ + default O visit(OWLDataIntersectionOf node) { + return doDefault(node); + } + + /** + * visit OWLDataUnionOf type + * + * @param node node to visit + * @return visitor value + */ + default O visit(OWLDataUnionOf node) { + return doDefault(node); + } + + /** + * visit OWLDatatypeRestriction type + * + * @param node node to visit + * @return visitor value + */ + default O visit(OWLDatatypeRestriction node) { + return doDefault(node); + } + + /** + * visit OWLFacetRestriction type + * + * @param node node to visit + * @return visitor value + */ + default O visit(OWLFacetRestriction node) { + return doDefault(node); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDatatype.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDatatype.java new file mode 100644 index 0000000000..f3667fcec0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDatatype.java @@ -0,0 +1,153 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * Represents a + * Datatype (named + * data range) in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDatatype extends OWLDataRange, OWLLogicalEntity, OWLNamedObject { + + @Override + default int hashIndex() { + return 269; + } + + @Override + default int typeIndex() { + return 4001; + } + + @Override + default EntityType getEntityType() { + return EntityType.DATATYPE; + } + + @Override + default DataRangeType getDataRangeType() { + return DataRangeType.DATATYPE; + } + + /** + * Gets the built in datatype information if this datatype is a built in + * datatype. This method should only be called if the isBuiltIn() method + * returns {@code true} + * + * @return The OWLDatatypeVocabulary that describes this built in datatype + * @throws OWLRuntimeException if this datatype is not a built in datatype. + */ + OWL2Datatype getBuiltInDatatype(); + + /** + * Determines if this datatype has the IRI {@code xsd:string}. + * + * @return {@code true} if this datatype has the IRI {@code xsd:string}, otherwise {@code + * false}. + */ + boolean isString(); + + /** + * Determines if this datatype has the IRI {@code xsd:integer}. + * + * @return {@code true} if this datatype has the IRI {@code xsd:integer}, otherwise {@code + * false}. + */ + boolean isInteger(); + + /** + * Determines if this datatype has the IRI {@code xsd:float}. + * + * @return {@code true} if this datatype has the IRI {@code xsd:float}, otherwise {@code false}. + */ + boolean isFloat(); + + /** + * Determines if this datatype has the IRI {@code xsd:double}. + * + * @return {@code true} if this datatype has the IRI {@code xsd:double}, otherwise {@code + * false}. + */ + boolean isDouble(); + + /** + * Determines if this datatype has the IRI {@code xsd:boolean}. + * + * @return {@code true} if this datatype has the IRI {@code xsd:boolean}, otherwise {@code + * false}. + */ + boolean isBoolean(); + + /** + * Determines if this datatype has the IRI {@code rdf:PlainLiteral}. + * + * @return {@code true} if this datatype has the IRI {@code rdf:PlainLiteral} otherwise {@code + * false} + */ + boolean isRDFPlainLiteral(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLEntityVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLEntityVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLNamedObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLNamedObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLDataVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLDataVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLDataRangeVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLDataRangeVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDatatypeDefinitionAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDatatypeDefinitionAxiom.java new file mode 100644 index 0000000000..fd1c808b5e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDatatypeDefinitionAxiom.java @@ -0,0 +1,92 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * Represents a + * DatatypeDefinition axiom in the OWL 2 Specification. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLDatatypeDefinitionAxiom extends OWLLogicalAxiom { + + @Override + default Stream components() { + return Stream.of(getDatatype(), getDataRange(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getDatatype().hashCode()); + hash = OWLObject.hashIteration(hash, getDataRange().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getDatatype(), getDataRange()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getDatatype(), getDataRange()); + } + + @Override + default int hashIndex() { + return 897; + } + + /** + * Gets the {@link OWLDatatype} that is assigned a definition. + * + * @return The datatype + */ + OWLDatatype getDatatype(); + + /** + * Gets the data range that defines the datatype. + * + * @return The defining data range + */ + OWLDataRange getDataRange(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.DATATYPE_DEFINITION; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDatatypeRestriction.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDatatypeRestriction.java new file mode 100644 index 0000000000..8fc362b644 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDatatypeRestriction.java @@ -0,0 +1,121 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.List; +import java.util.Set; +import java.util.stream.Stream; + +/** + * Represents a + * DatatypeRestriction data range in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDatatypeRestriction extends OWLDataRange { + + @Override + default Stream components() { + return Stream.of(getDatatype(), facetRestrictionsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getDatatype().hashCode()); + return OWLObject.hashIteration(hash, facetRestrictionsAsList().hashCode()); + } + + @Override + default int hashIndex() { + return 271; + } + + @Override + default int typeIndex() { + return 4006; + } + + @Override + default DataRangeType getDataRangeType() { + return DataRangeType.DATATYPE_RESTRICTION; + } + + /** + * Gets the data range that this data range restricts. + * + * @return The datatype that is restricted + */ + OWLDatatype getDatatype(); + + /** + * Gets the facet restrictions on this data range. + * + * @return A {@code Set} of facet restrictions that apply to this data range. The set that is + * returned is a copy; modifications to the returned set will not be reflected in this + * object. + */ + default Set getFacetRestrictions() { + return asSet(facetRestrictions()); + } + + /** + * Gets the sorted facet restrictions on this data range. + * + * @return A {@code Stream} of facet restrictions that apply to this data range + */ + Stream facetRestrictions(); + + /** + * Gets the sorted facet restrictions on this data range. + * + * @return A {@code List} of facet restrictions that apply to this data range + */ + default List facetRestrictionsAsList() { + return asList(facetRestrictions()); + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLDataVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLDataVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLDataRangeVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLDataRangeVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDeclarationAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDeclarationAxiom.java new file mode 100644 index 0000000000..91211095f5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDeclarationAxiom.java @@ -0,0 +1,88 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * Represents a + * Declaration in the OWL 2 Specification.
+ * A declaration axiom declares an entity in an ontology. It doesn't affect the logical meaning of + * the ontology. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDeclarationAxiom extends OWLAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLDeclarationAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 23; + } + + @Override + default Stream components() { + return Stream.of(getEntity(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getEntity().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getEntity()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getEntity()); + } + + /** + * @return The entity that is declared by this axiom. + */ + OWLEntity getEntity(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.DECLARATION; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDifferentIndividualsAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDifferentIndividualsAxiom.java new file mode 100644 index 0000000000..bcbc9efc5c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDifferentIndividualsAxiom.java @@ -0,0 +1,73 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Collection; + +/** + * Represents a + * DifferentIndividuals axiom in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDifferentIndividualsAxiom extends OWLNaryIndividualAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLDifferentIndividualsAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 29; + } + + /** + * Determines whether this axiom contains anonymous individuals. Anonymous individuals are not + * allowed in different individuals axioms. + * + * @return {@code true} if this axioms contains anonymous individual axioms + */ + boolean containsAnonymousIndividuals(); + + @Override + Collection asPairwiseAxioms(); + + @Override + Collection splitToAnnotatedPairs(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.DIFFERENT_INDIVIDUALS; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDisjointClassesAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDisjointClassesAxiom.java new file mode 100644 index 0000000000..594d16fd7c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDisjointClassesAxiom.java @@ -0,0 +1,65 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Collection; + +/** + * Represents a DisjointClasses + * axiom in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDisjointClassesAxiom extends OWLNaryClassAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLDisjointClassesAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 31; + } + + @Override + Collection asPairwiseAxioms(); + + @Override + Collection splitToAnnotatedPairs(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.DISJOINT_CLASSES; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDisjointDataPropertiesAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDisjointDataPropertiesAxiom.java new file mode 100644 index 0000000000..598798f2f7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDisjointDataPropertiesAxiom.java @@ -0,0 +1,66 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Collection; + +/** + * Represents a + * DisjointDataProperties axiom in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDisjointDataPropertiesAxiom + extends OWLNaryPropertyAxiom, OWLDataPropertyAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLDisjointDataPropertiesAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 37; + } + + @Override + Collection asPairwiseAxioms(); + + @Override + Collection splitToAnnotatedPairs(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.DISJOINT_DATA_PROPERTIES; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDisjointObjectPropertiesAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDisjointObjectPropertiesAxiom.java new file mode 100644 index 0000000000..631b348258 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDisjointObjectPropertiesAxiom.java @@ -0,0 +1,66 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Collection; + +/** + * Represents + * DisjointObjectProperties axioms in the OWL 2 specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDisjointObjectPropertiesAxiom + extends OWLNaryPropertyAxiom, OWLObjectPropertyAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLDisjointObjectPropertiesAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 41; + } + + @Override + Collection asPairwiseAxioms(); + + @Override + Collection splitToAnnotatedPairs(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.DISJOINT_OBJECT_PROPERTIES; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDisjointUnionAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDisjointUnionAxiom.java new file mode 100644 index 0000000000..5948b47243 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDisjointUnionAxiom.java @@ -0,0 +1,131 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * Represents a + * DisjointUnion axiom in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDisjointUnionAxiom extends OWLClassAxiom, HasOperands { + + @Override + @SuppressWarnings("unchecked") + OWLDisjointUnionAxiom getAxiomWithoutAnnotations(); + + @Override + default Stream components() { + return Stream.of(getOWLClass(), getOperandsAsList(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getOWLClass().hashCode()); + hash = OWLObject.hashIteration(hash, getOperandsAsList().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getOWLClass(), getOperandsAsList()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getOWLClass(), getOperandsAsList()); + } + + @Override + default int hashIndex() { + return 43; + } + + /** + * Gets the class which is equivalent to the disjoint union. + * + * @return the class that is equivalent to a disjoint union of other classes. + */ + OWLClass getOWLClass(); + + /** + * Gets the class expressions which are operands of the disjoint union. + * + * @return A {@code Set} containing the operands of the disjoint union, note that this does + * not include the {@code OWLClass} that is equivalent to the disjoint union. The + * set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + */ + default Set getClassExpressions() { + return asSet(classExpressions()); + } + + /** + * Gets the class expressions which are operands of the disjoint union. + * + * @return Sorted stream containing the operands of the disjoint union, note that this does + * not include the {@code OWLClass} that is equivalent to the disjoint union. + */ + Stream classExpressions(); + + /** + * Gets the part of this axiom that corresponds to an {@code EquivalentClasses} axiom. + * + * @return The equivalent classes axiom part of this axiom. This is essentially, {@code + * EquivalentClasses(CE, CEUnion)} where {@code CEUnion} is the union of the classes returned by + * the {@link #getClassExpressions()} method and {@code CE} is the class returned by the + * {@link #getOWLClass()} method. + */ + OWLEquivalentClassesAxiom getOWLEquivalentClassesAxiom(); + + /** + * Gets the part of this axiom that corresponds to an {@code DisjointClasses} axiom. + * + * @return The disjoint classes axiom part of this axiom. This is essentially, {@code + * DisjointClasses(CE1, ..., CEn)} where {@code CEi in (CE1, ..., CEn)} is contained in the + * classes returned by the {@link #getClassExpressions()} method. + */ + OWLDisjointClassesAxiom getOWLDisjointClassesAxiom(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.DISJOINT_UNION; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDocumentFormat.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDocumentFormat.java new file mode 100644 index 0000000000..022462207d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDocumentFormat.java @@ -0,0 +1,226 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.formats.PrefixDocumentFormat; +import org.semanticweb.owlapi.io.OWLOntologyLoaderMetaData; +import org.semanticweb.owlapi.model.parameters.Imports; + +import com.google.common.collect.LinkedListMultimap; +import com.google.common.collect.Multimap; + +/** + * Represents the concrete representation format of an ontology. The equality of an ontology format + * is defined by the equals and hashCode method (not its identity). + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLDocumentFormat extends Serializable { + + /** + * Determines if a declaration axiom (type triple) needs to be added to the specified ontology + * for the given entity. + * + * @param entity The entity + * @param ontology The ontology. + * @return {@code false} if the entity is built in. {@code false} if the ontology doesn't + * contain the entity in its signature. {@code false} if the entity is already declared + * in the imports closure of the ontology. {@code false} if the transitive imports does + * not contain the ontology but the entity is contained in the signature of one of the + * imported ontologies, {@code true} if none of the previous conditions are met. + */ + static boolean isMissingType(OWLEntity entity, OWLOntology ontology) { + // We don't need to declare built in entities + if (entity.isBuiltIn()) { + return false; + } + // If the ontology doesn't contain the entity in its signature then it + // shouldn't declare it + if (!ontology.containsEntityInSignature(entity)) { + return false; + } + if (ontology.isDeclared(entity, Imports.INCLUDED)) { + return false; + } + Set transitiveImports = asUnorderedSet(ontology.imports()); + if (!transitiveImports.contains(ontology)) { + // See if the entity should be declared in an imported ontology + for (OWLOntology importedOntology : transitiveImports) { + if (importedOntology.containsEntityInSignature(entity)) { + // Leave it for that ontology to declare the entity + return false; + } + } + } + return true; + } + + /** + * @param signature signature for the ontology + * @param punnedEntities the set of entities that are known already to be punned + * @param add true if missing declarations should be added. If false, no declarations will be + * added. + * @return collection of IRIS used in illegal punnings + */ + static Collection determineIllegalPunnings(boolean add, Stream signature, + Collection punnedEntities) { + if (!add) { + return Collections.emptySet(); + } + // determine what entities are illegally punned + Multimap> punnings = LinkedListMultimap.create(); + // disregard individuals as they do not give raise to illegal + // punnings; only keep track of punned entities, ignore the rest + signature.filter(e -> !e.isOWLNamedIndividual() && punnedEntities.contains(e.getIRI())) + .forEach(e -> punnings.put(e.getIRI(), e.getEntityType())); + return computeIllegals(punnings); + } + + /** + * @param punnings input punnings + * @return illegal punnings + */ + static Collection computeIllegals(Multimap> punnings) { + Collection illegals = new HashSet<>(); + for (IRI i : punnings.keySet()) { + Collection> puns = punnings.get(i); + if (puns.contains(EntityType.OBJECT_PROPERTY) + && puns.contains(EntityType.ANNOTATION_PROPERTY)) { + illegals.add(i); + } else if (puns.contains(EntityType.DATA_PROPERTY) + && puns.contains(EntityType.ANNOTATION_PROPERTY)) { + illegals.add(i); + } else if (puns.contains(EntityType.DATA_PROPERTY) + && puns.contains(EntityType.OBJECT_PROPERTY)) { + illegals.add(i); + } else if (puns.contains(EntityType.DATATYPE) && puns.contains(EntityType.CLASS)) { + illegals.add(i); + } + } + return illegals; + } + + /** + * Determines if untyped entities should automatically be typed (declared) during rendering. + * (This is a hint to an RDF renderer - the reference implementation will respect this). + * + * @return {@code true} if untyped entities should automatically be typed during rendering, + * otherwise {@code false}. + */ + boolean isAddMissingTypes(); + + /** + * Determines if untyped entities should automatically be typed during rendering. By default + * this is true. + * + * @param addMissingTypes {@code true} if untyped entities should automatically be typed during + * rendering, otherwise {@code false}. + */ + void setAddMissingTypes(boolean addMissingTypes); + + /** + * @param key key for the new entry + * @param value value for the new entry + */ + void setParameter(Serializable key, Serializable value); + + /** + * @param key key for the new entry + * @param defaultValue value for the new entry + * @param type + * @return the value + */ + T getParameter(Serializable key, T defaultValue); + + /** + * Determines if this format is an instance of a format that uses prefixes to shorted IRIs. + * + * @return {@code true} if this format is an instance of + * {@link org.semanticweb.owlapi.formats.PrefixDocumentFormat} other wise {@code false}. + */ + default boolean isPrefixOWLDocumentFormat() { + return false; + } + + /** + * If this format is an instance of {@link org.semanticweb.owlapi.formats.PrefixDocumentFormat} + * then this method will obtain it as a + * {@link org.semanticweb.owlapi.formats.PrefixDocumentFormat}. + * + * @return This format as a more specific + * {@link org.semanticweb.owlapi.formats.PrefixDocumentFormat}. + * @throws ClassCastException if this format is not an instance of + * {@link org.semanticweb.owlapi.formats.PrefixDocumentFormat} + */ + default PrefixDocumentFormat asPrefixOWLDocumentFormat() { + if (isPrefixOWLDocumentFormat()) { + return (PrefixDocumentFormat) this; + } + throw new ClassCastException(getClass().getName() + " is not a Prefix Document Format"); + } + + /** + * If this format describes an ontology that was loaded from some ontology document (rather than + * created programmatically) there may be some meta data about the loading process. Subclasses + * of {@code OWLDocumentFormat} will provide accessors etc. to details pertaining to the meta + * data about loading. + * + * @return An object containing the meta data about loading. . + */ + Optional getOntologyLoaderMetaData(); + + /** + * Sets the meta data for the ontology loader. + * + * @param loaderMetaData The metadata. + * @throws NullPointerException if the argument is {@code null}. + */ + void setOntologyLoaderMetaData(OWLOntologyLoaderMetaData loaderMetaData); + + /** + * @return A unique key for this format. + */ + String getKey(); + + /** + * Determines whether this format contains textual output, as opposed to binary output. + * + * @return True if this format represents a textual format, as opposed to a binary format. + * Defaults to true if not overridden. + */ + boolean isTextual(); + + /** + * Some formats support relative IRIs in output (all parsers must create axioms with absolute + * IRIs, but some formats allow relative IRIs, with the understanding that in parsing the base + * IRI will be used to convert them to absolute IRIs). If a format does not support relative + * IRIs, the renderer needs to know to output absolute IRIs. This defaults to true as this keeps + * the existing behaviour. + * + * @return true if relative IRIs are supported. + */ + default boolean supportsRelativeIRIs() { + return true; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDocumentFormatFactory.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDocumentFormatFactory.java new file mode 100644 index 0000000000..b0c7791b09 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDocumentFormatFactory.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; +import java.util.function.Supplier; + +/** + * Factory for ontology formats. + * + * @author Peter Ansell p_ansell@yahoo.com + * @since 4.0.0 + */ +public interface OWLDocumentFormatFactory extends Serializable, Supplier, + MIMETypeAware { + + /** + * Create a new format. Note that ontology formats currently carry prefix + * information for the ontology, so an instance cannot, in general, be + * reused for multiple parsings. + * + * @return new storer + */ + OWLDocumentFormat createFormat(); + + /** + * Returns the key for the OWLDocumentFormat that this class is a factory + * for without necessarily creating an instance of the OWLDocumentFormat. + * + * @return The key for the OWLDocumentFormat. + */ + String getKey(); + + /** + * Returns true if this format can be represented using textual characters. + * Returns false if this format must be dealt with using binary methods. + * + * @return True if this format is textual, and false if it is a binary format. + */ + boolean isTextual(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLDocumentFormatImpl.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLDocumentFormatImpl.java new file mode 100644 index 0000000000..20d18c3eed --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLDocumentFormatImpl.java @@ -0,0 +1,100 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.io.OWLOntologyLoaderMetaData; + +/** + * Represents the concrete representation format of an ontology. The equality of + * an ontology format is defined by the equals and hashCode method (not its + * identity). + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public abstract class OWLDocumentFormatImpl implements OWLDocumentFormat { + + private final Map parameterMap = new HashMap<>(); + @Nullable + private OWLOntologyLoaderMetaData loaderMetaData = null; + private boolean addMissingTypes = true; + + @Override + public boolean isAddMissingTypes() { + return addMissingTypes; + } + + @Override + public void setAddMissingTypes(boolean addMissingTypes) { + this.addMissingTypes = addMissingTypes; + } + + @Override + public void setParameter(Serializable key, Serializable value) { + parameterMap.put(key, value); + } + + @SuppressWarnings("unchecked") + @Override + public T getParameter(Serializable key, T defaultValue) { + Serializable val = parameterMap.get(key); + if (val == null) { + return defaultValue; + } + return (T) val; + } + + @Override + public Optional getOntologyLoaderMetaData() { + return Optional.ofNullable(loaderMetaData); + } + + @Override + public void setOntologyLoaderMetaData(OWLOntologyLoaderMetaData loaderMetaData) { + this.loaderMetaData = loaderMetaData; + } + + @Override + public boolean isTextual() { + return true; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (obj instanceof OWLDocumentFormat) { + return ((OWLDocumentFormat) obj).getKey().equals(getKey()); + } + return false; + } + + @Override + public int hashCode() { + return getKey().hashCode(); + } + + @Override + public String toString() { + return getKey(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLEntity.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLEntity.java new file mode 100644 index 0000000000..e1f7e090a8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLEntity.java @@ -0,0 +1,100 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; + +/** + * Represents + * Entities in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLEntity + extends OWLObject, OWLNamedObject, OWLPrimitive, AsOWLClass, AsOWLDataProperty, AsOWLDatatype, + AsOWLAnnotationProperty, AsOWLNamedIndividual, AsOWLObjectProperty { + + /** + * Gets the entity type for this entity. + * + * @return The entity type + */ + EntityType getEntityType(); + + /** + * Tests to see if this entity is of the specified type. + * + * @param entityType The entity type + * @return {@code true} if this entity is of the specified type, otherwise {@code false}. + */ + default boolean isType(EntityType entityType) { + return getEntityType().equals(entityType); + } + + /** + * Determines if this entity is a built in entity. The entity is a built in entity if it is: + *
    + *
  • a class and the URI corresponds to owl:Thing or owl:Nothing
  • + *
  • an object property and the URI corresponds to owl:topObjectProperty or + * owl:bottomObjectProperty
  • + *
  • a data property and the URI corresponds to owl:topDataProperty or + * owl:bottomDataProperty
  • + *
  • a datatype and the IRI is rdfs:Literal or is in the OWL 2 datatype map or is + * rdf:PlainLiteral
  • + *
  • an annotation property and the URI is in the set of built in annotation property URIs, + * i.e. one of: + *
      + *
    • rdfs:label
    • + *
    • rdfs:comment
    • + *
    • rdfs:seeAlso
    • + *
    • rdfs:isDefinedBy
    • + *
    • owl:deprecated
    • + *
    • owl:priorVersion
    • + *
    • owl:backwardCompatibleWith
    • + *
    • owl:incompatibleWith
    • + *
    + *
  • + *
+ * + * @return {@code true} if this entity is a built in entity, or {@code false} if this entity is + * not a builtin entity. + */ + default boolean isBuiltIn() { + return OWLRDFVocabulary.BUILT_IN_AP_IRIS.contains(getIRI()); + } + + /** + * @return a string representation that can be used as the ID of this entity. This is the + * {@code toString()} representation of the IRI + */ + String toStringID(); + + /** + * @param visitor visitor + */ + void accept(OWLEntityVisitor visitor); + + /** + * @param visitor visitor + * @param visitor return type + * @return visitor return value + */ + O accept(OWLEntityVisitorEx visitor); + + @Override + default boolean isAnonymous() { + return false; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLEntityVisitor.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLEntityVisitor.java new file mode 100644 index 0000000000..809f3a267f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLEntityVisitor.java @@ -0,0 +1,26 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface to an object that can accept visits from + * {@link org.semanticweb.owlapi.model.OWLEntity}s. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLEntityVisitor extends OWLIndividualEntityVisitorBase, + OWLPropertyEntityVisitorBase, OWLClassVisitorBase, + OWLDataEntityVisitorBase { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLEntityVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLEntityVisitorEx.java new file mode 100644 index 0000000000..6024eaafb9 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLEntityVisitorEx.java @@ -0,0 +1,24 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param return type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 3.0.0 + */ +public interface OWLEntityVisitorEx extends OWLClassVisitorExBase, + OWLPropertyEntityVisitorExBase, OWLIndividualEntityVisitorExBase, + OWLDataEntityVisitorExBase { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLEquivalentClassesAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLEquivalentClassesAxiom.java new file mode 100644 index 0000000000..72c0eed01e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLEquivalentClassesAxiom.java @@ -0,0 +1,116 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Collection; +import java.util.Set; +import java.util.stream.Stream; + +/** + * Represents an + * EquivalentClasses axiom in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLEquivalentClassesAxiom extends OWLNaryClassAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLEquivalentClassesAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 53; + } + + /** + * Determines if this equivalent classes axiom contains at least one named class (excluding + * owl:Thing or owl:Nothing). + * + * @return {@code true} if the axiom contains at least one named class otherwise {@code false}. + * Note that this method will return {@code false} if the only named classes are + * owl:Thing or owl:Nothing. + */ + boolean containsNamedEquivalentClass(); + + /** + * Gets the named classes (excluding owl:Thing and owl:Nothing) that are in this equivalent + * classes axiom. + * + * @return A set of classes that represents the named classes that are specified to be + * equivalent to some other class (expression), excluding the built in classes owl:Thing + * and owl:Nothing. The set that is returned is a copy; modifications to the returned + * set will not be reflected in this object. + */ + default Set getNamedClasses() { + return asSet(namedClasses()); + } + + /** + * Gets the named classes (excluding owl:Thing and owl:Nothing) that are in this equivalent + * classes axiom. + * + * @return stream of classes that represents the named classes that are specified to be + * equivalent to some other class (expression), excluding the built in classes owl:Thing + * and owl:Nothing + */ + Stream namedClasses(); + + /** + * Determines if this class axiom makes a class expression equivalent to nothing. + * + * @return {@code true} if this axiom contains owl:Nothing as an equivalent class. + */ + boolean containsOWLNothing(); + + /** + * Determines if this class axiom makes a class expression equivalent to thing. + * + * @return {@code true} if this axioms contains owl:Thing as an equivalent class. + */ + boolean containsOWLThing(); + + @Override + Collection asPairwiseAxioms(); + + @Override + Collection splitToAnnotatedPairs(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.EQUIVALENT_CLASSES; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLEquivalentDataPropertiesAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLEquivalentDataPropertiesAxiom.java new file mode 100644 index 0000000000..8c0df16582 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLEquivalentDataPropertiesAxiom.java @@ -0,0 +1,71 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Collection; + +/** + * Represents an + * EquivalentDataProperties axiom in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLEquivalentDataPropertiesAxiom + extends OWLNaryPropertyAxiom, OWLDataPropertyAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLEquivalentDataPropertiesAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 59; + } + + @Override + Collection asPairwiseAxioms(); + + @Override + Collection splitToAnnotatedPairs(); + + /** + * @return the axioms equivalent to the equivalent data properties axiom + */ + Collection asSubDataPropertyOfAxioms(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.EQUIVALENT_DATA_PROPERTIES; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLEquivalentObjectPropertiesAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLEquivalentObjectPropertiesAxiom.java new file mode 100644 index 0000000000..2d94eb1383 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLEquivalentObjectPropertiesAxiom.java @@ -0,0 +1,71 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Collection; + +/** + * Represents + * EquivalentObjectProperties axioms in the OWL 2 specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLEquivalentObjectPropertiesAxiom + extends OWLNaryPropertyAxiom, OWLObjectPropertyAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLEquivalentObjectPropertiesAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 61; + } + + @Override + Collection asPairwiseAxioms(); + + @Override + Collection splitToAnnotatedPairs(); + + /** + * @return the axioms equivalent to the equivalent object property axiom + */ + Collection asSubObjectPropertyOfAxioms(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.EQUIVALENT_OBJECT_PROPERTIES; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLException.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLException.java new file mode 100644 index 0000000000..9b27b99588 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLException.java @@ -0,0 +1,47 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * The root of checked exceptions in the OWL API. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLException extends Exception { + + protected OWLException() { + } + + /** + * @param message the message + */ + public OWLException(String message) { + super(message); + } + + /** + * @param message the message + * @param cause the cause + */ + public OWLException(String message, Throwable cause) { + super(message, cause); + } + + /** + * @param cause the cause + */ + public OWLException(Throwable cause) { + super(cause); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLFacetRestriction.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLFacetRestriction.java new file mode 100644 index 0000000000..99a0f7a119 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLFacetRestriction.java @@ -0,0 +1,90 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +import org.semanticweb.owlapi.vocab.OWLFacet; + +/** + * A facet restriction is used to restrict a particular datatype. For example the set of integers + * greater than 18 can be obtained by restricting the integer datatype using a minExclusive facet + * with a value of 18 + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLFacetRestriction extends OWLObject { + + @Override + default Stream components() { + return Stream.of(getFacet(), getFacetValue()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getFacet().hashCode()); + return OWLObject.hashIteration(hash, getFacetValue().hashCode()); + } + + @Override + default int hashIndex() { + return 563; + } + + @Override + default int typeIndex() { + return 4007; + } + + /** + * Gets the restricted facet. + * + * @return The restricted facet + */ + OWLFacet getFacet(); + + /** + * Gets the value that restricts the facet. + * + * @return the restricting value + */ + OWLLiteral getFacetValue(); + + /** + * @param visitor visitor + */ + default void accept(OWLDataVisitor visitor) { + visitor.visit(this); + } + + /** + * @param visitor visitor + * @param visitor return type + * @return visitor return value + */ + default O accept(OWLDataVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLFunctionalDataPropertyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLFunctionalDataPropertyAxiom.java new file mode 100644 index 0000000000..b787cd4610 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLFunctionalDataPropertyAxiom.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents a + * FunctionalDataProperty axiom in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLFunctionalDataPropertyAxiom + extends OWLDataPropertyCharacteristicAxiom, OWLSubClassOfAxiomShortCut { + + @Override + @SuppressWarnings("unchecked") + OWLFunctionalDataPropertyAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 67; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.FUNCTIONAL_DATA_PROPERTY; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLFunctionalObjectPropertyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLFunctionalObjectPropertyAxiom.java new file mode 100644 index 0000000000..adcff37941 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLFunctionalObjectPropertyAxiom.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents + * FunctionalObjectProperty axioms in the OWL 2 specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLFunctionalObjectPropertyAxiom + extends OWLObjectPropertyCharacteristicAxiom, OWLSubClassOfAxiomShortCut { + + @Override + @SuppressWarnings("unchecked") + OWLFunctionalObjectPropertyAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 71; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.FUNCTIONAL_OBJECT_PROPERTY; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLHasKeyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLHasKeyAxiom.java new file mode 100644 index 0000000000..99fa50bcad --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLHasKeyAxiom.java @@ -0,0 +1,161 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * Represents a HasKey axiom in the OWL 2 + * Specification. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLHasKeyAxiom extends OWLLogicalAxiom, HasOperands { + + @Override + @SuppressWarnings("unchecked") + OWLHasKeyAxiom getAxiomWithoutAnnotations(); + + @Override + default Stream components() { + return Stream.of(getClassExpression(), getOperandsAsList(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getClassExpression().hashCode()); + hash = OWLObject.hashIteration(hash, getOperandsAsList().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getClassExpression(), getOperandsAsList()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getClassExpression(), getOperandsAsList()); + } + + @Override + default int hashIndex() { + return 821; + } + + /** + * Gets the class expression, instances of which, this axiom acts as the key for. + * + * @return The class expression + */ + OWLClassExpression getClassExpression(); + + /** + * Gets the set of property expressions that form the key. + * + * @return The set of property expression that form the key. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + */ + default Set getPropertyExpressions() { + return asSet(propertyExpressions()); + } + + /** + * @return The stream of property expression that form the key + */ + Stream propertyExpressions(); + + /** + * Gets the set of object property expressions that make up the key. This is simply a + * convenience method that filters out the object property expressions in the key. All of the + * properties returned by this method are included in the return value of the + * {@link OWLHasKeyAxiom#getPropertyExpressions()} method. + * + * @return The set of object property expressions in the key described by this axiom. The set + * that is returned is a copy; modifications to the returned set will not be reflected + * in this object. + */ + default Set getObjectPropertyExpressions() { + return asSet(objectPropertiesInSignature(), OWLObjectPropertyExpression.class); + } + + /** + * Gets the stream of object property expressions that make up the key. This is simply a + * convenience method that filters out the object property expressions in the key. All of the + * properties returned by this method are included in the return value of the + * {@link OWLHasKeyAxiom#getPropertyExpressions()} method. + * + * @return stream of object property expressions in the key described by this axiom + */ + default Stream objectPropertyExpressions() { + return propertyExpressions().filter(OWLPropertyExpression::isObjectPropertyExpression) + .map(OWLPropertyExpression::asObjectPropertyExpression); + } + + /** + * Gets the set of data property expressions that make up the key. This is simply a convenience + * method that filters out the data property expressions in the key. All of the properties + * returned by this method are included in the return value of the + * {@link OWLHasKeyAxiom#getPropertyExpressions()} method. + * + * @return The set of object property expressions in the key described by this axiom. The set + * that is returned is a copy; modifications to the returned set will not be reflected + * in this object. + */ + default Set getDataPropertyExpressions() { + return asSet(dataPropertyExpressions()); + } + + /** + * Gets the stream of data property expressions that make up the key. This is simply a + * convenience method that filters out the data property expressions in the key. All of the + * properties returned by this method are included in the return value of the + * {@link OWLHasKeyAxiom#getPropertyExpressions()} method. + * + * @return The stream of object property expressions in the key described by this axiom + */ + default Stream dataPropertyExpressions() { + return propertyExpressions().filter(OWLPropertyExpression::isDataPropertyExpression) + .map(OWLPropertyExpression::asDataPropertyExpression); + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.HAS_KEY; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLHasValueRestriction.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLHasValueRestriction.java new file mode 100644 index 0000000000..9183e01077 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLHasValueRestriction.java @@ -0,0 +1,53 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * @param the value type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLHasValueRestriction extends OWLRestriction, HasFiller { + + @Override + default Stream components() { + return Stream.of(getProperty(), getFiller()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getProperty().hashCode()); + return OWLObject.hashIteration(hash, getFiller().hashCode()); + } + + /** + * @return the value + * @deprecated use {@link #getFiller()} instead + */ + @Deprecated + default V getValue() { + return getFiller(); + } + + /** + * A convenience method that obtains this restriction as an existential restriction with a + * nominal filler. + * + * @return The existential equivalent of this value restriction. simp(HasValue(p a)) = some(p + * {a}) + */ + OWLClassExpression asSomeValuesFrom(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLImportsDeclaration.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLImportsDeclaration.java new file mode 100644 index 0000000000..2e5bf8bc2c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLImportsDeclaration.java @@ -0,0 +1,35 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; + +/** + * Represents an import statement in an ontology. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLImportsDeclaration extends Comparable, HasIRI, + Serializable { + + /** + * Gets the import IRI. + * + * @return The import IRI that points to the ontology to be imported. The imported ontology + * might have this IRI as its ontology IRI but this is not mandated. For example, an ontology + * with a non resolvable ontology IRI can be deployed at a resolvable URL. + */ + @Override + IRI getIRI(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLIndividual.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLIndividual.java new file mode 100644 index 0000000000..e6d1d46e70 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLIndividual.java @@ -0,0 +1,53 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents a named or anonymous individual. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLIndividual extends OWLObject, OWLPropertyAssertionObject, AsOWLNamedIndividual { + + @Override + default boolean isIndividual() { + return true; + } + + /** + * Obtains this individual an anonymous individual if it is indeed anonymous. + * + * @return The individual as an anonymous individual + * @throws OWLRuntimeException if this individual is named + */ + OWLAnonymousIndividual asOWLAnonymousIndividual(); + + /** + * @return a string representation that can be used as the ID of this individual. This is the + * {@code toString()} representation of the node ID of this individual + */ + String toStringID(); + + /** + * @param visitor visitor + */ + void accept(OWLIndividualVisitor visitor); + + /** + * @param visitor visitor + * @param visitor return type + * @return visitor type + */ + O accept(OWLIndividualVisitorEx visitor); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLIndividualAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLIndividualAxiom.java new file mode 100644 index 0000000000..3345817997 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLIndividualAxiom.java @@ -0,0 +1,21 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLIndividualAxiom extends OWLLogicalAxiom { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLIndividualEntityVisitorBase.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLIndividualEntityVisitorBase.java new file mode 100644 index 0000000000..47c1a90537 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLIndividualEntityVisitorBase.java @@ -0,0 +1,29 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLIndividualEntityVisitorBase extends OWLVisitorBase { + + /** + * visit OWLNamedIndividual type + * + * @param individual individual to visit + */ + default void visit(OWLNamedIndividual individual) { + doDefault(individual); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLIndividualEntityVisitorExBase.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLIndividualEntityVisitorExBase.java new file mode 100644 index 0000000000..6dc8cc9d31 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLIndividualEntityVisitorExBase.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param return type + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLIndividualEntityVisitorExBase extends OWLVisitorExBase { + + /** + * visit OWLNamedIndividual type + * + * @param individual individual to visit + * @return visitor value + */ + default O visit(OWLNamedIndividual individual) { + return doDefault(individual); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLIndividualVisitor.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLIndividualVisitor.java new file mode 100644 index 0000000000..0a6ab1bd4e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLIndividualVisitor.java @@ -0,0 +1,22 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLIndividualVisitor extends + OWLAnonymousIndividualVisitorBase, OWLIndividualEntityVisitorBase { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLIndividualVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLIndividualVisitorEx.java new file mode 100644 index 0000000000..9124f77960 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLIndividualVisitorEx.java @@ -0,0 +1,24 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param return type + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLIndividualVisitorEx extends + OWLIndividualEntityVisitorExBase, + OWLAnonymousIndividualVisitorExBase { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLInverseFunctionalObjectPropertyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLInverseFunctionalObjectPropertyAxiom.java new file mode 100644 index 0000000000..8c7260e8c0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLInverseFunctionalObjectPropertyAxiom.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents + * InverseFunctionalObjectProperty axioms in the OWL 2 specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLInverseFunctionalObjectPropertyAxiom + extends OWLObjectPropertyCharacteristicAxiom, OWLSubClassOfAxiomShortCut { + + @Override + @SuppressWarnings("unchecked") + OWLInverseFunctionalObjectPropertyAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 79; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.INVERSE_FUNCTIONAL_OBJECT_PROPERTY; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLInverseObjectPropertiesAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLInverseObjectPropertiesAxiom.java new file mode 100644 index 0000000000..025a60c364 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLInverseObjectPropertiesAxiom.java @@ -0,0 +1,84 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Collection; + +/** + * Represents an + * InverseObjectProperties axiom in the OWL 2 Specification.
+ * Represents a statement that two properties are the inverse of each other. This property axiom + * contains a set of two properties. inverseOf(P, Q) is considered to be equal to inverseOf(Q, P) - + * i.e. the order in which the properties are specified isn't important. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLInverseObjectPropertiesAxiom + extends OWLNaryPropertyAxiom, OWLObjectPropertyAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLInverseObjectPropertiesAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 83; + } + + @Override + Collection asPairwiseAxioms(); + + @Override + Collection splitToAnnotatedPairs(); + + /** + * @return the first of the two object properties. + */ + OWLObjectPropertyExpression getFirstProperty(); + + /** + * @return the second of the two object properties. + */ + OWLObjectPropertyExpression getSecondProperty(); + + /** + * @return the set of subproperty axioms equivalent + */ + Collection asSubObjectPropertyOfAxioms(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.INVERSE_OBJECT_PROPERTIES; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLIrreflexiveObjectPropertyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLIrreflexiveObjectPropertyAxiom.java new file mode 100644 index 0000000000..666be8d7d4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLIrreflexiveObjectPropertyAxiom.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents + * IrreflexiveObjectProperty axioms in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLIrreflexiveObjectPropertyAxiom + extends OWLObjectPropertyCharacteristicAxiom, OWLSubClassOfAxiomShortCut { + + @Override + @SuppressWarnings("unchecked") + OWLIrreflexiveObjectPropertyAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 89; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.IRREFLEXIVE_OBJECT_PROPERTY; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLLiteral.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLLiteral.java new file mode 100644 index 0000000000..a3bf19fa43 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLLiteral.java @@ -0,0 +1,276 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.util.Optional; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +/** + * Represents a Literal + * in the OWL 2 Specification. + *

+ * Each literal consists of a lexical form, which is a string, and a datatype. A literal consisting + * of a lexical form {@code "abc"} and a datatype identified by the IRI {@code datatypeIRI} is + * written as {@code "abc"^^datatypeIRI}. + *

+ * Note that literals whose datatype is {@code rdf:PlainLiteral} can be abbreviated. For example, + * literals of the form {@code "abc@"^^rdf:PlainLiteral} can be abbreviated in the functional-style + * syntax, and other concrete syntaxes to "abc". Literals of the form + * "abc@langTag"^^rdf:PlainLiteral where "langTag" is not empty are abbreviated in functional-style + * syntax documents (and other concrete syntaxes) to "abc"@langTag whenever possible. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLLiteral extends OWLObject, OWLAnnotationObject, OWLAnnotationValue, + OWLPropertyAssertionObject, OWLPrimitive, HasLang { + + @Override + default Stream components() { + return Stream.of(getDatatype(), getLiteral(), getLang()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getDatatype().hashCode()); + hash = OWLObject.hashIteration(hash, getLiteral().hashCode()); + return OWLObject.hashIteration(hash, getLang().hashCode()); + } + + @Override + default int hashIndex() { + return 277; + } + + @Override + default int typeIndex() { + return 4008; + } + + /** + * Determines if the datatype of this literal is {@code rdf:PlainLiteral}. Note that literals + * that are abbreviated in the functional syntax (and other concrete syntaxes) and are of the + * form {@code "abc"} or {@code "abc"@langTag} will be of the type {@code rdf:PlainLiteral} + * after parsing. + * + * @return {@code true} if the datatype of this literal is rdf:PlainLiteral, otherwise {@code + * false}. + */ + default boolean isRDFPlainLiteral() { + return false; + } + + /** + * Gets the lexical value of this literal. Note that if the datatype is {@code rdf:PlainLiteral} + * then the abbreviated lexical form will be returned. That is, the language tag is not + * included. + * + * @return The lexical value of this literal. If the datatype is {@code rdf:PlainLiteral} then + * the return values are as follows: If the literal is of the form {@code + * "abc@"^^rdf:PlainLiteral} then the return value will be "abc" (without the language tag + * included). If the literal is of the form {@code "abc@langTag"^^rdf:PlainLiteral} then + * the return value will be "abc" (without the language tag included). + */ + String getLiteral(); + + @Override + default String getLang() { + return ""; + } + + /** + * Gets the {@code OWLDatatype} which types this literal. + * + * @return The {@code OWLDatatype} that types this literal. Note that for strings with language + * tag (previously considered to be untyped literals) the datatype will be + * rdf:PlainLiteral. The return value is never {@code null}. + */ + OWLDatatype getDatatype(); + + /** + * Determines if this literal has a language tag. + * + * @return {@code true} if this literal has a non-empty language tag, otherwise {@code false} + */ + default boolean hasLang() { + return false; + } + + /** + * Determines if this {@code OWLLiteral} has a particular language tag. + * + * @param lang The specific language tag to test for. The tag will be normalised - white space + * will be trimmed from the end and it will be converted to lower case. Null input will + * be treated as empty. + * @return {@code true} if this literal has a language tag equal to {@code lang}, otherwise + * {@code false}. + */ + default boolean hasLang(@SuppressWarnings("unused") @Nullable String lang) { + return false; + } + + /** + * Determines if this literal is typed with a datatype that has an IRI that is + * {@code "http://www.w3.org/2001/XMLSchema#"integer}. + * + * @return {@code true} if this literal is typed with + * {@code "http://www.w3.org/2001/XMLSchema#"integer}, i.e. this literal represents an + * integer, otherwise {@code false}. + */ + default boolean isInteger() { + return false; + } + + /** + * Parses the lexical value of this literal into an integer. The lexical value of this literal + * should be in the lexical space of the integer datatype + * ({@code "http://www.w3.org/2001/XMLSchema#"integer}) + * + * @return An integer value that is represented by this literal. + * @throws NumberFormatException if the lexical form could not be parsed into an integer because + * it is not in the lexical space of the integer datatype. + */ + default int parseInteger() { + throw new NumberFormatException( + getClass().getName() + " does not have an int value but has " + getLiteral()); + } + + /** + * Determines if this literal is typed with a datatype that has an IRI that is + * {@code "http://www.w3.org/2001/XMLSchema#"boolean}. + * + * @return {@code true} if this literal is typed with + * {@code "http://www.w3.org/2001/XMLSchema#"boolean}, i.e. this literal represents a + * boolean, otherwise {@code false}. + */ + default boolean isBoolean() { + return false; + } + + /** + * Parses the lexical value of this literal into a boolean. The lexical value of this literal + * should be in the lexical space of the boolean datatype + * ({@code "http://www.w3.org/2001/XMLSchema#"boolean}). + * + * @return A boolean value that is represented by this literal. + * @throws NumberFormatException if the lexical form could not be parsed into a boolean because + * it is not in the lexical space of the boolean datatype. + */ + default boolean parseBoolean() { + throw new OWLRuntimeException( + getClass().getName() + " does not have a boolean value but has " + getLiteral()); + } + + /** + * Determines if this literal is typed with a datatype that has an IRI that is + * {@code "http://www.w3.org/2001/XMLSchema#"double}. + * + * @return {@code true} if this literal is typed with + * {@code "http://www.w3.org/2001/XMLSchema#"double}, i.e. this literal represents a + * double, otherwise {@code false}. + */ + default boolean isDouble() { + return false; + } + + /** + * Parses the lexical value of this literal into a double. The lexical value of this literal + * should be in the lexical space of the double datatype ( + * {@code "http://www.w3.org/2001/XMLSchema#"double}). + * + * @return A double value that is represented by this literal. + * @throws NumberFormatException if the lexical form could not be parsed into a double because + * it is not in the lexical space of the double datatype. + */ + default double parseDouble() { + throw new NumberFormatException( + getClass().getName() + " does not have a double value but has " + getLiteral()); + } + + /** + * Determines if this literal is typed with a datatype that has an IRI that is + * {@code "http://www.w3.org/2001/XMLSchema#"float}. + * + * @return {@code true} if this literal is typed with + * {@code "http://www.w3.org/2001/XMLSchema#"float}, i.e. this literal represents a + * float, otherwise {@code false}. + */ + default boolean isFloat() { + return false; + } + + /** + * Parses the lexical value of this literal into a float. The lexical value of this literal + * should be in the lexical space of the float datatype ( + * {@code "http://www.w3.org/2001/XMLSchema#"float}). + * + * @return A float value that is represented by this literal. + * @throws NumberFormatException if the lexical form could not be parsed into a float because it + * is not in the lexical space of the float datatype. + */ + default float parseFloat() { + throw new NumberFormatException( + getClass().getName() + " does not have a float value but has " + getLiteral()); + } + + @Override + default Optional asLiteral() { + return optional(this); + } + + /** + * @param visitor visitor + */ + default void accept(OWLDataVisitor visitor) { + visitor.visit(this); + } + + /** + * @param visitor visitor + * @param visitor return type + * @return visitor return value + */ + default O accept(OWLDataVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAnnotationValueVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAnnotationValueVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default boolean isLiteral() { + return true; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLLiteralVisitorBase.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLLiteralVisitorBase.java new file mode 100644 index 0000000000..3e3201b326 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLLiteralVisitorBase.java @@ -0,0 +1,29 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 3.0.0 + */ +public interface OWLLiteralVisitorBase extends OWLVisitorBase { + + /** + * visit OWLLiteral type + * + * @param node node to visit + */ + default void visit(OWLLiteral node) { + doDefault(node); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLLiteralVisitorExBase.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLLiteralVisitorExBase.java new file mode 100644 index 0000000000..577e69b28f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLLiteralVisitorExBase.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param return type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 3.0.0 + */ +public interface OWLLiteralVisitorExBase extends OWLVisitorExBase { + + /** + * visit OWLLiteral type + * + * @param node node to visit + * @return visitor value + */ + default O visit(OWLLiteral node) { + return doDefault(node); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLLogicalAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLLogicalAxiom.java new file mode 100644 index 0000000000..2321e6047e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLLogicalAxiom.java @@ -0,0 +1,29 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * A base interface of all axioms that affect the logical meaning of an + * ontology. This excludes declaration axioms (including imports declarations) + * and annotation axioms. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLLogicalAxiom extends OWLAxiom { + + @Override + public default boolean isLogicalAxiom() { + return true; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLLogicalAxiomVisitor.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLLogicalAxiomVisitor.java new file mode 100644 index 0000000000..824405d4d8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLLogicalAxiomVisitor.java @@ -0,0 +1,308 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLLogicalAxiomVisitor extends SWRLRuleVisitorBase { + + /** + * visit OWLSubClassOfAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLSubClassOfAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLNegativeObjectPropertyAssertionAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLNegativeObjectPropertyAssertionAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLAsymmetricObjectPropertyAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLAsymmetricObjectPropertyAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLReflexiveObjectPropertyAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLReflexiveObjectPropertyAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLDisjointClassesAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLDisjointClassesAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLDataPropertyDomainAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLDataPropertyDomainAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLObjectPropertyDomainAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLObjectPropertyDomainAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLEquivalentObjectPropertiesAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLEquivalentObjectPropertiesAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLNegativeDataPropertyAssertionAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLNegativeDataPropertyAssertionAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLDifferentIndividualsAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLDifferentIndividualsAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLDisjointDataPropertiesAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLDisjointDataPropertiesAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLDisjointObjectPropertiesAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLDisjointObjectPropertiesAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLObjectPropertyRangeAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLObjectPropertyRangeAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLObjectPropertyAssertionAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLObjectPropertyAssertionAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLFunctionalObjectPropertyAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLFunctionalObjectPropertyAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLSubObjectPropertyOfAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLSubObjectPropertyOfAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLDisjointUnionAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLDisjointUnionAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLSymmetricObjectPropertyAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLSymmetricObjectPropertyAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLDataPropertyRangeAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLDataPropertyRangeAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLFunctionalDataPropertyAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLFunctionalDataPropertyAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLEquivalentDataPropertiesAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLEquivalentDataPropertiesAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLClassAssertionAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLClassAssertionAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLEquivalentClassesAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLEquivalentClassesAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLDataPropertyAssertionAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLDataPropertyAssertionAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLTransitiveObjectPropertyAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLTransitiveObjectPropertyAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLIrreflexiveObjectPropertyAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLIrreflexiveObjectPropertyAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLSubDataPropertyOfAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLSubDataPropertyOfAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLInverseFunctionalObjectPropertyAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLInverseFunctionalObjectPropertyAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLSameIndividualAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLSameIndividualAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLSubPropertyChainOfAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLSubPropertyChainOfAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLInverseObjectPropertiesAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLInverseObjectPropertiesAxiom axiom) { + doDefault(axiom); + } + + /** + * visit OWLHasKeyAxiom type + * + * @param axiom axiom to visit + */ + default void visit(OWLHasKeyAxiom axiom) { + doDefault(axiom); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLLogicalAxiomVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLLogicalAxiomVisitorEx.java new file mode 100644 index 0000000000..0084e46fe3 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLLogicalAxiomVisitorEx.java @@ -0,0 +1,341 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param visitor type + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLLogicalAxiomVisitorEx extends SWRLRuleVisitorExBase { + + /** + * visit OWLSubClassOfAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLSubClassOfAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLNegativeObjectPropertyAssertionAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLNegativeObjectPropertyAssertionAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLAsymmetricObjectPropertyAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLAsymmetricObjectPropertyAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLReflexiveObjectPropertyAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLReflexiveObjectPropertyAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLDisjointClassesAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLDisjointClassesAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLDataPropertyDomainAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLDataPropertyDomainAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLObjectPropertyDomainAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLObjectPropertyDomainAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLEquivalentObjectPropertiesAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLEquivalentObjectPropertiesAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLNegativeDataPropertyAssertionAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLNegativeDataPropertyAssertionAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLDifferentIndividualsAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLDifferentIndividualsAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLDisjointDataPropertiesAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLDisjointDataPropertiesAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLDisjointObjectPropertiesAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLDisjointObjectPropertiesAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLObjectPropertyRangeAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLObjectPropertyRangeAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLObjectPropertyAssertionAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLObjectPropertyAssertionAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLFunctionalObjectPropertyAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLFunctionalObjectPropertyAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLSubObjectPropertyOfAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLSubObjectPropertyOfAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLDisjointUnionAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLDisjointUnionAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLSymmetricObjectPropertyAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLSymmetricObjectPropertyAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLDataPropertyRangeAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLDataPropertyRangeAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLFunctionalDataPropertyAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLFunctionalDataPropertyAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLEquivalentDataPropertiesAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLEquivalentDataPropertiesAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLClassAssertionAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLClassAssertionAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLEquivalentClassesAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLEquivalentClassesAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLDataPropertyAssertionAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLDataPropertyAssertionAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLTransitiveObjectPropertyAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLTransitiveObjectPropertyAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLIrreflexiveObjectPropertyAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLIrreflexiveObjectPropertyAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLSubDataPropertyOfAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLSubDataPropertyOfAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLInverseFunctionalObjectPropertyAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLInverseFunctionalObjectPropertyAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLSameIndividualAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLSameIndividualAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLSubPropertyChainOfAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLSubPropertyChainOfAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLInverseObjectPropertiesAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLInverseObjectPropertiesAxiom axiom) { + return doDefault(axiom); + } + + /** + * visit OWLHasKeyAxiom type + * + * @param axiom axiom to visit + * @return visitor value + */ + default O visit(OWLHasKeyAxiom axiom) { + return doDefault(axiom); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLLogicalEntity.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLLogicalEntity.java new file mode 100644 index 0000000000..8b6815b557 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLLogicalEntity.java @@ -0,0 +1,34 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + * @deprecated this interface is redundant + */ +@Deprecated +public interface OWLLogicalEntity extends OWLEntity { + + @Override + default Stream components() { + return Stream.of(getIRI()); + } + + @Override + default int initHashCode() { + return OWLObject.hashIteration(hashIndex(), getIRI().hashCode()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLMutableOntology.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLMutableOntology.java new file mode 100644 index 0000000000..07aad6a788 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLMutableOntology.java @@ -0,0 +1,33 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.concurrent.locks.ReadWriteLock; + +/** + * Marker interface for ontologies where mutating actions must have an effect. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLMutableOntology extends OWLOntology { + + /** + * Override the lock in the ontology; this is a workaround for #806 + * + * @param lock overriding lock instance to use + */ + default void setLock(@SuppressWarnings("unused") ReadWriteLock lock) { + // do nothing in the default implementation + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLNamedIndividual.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLNamedIndividual.java new file mode 100644 index 0000000000..0452501e3e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLNamedIndividual.java @@ -0,0 +1,94 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents a + * Named + * Individual in the OWL 2 Specification. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLNamedIndividual extends OWLIndividual, OWLLogicalEntity { + + @Override + default int hashIndex() { + return 311; + } + + @Override + default int typeIndex() { + return 1005; + } + + @Override + default EntityType getEntityType() { + return EntityType.NAMED_INDIVIDUAL; + } + + @Override + default boolean isOWLNamedIndividual() { + return true; + } + + @Override + default OWLAnonymousIndividual asOWLAnonymousIndividual() { + throw new OWLRuntimeException("Not an anonymous individual"); + } + + @Override + default boolean isBuiltIn() { + return false; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLEntityVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLEntityVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLNamedObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLNamedObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLIndividualVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLIndividualVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLNamedObject.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLNamedObject.java new file mode 100644 index 0000000000..bd2036b4b8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLNamedObject.java @@ -0,0 +1,39 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents a named object for example, class, property, ontology etc. - i.e. + * anything that has an IRI as its name. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLNamedObject extends OWLObject, HasIRI { + + /** + * Accepts a visitor. + * + * @param visitor The visitor + */ + void accept(OWLNamedObjectVisitor visitor); + + /** + * Accepts a visitor. + * + * @param visitor return type + * @param visitor The visitor + * @return visitor return value + */ + O accept(OWLNamedObjectVisitorEx visitor); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLNamedObjectVisitor.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLNamedObjectVisitor.java new file mode 100644 index 0000000000..da0ad9326e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLNamedObjectVisitor.java @@ -0,0 +1,29 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLNamedObjectVisitor extends OWLPropertyEntityVisitorBase, OWLEntityVisitor { + + /** + * visit OWLOntology type + * + * @param ontology ontology to visit + */ + default void visit(OWLOntology ontology) { + doDefault(ontology); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLNamedObjectVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLNamedObjectVisitorEx.java new file mode 100644 index 0000000000..ef697daf06 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLNamedObjectVisitorEx.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param visitor type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public interface OWLNamedObjectVisitorEx extends OWLEntityVisitorEx { + + /** + * visit OWLOntology type + * + * @param ontology ontology to visit + * @return visitor value + */ + default O visit(OWLOntology ontology) { + return doDefault(ontology); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLNaryAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLNaryAxiom.java new file mode 100644 index 0000000000..97b6647ae6 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLNaryAxiom.java @@ -0,0 +1,138 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.allPairs; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.pairs; + +import java.util.Collection; +import java.util.Objects; +import java.util.stream.Stream; + +/** + * Represents an axiom that contains two or more operands that could also be represented with + * multiple pairwise axioms. + * + * @param class of contained objects + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLNaryAxiom extends OWLAxiom, HasOperands { + + /** + * @return a stream of all operands for this n-ary axiom. This provides a platform for common + * operations across different types, e.g., this will be the properties() stream for a + * DisjointObjectProperties, or a classExpressions() stream for a DisjointClasses. + */ + @Override + Stream operands(); + + /** + * Gets this axiom as a set of pairwise axioms; if the axiom contains only two operands, + * the axiom itself is returned unchanged, including its annotations. Note that, aside + * from this exception, annotations on this axiom will not be copied to each axiom + * returned in the set of pairwise axioms.
+ * Note: This will contain all pairs, i.e., for the set "a, b, c" the pairs "a, b", "a, c", "b, + * c" will be returned. For some applications, only "a, b", "b, c" are required. + * + * @return This axiom as a set of pairwise axioms. + */ + Collection> asPairwiseAxioms(); + + /** + * @param type returned by visitor + * @param visitor visitor to apply to all pairwise elements in this axiom; pairs are not + * ordered, i.e., only (i,j) will be considered, for i!=j; (j, i) is not considered. + * @return collection of all visitor return values that are not null + */ + default Collection walkPairwise(OWLPairwiseVisitor visitor) { + return asList(pairs(operands()).map(v -> visitor.visit(v.i, v.j)).filter(Objects::nonNull)); + } + + /** + * @param type returned by visitor + * @param visitor visitor to apply to all pairwise elements in this axiom; pairs are ordered, + * i.e., (i, j) and (j, i) will be considered. (i,i) is skipped. + * @return collection of all visitor return values that are not null + */ + default Collection walkAllPairwise(OWLPairwiseVisitor visitor) { + return asList( + allPairs(operands()).map(v -> visitor.visit(v.i, v.j)).filter(Objects::nonNull)); + } + + /** + * @param visitor visitor to apply to all pairwise elements in this axiom; pairs are not + * ordered, i.e., only (i,j) will be considered, for i!=j; (j, i) is not considered. + */ + default void forEach(OWLPairwiseVoidVisitor visitor) { + pairs(operands()).forEach(v -> visitor.visit(v.i, v.j)); + } + + /** + * @param visitor visitor to apply to all pairwise elements in this axiom; pairs are not + * ordered, i.e., only (i,j) will be considered, for i!=j; (j, i) is not considered. + * @return true if at least one pair evaluation is true + */ + default boolean anyMatch(OWLPairwiseBooleanVisitor visitor) { + return pairs(operands()).anyMatch(v -> visitor.visit(v.i, v.j)); + } + + /** + * @param visitor visitor to apply to all pairwise elements in this axiom; pairs are not + * ordered, i.e., only (i,j) will be considered, for i!=j; (j, i) is not considered. + * @return true if all pairs evaluation is true + */ + default boolean allMatch(OWLPairwiseBooleanVisitor visitor) { + return pairs(operands()).allMatch(v -> visitor.visit(v.i, v.j)); + } + + /** + * @param visitor visitor to apply to all pairwise elements in this axiom; pairs are ordered, + * i.e., (i, j) and (j, i) will be considered. (i,i) is skipped. + */ + default void forEachAllPairs(OWLPairwiseVoidVisitor visitor) { + allPairs(operands()).forEach(v -> visitor.visit(v.i, v.j)); + } + + /** + * @param visitor visitor to apply to all pairwise elements in this axiom; pairs are ordered, + * i.e., (i, j) and (j, i) will be considered. (i,i) is skipped. + * @return true if at least one pair evaluation is true + */ + default boolean anyMatchAllPairs(OWLPairwiseBooleanVisitor visitor) { + return allPairs(operands()).anyMatch(v -> visitor.visit(v.i, v.j)); + } + + /** + * @param visitor visitor to apply to all pairwise elements in this axiom; pairs are ordered, + * i.e., (i, j) and (j, i) will be considered. (i,i) is skipped. + * @return true if all pairs evaluation is true + */ + default boolean allMatchAllPairs(OWLPairwiseBooleanVisitor visitor) { + return allPairs(operands()).allMatch(v -> visitor.visit(v.i, v.j)); + } + + /** + * Splits this axiom to pairs, including annotations. This method implements the process + * described at http://www.w3.org/TR/owl2-mapping-to-rdf/# + * Axioms_that_are_Translated_to_Multiple_Triples which is used, for example, in serializing + * EquivalentProperty axioms with three operands. Note that annotations on this axiom will be + * copied to each axiom returned in the set of pairwise axioms. Note: This will contain only the + * "An, An+1" pairs, i.e., for the set "a, b, c" the pairs "a, b" and "b, c" will be returned, + * but not "a, c". + * + * @return This axiom as a set of pairwise axioms, annotations included. + */ + Collection splitToAnnotatedPairs(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLNaryBooleanClassExpression.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLNaryBooleanClassExpression.java new file mode 100644 index 0000000000..49e7522bf7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLNaryBooleanClassExpression.java @@ -0,0 +1,44 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLNaryBooleanClassExpression + extends OWLBooleanClassExpression, HasOperands { + + @Override + default Stream components() { + return Stream.of(getOperandsAsList()); + } + + @Override + default int initHashCode() { + return OWLObject.hashIteration(hashIndex(), getOperandsAsList().hashCode()); + } + + /** + * @return the class expressions. The set that is returned is a copy; modifications to the + * returned set will not be reflected in this object. + */ + default Set getOperands() { + return asSet(operands()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLNaryClassAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLNaryClassAxiom.java new file mode 100644 index 0000000000..53de700278 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLNaryClassAxiom.java @@ -0,0 +1,102 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.List; +import java.util.Set; +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLNaryClassAxiom extends OWLClassAxiom, OWLNaryAxiom, + OWLSubClassOfAxiomSetShortCut, HasOperands { + + @Override + default Stream components() { + return Stream.of(getOperandsAsList(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getOperandsAsList().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getOperandsAsList()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getOperandsAsList()); + } + + /** + * Gets all of the top level class expressions that appear in this axiom. + * + * @return A {@code Set} of class expressions that appear in the axiom. The set that is returned + * is a copy; modifications to the returned set will not be reflected in this object. + */ + default Set getClassExpressions() { + return asSet(classExpressions()); + } + + /** + * Gets all of the top level class expressions that appear in this axiom. + * + * @return Sorted stream of class expressions that appear in the axiom. + */ + Stream classExpressions(); + + @Override + default Stream operands() { + return classExpressions(); + } + + /** + * A convenience method that obtains the class expression returned by the + * {@link #getClassExpressions()} method as a list of class expressions. + * + * @return A list of the class expressions in this axiom. + * @deprecated use {@link #getOperandsAsList()} + */ + @Deprecated + default List getClassExpressionsAsList() { + return getOperandsAsList(); + } + + /** + * Determines if this class axiom contains the specified class expression as an operand. + * + * @param ce The class expression to test for + * @return {@code true} if this axiom contains the specified class expression as an operand, + * otherwise {@code false}. + */ + boolean contains(OWLClassExpression ce); + + /** + * Gets the set of class expressions that appear in this axiom minus the specified class + * expressions. + * + * @param desc The class expressions to subtract from the class expressions in this axiom + * @return A set containing all of the class expressions in this axiom (the class expressions + * returned by getClassExpressions()) minus the specified list of class expressions + */ + Set getClassExpressionsMinus(OWLClassExpression... desc); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLNaryDataRange.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLNaryDataRange.java new file mode 100644 index 0000000000..1300018aea --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLNaryDataRange.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLNaryDataRange extends OWLDataRange, HasOperands { + + @Override + default Stream components() { + return Stream.of(getOperandsAsList()); + } + + @Override + default int initHashCode() { + return OWLObject.hashIteration(hashIndex(), getOperandsAsList().hashCode()); + } + + /** + * @return the data ranges. The set that is returned is a copy; modifications to the returned + * set will not be reflected in this object. + */ + default Set getOperands() { + return asSet(operands()); + } + + /** + * @return the data ranges + */ + @Override + Stream operands(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLNaryIndividualAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLNaryIndividualAxiom.java new file mode 100644 index 0000000000..7890607ae7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLNaryIndividualAxiom.java @@ -0,0 +1,77 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.List; +import java.util.Set; +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLNaryIndividualAxiom extends OWLIndividualAxiom, OWLNaryAxiom, + OWLSubClassOfAxiomSetShortCut, HasOperands { + + @Override + default Stream components() { + return Stream.of(getOperandsAsList(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getOperandsAsList().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getOperandsAsList()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getOperandsAsList()); + } + + /** + * @return The individuals. The set that is returned is a copy; modifications to the returned + * set will not be reflected in this object. + */ + default Set getIndividuals() { + return asSet(individuals()); + } + + /** + * @return the sorted individuals + */ + Stream individuals(); + + @Override + default Stream operands() { + return individuals(); + } + + /** + * Gets the individuals returned by {@link #getIndividuals()} as a list. + * + * @return The sorted individuals in this axiom as a list + */ + default List getIndividualsAsList() { + return asList(individuals()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLNaryPropertyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLNaryPropertyAxiom.java new file mode 100644 index 0000000000..83e1e88385 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLNaryPropertyAxiom.java @@ -0,0 +1,73 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * @param

property expression + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLNaryPropertyAxiom

+ extends OWLPropertyAxiom, OWLNaryAxiom

, HasOperands

{ + + @Override + default Stream components() { + return Stream.of(getOperandsAsList(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getOperandsAsList().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getOperandsAsList()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getOperandsAsList()); + } + + /** + * @return all of the properties that appear in this axiom. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + */ + default Set

getProperties() { + return asSet(properties()); + } + + /** + * @return all of the properties that appear in this axiom + */ + Stream

properties(); + + @Override + default Stream

operands() { + return properties(); + } + + /** + * @param property the property to skip + * @return the set of properties minus property + */ + Set

getPropertiesMinus(P property); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLNegativeDataPropertyAssertionAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLNegativeDataPropertyAssertionAxiom.java new file mode 100644 index 0000000000..1bc7a62528 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLNegativeDataPropertyAssertionAxiom.java @@ -0,0 +1,65 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents a NegativeDataPropertyAssertion axiom in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLNegativeDataPropertyAssertionAxiom extends + OWLPropertyAssertionAxiom, OWLSubClassOfAxiomShortCut { + + @Override + @SuppressWarnings("unchecked") + OWLNegativeDataPropertyAssertionAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 97; + } + + /** + * Determines whether this axiom contains anonymous individuals. + * + * @return {@code true} if this axioms contains anonymous individual axioms + */ + boolean containsAnonymousIndividuals(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.NEGATIVE_DATA_PROPERTY_ASSERTION; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLNegativeObjectPropertyAssertionAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLNegativeObjectPropertyAssertionAxiom.java new file mode 100644 index 0000000000..be87458115 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLNegativeObjectPropertyAssertionAxiom.java @@ -0,0 +1,66 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents a + * NegativeObjectPropertyAssertion axiom in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLNegativeObjectPropertyAssertionAxiom + extends OWLPropertyAssertionAxiom, + OWLSubClassOfAxiomShortCut { + + @Override + @SuppressWarnings("unchecked") + OWLNegativeObjectPropertyAssertionAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 101; + } + + /** + * Determines whether this axiom contains anonymous individuals. + * + * @return {@code true} if this axioms contains anonymous individual axioms + */ + boolean containsAnonymousIndividuals(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.NEGATIVE_OBJECT_PROPERTY_ASSERTION; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObject.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObject.java new file mode 100644 index 0000000000..24d76c6bef --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObject.java @@ -0,0 +1,181 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.empty; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.flatComponents; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObject + extends Comparable, Serializable, HasSignature, HasContainsEntityInSignature, + HasAnonymousIndividuals, HasClassesInSignature, HasObjectPropertiesInSignature, + HasDataPropertiesInSignature, HasIndividualsInSignature, HasDatatypesInSignature, + HasAnnotationPropertiesInSignature, HasIndex, HasHashIndex, HasComponents, IsAnonymous { + + /** + * Gets all of the nested (includes top level) class expressions (anonymous and named) that are + * used in this object. For an ontology, this method visits the logical axioms, so entities that + * are only declared (and possibly annotated) but do not appear in any logical axiom are not + * returned as part of the set. The default implementation of this method returns an empty, + * modifiable set. + * + * @return A set of {@link org.semanticweb.owlapi.model.OWLClassExpression}s that represent the + * nested class expressions used in this object. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + */ + default Set getNestedClassExpressions() { + return asSet(nestedClassExpressions()); + } + + /** + * Gets all of the nested (includes top level) class expressions (anonymous and named) that are + * used in this object. For an ontology, this method visits the logical axioms, so entities that + * are only declared (and possibly annotated) but do not appear in any logical axiom are not + * returned as part of the stream. The default implementation of this method returns an empty + * stream. + * + * @return A stream of {@link org.semanticweb.owlapi.model.OWLClassExpression}s that represent + * the nested class expressions used in this object. + */ + default Stream nestedClassExpressions() { + return empty(); + } + + /** + * Accepts a visitor + * + * @param visitor The visitor + */ + void accept(OWLObjectVisitor visitor); + + /** + * Accepts a visitor + * + * @param visitor The visitor + * @param visitor return type + * @return visitor value + */ + O accept(OWLObjectVisitorEx visitor); + + /** + * Determines if this object is either, owl:Thing (the top class), owl:topObjectProperty (the + * top object property) , owl:topDataProperty (the top data property) or rdfs:Literal (the top + * datatype). + * + * @return {@code true} if this object corresponds to one of the above entities. + */ + default boolean isTopEntity() { + return false; + } + + /** + * Determines if this object is either, owl:Nothing (the bottom class), owl:bottomObjectProperty + * (the bottom object property) , owl:bottomDataProperty (the bottom data property). + * + * @return {@code true} if this object corresponds to one of the above entities. + */ + default boolean isBottomEntity() { + return false; + } + + /** + * @return true if this object is an IRI. + */ + default boolean isIRI() { + return false; + } + + /** + * @return true if this object is an individual. + */ + default boolean isIndividual() { + return false; + } + + /** + * @return true if this object is an axiom. + */ + default boolean isAxiom() { + return false; + } + + /** + * @return true for ontologies, false for any other OWL object + */ + default boolean isOntology() { + return false; + } + + /** + * @return true if this object is not an axiom, not an individual and anonymous; this is true + * for class and property expressions, as well as data ranges. + */ + default boolean isAnonymousExpression() { + return !isAxiom() && !isIndividual() && !isOntology() && !isIRI() + && !(this instanceof OWLLiteral) && isAnonymous(); + } + + /** + * @return true if this object contains anonymous expressions referred multiple times. This is + * called structure sharing. An example can be:
+ * + *

+     * some P C subClassOf some Q (some P C)
+     *         
+ * + *
+ * This can happen in axioms as well as in expressions:
+ * + *
+     * (some P C) and (some Q (some P C))
+     *         
+ * + *
+ */ + default boolean hasSharedStructure() { + Map counters = new HashMap<>(); + Stream filter = flatComponents(this).filter(x -> x instanceof OWLObject) + .map(x -> (OWLObject) x).filter(OWLObject::isAnonymousExpression); + filter + .forEach(x -> counters.computeIfAbsent(x, q -> new AtomicInteger(0)).incrementAndGet()); + return counters.values().stream().anyMatch(x -> x.get() > 1); + } + + /** + * @return hash code for the object; called on first use, cached by OWLObjectImpl in the default + * implementation. + */ + int initHashCode(); + + /** + * Iteration for hash codes + * + * @param a existing hash + * @param b hash to add + * @return new hash + */ + static int hashIteration(int a, int b) { + return a * 37 + b; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectAllValuesFrom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectAllValuesFrom.java new file mode 100644 index 0000000000..cba037af6c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectAllValuesFrom.java @@ -0,0 +1,59 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents an + * + * ObjectAllValuesFrom restriction in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectAllValuesFrom extends OWLQuantifiedObjectRestriction { + + @Override + default int hashIndex() { + return 193; + } + + @Override + default int typeIndex() { + return 3006; + } + + @Override + default ClassExpressionType getClassExpressionType() { + return ClassExpressionType.OBJECT_ALL_VALUES_FROM; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLClassExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLClassExpressionVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectCardinalityRestriction.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectCardinalityRestriction.java new file mode 100644 index 0000000000..e1d836d3de --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectCardinalityRestriction.java @@ -0,0 +1,23 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectCardinalityRestriction extends + OWLCardinalityRestriction, + OWLQuantifiedObjectRestriction, OWLObjectRestriction { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectComplementOf.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectComplementOf.java new file mode 100644 index 0000000000..9cdc2bfc35 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectComplementOf.java @@ -0,0 +1,75 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * Represents an + * ObjectComplementOf class expression in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectComplementOf extends OWLBooleanClassExpression { + + @Override + default Stream components() { + return Stream.of(getOperand()); + } + + @Override + default int initHashCode() { + return OWLObject.hashIteration(hashIndex(), getOperand().hashCode()); + } + + @Override + default int hashIndex() { + return 197; + } + + @Override + default int typeIndex() { + return 3003; + } + + @Override + default ClassExpressionType getClassExpressionType() { + return ClassExpressionType.OBJECT_COMPLEMENT_OF; + } + + /** + * @return the wrapped expression + */ + OWLClassExpression getOperand(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLClassExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLClassExpressionVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectExactCardinality.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectExactCardinality.java new file mode 100644 index 0000000000..61949e3abe --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectExactCardinality.java @@ -0,0 +1,67 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents an + * ObjectExactCardinality restriction in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectExactCardinality extends OWLObjectCardinalityRestriction { + + @Override + default int hashIndex() { + return 199; + } + + @Override + default int typeIndex() { + return 3009; + } + + @Override + default ClassExpressionType getClassExpressionType() { + return ClassExpressionType.OBJECT_EXACT_CARDINALITY; + } + + /** + * Obtains an equivalent form that is a conjunction of a min cardinality and + * max cardinality restriction. + * + * @return The semantically equivalent but structurally simpler form (= 1 R C) = >= 1 R C and + * <= 1 R C + */ + OWLClassExpression asIntersectionOfMinMax(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLClassExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLClassExpressionVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectHasSelf.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectHasSelf.java new file mode 100644 index 0000000000..3976a58a1a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectHasSelf.java @@ -0,0 +1,73 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * Represents an ObjectHasSelf + * class expression in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectHasSelf extends OWLRestriction, OWLObjectRestriction { + + @Override + default Stream components() { + return Stream.of(getProperty()); + } + + @Override + default int initHashCode() { + return OWLObject.hashIteration(hashIndex(), getProperty().hashCode()); + } + + @Override + default int hashIndex() { + return 233; + } + + @Override + default int typeIndex() { + return 3011; + } + + @Override + default ClassExpressionType getClassExpressionType() { + return ClassExpressionType.OBJECT_HAS_SELF; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLClassExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLClassExpressionVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + OWLObjectPropertyExpression getProperty(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectHasValue.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectHasValue.java new file mode 100644 index 0000000000..b235253996 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectHasValue.java @@ -0,0 +1,60 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents an + * + * ObjectHasValue class expression in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectHasValue extends OWLHasValueRestriction, + OWLObjectRestriction { + + @Override + default int hashIndex() { + return 251; + } + + @Override + default int typeIndex() { + return 3007; + } + + @Override + default ClassExpressionType getClassExpressionType() { + return ClassExpressionType.OBJECT_HAS_VALUE; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLClassExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLClassExpressionVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectIntersectionOf.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectIntersectionOf.java new file mode 100644 index 0000000000..e500beaf31 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectIntersectionOf.java @@ -0,0 +1,59 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents an + * ObjectIntersectionOf class expression in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectIntersectionOf extends OWLNaryBooleanClassExpression { + + @Override + default int hashIndex() { + return 211; + } + + @Override + default int typeIndex() { + return 3001; + } + + @Override + default ClassExpressionType getClassExpressionType() { + return ClassExpressionType.OBJECT_INTERSECTION_OF; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLClassExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLClassExpressionVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectInverseOf.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectInverseOf.java new file mode 100644 index 0000000000..10bda52ba7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectInverseOf.java @@ -0,0 +1,82 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * Represents a + * ObjectInverseOf Represents the inverse of a property expression. This can be used to refer to + * the inverse of a property, without actually naming the property. For example, consider the + * property hasPart, the inverse property of hasPart (isPartOf) can be referred to using this + * interface inverseOf(hasPart), which can be used in restrictions e.g. inverseOf(hasPart) some Car + * refers to the set of things that are part of at least one car. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectInverseOf extends OWLObjectPropertyExpression { + + @Override + default Stream components() { + return Stream.of(getInverse()); + } + + @Override + default int initHashCode() { + return OWLObject.hashIteration(hashIndex(), getInverse().hashCode()); + } + + @Override + default int hashIndex() { + return 307; + } + + @Override + default int typeIndex() { + return 1003; + } + + @Override + default OWLObjectPropertyExpression getInverseProperty() { + return getInverse(); + } + + /** + * Gets the property expression that this is the inverse of. + * + * @return The object property expression such that this object property expression is an + * inverse of it. + */ + OWLObjectPropertyExpression getInverse(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLPropertyExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLPropertyExpressionVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectMaxCardinality.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectMaxCardinality.java new file mode 100644 index 0000000000..b40511f306 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectMaxCardinality.java @@ -0,0 +1,59 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents an + * + * ObjectMaxCardinality restriction in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectMaxCardinality extends OWLObjectCardinalityRestriction { + + @Override + default int hashIndex() { + return 223; + } + + @Override + default int typeIndex() { + return 3010; + } + + @Override + default ClassExpressionType getClassExpressionType() { + return ClassExpressionType.OBJECT_MAX_CARDINALITY; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLClassExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLClassExpressionVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectMinCardinality.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectMinCardinality.java new file mode 100644 index 0000000000..4092111e7e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectMinCardinality.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents a + * ObjectMinCardinality restriction in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectMinCardinality extends OWLObjectCardinalityRestriction { + + @Override + default int hashIndex() { + return 227; + } + + @Override + default int typeIndex() { + return 3008; + } + + @Override + default ClassExpressionType getClassExpressionType() { + return ClassExpressionType.OBJECT_MIN_CARDINALITY; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLClassExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLClassExpressionVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectOneOf.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectOneOf.java new file mode 100644 index 0000000000..57492474b7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectOneOf.java @@ -0,0 +1,106 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +/** + * Represents an + * ObjectOneOf class expression in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectOneOf extends OWLAnonymousClassExpression, HasOperands { + + @Override + default Stream components() { + return Stream.of(getOperandsAsList()); + } + + @Override + default int initHashCode() { + return OWLObject.hashIteration(hashIndex(), getOperandsAsList().hashCode()); + } + + @Override + default int hashIndex() { + return 229; + } + + @Override + default int typeIndex() { + return 3004; + } + + @Override + default ClassExpressionType getClassExpressionType() { + return ClassExpressionType.OBJECT_ONE_OF; + } + + /** + * Gets the individuals that are in the oneOf. These individuals represent the exact instances + * (extension) of this class expression. + * + * @return The individuals that are the values of this {@code ObjectOneOf} class expression. The + * set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + */ + default Set getIndividuals() { + return asSet(individuals()); + } + + /** + * Gets the individuals that are in the oneOf. These individuals represent the exact instances + * (extension) of this class expression. + * + * @return The individuals that are the values of this {@code ObjectOneOf} class expression. + */ + Stream individuals(); + + @Override + default Stream operands() { + return individuals(); + } + + /** + * Simplifies this enumeration to a union of singleton nominals. + * + * @return This enumeration in a more standard DL form. simp({a}) = {a} simp({a0, ... , {an}) = + * unionOf({a0}, ... , {an}) + */ + OWLClassExpression asObjectUnionOf(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLClassExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLClassExpressionVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectProperty.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectProperty.java new file mode 100644 index 0000000000..4410795815 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectProperty.java @@ -0,0 +1,111 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; + +/** + * Represents an + * Object + * Property in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectProperty extends OWLObjectPropertyExpression, OWLProperty { + + @Override + default int hashIndex() { + return 293; + } + + @Override + default int typeIndex() { + return 1002; + } + + @Override + default EntityType getEntityType() { + return EntityType.OBJECT_PROPERTY; + } + + @Override + default OWLObjectProperty getNamedProperty() { + return this; + } + + @Override + default boolean isOWLObjectProperty() { + return true; + } + + @Override + default boolean isTopEntity() { + return isOWLTopObjectProperty(); + } + + @Override + default boolean isBottomEntity() { + return isOWLBottomObjectProperty(); + } + + @Override + default boolean isOWLTopObjectProperty() { + return getIRI().equals(OWLRDFVocabulary.OWL_TOP_OBJECT_PROPERTY.getIRI()); + } + + @Override + default boolean isOWLBottomObjectProperty() { + return getIRI().equals(OWLRDFVocabulary.OWL_BOTTOM_OBJECT_PROPERTY.getIRI()); + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLPropertyExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLPropertyExpressionVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLEntityVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLEntityVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLNamedObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLNamedObjectVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyAssertionAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyAssertionAxiom.java new file mode 100644 index 0000000000..54016eff35 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyAssertionAxiom.java @@ -0,0 +1,81 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents an + * ObjectPropertyAssertion axiom in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectPropertyAssertionAxiom + extends OWLPropertyAssertionAxiom, + OWLSubClassOfAxiomShortCut { + + @Override + @SuppressWarnings("unchecked") + OWLObjectPropertyAssertionAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 103; + } + + /** + * Gets a simplified version of this object property axiom. This is defined recursively as + * follows: + *
    + *
  • ObjectPropertyAssertion(P S O) = ObjectPropertyAssertion(P S O) + *
  • ObjectPropertyAssertion(ObjectInverseOf(P) S O) = ObjectPropertyAssertion(P O S) + *
+ * + * @return the simplified version + */ + OWLObjectPropertyAssertionAxiom getSimplified(); + + /** + * Determines if this axiom is in a simplified form, i.e. a form where the property is not a + * property inverse. ObjectPropertyAssertion(P S O) is in a simplified form, where as + * ObjectPropertyAssertion(ObjectInverseOf(P) S O) is not because it contains an inverse object + * property. + * + * @return {@code true} if this axiom is in a simplified form, otherwise {@code false} + */ + boolean isInSimplifiedForm(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.OBJECT_PROPERTY_ASSERTION; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyAxiom.java new file mode 100644 index 0000000000..604c8847df --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyAxiom.java @@ -0,0 +1,21 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectPropertyAxiom extends OWLPropertyAxiom { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyCharacteristicAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyCharacteristicAxiom.java new file mode 100644 index 0000000000..090335729f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyCharacteristicAxiom.java @@ -0,0 +1,23 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectPropertyCharacteristicAxiom extends + OWLObjectPropertyAxiom, + OWLUnaryPropertyAxiom { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyDomainAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyDomainAxiom.java new file mode 100644 index 0000000000..a022ee1dd0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyDomainAxiom.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents + * ObjectPropertyDomain axioms in the OWL 2 specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectPropertyDomainAxiom + extends OWLPropertyDomainAxiom, OWLObjectPropertyAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLObjectPropertyDomainAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 109; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.OBJECT_PROPERTY_DOMAIN; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyExpression.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyExpression.java new file mode 100644 index 0000000000..13ddb2d849 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyExpression.java @@ -0,0 +1,55 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectPropertyExpression extends OWLPropertyExpression, SWRLPredicate { + + /** + * Obtains the property that corresponds to the inverse of this property. + * + * @return The inverse of this property. Note that this property will not necessarily be in the + * simplest form. + */ + OWLObjectPropertyExpression getInverseProperty(); + + /** + * Returns this property in its simplified form. + * + * @return Let p be a property name and PE an object property expression. The simplification, + * 'simp', is defined as follows:
+ * {@code simp(p) = p}
+ * {@code simp(inv(p)) = inv(p)}
+ * @deprecated Since it is not legal to apply ObjectInverseOf to anything other than an Object + * Property, all object properties are always in the simplified form. + */ + @Deprecated + default OWLObjectPropertyExpression getSimplified() { + return this; + } + + /** + * Get the named object property used in this property expression. + * + * @return P if this expression is either inv(P) or P. + */ + OWLObjectProperty getNamedProperty(); + + @Override + default boolean isObjectPropertyExpression() { + return true; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyRangeAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyRangeAxiom.java new file mode 100644 index 0000000000..27ddf431b7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyRangeAxiom.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents + * ObjectPropertyRange axioms in the OWL 2 specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectPropertyRangeAxiom extends + OWLPropertyRangeAxiom, OWLObjectPropertyAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLObjectPropertyRangeAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 113; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.OBJECT_PROPERTY_RANGE; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectRestriction.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectRestriction.java new file mode 100644 index 0000000000..0e58661f21 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectRestriction.java @@ -0,0 +1,41 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents a restriction (Object Property Restriction or Data Property Restriction) in the OWL 2 specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectRestriction extends OWLRestriction, + HasProperty { + + /** + * Gets the property/properties that the restriction acts along depending on + * R being a scalar or collection type. + * + * @return The property + */ + @Override + OWLObjectPropertyExpression getProperty(); + + @Override + default boolean isObjectRestriction() { + return true; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectSomeValuesFrom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectSomeValuesFrom.java new file mode 100644 index 0000000000..6a770dec24 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectSomeValuesFrom.java @@ -0,0 +1,59 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents an + * + * ObjectSomeValuesFrom class expression in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectSomeValuesFrom extends OWLQuantifiedObjectRestriction { + + @Override + default int hashIndex() { + return 239; + } + + @Override + default int typeIndex() { + return 3005; + } + + @Override + default ClassExpressionType getClassExpressionType() { + return ClassExpressionType.OBJECT_SOME_VALUES_FROM; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLClassExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLClassExpressionVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectUnionOf.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectUnionOf.java new file mode 100644 index 0000000000..e81d995250 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectUnionOf.java @@ -0,0 +1,59 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents an + * + * ObjectUnionOf class expression in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectUnionOf extends OWLNaryBooleanClassExpression { + + @Override + default int hashIndex() { + return 241; + } + + @Override + default int typeIndex() { + return 3002; + } + + @Override + default ClassExpressionType getClassExpressionType() { + return ClassExpressionType.OBJECT_UNION_OF; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLClassExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLClassExpressionVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectVisitor.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectVisitor.java new file mode 100644 index 0000000000..d07e1a036f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectVisitor.java @@ -0,0 +1,26 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLObjectVisitor extends OWLAxiomVisitor, + OWLClassExpressionVisitor, OWLDataVisitor, + OWLPropertyExpressionVisitor, OWLEntityVisitor, + OWLAnnotationAxiomVisitor, OWLIndividualVisitor, + OWLAnnotationValueVisitor, OWLAnnotationObjectVisitor, + SWRLObjectVisitor, OWLNamedObjectVisitor { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectVisitorEx.java new file mode 100644 index 0000000000..911988965b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLObjectVisitorEx.java @@ -0,0 +1,26 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param visitor type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public interface OWLObjectVisitorEx extends OWLAxiomVisitorEx, + OWLClassExpressionVisitorEx, OWLDataVisitorEx, + OWLPropertyExpressionVisitorEx, OWLEntityVisitorEx, + OWLAnnotationObjectVisitorEx, SWRLObjectVisitorEx, + OWLNamedObjectVisitorEx, OWLIndividualVisitorEx { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntology.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntology.java new file mode 100644 index 0000000000..16448f56dd --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntology.java @@ -0,0 +1,526 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.io.OutputStream; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Set; +import java.util.function.Supplier; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.io.OWLOntologyDocumentTarget; +import org.semanticweb.owlapi.model.parameters.ChangeApplied; +import org.semanticweb.owlapi.model.parameters.Imports; + +/** + * Represents an OWL 2 Ontology in the + * OWL 2 specification.
+ * An {@code OWLOntology} consists of a possibly empty set of + * {@link org.semanticweb.owlapi.model.OWLAxiom}s and a possibly empty set of + * {@link OWLAnnotation}s. An ontology can have an ontology IRI which can be used to identify the + * ontology. If it has an ontology IRI then it may also have an ontology version IRI. Since OWL 2, + * an ontology need not have an ontology IRI. (See the + * OWL 2 Structural Specification An ontology cannot + * be modified directly. Changes must be applied via its {@code OWLOntologyManager}. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLOntology extends OWLObject, HasAnnotations, HasDirectImports, HasImportsClosure, + HasOntologyID, OWLAxiomCollection, OWLAxiomCollectionBooleanArgs, OWLSignature, + OWLSignatureBooleanArgs, OWLAxiomIndex, HasApplyChange, HasApplyChanges, HasDirectAddAxiom, + HasDirectAddAxioms, HasDirectRemoveAxiom, HasDirectRemoveAxioms, HasApplyDirectChange { + + @Override + default boolean isAxiom() { + return false; + } + + @Override + default boolean isIndividual() { + return false; + } + + @Override + default boolean isOntology() { + return true; + } + + @Override + default Stream components() { + return Stream.of(getOntologyID()); + } + + @Override + default int initHashCode() { + return OWLObject.hashIteration(hashIndex(), getOntologyID().hashCode()); + } + + @Override + default int hashIndex() { + return 0; + } + + @Override + default int typeIndex() { + return 1; + } + + // Default implementation of these mutating methods is to do nothing. + // Adding them to this interface allows access without casting, since + // OWLOntology is the de facto standard used in the code and + // OWLMutableOntology hardly appears. + @Override + default ChangeApplied applyChange(OWLOntologyChange change) { + return getOWLOntologyManager().applyChange(change); + } + + @Override + default ChangeApplied applyDirectChange(OWLOntologyChange change) { + return ChangeApplied.UNSUCCESSFULLY; + } + + @Override + default ChangeDetails applyChangesAndGetDetails(List changes) { + return getOWLOntologyManager().applyChangesAndGetDetails(changes); + } + + @Override + default ChangeApplied addAxiom(OWLAxiom axiom) { + return getOWLOntologyManager().addAxiom(this, axiom); + } + + @Override + default ChangeApplied addAxioms(Collection axioms) { + return getOWLOntologyManager().addAxioms(this, axioms.stream()); + } + + @Override + default ChangeApplied addAxioms(Stream axioms) { + return getOWLOntologyManager().addAxioms(this, axioms); + } + + @Override + default ChangeApplied addAxioms(OWLAxiom... axioms) { + return addAxioms(Arrays.asList(axioms)); + } + + @Override + default ChangeApplied removeAxiom(OWLAxiom axiom) { + return getOWLOntologyManager().removeAxioms(this, Stream.of(axiom)); + } + + @Override + default ChangeApplied removeAxioms(Collection axioms) { + return getOWLOntologyManager().removeAxioms(this, axioms.stream()); + } + + @Override + default ChangeApplied removeAxioms(Stream axioms) { + return getOWLOntologyManager().removeAxioms(this, axioms); + } + + @Override + default ChangeApplied removeAxioms(OWLAxiom... axioms) { + return removeAxioms(Arrays.asList(axioms)); + } + + /** + * accept for named object visitor + * + * @param visitor the visitor + */ + default void accept(OWLNamedObjectVisitor visitor) { + visitor.visit(this); + } + + /** + * Accepts a visitor + * + * @param visitor return type + * @param visitor The visitor + * @return visitor return value + */ + default O accept(OWLNamedObjectVisitorEx visitor) { + return visitor.visit(this); + } + + /** + * Gets the manager that manages this ontology. The manager is used by various methods on + * OWLOntology to resolve imports + * + * @return The manager for this ontology. + */ + OWLOntologyManager getOWLOntologyManager(); + + /** + * Sets the manager for this ontology. This method is used when moving ontologies from one + * manager to another and when removing an ontology form a manager, and should be used by + * OWLOntologyManager implementations only. + * + * @param manager the new manager for this ontology + */ + void setOWLOntologyManager(@Nullable OWLOntologyManager manager); + + /** + * @return ontology format for this ontology; can be null if the ontology has been created + * programmatically and not loaded/saved, so it does not have any format information + * associated. + */ + @Nullable + default OWLDocumentFormat getFormat() { + return getOWLOntologyManager().getOntologyFormat(this); + } + + /** + * Gets the ontology format for this ontology, ensuring it is not null (an error is thrown if + * the ontology has no format). Do not use this method to check if an ontology has a format + * associated with it; prefer {@link #getFormat()}. + * + * @return The format of the ontology + */ + default OWLDocumentFormat getNonnullFormat() { + return verifyNotNull(getFormat(), + (Supplier) () -> "There is no format specified for ontology " + getOntologyID() + + ", the ontology format needs to be set before saving or specified in the save call"); + } + + // Imported ontologies + + /** + * Gets the set of loaded ontologies that this ontology is related to via the + * transitive closure of the + * directlyImports relation.
+ * For example, if this ontology imports ontology B, and ontology B imports ontology C, then + * this method will return the set consisting of ontology B and ontology C. + * + * @return The set of ontologies that this ontology is related to via the transitive closure of + * the directlyImports relation. The set that is returned is a copy; modifications to + * the returned set will not be reflected in this object. + * @throws UnknownOWLOntologyException if this ontology is no longer managed by its manager + * because it was removed from the manager. + */ + default Set getImports() { + return asSet(imports()); + } + + /** + * Gets the stream of loaded ontologies that this ontology is related to via the + * transitive closure of the + * directlyImports relation.
+ * For example, if this ontology imports ontology B, and ontology B imports ontology C, then + * this method will return the set consisting of ontology B and ontology C. + * + * @return The stream of ontologies that this ontology is related to via the transitive closure + * of the directlyImports relation. + * @throws UnknownOWLOntologyException if this ontology is no longer managed by its manager + * because it was removed from the manager. + */ + Stream imports(); + + /** + * Gets the set of imports declarations for this ontology. The set returned represents the set + * of IRIs that correspond to the set of IRIs in an ontology's directlyImportsDocuments (see + * Section 3 in the OWL 2 structural specification). + * + * @return The set of imports declarations that correspond to the set of ontology document IRIs + * that are directly imported by this ontology. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + */ + default Set getImportsDeclarations() { + return asSet(importsDeclarations()); + } + + /** + * Gets the stream of imports declarations for this ontology. These are the IRIs that correspond + * to the set of IRIs in an ontology's directlyImportsDocuments (see Section 3 in the OWL 2 + * structural specification). + * + * @return Sorted stream of imports declarations that correspond to the set of ontology document + * IRIs that are directly imported by this ontology. + */ + Stream importsDeclarations(); + + // Methods to retrive class, property and individual axioms + + /** + * Determines if this ontology is empty - an ontology is empty if it does not contain any axioms + * (i.e. {@link #axioms()} is empty), and it does not have any annotations (i.e. + * {@link #annotations()} is empty). + * + * @return {@code true} if the ontology is empty, otherwise {@code false}. + */ + boolean isEmpty(); + + /** + * Gets the axioms that form the TBox for this ontology, i.e., the ones whose type is in the + * AxiomType::TBoxAxiomTypes. + * + * @param includeImportsClosure if INCLUDED, the imports closure is included. + * @return A set containing the axioms which are of the specified type. The set that is returned + * is a copy; modifications to the returned set will not be reflected in this object. + */ + default Set getTBoxAxioms(Imports includeImportsClosure) { + return asSet(tboxAxioms(includeImportsClosure)); + } + + /** + * Gets the axioms that form the TBox for this ontology, i.e., the ones whose type is in the + * AxiomType::TBoxAxiomTypes. + * + * @param includeImportsClosure if INCLUDED, the imports closure is included. + * @return A stream containing the axioms which are of the specified type. + */ + Stream tboxAxioms(Imports includeImportsClosure); + + /** + * Gets the axioms that form the ABox for this ontology, i.e., the ones whose type is in the + * AxiomType::ABoxAxiomTypes. + * + * @param includeImportsClosure if INCLUDED, the imports closure is included. + * @return A set containing the axioms which are of the specified type. The set that is returned + * is a copy; modifications to the returned set will not be reflected in this object. + */ + default Set getABoxAxioms(Imports includeImportsClosure) { + return asSet(aboxAxioms(includeImportsClosure)); + } + + /** + * Gets the axioms that form the ABox for this ontology, i.e., the ones whose type is in the + * AxiomType::ABoxAxiomTypes. + * + * @param includeImportsClosure if INCLUDED, the imports closure is included. + * @return A stream containing the axioms which are of the specified type. + */ + Stream aboxAxioms(Imports includeImportsClosure); + + /** + * Gets the axioms that form the RBox for this ontology, i.e., the ones whose type is in the + * AxiomType::RBoxAxiomTypes. + * + * @param includeImportsClosure if INCLUDED, the imports closure is included. + * @return A set containing the axioms which are of the specified type. The set that is returned + * is a copy; modifications to the returned set will not be reflected in this object. + */ + default Set getRBoxAxioms(Imports includeImportsClosure) { + return asSet(rboxAxioms(includeImportsClosure)); + } + + /** + * Gets the axioms that form the RBox for this ontology, i.e., the ones whose type is in the + * AxiomType::RBoxAxiomTypes. + * + * @param includeImportsClosure if INCLUDED, the imports closure is included. + * @return A stream containing the axioms which are of the specified type. + */ + Stream rboxAxioms(Imports includeImportsClosure); + + /** + * Gets the set of general axioms in this ontology. This includes: + *
    + *
  • Subclass axioms that have a complex class as the subclass
  • + *
  • Equivalent class axioms that don't contain any named classes ( {@code OWLClass}es)
  • + *
  • Disjoint class axioms that don't contain any named classes ( {@code OWLClass}es)
  • + *
+ * + * @return The set of general axioms in this ontology. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + */ + default Set getGeneralClassAxioms() { + return asSet(generalClassAxioms()); + } + + /** + * Gets the stream of general axioms in this ontology. This includes: + *
    + *
  • Subclass axioms that have a complex class as the subclass
  • + *
  • Equivalent class axioms that don't contain any named classes ( {@code OWLClass}es)
  • + *
  • Disjoint class axioms that don't contain any named classes ( {@code OWLClass}es)
  • + *
+ * + * @return The sorted stream containing the general axioms in the ontology. + */ + Stream generalClassAxioms(); + + // References/usage + + /** + * Gets the entities that are in the signature of this ontology. The signature of an ontology is + * the set of entities that are used to build axioms and annotations in the ontology. (See + * The + * OWL 2 Structural Specification) + * + * @param imports if INCLUDED, the imports closure is included. + * @return A set of {@code OWLEntity} objects. The set that is returned is a copy; modifications + * to the returned set will not be reflected in this object. + * @see #classesInSignature() + * @see #objectPropertiesInSignature() + * @see #dataPropertiesInSignature() + * @see #individualsInSignature() + */ + default Set getSignature(Imports imports) { + return asSet(signature(imports)); + } + + /** + * Gets the entities that are in the signature of this ontology. The signature of an ontology is + * the set of entities that are used to build axioms and annotations in the ontology. (See + * The + * OWL 2 Structural Specification) + * + * @param imports if INCLUDED, the imports closure is included. + * @return A stream of {@code OWLEntity} objects. + * @see #classesInSignature() + * @see #objectPropertiesInSignature() + * @see #dataPropertiesInSignature() + * @see #individualsInSignature() + */ + default Stream signature(Imports imports) { + return imports.stream(this).flatMap(OWLOntology::signature); + } + + /** + * Determines if this ontology declares an entity i.e. it contains a declaration axiom for the + * specified entity. + * + * @param owlEntity The entity to be tested for + * @return {@code true} if the ontology contains a declaration for the specified entity, + * otherwise {@code false}. + */ + boolean isDeclared(OWLEntity owlEntity); + + /** + * Determines if this ontology or its imports closure declares an entity i.e. contains a + * declaration axiom for the specified entity. + * + * @param owlEntity The entity to be tested for + * @param imports if INCLUDED, the imports closure is included. + * @return {@code true} if the ontology or its imports closure contains a declaration for the + * specified entity, otherwise {@code false}. + */ + default boolean isDeclared(OWLEntity owlEntity, Imports imports) { + return imports.stream(this).anyMatch(o -> o.isDeclared(owlEntity)); + } + + /** + * Saves the ontology. The ontology will be saved to the location that it was loaded from, or if + * it was created programmatically, it will be saved to the location specified by an ontology + * IRI mapper at creation time. The ontology will be saved in the same format which it was + * loaded from, or the default ontology format if the ontology was created programmatically. + * + * @throws OWLOntologyStorageException An exception will be thrown if there is a problem with + * saving the ontology, or the ontology can't be saved in the format it was loaded from. + */ + default void saveOntology() throws OWLOntologyStorageException { + getOWLOntologyManager().saveOntology(this); + } + + /** + * Saves the ontology, using the specified document IRI to determine where/how the ontology + * should be saved. + * + * @param documentIRI The document IRI where the ontology should be saved to + * @throws OWLOntologyStorageException If the ontology cannot be saved + */ + default void saveOntology(IRI documentIRI) throws OWLOntologyStorageException { + getOWLOntologyManager().saveOntology(this, documentIRI); + } + + /** + * Saves the ontology, to the specified output stream + * + * @param outputStream The output stream where the ontology will be saved to + * @throws OWLOntologyStorageException If there was a problem saving this ontology to the + * specified output stream + */ + default void saveOntology(OutputStream outputStream) throws OWLOntologyStorageException { + getOWLOntologyManager().saveOntology(this, outputStream); + } + + /** + * Saves the ontology in the specified ontology format to its document URI. + * + * @param ontologyFormat The format in which the ontology should be saved. + * @throws OWLOntologyStorageException If the ontology cannot be saved. + */ + default void saveOntology(OWLDocumentFormat ontologyFormat) throws OWLOntologyStorageException { + getOWLOntologyManager().saveOntology(this, ontologyFormat); + } + + /** + * Saves the ontology to the specified document IRI in the specified ontology format. + * + * @param ontologyFormat The format in which to save the ontology + * @param documentIRI The document IRI where the ontology should be saved to + * @throws OWLOntologyStorageException If the ontology could not be saved. + */ + default void saveOntology(OWLDocumentFormat ontologyFormat, IRI documentIRI) + throws OWLOntologyStorageException { + getOWLOntologyManager().saveOntology(this, ontologyFormat, documentIRI); + } + + /** + * Saves the ontology to the specified output stream in the specified ontology format. + * + * @param ontologyFormat The format in which to save the ontology + * @param outputStream The output stream where the ontology will be saved to. + * @throws OWLOntologyStorageException If the ontology could not be saved. + */ + default void saveOntology(OWLDocumentFormat ontologyFormat, OutputStream outputStream) + throws OWLOntologyStorageException { + getOWLOntologyManager().saveOntology(this, ontologyFormat, outputStream); + } + + /** + * Saves the ontology to the specified + * {@link org.semanticweb.owlapi.io.OWLOntologyDocumentTarget}. + * + * @param documentTarget The output target where the ontology will be saved to. + * @throws OWLOntologyStorageException If the ontology could not be saved. + */ + default void saveOntology(OWLOntologyDocumentTarget documentTarget) + throws OWLOntologyStorageException { + getOWLOntologyManager().saveOntology(this, documentTarget); + } + + /** + * Saves the ontology to the specified output target in the specified ontology format. + * + * @param ontologyFormat The output format in which to save the ontology + * @param documentTarget The output target where the ontology will be saved to + * @throws OWLOntologyStorageException If the ontology could not be saved. + */ + default void saveOntology(OWLDocumentFormat ontologyFormat, + OWLOntologyDocumentTarget documentTarget) throws OWLOntologyStorageException { + getOWLOntologyManager().saveOntology(this, ontologyFormat, documentTarget); + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyAlreadyExistsException.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyAlreadyExistsException.java new file mode 100644 index 0000000000..06b63a1a90 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyAlreadyExistsException.java @@ -0,0 +1,116 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import javax.annotation.Nullable; + +/** + * Indicates that an ontology with the given ontology IRI (and possible version + * IRI) exists. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class OWLOntologyAlreadyExistsException extends OWLOntologyCreationException { + + private static final String ONTOLOGY_ALREADY_EXISTS = "Ontology already exists. "; + private final OWLOntologyID ontologyID; + @Nullable + private final IRI documentIRI; + + /** + * Constructs an {@code OWLOntologyAlreadyExistsException} to describe the + * situation where an attempt to create an ontology failed because the + * manager already contained an ontology with specified ontology ID. + * + * @param id The ID of the ontology (not {@code null}) that was already contained in the + * manager. + */ + public OWLOntologyAlreadyExistsException(OWLOntologyID id) { + super(ONTOLOGY_ALREADY_EXISTS + id); + ontologyID = id; + documentIRI = null; + } + + /** + * Constructs an {@code OWLOntologyAlreadyExistsException} to describe the + * situation where an attempt to load an ontology failed because the manager + * already contained an ontology with the ID that was the same as the + * ontology being loaded. + * + * @param ontologyID The ontology ID + * @param documentIRI The IRI of the document where the load attempt occurred from + */ + public OWLOntologyAlreadyExistsException(OWLOntologyID ontologyID, IRI documentIRI) { + super(ONTOLOGY_ALREADY_EXISTS + ontologyID + " (New ontology loaded from " + documentIRI + .toQuotedString() + + ')'); + this.ontologyID = ontologyID; + this.documentIRI = documentIRI; + } + + /** + * Constructs an {@code OWLOntologyAlreadyExistsException} to describe the + * situation where an attempt to create an ontology failed because the + * manager already contained an ontology with specified ontology ID. + * + * @param id The ID of the ontology (not {@code null}) that was already contained in the + * manager. + * @param t the cause + */ + public OWLOntologyAlreadyExistsException(OWLOntologyID id, Throwable t) { + super(ONTOLOGY_ALREADY_EXISTS + id, t); + ontologyID = id; + documentIRI = null; + } + + /** + * Constructs an {@code OWLOntologyAlreadyExistsException} to describe the + * situation where an attempt to load an ontology failed because the manager + * already contained an ontology with the ID that was the same as the + * ontology being loaded. + * + * @param ontologyID The ontology ID + * @param documentIRI The IRI of the document where the load attempt occurred from + * @param t the cause + */ + public OWLOntologyAlreadyExistsException(OWLOntologyID ontologyID, IRI documentIRI, + Throwable t) { + super(ONTOLOGY_ALREADY_EXISTS + ontologyID + " (New ontology loaded from " + documentIRI + .toQuotedString() + ')', + t); + this.ontologyID = ontologyID; + this.documentIRI = documentIRI; + } + + /** + * Gets the ID of the ontology that already exists. + * + * @return The ontology ID. + */ + public OWLOntologyID getOntologyID() { + return ontologyID; + } + + /** + * Gets the document IRI where the ontology was loaded from. + * + * @return The IRI of the document where the ontology was loaded from. If the ontology was + * created without loading it from an ontology document then the return value will be {@code + * null}. + */ + @Nullable + public IRI getDocumentIRI() { + return documentIRI; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyBuilder.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyBuilder.java new file mode 100644 index 0000000000..7b86cf212f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyBuilder.java @@ -0,0 +1,44 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; +import java.util.concurrent.locks.ReadWriteLock; + +/** + * An ontology builder is responsible for choosing an OWLOntology implementation. This interface + * allows for injecting different OWLOntology implementations without having to rewrite code + * implemented in OWLOntologyFactory classes. + * + * @author Ignazio + * @since 4.0.0 + */ +@FunctionalInterface +public interface OWLOntologyBuilder extends Serializable { + + /** + * @param manager manager for the ontology to be created + * @param ontologyID id for the ontology to be created + * @return new ontology instance + */ + OWLOntology createOWLOntology(OWLOntologyManager manager, OWLOntologyID ontologyID); + + /** + * Override the lock in the ontology builder; this is a workaround for #806 + * + * @param lock overriding lock instance to use + */ + default void setLock(@SuppressWarnings("unused") ReadWriteLock lock) { + // do nothing for the default implementation + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChange.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChange.java new file mode 100644 index 0000000000..4cd338f38b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChange.java @@ -0,0 +1,171 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.io.Serializable; +import java.util.Optional; + +import org.semanticweb.owlapi.change.OWLOntologyChangeData; +import org.semanticweb.owlapi.change.OWLOntologyChangeRecord; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public abstract class OWLOntologyChange implements HasSignature, Serializable { + + private final OWLOntology ont; + + /** + * @param ont the ontology to which the change is to be applied + */ + public OWLOntologyChange(OWLOntology ont) { + this.ont = checkNotNull(ont, "ontology must not be null"); + } + + /** + * @return for axiom changes, the axiom added or removed; empty optional otherwise. Same as + * {@code getAxiom()}, but it never throws an exception or returns null. + */ + public Optional getAddedOrRemovedAxiom() { + return Optional.empty(); + } + + /** + * @return for add axiom changes, the axiom added; empty optional otherwise + */ + public Optional getAddedAxiom() { + return Optional.empty(); + } + + /** + * @return for remove axiom changes, the axiom removed; empty optional otherwise + */ + public Optional getRemovedAxiom() { + return Optional.empty(); + } + + /** + * @param type axiom type to check + * @return true if this is an axiom change and the axiom type is the specified type + */ + public boolean isAxiomChange(AxiomType type) { + return getAddedOrRemovedAxiom().filter(ax -> ax.getAxiomType().equals(type)).isPresent(); + } + + /** + * Determines if the change will cause the addition or removal of an axiom from an ontology. + * + * @return {@code true} if the change is an {@code OWLAddAxiomChange} or {@code + * OWLRemoveAxiomChange} otherwise {@code false}. + */ + public boolean isAxiomChange() { + return false; + } + + /** + * Determines if the change will add an axiom to an ontology. + * + * @return {@code true} if the change is an AddAxiom change and it will add an axiom to an + * ontology, {@code false} otherwise. + */ + public boolean isAddAxiom() { + return false; + } + + /** + * Determines if the change will remove an axiom from an ontology. + * + * @return {@code true} if the change is a RemoveAxiom change and it will remove an axiom from + * an ontology, {@code false} otherwise. + */ + public boolean isRemoveAxiom() { + return isAxiomChange() && !isAddAxiom(); + } + + /** + * If the change is an axiom change (i.e. AddAxiom or RemoveAxiom) this method obtains the + * axiom. + * + * @return The Axiom if this change is an axiom change + * @throws IllegalStateException if the change has no axiom; UnsupportedOperationException If + * the change is not an axiom change (check with the {@code isAxiomChange} method + * first). + */ + public OWLAxiom getAxiom() { + throw new UnsupportedOperationException( + "This is an " + getClass().getSimpleName() + ", not an axiom change: " + this); + } + + /** + * Determines if this change is an import change and hence causes a change to the imports + * closure of an ontology. + * + * @return {@code true} if this change is an import change, otherwise {@code false}. + */ + public boolean isImportChange() { + return false; + } + + /** + * Gets the ontology that the change is/was applied to. + * + * @return The ontology that the change is applicable to + */ + public OWLOntology getOntology() { + return ont; + } + + /** + * Gets the data (independent of the ontology) associated with this specific change. + * + * @return The {@link OWLOntologyChangeData} associated with this {@code OWLOntologyChange}. + */ + public abstract OWLOntologyChangeData getChangeData(); + + /** + * Gets a {@link OWLOntologyChangeRecord} that is derived from this {@code OWLOntologyChange}'s + * {@link OWLOntologyID} and it's {@link OWLOntologyChangeData}. + * + * @return An {@link OWLOntologyChangeRecord} containing an {@link OWLOntologyID} equal to the + * {@link OWLOntologyID} of this {@code OWLOntologyChange}'s {@link OWLOntology}. Not + * {@code + * null} . + */ + public OWLOntologyChangeRecord getChangeRecord() { + return new OWLOntologyChangeRecord(ont.getOntologyID(), getChangeData()); + } + + /** + * Accepts a visitor. + * + * @param visitor The visitor + */ + public abstract void accept(OWLOntologyChangeVisitor visitor); + + /** + * Accepts a visitor. + * + * @param visitor The visitor + * @param visitor return type + * @return visitor value + */ + public abstract O accept(OWLOntologyChangeVisitorEx visitor); + + /** + * @return the reverse of this change; can be used to create undo changes. + */ + public abstract OWLOntologyChange reverseChange(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeBroadcastStrategy.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeBroadcastStrategy.java new file mode 100644 index 0000000000..7bee0f7656 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeBroadcastStrategy.java @@ -0,0 +1,35 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; +import java.util.List; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +@FunctionalInterface +public interface OWLOntologyChangeBroadcastStrategy extends Serializable { + + /** + * Broadcasts the list of changes to the specified listeners. + * + * @param changes The changes to be broadcast. + * @param listener The listeners that the changes should be broadcast to + * @throws OWLException for any exception raised + */ + void broadcastChanges(OWLOntologyChangeListener listener, + List changes) + throws OWLException; +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeException.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeException.java new file mode 100644 index 0000000000..4a80486f81 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeException.java @@ -0,0 +1,65 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.change.OWLOntologyChangeData; + +/** + * A high level exception interface that describes errors that occurred when + * applying changes to ontologies. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public abstract class OWLOntologyChangeException extends OWLRuntimeException { + + private final OWLOntologyChangeData change; + + /** + * @param change change causing the error + * @param message message + */ + public OWLOntologyChangeException(OWLOntologyChangeData change, + String message) { + super(message); + this.change = change; + } + + /** + * @param change change causing the error + * @param message message + * @param cause cause + */ + public OWLOntologyChangeException(OWLOntologyChangeData change, + String message, Throwable cause) { + super(message, cause); + this.change = change; + } + + /** + * @param change change causing the error + * @param cause cause + */ + public OWLOntologyChangeException(OWLOntologyChangeData change, + Throwable cause) { + super(cause); + this.change = change; + } + + /** + * @return the ontology change that caused the exception. + */ + public OWLOntologyChangeData getChange() { + return change; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeListener.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeListener.java new file mode 100644 index 0000000000..7dd450bc77 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeListener.java @@ -0,0 +1,32 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.List; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +@FunctionalInterface +public interface OWLOntologyChangeListener { + + /** + * Called when some changes have been applied to various ontologies. These + * may be an axiom added or an axiom removed changes. + * + * @param changes A list of changes that have occurred. Each change may be examined to determine + * which ontology it was applied to. + */ + void ontologiesChanged(List changes); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeProgressListener.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeProgressListener.java new file mode 100644 index 0000000000..ac5551542c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeProgressListener.java @@ -0,0 +1,41 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; + +/** + * Objects that want to listen to the progress of applying changes to an + * ontology should implement this interface and add themselves as listener to a + * manager. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLOntologyChangeProgressListener extends Serializable { + + /** + * @param size the start size + */ + void begin(int size); + + /** + * @param change the change just applied + */ + void appliedChange(OWLOntologyChange change); + + /** + * end of the progress. + */ + void end(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeVetoException.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeVetoException.java new file mode 100644 index 0000000000..d57db64ead --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeVetoException.java @@ -0,0 +1,53 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.change.OWLOntologyChangeData; + +/** + * Describes a situation where a change was vetoed for some reason. Subclasses + * of this class may provide more information about why the change was vetoed. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLOntologyChangeVetoException extends OWLOntologyChangeException { + + /** + * @param change change causing the error + * @param message message + */ + public OWLOntologyChangeVetoException(OWLOntologyChangeData change, + String message) { + super(change, message); + } + + /** + * @param change change causing the error + * @param message message + * @param cause cause + */ + public OWLOntologyChangeVetoException(OWLOntologyChangeData change, + String message, Throwable cause) { + super(change, message, cause); + } + + /** + * @param change change causing the error + * @param cause cause + */ + public OWLOntologyChangeVetoException(OWLOntologyChangeData change, + Throwable cause) { + super(change, cause); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeVisitor.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeVisitor.java new file mode 100644 index 0000000000..94bd2d79d1 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeVisitor.java @@ -0,0 +1,77 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +@SuppressWarnings("unused") +public interface OWLOntologyChangeVisitor { + + /** + * visit AddAxiom type + * + * @param change change to visit + */ + default void visit(AddAxiom change) { + } + + /** + * visit RemoveAxiom type + * + * @param change change to visit + */ + default void visit(RemoveAxiom change) { + } + + /** + * visit SetOntologyID type + * + * @param change change to visit + */ + default void visit(SetOntologyID change) { + } + + /** + * visit AddImport type + * + * @param change change to visit + */ + default void visit(AddImport change) { + } + + /** + * visit RemoveImport type + * + * @param change change to visit + */ + default void visit(RemoveImport change) { + } + + /** + * visit AddOntologyAnnotation type + * + * @param change change to visit + */ + default void visit(AddOntologyAnnotation change) { + } + + /** + * visit RemoveOntologyAnnotation type + * + * @param change change to visit + */ + default void visit(RemoveOntologyAnnotation change) { + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeVisitorEx.java new file mode 100644 index 0000000000..8140df4da1 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangeVisitorEx.java @@ -0,0 +1,77 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param visitor type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLOntologyChangeVisitorEx { + + /** + * Visit AddAxiom type. + * + * @param change change to visit + * @return visitor value + */ + O visit(AddAxiom change); + + /** + * Visit RemoveAxiom type. + * + * @param change change to visit + * @return visitor value + */ + O visit(RemoveAxiom change); + + /** + * Visit SetOntologyID type. + * + * @param change change to visit + * @return visitor value + */ + O visit(SetOntologyID change); + + /** + * Visit AddImport type. + * + * @param change change to visit + * @return visitor value + */ + O visit(AddImport change); + + /** + * Visit RemoveImport type. + * + * @param change change to visit + * @return visitor value + */ + O visit(RemoveImport change); + + /** + * Visit AddOntologyAnnotation type. + * + * @param change change to visit + * @return visitor value + */ + O visit(AddOntologyAnnotation change); + + /** + * Visit RemoveOntologyAnnotation type. + * + * @param change change to visit + * @return visitor value + */ + O visit(RemoveOntologyAnnotation change); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangesVetoedListener.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangesVetoedListener.java new file mode 100644 index 0000000000..d2bdcca414 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyChangesVetoedListener.java @@ -0,0 +1,33 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; +import java.util.List; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +@FunctionalInterface +public interface OWLOntologyChangesVetoedListener extends Serializable { + + /** + * Called when a list of ontology changes has been vetoed for some reason. + * + * @param changes The changes that were vetoed. + * @param veto The cause of the veto. + */ + void ontologyChangesVetoed(List changes, + OWLOntologyChangeVetoException veto); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyCreationException.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyCreationException.java new file mode 100644 index 0000000000..493b3906f4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyCreationException.java @@ -0,0 +1,53 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An exception which describes an error during the creation of an ontology. If + * an ontology cannot be created then subclasses of this class will describe the + * reasons. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLOntologyCreationException extends OWLException { + + /** + * Default constructor. + */ + public OWLOntologyCreationException() { + super(); + } + + /** + * @param message message + */ + public OWLOntologyCreationException(String message) { + super(message); + } + + /** + * @param message message + * @param cause cause + */ + public OWLOntologyCreationException(String message, Throwable cause) { + super(message, cause); + } + + /** + * @param cause cause + */ + public OWLOntologyCreationException(Throwable cause) { + super(cause); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyDocumentAlreadyExistsException.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyDocumentAlreadyExistsException.java new file mode 100644 index 0000000000..94f142c5f0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyDocumentAlreadyExistsException.java @@ -0,0 +1,41 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An exception that describes the situation where there was an attempt to + * create or load an ontology where the corresponding ontology document IRI + * already was already mapped to an ontology. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class OWLOntologyDocumentAlreadyExistsException extends + OWLOntologyCreationException { + + private final IRI ontologyDocumentIRI; + + /** + * @param ontologyDocumentIRI iri already present + */ + public OWLOntologyDocumentAlreadyExistsException(IRI ontologyDocumentIRI) { + this.ontologyDocumentIRI = ontologyDocumentIRI; + } + + /** + * @return duplicated iri + */ + public IRI getOntologyDocumentIRI() { + return ontologyDocumentIRI; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyFactory.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyFactory.java new file mode 100644 index 0000000000..7d61bd493c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyFactory.java @@ -0,0 +1,114 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; +import java.util.concurrent.locks.ReadWriteLock; + +import org.semanticweb.owlapi.io.OWLOntologyDocumentSource; + +/** + * An ontology factory is responsible from creating new ontologies and creating ontologies from + * ontology document IRIs. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLOntologyFactory extends Serializable { + + /** + * Creates an (empty) ontology. + * + * @param manager the ontology manager to set. + * @param ontologyID The ID of the ontology to create. This MUST NOT BE {@code null}. + * @param documentIRI The document IRI of the ontology + * @param handler The ontology creation handler that will be notified when the ontology has been + * created. + * @return The newly created ontology + * @throws OWLOntologyCreationException if the ontology could not be created. + */ + OWLOntology createOWLOntology(OWLOntologyManager manager, OWLOntologyID ontologyID, + IRI documentIRI, OWLOntologyCreationHandler handler) throws OWLOntologyCreationException; + + /** + * Creates and loads an {@code OWLOntology}. + * + * @param manager the ontology manager to set. + * @param documentSource The document source that provides the means of getting a representation + * of a document. + * @param handler A pointer to an {@code OWLOntologyCreationHandler} which will be notified + * immediately after and empty ontology has been created, but before the source data is + * read and the ontology is loaded with axioms. + * @param configuration A configuration object which can be used to pass various options to the + * loader. + * @return The newly created and loaded ontology. + * @throws OWLOntologyCreationException if the ontology could not be created + */ + OWLOntology loadOWLOntology(OWLOntologyManager manager, + OWLOntologyDocumentSource documentSource, OWLOntologyCreationHandler handler, + OWLOntologyLoaderConfiguration configuration) throws OWLOntologyCreationException; + + /** + * Determines if the factory can create an ontology for the specified ontology document IRI. + * + * @param documentIRI The document IRI + * @return {@code true} if the factory can create an ontology given the specified document IRI, + * or {@code false} if the factory cannot create an ontology given the specified + * document IRI. + */ + boolean canCreateFromDocumentIRI(IRI documentIRI); + + /** + * Determines if the factory can load an ontology for the specified input source. + * + * @param documentSource The input source from which to load the ontology + * @return {@code true} if the factory can load from the specified input source. + */ + boolean canAttemptLoading(OWLOntologyDocumentSource documentSource); + + /** + * Override the lock in the ontology builder; this is a workaround for #806 + * + * @param lock overriding lock instance to use + */ + default void setLock(@SuppressWarnings("unused") ReadWriteLock lock) { + // do nothing for the default implementation + } + + /** + * An {@code OWLOntologyCreationHandler} gets notified when the factory has created an empty + * ontology (during the loading process). This may be needed to handle features such as cyclic + * imports. For example if OntA and OntB are ontologies and OntA imports OntB and vice versa, + * OntA will probably be partially loaded, but then will require the loading of OntB to ensure + * that all entities are declared. OntB will also require the partial loading of OntA for the + * same reason. The handler allows a reference to an ontology which is being loaded to be + * obtained before loading is finished. + */ + interface OWLOntologyCreationHandler { + + /** + * The factory calls this method as soon as it has created an ontology. If the factory is + * loading an ontology then the ontology will not have been populated with axioms at this + * stage. + * + * @param ontology The newly created ontology. + */ + void ontologyCreated(OWLOntology ontology); + + /** + * @param ontology the ontology + * @param format the format + */ + void setOntologyFormat(OWLOntology ontology, OWLDocumentFormat format); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyFactoryNotFoundException.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyFactoryNotFoundException.java new file mode 100644 index 0000000000..21f25f00af --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyFactoryNotFoundException.java @@ -0,0 +1,28 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLOntologyFactoryNotFoundException extends OWLRuntimeException { + + /** + * @param documentIRI iri for ontology that cannot be parsed + */ + public OWLOntologyFactoryNotFoundException(IRI documentIRI) { + super("Could not find an appropriate factory to load ontology from ontology document: " + + documentIRI.toQuotedString()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyID.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyID.java new file mode 100644 index 0000000000..75fce7f27f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyID.java @@ -0,0 +1,304 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.Optional; +import java.util.concurrent.atomic.AtomicInteger; + +import javax.annotation.Nullable; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * An object that identifies an ontology. Since OWL 2, ontologies do not have to have an ontology + * IRI, or if they have an ontology IRI then they can optionally also have a version IRI. Instances + * of this OWLOntologyID class bundle identifying information of an ontology together. If an + * ontology doesn't have an ontology IRI then we say that it is "anonymous". + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class OWLOntologyID implements Comparable, Serializable, IsAnonymous { + + private static final Logger LOGGER = LoggerFactory.getLogger(OWLOntologyID.class); + private static final AtomicInteger COUNTER = new AtomicInteger(); + private static final String ANON_PREFIX = "Anonymous-"; + private transient Optional internalID = emptyOptional(); + private transient Optional ontologyIRI; + private transient Optional versionIRI; + private int hashCode; + + /** + * Constructs an ontology identifier specifying the ontology IRI and version IRI. Equivalent to + * OWLOntologyID(Optional + * + * @param iri The ontology IRI (may be {@code null}) + */ + public OWLOntologyID(@Nullable IRI iri) { + this(opt(iri), emptyOptional(IRI.class)); + } + + /** + * Constructs an ontology identifier specifying the ontology IRI and version IRI. + * + * @param iri The ontology IRI (may be {@code null}) + * @param versionIRI The version IRI (must be {@code null} if the ontologyIRI is null) + */ + public OWLOntologyID(@Nullable IRI iri, @Nullable IRI versionIRI) { + this(opt(iri), opt(versionIRI)); + } + + /** + * Constructs an ontology identifier specifying the ontology IRI and version IRI. + * + * @param iri The ontology IRI (may be absent) + * @param version The version IRI (must be absent if the ontologyIRI is absent) + */ + public OWLOntologyID(Optional iri, Optional version) { + ontologyIRI = opt(iri); + hashCode = 17; + if (ontologyIRI.isPresent()) { + hashCode += 37 * ontologyIRI.hashCode(); + } else { + internalID = optional(ANON_PREFIX + COUNTER.getAndIncrement()); + hashCode += 37 * internalID.hashCode(); + } + versionIRI = opt(version); + if (versionIRI.isPresent()) { + if (!ontologyIRI.isPresent()) { + throw new IllegalArgumentException( + "If the ontology IRI is null then it is not possible to specify a version IRI"); + } + hashCode += 37 * versionIRI.hashCode(); + } + } + + /** + * Constructs an ontology identifier specifying that the ontology IRI (and hence the version + * IRI) is not present. + */ + public OWLOntologyID() { + this(emptyOptional(IRI.class), emptyOptional(IRI.class)); + } + + private static Optional opt(@Nullable IRI i) { + if (i == null || NodeID.isAnonymousNodeIRI(i)) { + return emptyOptional(); + } + if (!i.isAbsolute()) { + LOGGER.error( + "Ontology IRIs must be absolute; IRI {} is relative and will be made absolute by prefixing urn:absolute: to it", + i); + return optional(IRI.create("urn:absolute:" + i)); + } + return optional(i); + } + + /** + * Replace an optional with a blank node iri with an absent optional. + * + * @param i Optional to check + * @return input optional if its iri is not a blank node iri, absent otherwise + */ + private static Optional opt(Optional i) { + if (NodeID.isAnonymousNodeIRI(i.orElse(null))) { + return emptyOptional(); + } + return i; + } + + private void readObject(ObjectInputStream stream) throws ClassNotFoundException, IOException { + stream.defaultReadObject(); + ontologyIRI = optional((IRI) stream.readObject()); + versionIRI = optional((IRI) stream.readObject()); + internalID = optional((String) stream.readObject()); + } + + private void writeObject(ObjectOutputStream stream) throws IOException { + stream.defaultWriteObject(); + stream.writeObject(ontologyIRI.orElse(null)); + stream.writeObject(versionIRI.orElse(null)); + stream.writeObject(internalID.orElse(null)); + } + + /** + * @param iri the iri to check + * @return true if the input iri matches the ontology iri or the version iri + */ + public boolean match(IRI iri) { + return matchOntology(iri) || matchVersion(iri); + } + + /** + * @param iri the iri to check + * @return true if the input iri matches the version iri + */ + public boolean matchVersion(IRI iri) { + return iri.equals(versionIRI.orElse(null)); + } + + /** + * @param iri the iri to check + * @return true if the input iri matches the default document iri + */ + public boolean matchDocument(IRI iri) { + return iri.equals(getDefaultDocumentIRI().orElse(null)); + } + + /** + * @param iri the iri to check + * @return true if the input iri matches the ontology iri + */ + public boolean matchOntology(IRI iri) { + return iri.equals(ontologyIRI.orElse(null)); + } + + /** + * @param id the id to check + * @return true if the input id has the same ontology iri + */ + public boolean match(OWLOntologyID id) { + return ontologyIRI.equals(id.getOntologyIRI()); + } + + /** + * Determines if this is a valid OWL 2 DL ontology ID. To be a valid OWL 2 DL ID, the ontology + * IRI and version IRI must not be reserved vocabulary. + * + * @return {@code true} if this is a valid OWL 2 DL ontology ID, otherwise {@code false} + * @see org.semanticweb.owlapi.model.IRI#isReservedVocabulary() + */ + public boolean isOWL2DLOntologyID() { + return !ontologyIRI.isPresent() || !ontologyIRI.get().isReservedVocabulary() + && (!versionIRI.isPresent() || !versionIRI.get().isReservedVocabulary()); + } + + @Override + public int compareTo(@Nullable OWLOntologyID o) { + checkNotNull(o); + assert o != null; + return toString().compareTo(o.toString()); + } + + /** + * Gets the ontology IRI. If the ontology is anonymous, it will return an absent Optional (i.e., + * getOntologyIRI().isPresent() will return false. + * + * @return Optional of the ontology IRI, or Optional.absent if there is no ontology IRI. + */ + public Optional getOntologyIRI() { + return ontologyIRI; + } + + /** + * Gets the version IRI. + * + * @return an optional of the version IRI, or Optional.absent if there is no version IRI. + */ + public Optional getVersionIRI() { + return versionIRI; + } + + /** + * Gets the IRI which is used as a default for the document that contain a representation of an + * ontology with this ID. This will be the version IRI if there is an ontology IRI and version + * IRI, else it will be the ontology IRI if there is an ontology IRI but no version IRI, else it + * will be {@code null} if there is no ontology IRI. See + * Ontology Documents in the + * OWL 2 Structural Specification. + * + * @return An Optional of the IRI that can be used as a default for an ontology document + * containing an ontology as identified by this ontology ID. Returns the default IRI or + * an Optional.absent. + */ + public Optional getDefaultDocumentIRI() { + if (ontologyIRI.isPresent()) { + if (versionIRI.isPresent()) { + return versionIRI; + } else { + return ontologyIRI; + } + } else { + return emptyOptional(); + } + } + + /** + * Determines if this ID names an ontology or whether it is an ID for an ontology without an + * IRI. If the result of this method is true, getOntologyIRI() will return an Optional.absent. + * + * @return {@code true} if this ID is an ID for an ontology without an IRI, or {@code false} if + * this ID is an ID for an ontology with an IRI. + */ + @Override + public boolean isAnonymous() { + return !ontologyIRI.isPresent(); + } + + @Override + public String toString() { + if (ontologyIRI.isPresent()) { + String template = "OntologyID(OntologyIRI(<%s>) VersionIRI(<%s>))"; + return String.format(template, ontologyIRI.get(), versionIRI.orElse(null)); + } + return "OntologyID(" + internalID.orElse(null) + ')'; + } + + @Override + public int hashCode() { + return hashCode; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (!(obj instanceof OWLOntologyID)) { + return false; + } + OWLOntologyID other = (OWLOntologyID) obj; + if (isAnonymous() && other.isAnonymous()) { + // both anonymous: check the anon version + return internalID.equals(other.internalID); + } + if (isAnonymous() != other.isAnonymous()) { + // one anonymous, one not: equals is false + return false; + } + if (!isAnonymous()) { + boolean toReturn = ontologyIRI.equals(other.ontologyIRI); + if (!toReturn) { + return toReturn; + } + // if toReturn is true, compare the version iris + toReturn = versionIRI.equals(other.versionIRI); + return toReturn; + } + // else this is anonymous and the other cannot be anonymous, so return + // false + return false; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyIRIMapper.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyIRIMapper.java new file mode 100644 index 0000000000..b25dd0135e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyIRIMapper.java @@ -0,0 +1,38 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; +import javax.annotation.Nullable; + +/** + * The interface to an object that is capable of mapping ontology IRIs to + * document IRIs. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +@FunctionalInterface +public interface OWLOntologyIRIMapper extends Serializable { + + /** + * Given an ontology IRI, this method maps the ontology IRI to a document + * IRI. + * + * @param ontologyIRI The ontology IRI to be mapped. + * @return The document IRI of the ontology, or {@code null} if the mapper doesn't have mapping + * for the specified ontology IRI. + */ + @Nullable + IRI getDocumentIRI(IRI ontologyIRI); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyIRIMappingNotFoundException.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyIRIMappingNotFoundException.java new file mode 100644 index 0000000000..62fe50a2d0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyIRIMappingNotFoundException.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An exception which describes the situation where no ontology document IRI + * mapping could be found. This is a runtime exception since clients should + * really ensure that a mapping exists before attempting to load an ontology. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLOntologyIRIMappingNotFoundException extends OWLRuntimeException { + + /** + * @param ontologyIRI iri that cannot be mapped + */ + public OWLOntologyIRIMappingNotFoundException(IRI ontologyIRI) { + super("Could not find ontology document mapping for " + ontologyIRI.toQuotedString()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyLoaderConfiguration.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyLoaderConfiguration.java new file mode 100644 index 0000000000..e93412b5fb --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyLoaderConfiguration.java @@ -0,0 +1,550 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.ACCEPT_HTTP_COMPRESSION; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.ALLOW_DUPLICATES_IN_CONSTRUCT_SETS; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.AUTHORIZATION_VALUE; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.BANNED_PARSERS; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.CONNECTION_TIMEOUT; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.ENTITY_EXPANSION_LIMIT; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.FOLLOW_REDIRECTS; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.LOAD_ANNOTATIONS; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.MISSING_IMPORT_HANDLING_STRATEGY; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.MISSING_ONTOLOGY_HEADER_STRATEGY; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.PARSE_WITH_STRICT_CONFIGURATION; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.PRIORITY_COLLECTION_SORTING; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.REPAIR_ILLEGAL_PUNNINGS; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.REPORT_STACK_TRACES; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.RETRIES_TO_ATTEMPT; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.SKIP_MODULE_ANNOTATIONS; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.TREAT_DUBLINCORE_AS_BUILTIN; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.TRIM_TO_SIZE; + +import java.io.Serializable; +import java.util.EnumMap; +import java.util.HashSet; +import java.util.Set; + +import org.semanticweb.owlapi.model.parameters.ConfigurationOptions; +import org.semanticweb.owlapi.vocab.Namespaces; + +/** + * A configuration object that specifies options and hints to objects that load {@code OWLOntology} + * instances. Every {@code OWLOntologyLoaderConfiguration} is immutable. Changing a setting results + * in the creation of a new {@code OWLOntologyLoaderConfiguration} with that setting. For example, + * + *
+ * OWLOntologyLoaderConfiguration config = new OWLOntologyLoaderConfiguration();
+ * config = config.setLoadAnnotationAxioms(false);
+ * 
+ * + * creates an {@code OWLOntologyLoaderConfiguration} object with the load annotation axioms set to + * {@code false}. + * + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.2.0 + */ +public class OWLOntologyLoaderConfiguration implements Serializable { + + /** + * set of imports to ignore + */ + private final Set ignoredImports = new HashSet<>(); + /** + * Local override map. + */ + private final EnumMap overrides = + new EnumMap<>(ConfigurationOptions.class); + + /** + * Adds an ontology document IRI to the list of ontology imports that will be ignored during + * ontology loading. + * + * @param ontologyDocumentIRI The ontology document IRI that will be ignored if it is + * encountered as an imported ontology during loading. + * @return An {@code OWLOntologyLoaderConfiguration} with the ignored ontology document IRI set. + */ + public OWLOntologyLoaderConfiguration addIgnoredImport(IRI ontologyDocumentIRI) { + OWLOntologyLoaderConfiguration configuration = copyConfiguration(); + configuration.ignoredImports.add(ontologyDocumentIRI); + return configuration; + } + + /** + * Clears all ontology document IRIs from the list of ignored ontology document IRIs. + * + * @return An {@code OWLOntologyLoaderConfiguration} with the list of ignored ontology document + * IRIs set to be empty. + */ + public OWLOntologyLoaderConfiguration clearIgnoredImports() { + OWLOntologyLoaderConfiguration configuration = copyConfiguration(); + configuration.ignoredImports.clear(); + return configuration; + } + + /** + * @param iri iri to check + * @return true if iri should be ignored + */ + public boolean isIgnoredImport(IRI iri) { + return Namespaces.isDefaultIgnoredImport(iri) || ignoredImports.contains(iri); + } + + /** + * Removes an ontology document IRI from the list of ontology imports that will be ignored + * during ontology loading. + * + * @param ontologyDocumentIRI The ontology document IRI that would be ignored if it is + * encountered as an imported ontology during loading. + * @return An {@code OWLOntologyLoaderConfiguration} with the ignored ontology document IRI + * removed. + */ + public OWLOntologyLoaderConfiguration removeIgnoredImport(IRI ontologyDocumentIRI) { + OWLOntologyLoaderConfiguration configuration = copyConfiguration(); + configuration.ignoredImports.remove(ontologyDocumentIRI); + return configuration; + } + + /** + * Internally copies this configuration object. + * + * @return The copied configuration + */ + private OWLOntologyLoaderConfiguration copyConfiguration() { + OWLOntologyLoaderConfiguration copy = new OWLOntologyLoaderConfiguration(); + copy.overrides.putAll(overrides); + copy.ignoredImports.clear(); + copy.ignoredImports.addAll(ignoredImports); + return copy; + } + + /** + * @return The {@code PriorityCollectionSorting} for this configuration. It determines how + * parsers, storers and mappers are ordered. Default is + * {@link PriorityCollectionSorting#ON_SET_INJECTION_ONLY} + */ + public PriorityCollectionSorting getPriorityCollectionSorting() { + return PRIORITY_COLLECTION_SORTING.getValue(PriorityCollectionSorting.class, overrides); + } + + /** + * Set the priority collection sorting option. + * + * @param sorting the sorting option to be used. + * @return An {@code OWLOntologyLoaderConfiguration} with the new sorting option set. + */ + public OWLOntologyLoaderConfiguration setPriorityCollectionSorting( + PriorityCollectionSorting sorting) { + if (sorting.equals(getPriorityCollectionSorting())) { + return this; + } + OWLOntologyLoaderConfiguration configuration = copyConfiguration(); + configuration.overrides.put(PRIORITY_COLLECTION_SORTING, sorting); + return configuration; + } + + /** + * @return the connection timeout for this configuration + */ + public int getConnectionTimeout() { + return CONNECTION_TIMEOUT.getValue(Integer.class, overrides).intValue(); + } + + /** + * @param l new timeout Note: the timeout is an int and represents milliseconds. This is + * necessary for use in {@code URLConnection} + * @return A {@code OWLOntologyLoaderConfiguration} with the connection timeout set to the new + * value. + */ + public OWLOntologyLoaderConfiguration setConnectionTimeout(int l) { + if (getConnectionTimeout() == l) { + return this; + } + OWLOntologyLoaderConfiguration configuration = copyConfiguration(); + configuration.overrides.put(CONNECTION_TIMEOUT, Integer.valueOf(l)); + return configuration; + } + + /** + * Gets the strategy used for missing imports. + * + * @return The strategy. See {@link MissingImportHandlingStrategy} for the strategies and their + * descriptions. + * @since 3.3 + */ + public MissingImportHandlingStrategy getMissingImportHandlingStrategy() { + return MISSING_IMPORT_HANDLING_STRATEGY.getValue(MissingImportHandlingStrategy.class, + overrides); + } + + /** + * Sets the strategy that is used for missing imports handling. See + * {@link MissingImportHandlingStrategy} for the strategies and their descriptions. + * + * @param missingImportHandlingStrategy The strategy to be used. + * @return An {@code OWLOntologyLoaderConfiguration} object with the strategy set. + * @since 3.3 + */ + public OWLOntologyLoaderConfiguration setMissingImportHandlingStrategy( + MissingImportHandlingStrategy missingImportHandlingStrategy) { + // do not make copies if setting the same value + if (getMissingImportHandlingStrategy() == missingImportHandlingStrategy) { + return this; + } + OWLOntologyLoaderConfiguration copy = copyConfiguration(); + copy.overrides.put(MISSING_IMPORT_HANDLING_STRATEGY, missingImportHandlingStrategy); + return copy; + } + + /** + * @return the ontology header strategy + */ + public MissingOntologyHeaderStrategy getMissingOntologyHeaderStrategy() { + return MISSING_ONTOLOGY_HEADER_STRATEGY.getValue(MissingOntologyHeaderStrategy.class, + overrides); + } + + /** + * @param missingOntologyHeaderStrategy new value + * @return a copy of this configuration object with a different strategy + */ + public OWLOntologyLoaderConfiguration setMissingOntologyHeaderStrategy( + MissingOntologyHeaderStrategy missingOntologyHeaderStrategy) { + // do not make copies if setting the same value + if (getMissingOntologyHeaderStrategy() == missingOntologyHeaderStrategy) { + return this; + } + OWLOntologyLoaderConfiguration copy = copyConfiguration(); + copy.overrides.put(MISSING_ONTOLOGY_HEADER_STRATEGY, missingOntologyHeaderStrategy); + return copy; + } + + /** + * @return number of retries to attempt when retrieving an ontology form a remote URL. + */ + public int getRetriesToAttempt() { + return RETRIES_TO_ATTEMPT.getValue(Integer.class, overrides).intValue(); + } + + /** + * @param retries new value of retries to attempt + * @return copy of this configuration with modified retries attempts. + */ + public OWLOntologyLoaderConfiguration setRetriesToAttempt(int retries) { + // do not make copies if setting the same value + if (getRetriesToAttempt() == retries) { + return this; + } + OWLOntologyLoaderConfiguration copy = copyConfiguration(); + copy.overrides.put(RETRIES_TO_ATTEMPT, Integer.valueOf(retries)); + return copy; + } + + /** @return authorization header value */ + public String getAuthorizationValue() { + return AUTHORIZATION_VALUE.getValue(String.class, overrides); + } + + /** + * @return true if http compression should be accepted. + */ + public boolean isAcceptingHTTPCompression() { + return ACCEPT_HTTP_COMPRESSION.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @return true if ontology should be trimmed to size after load + */ + public boolean shouldTrimToSize() { + return TRIM_TO_SIZE.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @param b true if HTTP compression should be accepted + * @return a copy of this configuration with accepting HTTP compression set to the new value + */ + public OWLOntologyLoaderConfiguration setAcceptingHTTPCompression(boolean b) { + // do not make copies if setting the same value + if (isAcceptingHTTPCompression() == b) { + return this; + } + OWLOntologyLoaderConfiguration copy = copyConfiguration(); + copy.overrides.put(ACCEPT_HTTP_COMPRESSION, Boolean.valueOf(b)); + return copy; + } + + /** + * When loading an ontology, a parser might connect to a remote URL. If the remote URL is a 302 + * redirect and the protocol is different, e.g., http to https, the parser needs to decide + * whether to follow the redirect and download the ontology from an alternate source, or stop + * with an UnloadableOntologyError. By default this is true, meaning redirects will be followed + * across protocols. If set to false, redirects will be followed only within the same protocol + * (URLConnection limits this to five redirects). + * + * @return true if redirects should be followed when importing ontologies from remote URLs + */ + public boolean isFollowRedirects() { + return FOLLOW_REDIRECTS.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @param value true if redirects should be followed across protocols, false otherwise. + * @return a copy of the current object with follow redirects set to the new value. + */ + public OWLOntologyLoaderConfiguration setFollowRedirects(boolean value) { + // as the objects are immutable, setting to the same value returns the + // same object + if (value == isFollowRedirects()) { + return this; + } + OWLOntologyLoaderConfiguration copy = copyConfiguration(); + copy.overrides.put(FOLLOW_REDIRECTS, Boolean.valueOf(value)); + return copy; + } + + /** + * Determines whether or not annotation axioms (instances of {@code OWLAnnotationAxiom}) should + * be loaded. By default, the loading of annotation axioms is enabled. + * + * @return {@code true} if annotation assertions will be loaded, or {@code false} if annotation + * assertions will not be loaded because they will be discarded on loading. + */ + public boolean isLoadAnnotationAxioms() { + return LOAD_ANNOTATIONS.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * Specifies whether or not annotation axioms (instances of {@code OWLAnnotationAxiom}) should + * be loaded or whether they should be discarded on loading. By default, the loading of + * annotation axioms is enabled. + * + * @param b {@code true} if annotation axioms should be loaded, or {@code false} if annotation + * axioms should not be loaded and should be discarded on loading. + * @return An {@code OWLOntologyLoaderConfiguration} object with the option set. + */ + public OWLOntologyLoaderConfiguration setLoadAnnotationAxioms(boolean b) { + // do not make copies if setting the same value + if (isLoadAnnotationAxioms() == b) { + return this; + } + OWLOntologyLoaderConfiguration copy = copyConfiguration(); + copy.overrides.put(LOAD_ANNOTATIONS, Boolean.valueOf(b)); + return copy; + } + + /** + * @return value for the report stack trace flag. + */ + public boolean isReportStackTrace() { + return REPORT_STACK_TRACES.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @return true if parsing should be strict + */ + public boolean isStrict() { + return PARSE_WITH_STRICT_CONFIGURATION.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @return true if illegal punnings should be repaired + */ + public boolean shouldRepairIllegalPunnings() { + return REPAIR_ILLEGAL_PUNNINGS.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @param strict new value for strict + * @return copy of the configuration with new strict value + */ + public OWLOntologyLoaderConfiguration setStrict(boolean strict) { + // do not make copies if setting the same value + if (isStrict() == strict) { + return this; + } + OWLOntologyLoaderConfiguration copy = copyConfiguration(); + copy.overrides.put(PARSE_WITH_STRICT_CONFIGURATION, Boolean.valueOf(strict)); + return copy; + } + + /** + * Determines if the various parsers, for formats such as RDF based formats that do not require + * strong typing, should treat Dublin Core Vocabulary as built in vocabulary, so that Dublin + * Core metadata properties are interpreted as annotation properties. + * + * @return {@code true} if the Dublin Core Vocabulary should be treated as built in vocabulary + * and Dublin Core properties are interpreted as annotation properties, otherwise + * {@code false}. The default is {@code true}. + */ + public boolean isTreatDublinCoreAsBuiltIn() { + return TREAT_DUBLINCORE_AS_BUILTIN.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @param value true if Dublin Core vocabulary should be treated as built in. + * @return a copy of the current object with treat dublin core as builtIn set to the new value. + */ + public OWLOntologyLoaderConfiguration setTreatDublinCoreAsBuiltIn(boolean value) { + // as the objects are immutable, setting to the same value returns the + // same object + if (isTreatDublinCoreAsBuiltIn() == value) { + return this; + } + OWLOntologyLoaderConfiguration copy = copyConfiguration(); + copy.overrides.put(TREAT_DUBLINCORE_AS_BUILTIN, Boolean.valueOf(value)); + return copy; + } + + /** + * @return list of parser factory class names that should be skipped when attempting ontology + * parsing. The list is space separated. + */ + public String getBannedParsers() { + return BANNED_PARSERS.getValue(String.class, overrides); + } + + /** + * @param ban list of parser factory class names that should be skipped when attempting ontology + * parsing. The list is space separated. + * @return An {@code OntologyConfigurator} with the new option set. + */ + public OWLOntologyLoaderConfiguration setBannedParsers(String ban) { + if (getBannedParsers().equals(ban)) { + return this; + } + OWLOntologyLoaderConfiguration configuration = copyConfiguration(); + configuration.overrides.put(BANNED_PARSERS, ban); + return configuration; + } + + /** + * @return max number of XML entity expansions to perform while parsing RDF/XML. + */ + public String getEntityExpansionLimit() { + return ENTITY_EXPANSION_LIMIT.getValue(String.class, overrides); + } + + /** + * @param limit maximum number of XML entities to expand. + * @return An {@code OntologyConfigurator} with the new option set. + */ + public OWLOntologyLoaderConfiguration setEntityExpansionLimit(String limit) { + if (getEntityExpansionLimit().equals(limit)) { + return this; + } + OWLOntologyLoaderConfiguration configuration = copyConfiguration(); + configuration.overrides.put(ENTITY_EXPANSION_LIMIT, limit); + return configuration; + } + + /** + * Set the value for the report stack traces flag. If true, parsing exceptions will have the + * full stack trace for the source exceptions. Default is false. + * + * @param b the new value for the flag + * @return A {@code OWLOntologyLoaderConfiguration} with the report flag set to the new value. + */ + public OWLOntologyLoaderConfiguration setReportStackTraces(boolean b) { + if (isReportStackTrace() == b) { + return this; + } + OWLOntologyLoaderConfiguration configuration = copyConfiguration(); + configuration.overrides.put(REPORT_STACK_TRACES, Boolean.valueOf(b)); + return configuration; + } + + /** + * @param b if illegal punnings should be repaired + * @return A {@code OWLOntologyLoaderConfiguration} with the repair flag set to the new value. + */ + public OWLOntologyLoaderConfiguration setRepairIllegalPunnings(boolean b) { + if (shouldRepairIllegalPunnings() == b) { + return this; + } + OWLOntologyLoaderConfiguration configuration = copyConfiguration(); + configuration.overrides.put(REPAIR_ILLEGAL_PUNNINGS, Boolean.valueOf(b)); + return configuration; + } + + /** + * @param authorizationValue Authorization header value. + * @return An {@code OntologyConfigurator} with the new option set. + */ + public OWLOntologyLoaderConfiguration setAuthorizationValue(String authorizationValue) { + if (getAuthorizationValue().equals(authorizationValue)) { + return this; + } + OWLOntologyLoaderConfiguration configuration = copyConfiguration(); + configuration.overrides.put(AUTHORIZATION_VALUE, authorizationValue); + return configuration; + } + + /** + * @param value new value for trim to size + * @return An {@code OntologyConfigurator} with the new option set. + */ + public OWLOntologyLoaderConfiguration setTrimToSize(boolean value) { + if (shouldTrimToSize() == value) { + return this; + } + OWLOntologyLoaderConfiguration configuration = copyConfiguration(); + configuration.overrides.put(TRIM_TO_SIZE, Boolean.valueOf(value)); + return configuration; + } + + /** + * @return true if module extraction should not add annotation axioms to the module. + */ + public boolean shouldSkipModuleAnnotations() { + return SKIP_MODULE_ANNOTATIONS.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @param value true if annotation axioms should not be added to modules + * @return A {@code OWLOntologyLoaderConfiguration} with the annotation axioms flag set to the + * new value. + */ + public OWLOntologyLoaderConfiguration withSkipModuleAnnotations(boolean value) { + if (shouldSkipModuleAnnotations() == value) { + return this; + } + OWLOntologyLoaderConfiguration configuration = copyConfiguration(); + configuration.overrides.put(SKIP_MODULE_ANNOTATIONS, Boolean.valueOf(value)); + return configuration; + } + + /** + * @return false if collections used in constructs such as equivalent classes and properties + * should be duplicate free. Some systems might need to allow this, e.g., reasoners + * which require the creation of a tautology like {@code Equivalent(A, A)}. + */ + public boolean shouldAllowDuplicatesInConstructSets() { + return ALLOW_DUPLICATES_IN_CONSTRUCT_SETS.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @param value false if collections used in constructs such as equivalent classes and + * properties should be duplicate free. + * @return A {@code OWLOntologyLoaderConfiguration} with the allow duplicates flag set to the + * new value. + */ + public OWLOntologyLoaderConfiguration withAllowDuplicatesInConstructSets(boolean value) { + if (shouldAllowDuplicatesInConstructSets() == value) { + return this; + } + OWLOntologyLoaderConfiguration configuration = copyConfiguration(); + configuration.overrides.put(ALLOW_DUPLICATES_IN_CONSTRUCT_SETS, Boolean.valueOf(value)); + return configuration; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyLoaderListener.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyLoaderListener.java new file mode 100644 index 0000000000..7718a604bc --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyLoaderListener.java @@ -0,0 +1,139 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; +import javax.annotation.Nullable; + +/** + * Receives notification of ontology loading starting and finishing from a + * manager. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public interface OWLOntologyLoaderListener extends Serializable { + + /** + * Called when the process of attempting to load an ontology starts. + * + * @param event The loading started event that describes the ontology that is being loaded. + */ + void startedLoadingOntology(LoadingStartedEvent event); + + /** + * Called when the process of loading an ontology has finished. This method + * will be called regardless of whether the ontology could be loaded or not + * - it merely indicates that the process of attempting to load an ontology + * has finished. + * + * @param event The loading finished event that describes the ontology that was loaded. + */ + void finishedLoadingOntology(LoadingFinishedEvent event); + + /** + * Loading event. + */ + class LoadingEvent { + + private final OWLOntologyID ontologyID; + private final IRI documentIRI; + private final boolean imported; + + public LoadingEvent(OWLOntologyID ontologyID, IRI documentIRI, boolean imported) { + this.ontologyID = ontologyID; + this.documentIRI = documentIRI; + this.imported = imported; + } + + /** + * Gets the ID of the ontology being loaded. + * + * @return The ontology ID. + */ + public OWLOntologyID getOntologyID() { + return ontologyID; + } + + /** + * Gets the document IRI for the ontology being loaded. + * + * @return The document IRI that describes where the ontology was loaded from. + */ + public IRI getDocumentIRI() { + return documentIRI; + } + + /** + * Determines if the ontology was loaded because of an imports + * statement. + * + * @return {@code true} if the ontology was loaded because it was imported by another + * ontology, or {@code false} if the ontology was loaded by a direct load request on + * OWLOntologyManager. + */ + public boolean isImported() { + return imported; + } + } + + /** + * Loading start event. + */ + class LoadingStartedEvent extends LoadingEvent { + + public LoadingStartedEvent(OWLOntologyID ontologyID, IRI documentIRI, boolean imported) { + super(ontologyID, documentIRI, imported); + } + } + + /** + * Describes the situation when the loading process for an ontology has + * finished. + */ + class LoadingFinishedEvent extends LoadingEvent { + + @Nullable + private final Exception ex; + + public LoadingFinishedEvent(OWLOntologyID ontologyID, IRI documentIRI, boolean imported, + @Nullable Exception ex) { + super(ontologyID, documentIRI, imported); + this.ex = ex; + } + + /** + * Determines if the ontology was successfully loaded. + * + * @return {@code true} if the ontology was successfully loaded, {@code false} if the + * ontology was not successfully loaded. Note that an ontology being successfully loaded + * does not imply that any ontologies that the ontology imports were successfully loaded. + */ + public boolean isSuccessful() { + return ex == null; + } + + /** + * If the ontology was not loaded successfully then this method can be + * used to access the exception that describes why the ontology was not + * loaded successfully. + * + * @return The exception that describes why the ontology was not loaded successfully, or + * {@code null} if the ontology was loaded successfully. + */ + @Nullable + public Exception getException() { + return ex; + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyManager.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyManager.java new file mode 100644 index 0000000000..362115e364 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyManager.java @@ -0,0 +1,1125 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.io.File; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Serializable; +import java.util.Collection; +import java.util.List; +import java.util.Set; +import java.util.function.Supplier; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.io.FileDocumentSource; +import org.semanticweb.owlapi.io.IRIDocumentSource; +import org.semanticweb.owlapi.io.OWLOntologyDocumentSource; +import org.semanticweb.owlapi.io.OWLOntologyDocumentTarget; +import org.semanticweb.owlapi.io.OWLParserFactory; +import org.semanticweb.owlapi.io.StreamDocumentSource; +import org.semanticweb.owlapi.io.StreamDocumentTarget; +import org.semanticweb.owlapi.model.parameters.OntologyCopy; +import org.semanticweb.owlapi.util.PriorityCollection; + +/** + * An {@code OWLOntologyManager} manages a set of ontologies. It is the main point for creating, + * loading and accessing ontologies.
+ * An {@code OWLOntologyManager} also manages the mapping between an ontology and its ontology + * document. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLOntologyManager extends OWLOntologySetProvider, HasDataFactory, + HasGetOntologyById, HasApplyChanges, HasApplyChange, HasAddAxioms, HasAddAxiom, HasRemoveAxioms, + HasRemoveAxiom, HasContainsOntology, HasOntologyChangeListeners, HasOntologyConfigurator, + HasOntologyLoaderConfiguration, HasOntologyWriterConfiguration, Serializable { + + /** + * Clear all ontologies, listeners and maps from the manager. Leave injected factories, storers + * and parsers. + */ + public void clearOntologies(); + + /** + * Gets the ontologies that are managed by this manager that contain the specified axiom. + * + * @param axiom The axioms + * @return The set of ontologies such that for each ontology O the specified axiom is contained + * in O. The set that is returned is a copy; modifications to the returned set will not + * be reflected in this object. + */ + default Set getOntologies(OWLAxiom axiom) { + return asSet(ontologies(axiom)); + } + + /** + * Gets the ontologies that are managed by this manager that contain the specified axiom. + * + * @param axiom The axioms + * @return The stream of ontologies such that for each ontology O the specified axiom is + * contained in O. + */ + default Stream ontologies(OWLAxiom axiom) { + return ontologies().filter(o -> o.containsAxiom(axiom)); + } + + /** + * Gets the versions (if any) of the ontology that have the specified IRI + * + * @param ontology The ontology IRI + * @return The set of ontologies that have the specified ontology IRI. + * @deprecated use {@link #versions(IRI)} + */ + @Deprecated + default Set getVersions(IRI ontology) { + return asSet(versions(ontology)); + } + + /** + * Gets the versions (if any) of the ontology that have the specified IRI + * + * @param ontology The ontology IRI + * @return The set of ontologies that have the specified ontology IRI. + */ + default Stream versions(IRI ontology) { + return ontologies().filter(o -> o.getOntologyID().matchOntology(ontology)); + } + + /** + * @param ontology ontology to check + * @return true if the ontology is contained + */ + boolean contains(OWLOntology ontology); + + /** + * Determines if there is an ontology that has the specified ontology IRI, regardless of version + * IRI. If there is no ontology which has the input IRI as ontology IRI, the IRI is matched + * against the version IRI. + * + * @param ontologyIRI The IRI of the ontology to test for. + * @return {@code true} if there is an ontology with the specified IRI or version IRI, that is + * managed by this manager, otherwise {@code false}. + */ + boolean contains(IRI ontologyIRI); + + /** + * Determines if there is an ontology with the specified id that is managed by this manager; + * this method works only with non anonymous ids. + * + * @param id The id of the ontology to test for + * @return {@code true} if there is an ontology with the specified id that is managed by this + * manager, otherwise {@code false}. + */ + @Override + boolean contains(OWLOntologyID id); + + /** + * Determines if there is an ontology with the specified version IRI, that is managed by this + * manager. + * + * @param ontologyVersionIRI The version IRI of the ontology to test for (the ontology IRI may + * be anything) + * @return {@code true} if there is an ontology with the specified version IRI, that is managed + * by this manager, otherwise {@code false}. + */ + boolean containsVersion(IRI ontologyVersionIRI); + + /** + * Gets a set of OWLOntologyIDs representing ontologies that are managed by this manager. + * + * @param ontologyVersionIRI The version IRI to match against all of the known ontologies. + * @return A set of OWLOntologyIDs where the version matches the given version or the empty set + * if none match. The set that is returned is a copy; modifications to the returned set + * will not be reflected in this object. + */ + default Set getOntologyIDsByVersion(IRI ontologyVersionIRI) { + return asSet(ontologyIDsByVersion(ontologyVersionIRI)); + } + + /** + * Gets a stream of OWLOntologyIDs representing ontologies that are managed by this manager. + * + * @param ontologyVersionIRI The version IRI to match against all of the known ontologies. + * @return A stream of OWLOntologyIDs where the version matches the given version or the empty + * set if none match. + */ + Stream ontologyIDsByVersion(IRI ontologyVersionIRI); + + /** + * Gets a previously loaded/created ontology that has the specified ontology IRI, regardless of + * version IRI. If there is no ontology which has the input IRI as ontology IRI, the IRI is + * matched against the version IRI. + * + * @param ontologyIRI The IRI of the ontology to be retrieved. + * @return The ontology that has the specified IRI, {@code null} if none found. + */ + @Nullable + OWLOntology getOntology(IRI ontologyIRI); + + @Nullable + @Override + OWLOntology getOntology(OWLOntologyID ontologyID); + + /** + * Given an imports declaration, obtains the ontology that this import has been resolved to. + * + * @param declaration The declaration that points to the imported ontology. + * @return The ontology that the imports declaration resolves to, or {@code null} if the imports + * declaration could not be resolved to an ontology, because the ontology was not loaded + * or has been removed from this manager + */ + @Nullable + OWLOntology getImportedOntology(OWLImportsDeclaration declaration); + + /** + * Gets the set of loaded ontologies that the specified ontology is related to via the + * directlyImports relation as defined in Section 3.4 of the OWL 2 Structural specification + * + * @param ontology The ontology whose direct imports are to be retrieved. + * @return The set of loaded ontologies that the specified ontology is related to via + * the directlyImports relation. If the ontology is not managed by this manager then the + * empty set will be returned. The set that is returned is a copy; modifications to the + * returned set will not be reflected in this object. + */ + default Set getDirectImports(OWLOntology ontology) { + return asSet(directImports(ontology)); + } + + /** + * Stream of loaded ontologies that the specified ontology is related to via the + * directlyImports relation as defined in Section 3.4 of the OWL 2 Structural specification + * + * @param ontology The ontology whose direct imports are to be retrieved. + * @return Stream of loaded ontologies that the specified ontology is related to via + * the directlyImports relation. If the ontology is not managed by this manager then the + * empty set will be returned. + */ + Stream directImports(OWLOntology ontology); + + /** + * Gets the set of ontologies that are in the transitive closure of the directly imports + * relation. + * + * @param ontology The ontology whose imports are to be retrieved. + * @return A set of {@code OWLOntology} instances that are in the transitive closure of the + * directly imports relation of this ontology. If, for what ever reason, an imported + * ontology could not be loaded, then it will not be contained in the returned set of + * ontologies. If the ontology is not managed by this manager then the empty set will be + * returned. The set that is returned is a copy; modifications to the returned set will + * not be reflected in this object. + */ + default Set getImports(OWLOntology ontology) { + return asSet(imports(ontology)); + } + + /** + * Gets the stream of ontologies that are in the transitive closure of the directly imports + * relation. + * + * @param ontology The ontology whose imports are to be retrieved. + * @return Sorted stream of {@code OWLOntology}ies that are in the transitive closure of the + * directly imports relation of this ontology. If, for what ever reason, an imported + * ontology could not be loaded, then it will not be contained in the returned set of + * ontologies. If the ontology is not managed by this manager then the empty set will be + * returned. + */ + Stream imports(OWLOntology ontology); + + /** + * Gets the imports closure for the specified ontology. + * + * @param ontology The ontology whose imports closure is to be retrieved. + * @return A {@code Set} of ontologies that contains the imports closure for the specified + * ontology. This set will also include the specified ontology. Example: if A imports B + * and B imports C, then calling this method with A will return the set consisting of A, + * B and C. If, for what ever reason, an imported ontology could not be loaded, then it + * will not be contained in the returned set of ontologies. If the ontology is not + * managed by this manager then the empty set will be returned. The set that is returned + * is a copy; modifications to the returned set will not be reflected in this object. + */ + default Set getImportsClosure(OWLOntology ontology) { + return asSet(importsClosure(ontology)); + } + + /** + * Imports closure stream for the specified ontology. + * + * @param ontology The ontology whose imports closure is to be retrieved. + * @return Sorted stream of ontologies that contains the imports closure for the specified + * ontology. It includes the specified ontology. + */ + Stream importsClosure(OWLOntology ontology); + + /** + * Gets the topologically ordered imports closure. + * + * @param ontology The ontology whose imports closure is to be determined. + * @return A list that represents a topological ordering of the imports closure. The first + * element in the list will be the specified ontology. If the ontology is not managed by + * this manager then an empty list will be returned. + */ + List getSortedImportsClosure(OWLOntology ontology); + + // Ontology change + // Ontology creation + + /** + * Creates a new (empty) ontology that does not have an ontology IRI (and therefore does not + * have a version IRI). A document IRI will automatically be generated. + * + * @return The newly created ontology + * @throws OWLOntologyCreationException if there was a problem creating the ontology + */ + default OWLOntology createOntology() throws OWLOntologyCreationException { + // Brand new ontology without a URI + return createOntology(new OWLOntologyID()); + } + + /** + * Creates a new ontology that is initialised to contain specific axioms. The ontology will not + * have an IRI. The document IRI of the created ontology will be auto-generated. + * + * @param axioms The axioms that should be copied into the new ontology + * @return An ontology without an IRI that contains all of the specified axioms + * @throws OWLOntologyCreationException if there was a problem creating the new ontology. + * @throws OWLOntologyChangeException if there was a problem copying the axioms. + */ + default OWLOntology createOntology(Collection axioms) + throws OWLOntologyCreationException { + return createOntology(axioms, IRI.getNextDocumentIRI("urn:unnamed:ontology#ont")); + } + + /** + * Creates a new ontology that is initialised to contain specific axioms. The ontology will not + * have an IRI. The document IRI of the created ontology will be auto-generated. + * + * @param axioms The axioms that should be copied into the new ontology + * @return An ontology without an IRI that contains all of the specified axioms + * @throws OWLOntologyCreationException if there was a problem creating the new ontology. + * @throws OWLOntologyChangeException if there was a problem copying the axioms. + */ + default OWLOntology createOntology(Stream axioms) + throws OWLOntologyCreationException { + return createOntology(axioms, IRI.getNextDocumentIRI("urn:unnamed:ontology#ont")); + } + + /** + * Creates a new ontology that has the specified ontology IRI and is initialised to contain + * specific axioms. + * + * @param ontologyIRI The IRI of the new ontology.
+ * The ontology document IRI of the created ontology will be set to the value returned by + * any installed {@link org.semanticweb.owlapi.model.OWLOntologyIRIMapper}s. If no + * mappers are installed or the ontology IRI was not mapped to a document IRI by any of + * the installed mappers, then the ontology document IRI will be set to the value of + * {@code ontologyIRI}. + * @param axioms The axioms that should be copied into the new ontology + * @return An ontology that has the specified IRI and contains all of the specified axioms + * @throws OWLOntologyCreationException if there was a problem creating the new ontology, if the + * new ontology already exists in this manager. + * @throws OWLOntologyChangeException if there was a problem copying the axioms. + * @throws OWLOntologyAlreadyExistsException if the manager already contains an ontology with + * the specified {@code ontologyIRI}. + * @throws OWLOntologyDocumentAlreadyExistsException if the specified {@code ontologyIRI} is + * mapped to a ontology document IRI for which there already exists a mapping in this + * manager. + */ + default OWLOntology createOntology(Collection axioms, IRI ontologyIRI) + throws OWLOntologyCreationException { + return createOntology(axioms.stream(), ontologyIRI); + } + + /** + * Creates a new ontology that has the specified ontology IRI and is initialised to contain + * specific axioms. + * + * @param ontologyIRI The IRI of the new ontology.
+ * The ontology document IRI of the created ontology will be set to the value returned by + * any installed {@link org.semanticweb.owlapi.model.OWLOntologyIRIMapper}s. If no + * mappers are installed or the ontology IRI was not mapped to a document IRI by any of + * the installed mappers, then the ontology document IRI will be set to the value of + * {@code ontologyIRI}. + * @param axioms The axioms that should be copied into the new ontology + * @return An ontology that has the specified IRI and contains all of the specified axioms + * @throws OWLOntologyCreationException if there was a problem creating the new ontology, if the + * new ontology already exists in this manager. + * @throws OWLOntologyChangeException if there was a problem copying the axioms. + * @throws OWLOntologyAlreadyExistsException if the manager already contains an ontology with + * the specified {@code ontologyIRI}. + * @throws OWLOntologyDocumentAlreadyExistsException if the specified {@code ontologyIRI} is + * mapped to a ontology document IRI for which there already exists a mapping in this + * manager. + */ + OWLOntology createOntology(Stream axioms, IRI ontologyIRI) + throws OWLOntologyCreationException; + + /** + * Creates a new (empty) ontology that has the specified ontology IRI (and no version IRI).
+ * The ontology document IRI of the created ontology will be set to the value returned by any + * installed {@link org.semanticweb.owlapi.model.OWLOntologyIRIMapper}s. If no mappers are + * installed or the ontology IRI was not mapped to a document IRI by any of the installed + * mappers, then the ontology document IRI will be set to the value of {@code ontologyIRI}. + * + * @param ontologyIRI The IRI of the ontology to be created. The ontology IRI will be mapped to + * a document IRI in order to determine the type of ontology factory that will be used to + * create the ontology. If this mapping is {@code null} then a default (in memory) + * implementation of the ontology will most likely be created. + * @return The newly created ontology, or if an ontology with the specified IRI already exists + * then this existing ontology will be returned. + * @throws OWLOntologyCreationException If the ontology could not be created. + * @throws OWLOntologyAlreadyExistsException if the manager already contains an ontology with + * the specified {@code ontologyIRI} (and no version IRI). + * @throws OWLOntologyDocumentAlreadyExistsException if the specified {@code ontologyIRI} is + * mapped to a ontology document IRI for which there already exists a mapping in this + * manager. + */ + default OWLOntology createOntology(IRI ontologyIRI) throws OWLOntologyCreationException { + return createOntology(new OWLOntologyID(optional(ontologyIRI), emptyOptional(IRI.class))); + } + + /** + * Creates a new (empty) ontology that has the specified ontology ID. + * + * @param ontologyID The ID of the ontology to be created.
+ * The ontology document IRI of the created ontology will be set to the value returned by + * any installed {@link org.semanticweb.owlapi.model.OWLOntologyIRIMapper}s. If no + * mappers are installed or the ontology IRI was not mapped to a document IRI by any of + * the installed mappers, then the ontology document IRI will be set to the value of + * {@code ontologyIRI}. + * @return The newly created ontology, or if an ontology with the specified IRI already exists + * then this existing ontology will be returned. + * @throws OWLOntologyCreationException If the ontology could not be created. + * @throws OWLOntologyAlreadyExistsException if the manager already contains an ontology with + * the specified {@code ontologyID} (and no version IRI). + * @throws OWLOntologyDocumentAlreadyExistsException if the specified {@code ontologyID} is + * mapped to a ontology document IRI for which there already exists a mapping in this + * manager. + */ + OWLOntology createOntology(OWLOntologyID ontologyID) throws OWLOntologyCreationException; + + /** + * Creates a new ontology that has the specified ontology IRI and is initialised to contain the + * axioms that are contained in the specified ontologies. Note that the specified ontologies + * need not be managed by this manager.
+ * The ontology document IRI of the created ontology will be set to the value returned by any + * installed {@link org.semanticweb.owlapi.model.OWLOntologyIRIMapper}s. If no mappers are + * installed or the ontology IRI was not mapped to a document IRI by any of the installed + * mappers, then the ontology document IRI will be set to the value of {@code ontologyIRI}. + * + * @param ontologyIRI The IRI of the new ontology. + * @param ontologies The ontologies whose axioms should be copied into the new ontology + * @param copyLogicalAxiomsOnly If set to {@code true} only logical axioms are copied into the + * new ontology. If set to {@code false} then all axioms (including annotation axioms) + * are copied into the new ontology. + * @return An ontology that has the specified IRI and contains all of the axioms that are + * contained in the specified ontologies possibly minus all non-logical axioms + * @throws OWLOntologyCreationException if there was a problem creating the new ontology, if the + * new ontology already exists in this manager. + * @throws OWLOntologyAlreadyExistsException if the manager already contains an ontology with + * the specified {@code ontologyIRI} (and no ontology version IRI). + * @throws OWLOntologyDocumentAlreadyExistsException if the specified {@code ontologyIRI} is + * mapped to a ontology document IRI for which there already exists a mapping in this + * manager. + */ + default OWLOntology createOntology(IRI ontologyIRI, Collection ontologies, + boolean copyLogicalAxiomsOnly) throws OWLOntologyCreationException { + return createOntology(ontologyIRI, ontologies.stream(), copyLogicalAxiomsOnly); + } + + /** + * Creates a new ontology that has the specified ontology IRI and is initialised to contain the + * axioms that are contained in the specified ontologies. Note that the specified ontologies + * need not be managed by this manager.
+ * The ontology document IRI of the created ontology will be set to the value returned by any + * installed {@link org.semanticweb.owlapi.model.OWLOntologyIRIMapper}s. If no mappers are + * installed or the ontology IRI was not mapped to a document IRI by any of the installed + * mappers, then the ontology document IRI will be set to the value of {@code ontologyIRI}. + * + * @param ontologyIRI The IRI of the new ontology. + * @param ontologies The ontologies whose axioms should be copied into the new ontology + * @param copyLogicalAxiomsOnly If set to {@code true} only logical axioms are copied into the + * new ontology. If set to {@code false} then all axioms (including annotation axioms) + * are copied into the new ontology. + * @return An ontology that has the specified IRI and contains all of the axioms that are + * contained in the specified ontologies possibly minus all non-logical axioms + * @throws OWLOntologyCreationException if there was a problem creating the new ontology, if the + * new ontology already exists in this manager. + * @throws OWLOntologyAlreadyExistsException if the manager already contains an ontology with + * the specified {@code ontologyIRI} (and no ontology version IRI). + * @throws OWLOntologyDocumentAlreadyExistsException if the specified {@code ontologyIRI} is + * mapped to a ontology document IRI for which there already exists a mapping in this + * manager. + */ + OWLOntology createOntology(IRI ontologyIRI, Stream ontologies, + boolean copyLogicalAxiomsOnly) throws OWLOntologyCreationException; + + /** + * Creates a new ontology that has the specified ontology IRI and is initialised to contain the + * axioms that are contained in the specified ontologies. Note that the specified ontologies + * need not be managed by this manager.
+ * The ontology document IRI of the created ontology will be set to the value returned by any + * installed {@link org.semanticweb.owlapi.model.OWLOntologyIRIMapper}s. If no mappers are + * installed or the ontology IRI was not mapped to a document IRI by any of the installed + * mappers, then the ontology document IRI will be set to the value of {@code ontologyIRI}. + * + * @param ontologyIRI The IRI of the new ontology. + * @param ontologies The ontologies whose axioms should be copied into the new ontology + * @return An ontology that has the specified IRI and contains all of the axioms that are + * contained in the specified ontologies + * @throws OWLOntologyCreationException if there was a problem creating the new ontology, if the + * new ontology already exists in this manager. + * @throws OWLOntologyAlreadyExistsException if the manager already contains an ontology with + * the specified {@code ontologyIRI} (and no version IRI). + * @throws OWLOntologyDocumentAlreadyExistsException if the specified {@code ontologyIRI} is + * mapped to a ontology document IRI for which there already exists a mapping in this + * manager. + */ + default OWLOntology createOntology(IRI ontologyIRI, Collection ontologies) + throws OWLOntologyCreationException { + return createOntology(ontologyIRI, ontologies, false); + } + + /** + * Copy an ontology from another manager to this one. The returned OWLOntology will return this + * manager when getOWLOntologyManager() is invoked. The copy mode is defined by the OntologyCopy + * parameter: SHALLOW for simply creating a new ontology containing the same axioms and same id, + * DEEP for copying across format and document IRI, MOVE to remove the ontology from its + * previous manager. + * + * @param toCopy ontology to copy + * @param settings settings for the copy + * @return copied ontology. This is the same object as toCopy only for MOVE copies + * @throws OWLOntologyCreationException if this manager cannot add the new ontology + */ + OWLOntology copyOntology(OWLOntology toCopy, OntologyCopy settings) + throws OWLOntologyCreationException; + + // Loading + + /** + * Loads an ontology that is assumed to have the specified {@code ontologyIRI} as its IRI or + * version IRI.
+ * The ontology IRI will be mapped to an ontology document IRI. The mapping will be determined + * using one of the loaded {@link OWLOntologyIRIMapper} objects. By default, if no custom + * {@code OWLOntologyIRIMapper}s have been registered using the {@link #getIRIMappers()} + * PriorityCollection {@link PriorityCollection#add(Serializable...)} method, or no mapping can + * be found, the ontology document IRI is taken to be the specified ontology IRI. + * + * @param ontologyIRI The IRI that identifies the ontology. It is expected that the ontology + * will also have this IRI (although the OWL API will tolerated situations where this is + * not the case). + * @return The {@code OWLOntology} representation of the ontology that was loaded. + * @throws OWLOntologyCreationException If there was a problem in creating and loading the + * ontology. + * @throws org.semanticweb.owlapi.io.UnparsableOntologyException if the ontology was being + * parsed from a document and the document contained syntax errors. + * @throws UnloadableImportException if the ontology imports ontologies and one of the imports + * could not be loaded for what ever reason. If the + * {@link MissingImportHandlingStrategy} is set to + * {@link MissingImportHandlingStrategy#SILENT} then this exception will not be thrown. + * The {@code UnloadableImportException} contains information about the import + * declaration that triggered the import and the cause of this exception is an {@code + * OWLOntologyCreationException} which contains information about why the import could not be + * loaded. + * @throws org.semanticweb.owlapi.io.OWLOntologyCreationIOException if there was an {@code + * IOException} when trying to load the ontology. + * @throws OWLOntologyAlreadyExistsException if the manager already contains an ontology with + * the specified {@code ontologyIRI} (where the ontology doesn't have a version IRI). + * @throws OWLOntologyDocumentAlreadyExistsException if the specified {@code ontologyIRI} is + * mapped to a ontology document IRI for which there already exists a mapping in this + * manager. + */ + OWLOntology loadOntology(IRI ontologyIRI) throws OWLOntologyCreationException; + + /** + * Loads an ontology from an ontology document specified by an IRI. In contrast the the + * {@link #loadOntology(IRI)} method, no mapping is performed on the specified IRI. + * + * @param documentIRI The ontology document IRI where the ontology will be loaded from. + * @return The ontology that was loaded. + * @throws OWLOntologyCreationException If there was a problem in creating and loading the + * ontology. + * @throws org.semanticweb.owlapi.io.UnparsableOntologyException if the ontology was being + * parsed from a document and the document contained syntax errors. + * @throws UnloadableImportException if the ontology imports ontologies and one of the imports + * could not be loaded for what ever reason. If the + * {@link MissingImportHandlingStrategy} is set to + * {@link MissingImportHandlingStrategy#SILENT} then this exception will not be thrown. + * The {@code UnloadableImportException} contains information about the import + * declaration that triggered the import and the cause of this exception is an {@code + * OWLOntologyCreationException} which contains information about why the import could not be + * loaded. + * @throws org.semanticweb.owlapi.io.OWLOntologyCreationIOException if there was an {@code + * IOException} when trying to load the ontology. + * @throws OWLOntologyDocumentAlreadyExistsException if the specified {@code documentIRI} is + * already the document IRI for a loaded ontology. + * @throws OWLOntologyAlreadyExistsException if the manager already contains an ontology whose + * ontology IRI and version IRI is the same as the ontology IRI and version IRI of the + * ontology contained in the document pointed to by {@code documentIRI}. + */ + default OWLOntology loadOntologyFromOntologyDocument(IRI documentIRI) + throws OWLOntologyCreationException { + // Ontology URI not known in advance + return loadOntologyFromOntologyDocument(new IRIDocumentSource(documentIRI, null, null), + getOntologyLoaderConfiguration()); + } + + /** + * Loads an ontology from an ontology document contained in a local file. The loaded ontology + * will be assigned a document IRI that corresponds to the file IRI. + * + * @param file The file that contains a representation of an ontology + * @return The ontology that was parsed from the file. + * @throws OWLOntologyCreationException If there was a problem in creating and loading the + * ontology. + * @throws org.semanticweb.owlapi.io.UnparsableOntologyException if the ontology could not be + * parsed. + * @throws UnloadableImportException if the ontology imports ontologies and one of the imports + * could not be loaded for what ever reason. If the + * {@link MissingImportHandlingStrategy} is set to + * {@link MissingImportHandlingStrategy#SILENT} then this exception will not be thrown. + * The {@code UnloadableImportException} contains information about the import + * declaration that triggered the import and the cause of this exception is an {@code + * OWLOntologyCreationException} which contains information about why the import could not be + * loaded. + * @throws org.semanticweb.owlapi.io.OWLOntologyCreationIOException if there was an {@code + * IOException} when trying to load the ontology. + * @throws OWLOntologyDocumentAlreadyExistsException if the IRI of the specified file is already + * the document IRI for a loaded ontology. + * @throws OWLOntologyAlreadyExistsException if the manager already contains an ontology whose + * ontology IRI and version IRI is the same as the ontology IRI and version IRI of the + * ontology contained in the document pointed to by {@code documentIRI}. + */ + default OWLOntology loadOntologyFromOntologyDocument(File file) + throws OWLOntologyCreationException { + return loadOntologyFromOntologyDocument(new FileDocumentSource(file)); + } + + /** + * Loads an ontology from an ontology document obtained from an input stream. The loaded + * ontology will be assigned an auto-generated document IRI with "inputstream" as its scheme. + * + * @param inputStream The input stream that can be used to obtain a representation of an + * ontology + * @return The ontology that was parsed from the input stream. + * @throws OWLOntologyCreationException If there was a problem in creating and loading the + * ontology. + * @throws org.semanticweb.owlapi.io.UnparsableOntologyException if the ontology could not be + * parsed. + * @throws UnloadableImportException if the ontology imports ontologies and one of the imports + * could not be loaded for what ever reason. If the + * {@link MissingImportHandlingStrategy} is set to + * {@link MissingImportHandlingStrategy#SILENT} then this exception will not be thrown. + * The {@code UnloadableImportException} contains information about the import + * declaration that triggered the import and the cause of this exception is an {@code + * OWLOntologyCreationException} which contains information about why the import could not be + * loaded. + * @throws org.semanticweb.owlapi.io.OWLOntologyCreationIOException if there was an {@code + * IOException} when trying to load the ontology. + * @throws OWLOntologyAlreadyExistsException if the manager already contains an ontology whose + * ontology IRI and version IRI is the same as the ontology IRI and version IRI of the + * ontology obtained from parsing the content of the input stream. + */ + default OWLOntology loadOntologyFromOntologyDocument(InputStream inputStream) + throws OWLOntologyCreationException { + return loadOntologyFromOntologyDocument(new StreamDocumentSource(inputStream)); + } + + /** + * A convenience method that load an ontology from an input source. + * + * @param documentSource The input source that describes where the ontology should be loaded + * from. + * @return The ontology that was loaded. + * @throws OWLOntologyCreationException If there was a problem in creating and loading the + * ontology. + * @throws org.semanticweb.owlapi.io.UnparsableOntologyException if the ontology was being + * parsed from a document and the document contained syntax errors. + * @throws UnloadableImportException if the ontology imports ontologies and one of the imports + * could not be loaded for what ever reason. If the + * {@link MissingImportHandlingStrategy} is set to + * {@link MissingImportHandlingStrategy#SILENT} then this exception will not be thrown. + * The {@code UnloadableImportException} contains information about the import + * declaration that triggered the import and the cause of this exception is an {@code + * OWLOntologyCreationException} which contains information about why the import could not be + * loaded. + * @throws org.semanticweb.owlapi.io.OWLOntologyCreationIOException if there was an {@code + * IOException} when trying to load the ontology. + * @throws OWLOntologyDocumentAlreadyExistsException if the document IRI of the input source is + * already the document IRI for a loaded ontology. + * @throws OWLOntologyAlreadyExistsException if the manager already contains an ontology whose + * ontology IRI and version IRI is the same as the ontology IRI and version IRI of the + * ontology contained in the document represented by the input source. + */ + default OWLOntology loadOntologyFromOntologyDocument(OWLOntologyDocumentSource documentSource) + throws OWLOntologyCreationException { + // Ontology URI not known in advance + return loadOntologyFromOntologyDocument(documentSource, getOntologyLoaderConfiguration()); + } + + /** + * A convenience method that load an ontology from an input source with specified configuration. + * + * @param documentSource The input source that describes where the ontology should be loaded + * from. + * @param config the configuration to use + * @return The ontology that was loaded. + * @throws OWLOntologyCreationException If there was a problem in creating and loading the + * ontology. + * @throws org.semanticweb.owlapi.io.UnparsableOntologyException if the ontology was being + * parsed from a document and the document contained syntax errors. + * @throws UnloadableImportException if the ontology imports ontologies and one of the imports + * could not be loaded for what ever reason. If the + * {@link MissingImportHandlingStrategy} is set to + * {@link MissingImportHandlingStrategy#SILENT} then this exception will not be thrown. + * The {@code UnloadableImportException} contains information about the import + * declaration that triggered the import and the cause of this exception is an {@code + * OWLOntologyCreationException} which contains information about why the import could not be + * loaded. + * @throws org.semanticweb.owlapi.io.OWLOntologyCreationIOException if there was an {@code + * IOException} when trying to load the ontology. + * @throws OWLOntologyDocumentAlreadyExistsException if the document IRI of the input source is + * already the document IRI for a loaded ontology. + * @throws OWLOntologyAlreadyExistsException if the manager already contains an ontology whose + * ontology IRI and version IRI is the same as the ontology IRI and version IRI of the + * ontology contained in the document represented by the input source. + */ + OWLOntology loadOntologyFromOntologyDocument(OWLOntologyDocumentSource documentSource, + OWLOntologyLoaderConfiguration config) throws OWLOntologyCreationException; + + /** + * Attempts to remove an ontology. The ontology which is identified by the specified IRI is + * removed regardless of whether it is referenced by other ontologies via imports statements. + * + * @param ontology The ontology to be removed. If this manager does not manage the ontology then + * nothing happens. + */ + default void removeOntology(OWLOntology ontology) { + removeOntology(ontology.getOntologyID()); + } + + /** + * Attempts to remove an ontology. The ontology which is identified by the specified IRI is + * removed regardless of whether it is referenced by other ontologies via imports statements. + * + * @param ontologyID The ontology to be removed. If this manager does not manage the ontology + * then nothing happens. + */ + void removeOntology(OWLOntologyID ontologyID); + + /** + * Gets the document IRI for a given ontology. This will either be the document IRI from where + * the ontology was obtained from during loading, or the document IRI which was specified (via a + * mapper) when the (empty) ontology was created. Note that this may not correspond to the first + * document IRI found in the list of mappings from ontology IRI to document IRI. The reason for + * this is that it might not have been possible to load the ontology from the first document IRI + * found in the mapping table. + * + * @param ontology The ontology whose document IRI is to be obtained. + * @return The document IRI of the ontology. + * @throws UnknownOWLOntologyException If the specified ontology is not managed by this manager. + */ + IRI getOntologyDocumentIRI(OWLOntology ontology); + + /** + * Overrides the current document IRI for a given ontology. This method does not alter the IRI + * mappers which are installed, but alters the actual document IRI of an ontology that has + * already been loaded. + * + * @param ontology The ontology that has already been loaded. + * @param documentIRI The new ontology document IRI + * @throws UnknownOWLOntologyException If the specified ontology is not managed by this manager. + */ + void setOntologyDocumentIRI(OWLOntology ontology, IRI documentIRI); + + /** + * Gets the ontology format for the specified ontology. + * + * @param ontology The ontology whose format is to be obtained. + * @return The format of the ontology, or {@code null} if the ontology has no format (e.g., + * programmatically created ontology) + */ + @Nullable + OWLDocumentFormat getOntologyFormat(OWLOntology ontology); + + /** + * Gets the ontology format for the specified ontology, ensuring it is not null (an error is + * thrown if the ontology has no format). Do not use this method to check if an ontology has a + * format associated with it; prefer {@link #getOntologyFormat(OWLOntology)}. + * + * @param ontology The ontology whose format is to be obtained. + * @return The format of the ontology + */ + default OWLDocumentFormat getNonnullOntologyFormat(OWLOntology ontology) { + return verifyNotNull(getOntologyFormat(ontology), + (Supplier) () -> "There is no format specified for ontology " + + ontology.getOntologyID() + + ", the ontology format needs to be set before saving or specified in the save call"); + } + + /** + * Sets the format for the specified ontology. + * + * @param ontology The ontology whose format is to be set. + * @param ontologyFormat The format for the specified ontology. + * @throws UnknownOWLOntologyException If the specified ontology is not managed by this manager. + */ + void setOntologyFormat(OWLOntology ontology, OWLDocumentFormat ontologyFormat); + + /** + * Saves the specified ontology. The ontology will be saved to the location that it was loaded + * from, or if it was created programmatically, it will be saved to the location specified by an + * ontology IRI mapper at creation time. The ontology will be saved in the same format which it + * was loaded from, or the default ontology format if the ontology was created programmatically. + * + * @param ontology The ontology to be saved. + * @throws OWLOntologyStorageException An exception will be thrown if there is a problem with + * saving the ontology, or the ontology can't be saved in the format it was loaded from. + * @throws UnknownOWLOntologyException if this manager does not manage the specified ontology + */ + default void saveOntology(OWLOntology ontology) throws OWLOntologyStorageException { + saveOntology(ontology, getNonnullOntologyFormat(ontology)); + } + + /** + * Saves the specified ontology, using the specified document IRI to determine where/how the + * ontology should be saved. + * + * @param ontology The ontology to be saved. + * @param documentIRI The document IRI where the ontology should be saved to + * @throws OWLOntologyStorageException If the ontology cannot be saved + * @throws UnknownOWLOntologyException if the specified ontology is not managed by this manager. + */ + default void saveOntology(OWLOntology ontology, IRI documentIRI) + throws OWLOntologyStorageException { + saveOntology(ontology, getNonnullOntologyFormat(ontology), documentIRI); + } + + /** + * Saves the specified ontology, to the specified output stream + * + * @param ontology The ontology to be saved. + * @param outputStream The output stream where the ontology will be saved to + * @throws OWLOntologyStorageException If there was a problem saving this ontology to the + * specified output stream + * @throws UnknownOWLOntologyException if this manager does not manage the specified ontology. + */ + default void saveOntology(OWLOntology ontology, OutputStream outputStream) + throws OWLOntologyStorageException { + saveOntology(ontology, new StreamDocumentTarget(outputStream)); + } + + /** + * Saves the specified ontology in the specified ontology format to its document URI. + * + * @param ontology The ontology to be saved. + * @param ontologyFormat The format in which the ontology should be saved. + * @throws OWLOntologyStorageException If the ontology cannot be saved. + * @throws UnknownOWLOntologyException if the specified ontology is not managed by this manager + */ + default void saveOntology(OWLOntology ontology, OWLDocumentFormat ontologyFormat) + throws OWLOntologyStorageException { + saveOntology(ontology, ontologyFormat, getOntologyDocumentIRI(ontology)); + } + + /** + * Saves the specified ontology to the specified document IRI in the specified ontology format. + * + * @param ontology The ontology to be saved + * @param ontologyFormat The format in which to save the ontology + * @param documentIRI The document IRI where the ontology should be saved to + * @throws OWLOntologyStorageException If the ontology could not be saved. + * @throws UnknownOWLOntologyException if the specified ontology is not managed by the manager. + */ + void saveOntology(OWLOntology ontology, OWLDocumentFormat ontologyFormat, IRI documentIRI) + throws OWLOntologyStorageException; + + /** + * Saves the specified ontology to the specified output stream in the specified ontology format. + * + * @param ontology The ontology to be saved + * @param ontologyFormat The format in which to save the ontology + * @param outputStream The output stream where the ontology will be saved to. + * @throws OWLOntologyStorageException If the ontology could not be saved. + * @throws UnknownOWLOntologyException if the specified ontology is not managed by the manager. + */ + default void saveOntology(OWLOntology ontology, OWLDocumentFormat ontologyFormat, + OutputStream outputStream) throws OWLOntologyStorageException { + saveOntology(ontology, ontologyFormat, new StreamDocumentTarget(outputStream)); + } + + /** + * Saves the specified ontology to the specified + * {@link org.semanticweb.owlapi.io.OWLOntologyDocumentTarget}. + * + * @param ontology The ontology to be saved. + * @param documentTarget The output target where the ontology will be saved to. + * @throws OWLOntologyStorageException If the ontology could not be saved. + * @throws UnknownOWLOntologyException if the specified ontology is not managed by this manager. + */ + default void saveOntology(OWLOntology ontology, OWLOntologyDocumentTarget documentTarget) + throws OWLOntologyStorageException { + saveOntology(ontology, getNonnullOntologyFormat(ontology), documentTarget); + } + + /** + * Saves the specified ontology to the specified output target in the specified ontology format. + * + * @param ontology The ontology to be saved. + * @param ontologyFormat The output format in which to save the ontology + * @param documentTarget The output target where the ontology will be saved to + * @throws OWLOntologyStorageException If the ontology could not be saved. + * @throws UnknownOWLOntologyException If the specified ontology is not managed by this manager. + */ + void saveOntology(OWLOntology ontology, OWLDocumentFormat ontologyFormat, + OWLOntologyDocumentTarget documentTarget) throws OWLOntologyStorageException; + + /** + * Add an IRI mapper to the manager + * + * @param mapper the mapper to add + * @deprecated use {@code getIRIMappers().add()} instead + */ + @Deprecated + void addIRIMapper(OWLOntologyIRIMapper mapper); + + /** + * Remove an IRI mapper from the manager + * + * @param mapper the mapper to remove + * @deprecated use {@code getIRIMappers().remove()} instead + */ + @Deprecated + void removeIRIMapper(OWLOntologyIRIMapper mapper); + + /** + * Clear the manager mappers + * + * @deprecated use {@code getIRIMappers().clear()} instead + */ + @Deprecated + void clearIRIMappers(); + + /** + * Add a storer to the manager + * + * @param storer the storer to add + * @deprecated use {@code getOntologyStorers().add()} instead + */ + @Deprecated + void addOntologyStorer(OWLStorerFactory storer); + + /** + * Remove a storer from the manager + * + * @param storer the storer to remove + * @deprecated use {@code getOntologyStorers().remove()} instead + */ + @Deprecated + void removeOntologyStorer(OWLStorerFactory storer); + + /** + * Clear the manager storers + * + * @deprecated use {@code getOntologyStorers().clear()} instead + */ + @Deprecated + void clearOntologyStorers(); + + /** + * @return the collection of IRI mappers. This allows for iteration and modification of the + * list. + */ + PriorityCollection getIRIMappers(); + + /** + * Set the collection of IRI mappers. The mappers are used to obtain ontology document IRIs for + * ontology IRIs. If their type is annotated with a HasPriority type, this will be used to + * decide the order they are used. Otherwise, the order in which the collection is iterated will + * determine the order in which the mappers are used. + * + * @param mappers the mappers to be injected + */ + void setIRIMappers(Set mappers); + + /** + * @return the collection of parsers. This allows for iteration and modification of the list. + */ + PriorityCollection getOntologyParsers(); + + /** + * Set the collection of parsers. If the parsers are annotated with a HasPriority type, this + * will be used to decide the order they are used. Otherwise, the order in which the collection + * is iterated will determine the order in which the parsers are used. + * + * @param parsers the factories to be injected + */ + void setOntologyParsers(Set parsers); + + /** + * @return the collection of ontology factories. This allows for iteration and modification of + * the list. + */ + PriorityCollection getOntologyFactories(); + + /** + * Set the collection of ontology factories. If the factories are annotated with a HasPriority + * type, this will be used to decide the order they are used. Otherwise, the order in which the + * collection is iterated will determine the order in which the parsers are used. + * + * @param factories the factories to be injected + */ + void setOntologyFactories(Set factories); + + /** + * @return the collection of storers. This allows for iteration and modification of the list. + */ + PriorityCollection getOntologyStorers(); + + /** + * Set the list of ontology storers. If their type is annotated with a HasPriority type, this + * will be used to decide the order they are used. Otherwise, the order in which the collection + * is iterated will determine the order in which the storers are used. + * + * @param storers The storers to be used + */ + void setOntologyStorers(Set storers); + + /** + * Adds an ontology change listener, which listens to ontology changes. An ontology change + * broadcast strategy must be specified, which determines the changes that are broadcast to the + * listener. + * + * @param listener The listener to be added. + * @param strategy The strategy that should be used for broadcasting changes to the listener. + */ + void addOntologyChangeListener(OWLOntologyChangeListener listener, + OWLOntologyChangeBroadcastStrategy strategy); + + /** + * @param listener the listener to add + */ + void addImpendingOntologyChangeListener(ImpendingOWLOntologyChangeListener listener); + + /** + * @param listener the listener to remove + */ + void removeImpendingOntologyChangeListener(ImpendingOWLOntologyChangeListener listener); + + /** + * @param listener the listener to add + */ + void addOntologyChangesVetoedListener(OWLOntologyChangesVetoedListener listener); + + /** + * @param listener the listener to remove + */ + void removeOntologyChangesVetoedListener(OWLOntologyChangesVetoedListener listener); + + /** + * Sets the default strategy that is used to broadcast ontology changes. + * + * @param strategy The strategy to be used for broadcasting changes. This strategy will override + * any previously set broadcast strategy. + * @see org.semanticweb.owlapi.model.DefaultChangeBroadcastStrategy + * @see org.semanticweb.owlapi.model.EDTChangeBroadcastStrategy + */ + void setDefaultChangeBroadcastStrategy(OWLOntologyChangeBroadcastStrategy strategy); + + /** + * Requests that the manager loads an imported ontology that is described by an imports + * statement. This method is generally used by parsers and other kinds of loaders. For simply + * loading an ontology, use the loadOntologyXXX methods. The method respects the list of ignored + * imports in the specified configuration. In other words, if this methods is called for an + * ignored import as specified by the configuration object then the import won't be loaded. The + * ontology loader configuration used is the default one for this manager. + * + * @param declaration The declaration that describes the import to be loaded. + * @throws UnloadableImportException if there was a problem creating and loading the import and + * silent missing imports handling is not turned on. If silent missing import handling + * is turned on then this exception will not be thrown. + */ + default void makeLoadImportRequest(OWLImportsDeclaration declaration) { + makeLoadImportRequest(declaration, getOntologyLoaderConfiguration()); + } + + /** + * Requests that the manager loads an imported ontology that is described by an imports + * statement. This method is generally used by parsers and other kinds of loaders. For simply + * loading an ontology, use the loadOntologyXXX methods. The method respects the list of ignored + * imports in the specified configuration. In other words, if this methods is called for an + * ignored import as specified by the configuration object then the import won't be loaded. + * + * @param declaration The declaration that describes the import to be loaded. + * @param configuration The configuration object that passes arguments to the mechanism used for + * loading. + * @throws UnloadableImportException if there was a problem creating and loading the import and + * silent missing imports handling is not turned on. If silent missing import handling + * is turned on then this exception will not be thrown. + */ + void makeLoadImportRequest(OWLImportsDeclaration declaration, + OWLOntologyLoaderConfiguration configuration); + + /** + * In the case where silent missing imports handling is enabled, a listener can be attached via + * this method so that there is a mechanism that allows clients to be informed of the reason + * when an import cannot be loaded. + * + * @param listener The listener to be added. + */ + void addMissingImportListener(MissingImportListener listener); + + /** + * Removes a previously added missing import listener. + * + * @param listener The listener to be removed. + */ + void removeMissingImportListener(MissingImportListener listener); + + /** + * Adds an ontology loaded listener to this manager. + * + * @param listener The listener to be added. + */ + void addOntologyLoaderListener(OWLOntologyLoaderListener listener); + + /** + * Removes a previously added ontology loaded listener. + * + * @param listener The listener to be removed. + */ + void removeOntologyLoaderListener(OWLOntologyLoaderListener listener); + + /** + * Adds an ontology change progress listener. + * + * @param listener The listener to be added. + */ + void addOntologyChangeProgessListener(OWLOntologyChangeProgressListener listener); + + /** + * Removes a previously added ontology change listener. + * + * @param listener The listener to be removed. + */ + void removeOntologyChangeProgessListener(OWLOntologyChangeProgressListener listener); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyManagerFactory.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyManagerFactory.java new file mode 100644 index 0000000000..469e10d246 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyManagerFactory.java @@ -0,0 +1,32 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; +import java.util.function.Supplier; + +/** + * An ontology manager factory is responsible from creating new ontology + * managers. + * + * @author ignazio + * @since 4.0.0 + */ +public interface OWLOntologyManagerFactory extends Serializable, Supplier { + + /** + * Creates a new ontology manager. + */ + @Override + OWLOntologyManager get(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyRenameException.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyRenameException.java new file mode 100644 index 0000000000..f55d460841 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyRenameException.java @@ -0,0 +1,47 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.change.OWLOntologyChangeData; + +/** + * An exception that describes the situation where an ontology could not be + * renamed (have its ID set) because its manager already contained an ontology + * with the same name. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class OWLOntologyRenameException extends OWLOntologyChangeException { + + private final OWLOntologyID ontologyID; + + /** + * @param change change causing the error + * @param ontologyID ontology id that cannot be renamed + */ + public OWLOntologyRenameException(OWLOntologyChangeData change, + OWLOntologyID ontologyID) { + super(change, + "Could not rename ontology. An ontology with this ID already exists: " + + ontologyID); + this.ontologyID = ontologyID; + } + + /** + * @return id of the ontology + */ + public OWLOntologyID getOntologyID() { + return ontologyID; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyResourceAccessException.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyResourceAccessException.java new file mode 100644 index 0000000000..5ac0f68526 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyResourceAccessException.java @@ -0,0 +1,53 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An exception to describe a problem in accessing an ontology. Since there + * could be any kind of implementation of {@code OWLOntology} (and other model + * interfaces), some of which may use secondary storage, such as a database + * backend, there could be problems with accessing ontology objects such as + * axioms. In such situations the implementation should wrap the implementation + * specific exceptions in this exception and rethrow an instance of this + * exception. Note that exceptions of this type are unchecked (runtime) + * exceptions - this is because they represent potentially nasty situations + * where client code calling methods such as getAxioms() probably doesn't know + * (or care) how to handle situations where network/database connections fail. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLOntologyResourceAccessException extends OWLRuntimeException { + + /** + * @param message message + */ + public OWLOntologyResourceAccessException(String message) { + super(message); + } + + /** + * @param message message + * @param cause cause + */ + public OWLOntologyResourceAccessException(String message, Throwable cause) { + super(message, cause); + } + + /** + * @param cause cause + */ + public OWLOntologyResourceAccessException(Throwable cause) { + super(cause); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologySetProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologySetProvider.java new file mode 100644 index 0000000000..d95eac1c24 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologySetProvider.java @@ -0,0 +1,26 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; + +/** + * Inputs to algorithms etc. can require a set of ontologies. This interface + * provides a convenient lightweight access point for such a set. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLOntologySetProvider extends HasGetOntologies, Serializable { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyStorageException.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyStorageException.java new file mode 100644 index 0000000000..d3a7b67f54 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyStorageException.java @@ -0,0 +1,42 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLOntologyStorageException extends OWLException { + + /** + * @param message message + */ + public OWLOntologyStorageException(String message) { + super(message); + } + + /** + * @param message message + * @param cause cause + */ + public OWLOntologyStorageException(String message, Throwable cause) { + super(message, cause); + } + + /** + * @param cause cause + */ + public OWLOntologyStorageException(Throwable cause) { + super(cause); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyWriterConfiguration.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyWriterConfiguration.java new file mode 100644 index 0000000000..eb576349ca --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyWriterConfiguration.java @@ -0,0 +1,204 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; + +/** + * A configuration object that specifies options for output. + * + * @author Ignazio + * @since 5.0.0 + */ +public class OWLOntologyWriterConfiguration implements Serializable { + + private boolean saveIds = false; + private boolean remapIds = true; + private boolean useNamespaceEntities = false; + private boolean indenting = true; + private boolean labelsAsBanner = false; + private boolean bannersEnabled = true; + private int indentSize = 4; + private boolean outputNamedGraphIRI = false; + + private OWLOntologyWriterConfiguration copy() { + OWLOntologyWriterConfiguration toReturn = new OWLOntologyWriterConfiguration(); + toReturn.indenting = indenting; + toReturn.labelsAsBanner = labelsAsBanner; + toReturn.useNamespaceEntities = useNamespaceEntities; + toReturn.remapIds = remapIds; + toReturn.saveIds = saveIds; + toReturn.outputNamedGraphIRI = outputNamedGraphIRI; + return toReturn; + } + + /** + * @return should output banners + */ + public boolean shouldUseBanners() { + return bannersEnabled; + } + + /** + * @return true if all anonymous individuals should have their ids persisted + */ + public boolean shouldSaveIdsForAllAnonymousIndividuals() { + return saveIds; + } + + /** + * @return true if all anonymous individuals should have their ids remapped upon reading + */ + public boolean shouldRemapAllAnonymousIndividualsIds() { + return remapIds; + } + + /** + * @return use namespace entities + */ + public boolean isUseNamespaceEntities() { + return useNamespaceEntities; + } + + /** + * @return indenting + */ + public boolean isIndenting() { + return indenting; + } + + /** + * @return indent size + */ + public int getIndentSize() { + return indentSize; + } + + /** + * @return true if labels should be used for banner comments + */ + public boolean isLabelsAsBanner() { + return labelsAsBanner; + } + + /** + * @param banners True if banner comments should be enabled. + * @return new config object + */ + public OWLOntologyWriterConfiguration withBannersEnabled(boolean banners) { + if (bannersEnabled == banners) { + return this; + } + OWLOntologyWriterConfiguration copy = copy(); + copy.bannersEnabled = banners; + return copy; + } + + /** + * @param b true if all anonymous individuals should have their ids persisted + * @return new config object + */ + public OWLOntologyWriterConfiguration withSaveIdsForAllAnonymousIndividuals(boolean b) { + if (saveIds == b) { + return this; + } + OWLOntologyWriterConfiguration copy = copy(); + copy.saveIds = b; + return copy; + } + + /** + * @param b true if all anonymous individuals should have their ids remapped after parsing + * @return new config object + */ + public OWLOntologyWriterConfiguration withRemapAllAnonymousIndividualsIds(boolean b) { + if (remapIds == b) { + return this; + } + OWLOntologyWriterConfiguration copy = copy(); + copy.remapIds = b; + return copy; + } + + /** + * @param useEntities true if namespace entities should be used + * @return new config object + */ + public OWLOntologyWriterConfiguration withUseNamespaceEntities(boolean useEntities) { + if (useNamespaceEntities == useEntities) { + return this; + } + OWLOntologyWriterConfiguration copy = copy(); + copy.useNamespaceEntities = useEntities; + return copy; + } + + /** + * @param indent indent + * @return new config object + */ + public OWLOntologyWriterConfiguration withIndenting(boolean indent) { + if (indenting == indent) { + return this; + } + OWLOntologyWriterConfiguration copy = copy(); + copy.indenting = indent; + return copy; + } + + /** + * @param indent indent size + * @return new config object + */ + public OWLOntologyWriterConfiguration withIndentSize(int indent) { + if (indentSize == indent) { + return this; + } + OWLOntologyWriterConfiguration copy = copy(); + copy.indentSize = indent; + return copy; + } + + /** + * @param label true if labels should be used for banner comments + * @return new config object + */ + public OWLOntologyWriterConfiguration withLabelsAsBanner(boolean label) { + if (labelsAsBanner == label) { + return this; + } + OWLOntologyWriterConfiguration copy = copy(); + copy.labelsAsBanner = label; + return copy; + } + + /** + * @param label True if named graph IRIs comments should be enabled. + * @return new config object + */ + public OWLOntologyWriterConfiguration withNamedGraphIRIEnabled(boolean label) { + if (outputNamedGraphIRI == label) { + return this; + } + OWLOntologyWriterConfiguration copy = copy(); + copy.outputNamedGraphIRI = label; + return copy; + } + + /** + * @return should output named graph IRIs + */ + public boolean shouldOutputNamedGraphIRI() { + return outputNamedGraphIRI; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLPairwiseBooleanVisitor.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLPairwiseBooleanVisitor.java new file mode 100644 index 0000000000..fc635e8105 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLPairwiseBooleanVisitor.java @@ -0,0 +1,37 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + + +/** + * Functional interface for a visitor that applies a function to two arguments, + * and returns a value. This is used by OWLNaryAxiom to pass the elements in its + * collection in pairs, e.g., all pairwise disjoint class expressions in a + * disjoint class axiom. + * + * @param type of elements to accept + * @author ignazio + * @since 5.0.0 + */ +@FunctionalInterface +public interface OWLPairwiseBooleanVisitor { + + /** + * The order of the arguments depend on the visited element. + * + * @param a first argument + * @param b second argument + * @return return value for the visitor + */ + boolean visit(C a, C b); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLPairwiseVisitor.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLPairwiseVisitor.java new file mode 100644 index 0000000000..d042668542 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLPairwiseVisitor.java @@ -0,0 +1,40 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import javax.annotation.Nullable; + +/** + * Functional interface for a visitor that applies a function to two arguments, + * and returns a value. This is used by OWLNaryAxiom to pass the elements in its + * collection in pairs, e.g., all pairwise disjoint class expressions in a + * disjoint class axiom. + * + * @param returned type + * @param type of elements to accept + * @author ignazio + * @since 4.0.0 + */ +@FunctionalInterface +public interface OWLPairwiseVisitor { + + /** + * The order of the arguments depend on the visited element. + * + * @param a first argument + * @param b second argument + * @return return value for the visitor + */ + @Nullable + T visit(C a, C b); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLPairwiseVoidVisitor.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLPairwiseVoidVisitor.java new file mode 100644 index 0000000000..f17fcf8c91 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLPairwiseVoidVisitor.java @@ -0,0 +1,35 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Functional interface for a visitor that applies a function to two arguments, + * and returns a value. This is used by OWLNaryAxiom to pass the elements in its + * collection in pairs, e.g., all pairwise disjoint class expressions in a + * disjoint class axiom. + * + * @param type of elements to accept + * @author ignazio + * @since 5.0.0 + */ +@FunctionalInterface +public interface OWLPairwiseVoidVisitor { + + /** + * The order of the arguments depend on the visited element. + * + * @param a first argument + * @param b second argument + */ + void visit(C a, C b); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLPrimitive.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLPrimitive.java new file mode 100644 index 0000000000..339f2458af --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLPrimitive.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * A common interface for: {@link org.semanticweb.owlapi.model.OWLClass}, + * {@link org.semanticweb.owlapi.model.OWLObjectProperty}, + * {@link org.semanticweb.owlapi.model.OWLDataProperty}, + * {@link org.semanticweb.owlapi.model.OWLAnnotationProperty}, + * {@link org.semanticweb.owlapi.model.OWLDatatype}, + * {@link org.semanticweb.owlapi.model.OWLAnonymousIndividual}, + * {@link org.semanticweb.owlapi.model.OWLLiteral}, + * {@link org.semanticweb.owlapi.model.IRI}. i.e. the basic "leaf" objects that + * are used in axioms, class expressions an annotations. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +public interface OWLPrimitive extends OWLObject { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLProperty.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLProperty.java new file mode 100644 index 0000000000..a01511e759 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLProperty.java @@ -0,0 +1,26 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * A marker interface for properties that aren't expression i.e. named + * properties. By definition, properties are either data properties or object + * properties. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLProperty extends OWLPropertyExpression, OWLLogicalEntity, + OWLNamedObject { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyAssertionAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyAssertionAxiom.java new file mode 100644 index 0000000000..c774df8821 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyAssertionAxiom.java @@ -0,0 +1,77 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * Represents an Assertion in the OWL 2 + * specification. + * + * @param

property expression + * @param object + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLPropertyAssertionAxiom

+ extends OWLIndividualAxiom, OWLSubClassOfAxiomShortCut, HasSubject, + HasProperty

, HasObject { + + @Override + default Stream components() { + return Stream.of(getSubject(), getProperty(), getObject(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getSubject().hashCode()); + hash = OWLObject.hashIteration(hash, getProperty().hashCode()); + hash = OWLObject.hashIteration(hash, getObject().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getSubject(), getProperty(), getObject()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getSubject(), getProperty(), getObject()); + } + + /** + * Gets the individual that is the subject of this assertion. + * + * @return The individual that represents the subject of this assertion. + */ + @Override + OWLIndividual getSubject(); + + /** + * Gets the property that this assertion acts along. + * + * @return The property + */ + @Override + P getProperty(); + + /** + * Gets the object of this assertion. + * + * @return The object that this assertion points to. + */ + @Override + O getObject(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyAssertionObject.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyAssertionObject.java new file mode 100644 index 0000000000..e5f27c4299 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyAssertionObject.java @@ -0,0 +1,24 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * A marker interface for the types of property assertion objects (individuals + * and literals) that are the objects of property assertions. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLPropertyAssertionObject extends OWLObject { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyAxiom.java new file mode 100644 index 0000000000..aa4c5dab69 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyAxiom.java @@ -0,0 +1,23 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * The base interface for property axioms. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLPropertyAxiom extends OWLLogicalAxiom { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyDomain.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyDomain.java new file mode 100644 index 0000000000..6723e2cb96 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyDomain.java @@ -0,0 +1,23 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * A marker interface, for objects that can be the ranges of properties. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLPropertyDomain extends OWLObject { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyDomainAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyDomainAxiom.java new file mode 100644 index 0000000000..87783548d4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyDomainAxiom.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * Represents + * ObjectPropertyDomain axioms in the OWL 2 specification. + * + * @param

property expression + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLPropertyDomainAxiom

+ extends OWLUnaryPropertyAxiom

, OWLSubClassOfAxiomShortCut, HasDomain { + + @Override + default Stream components() { + return Stream.of(getProperty(), getDomain(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getProperty().hashCode()); + hash = OWLObject.hashIteration(hash, getDomain().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getProperty(), getDomain()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getProperty(), getDomain()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyEntityVisitorBase.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyEntityVisitorBase.java new file mode 100644 index 0000000000..8e90df9e1a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyEntityVisitorBase.java @@ -0,0 +1,47 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public interface OWLPropertyEntityVisitorBase extends OWLVisitorBase { + + /** + * visit OWLObjectProperty type + * + * @param property property to visit + */ + default void visit(OWLObjectProperty property) { + doDefault(property); + } + + /** + * visit OWLDataProperty type + * + * @param property property to visit + */ + default void visit(OWLDataProperty property) { + doDefault(property); + } + + /** + * visit OWLAnnotationProperty type + * + * @param property property to visit + */ + default void visit(OWLAnnotationProperty property) { + doDefault(property); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyEntityVisitorExBase.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyEntityVisitorExBase.java new file mode 100644 index 0000000000..b4ac3d211d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyEntityVisitorExBase.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param visitor type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public interface OWLPropertyEntityVisitorExBase extends OWLVisitorExBase { + + /** + * visit OWLObjectProperty type + * + * @param property property to visit + * @return visitor value + */ + default O visit(OWLObjectProperty property) { + return doDefault(property); + } + + /** + * visit OWLDataProperty type + * + * @param property property to visit + * @return visitor value + */ + default O visit(OWLDataProperty property) { + return doDefault(property); + } + + /** + * visit OWLAnnotationProperty type + * + * @param property property to visit + * @return visitor value + */ + default O visit(OWLAnnotationProperty property) { + return doDefault(property); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyExpression.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyExpression.java new file mode 100644 index 0000000000..a9c342e377 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyExpression.java @@ -0,0 +1,106 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents a property or possibly the inverse of a property. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLPropertyExpression extends OWLObject, AsOWLObjectProperty, AsOWLDataProperty, + AsOWLAnnotationProperty { + + /** + * @param visitor visitor to accept + */ + void accept(OWLPropertyExpressionVisitor visitor); + + /** + * @param visitor visitor to accept + * @param visitor return type + * @return visitor value + */ + O accept(OWLPropertyExpressionVisitorEx visitor); + + /** + * @return true if this is a data property + */ + default boolean isDataPropertyExpression() { + return false; + } + + /** + * @return this instance cast as an OWLDataPropertyExpression + */ + default OWLDataPropertyExpression asDataPropertyExpression() { + if (isDataPropertyExpression()) { + return (OWLDataPropertyExpression) this; + } + throw new ClassCastException(getClass().getName() + "is not an OWLDataPropertyExpression"); + } + + /** + * @return true if this is an object property + */ + default boolean isObjectPropertyExpression() { + return false; + } + + /** + * @return this instance cast as an OWLObjectPropertyExpression + */ + default OWLObjectPropertyExpression asObjectPropertyExpression() { + if (isObjectPropertyExpression()) { + return (OWLObjectPropertyExpression) this; + } + throw new ClassCastException( + getClass().getName() + "is not an OWLObjectPropertyExpression"); + } + + /** + * Determines if this is the owl:topObjectProperty. + * + * @return {@code true} if this property is the owl:topObjectProperty otherwise {@code false} + */ + default boolean isOWLTopObjectProperty() { + return false; + } + + /** + * Determines if this is the owl:bottomObjectProperty. + * + * @return {@code true} if this property is the owl:bottomObjectProperty otherwise {@code false} + */ + default boolean isOWLBottomObjectProperty() { + return false; + } + + /** + * Determines if this is the owl:topDataProperty. + * + * @return {@code true} if this property is the owl:topDataProperty otherwise {@code false} + */ + default boolean isOWLTopDataProperty() { + return false; + } + + /** + * Determines if this is the owl:bottomDataProperty. + * + * @return {@code true} if this property is the owl:bottomDataProperty otherwise {@code false} + */ + default boolean isOWLBottomDataProperty() { + return false; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyExpressionVisitor.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyExpressionVisitor.java new file mode 100644 index 0000000000..5309c30659 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyExpressionVisitor.java @@ -0,0 +1,32 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * An interface to object that can visit the different types of property + * expressions. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLPropertyExpressionVisitor extends OWLPropertyEntityVisitorBase { + + /** + * visit OWLObjectInverseOf type + * + * @param property property to visit + */ + default void visit(OWLObjectInverseOf property) { + doDefault(property); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyExpressionVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyExpressionVisitorEx.java new file mode 100644 index 0000000000..0f6e0fdbd1 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyExpressionVisitorEx.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param visitor type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public interface OWLPropertyExpressionVisitorEx extends OWLPropertyEntityVisitorExBase { + + /** + * visit OWLObjectInverseOf type + * + * @param property property to visit + * @return visitor value + */ + default O visit(OWLObjectInverseOf property) { + return doDefault(property); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyRange.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyRange.java new file mode 100644 index 0000000000..876364c1d1 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyRange.java @@ -0,0 +1,23 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * A marker interface, for objects that can be the ranges of properties. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLPropertyRange extends OWLObject { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyRangeAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyRangeAxiom.java new file mode 100644 index 0000000000..081b778705 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLPropertyRangeAxiom.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * Represents + * ObjectPropertyRange axioms in the OWL 2 specification. + * + * @param range + * @param

property expression + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLPropertyRangeAxiom

+ extends OWLUnaryPropertyAxiom

, OWLSubClassOfAxiomShortCut, HasRange { + + @Override + default Stream components() { + return Stream.of(getProperty(), getRange(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getProperty().hashCode()); + hash = OWLObject.hashIteration(hash, getRange().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getProperty(), getRange()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getProperty(), getRange()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLQuantifiedDataRestriction.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLQuantifiedDataRestriction.java new file mode 100644 index 0000000000..97d609917f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLQuantifiedDataRestriction.java @@ -0,0 +1,21 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * A quantified data restriction. + */ +public interface OWLQuantifiedDataRestriction extends + OWLQuantifiedRestriction, OWLDataRestriction { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLQuantifiedObjectRestriction.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLQuantifiedObjectRestriction.java new file mode 100644 index 0000000000..caa7e66850 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLQuantifiedObjectRestriction.java @@ -0,0 +1,21 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * A quantified object restriction. + */ +public interface OWLQuantifiedObjectRestriction extends + OWLQuantifiedRestriction, OWLObjectRestriction { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLQuantifiedRestriction.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLQuantifiedRestriction.java new file mode 100644 index 0000000000..e4879300a8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLQuantifiedRestriction.java @@ -0,0 +1,36 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * @param value + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLQuantifiedRestriction + extends OWLRestriction, HasFiller { + + @Override + default Stream components() { + return Stream.of(getProperty(), getFiller()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getProperty().hashCode()); + return OWLObject.hashIteration(hash, getFiller().hashCode()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLReflexiveObjectPropertyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLReflexiveObjectPropertyAxiom.java new file mode 100644 index 0000000000..23d57a200d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLReflexiveObjectPropertyAxiom.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents + * ReflexiveObjectProperty axioms in the OWL 2 specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLReflexiveObjectPropertyAxiom + extends OWLObjectPropertyCharacteristicAxiom, OWLSubClassOfAxiomShortCut { + + @Override + @SuppressWarnings("unchecked") + OWLReflexiveObjectPropertyAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 131; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.REFLEXIVE_OBJECT_PROPERTY; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLRestriction.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLRestriction.java new file mode 100644 index 0000000000..3a201bcb17 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLRestriction.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents a restriction (Object + * Property Restriction or Data + * Property Restriction) in the OWL 2 specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLRestriction extends OWLAnonymousClassExpression { + + /** + * Determines if this is an object restriction. + * + * @return {@code true} if this is an object restriction, otherwise {@code false} + */ + default boolean isObjectRestriction() { + return false; + } + + /** + * Determines if this is a data restriction. + * + * @return {@code true} if this is a data restriction, otherwise {@code false} + */ + default boolean isDataRestriction() { + return false; + } + + /** + * @return property being restricted + */ + OWLPropertyExpression getProperty(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLRuntimeException.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLRuntimeException.java new file mode 100644 index 0000000000..32ff8c6604 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLRuntimeException.java @@ -0,0 +1,54 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; +import javax.annotation.Nullable; + +/** + * The root of runtime exceptions in the OWL API. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLRuntimeException extends RuntimeException implements Serializable { + + /** + * Default constructor. + */ + public OWLRuntimeException() { + super(); + } + + /** + * @param message message + */ + public OWLRuntimeException(@Nullable String message) { + super(message); + } + + /** + * @param message message + * @param cause cause + */ + public OWLRuntimeException(@Nullable String message, @Nullable Throwable cause) { + super(message, cause); + } + + /** + * @param cause cause + */ + public OWLRuntimeException(@Nullable Throwable cause) { + super(cause); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLSameIndividualAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLSameIndividualAxiom.java new file mode 100644 index 0000000000..38b95745d6 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLSameIndividualAxiom.java @@ -0,0 +1,73 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Collection; + +/** + * Represents an SameIndividual + * axiom in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLSameIndividualAxiom extends OWLNaryIndividualAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLSameIndividualAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 137; + } + + /** + * Determines whether this axiom contains anonymous individuals. Anonymous individuals are not + * allowed in same individuals axioms. + * + * @return {@code true} if this axioms contains anonymous individual axioms + */ + boolean containsAnonymousIndividuals(); + + @Override + Collection asPairwiseAxioms(); + + @Override + Collection splitToAnnotatedPairs(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.SAME_INDIVIDUAL; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLSignature.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLSignature.java new file mode 100644 index 0000000000..320b55d1f2 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLSignature.java @@ -0,0 +1,473 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.parameters.Imports; + +/** + * Ontology methods related to its signature. + * + * @author ignazio + * @since 4.0.0 + */ +public interface OWLSignature + extends HasGetEntitiesInSignature, HasClassesInSignature, HasAnnotationPropertiesInSignature, + HasObjectPropertiesInSignature, HasDataPropertiesInSignature, HasDatatypesInSignature, + HasIndividualsInSignature, HasContainsEntityInSignature, HasImportsClosure { + + /** + * Gets the classes in the signature and optionally the imports closure. + * + * @param imports if INCLUDED, include imports closure. + * @return the set of classes in the signature, optionally including the import closure. The set + * that is returned is a copy; modifications to the returned set will not be reflected + * in this object. + */ + default Set getClassesInSignature(Imports imports) { + return asSet(classesInSignature(imports)); + } + + /** + * Gets the classes in the signature and optionally the imports closure. + * + * @param imports if INCLUDED, include imports closure. + * @return the stream of classes in the signature, optionally including the import closure. + */ + default Stream classesInSignature(Imports imports) { + return imports.stream(this).flatMap(OWLOntology::classesInSignature).distinct().sorted(); + } + + /** + * Gets the object properties in the signature and optionally the imports closure. + * + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return the set of object properties in the signature, optionally including the import + * closure. The set that is returned is a copy; modifications to the returned set will + * not be reflected in this object. + */ + default Set getObjectPropertiesInSignature(Imports includeImportsClosure) { + return asSet(objectPropertiesInSignature(includeImportsClosure)); + } + + /** + * Gets the object properties in the signature and optionally the imports closure. + * + * @param imports if INCLUDED, include imports closure. + * @return the stream of object properties in the signature, optionally including the import + * closure. + */ + default Stream objectPropertiesInSignature(Imports imports) { + return imports.stream(this).flatMap(OWLOntology::objectPropertiesInSignature).distinct() + .sorted(); + } + + /** + * Gets the data properties in the signature and optionally the imports closure. + * + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return the set of data properties in the signature, optionally including the import closure. + * The set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + */ + default Set getDataPropertiesInSignature(Imports includeImportsClosure) { + return asSet(dataPropertiesInSignature(includeImportsClosure)); + } + + /** + * Gets the data properties in the signature and optionally the imports closure. + * + * @param imports if INCLUDED, include imports closure. + * @return the stream of data properties in the signature, optionally including the import + * closure. + */ + default Stream dataPropertiesInSignature(Imports imports) { + return imports.stream(this).flatMap(OWLOntology::dataPropertiesInSignature).distinct() + .sorted(); + } + + /** + * Gets the named individuals in the signature and optionally the imports closure. + * + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return the set of individuals in the signature, optionally including the import closure. The + * set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + */ + default Set getIndividualsInSignature(Imports includeImportsClosure) { + return asSet(individualsInSignature(includeImportsClosure)); + } + + /** + * Gets the named individuals in the signature and optionally the imports closure. + * + * @param imports if INCLUDED, include imports closure. + * @return the stream of individuals in the signature, optionally including the import closure. + */ + default Stream individualsInSignature(Imports imports) { + return imports.stream(this).flatMap(OWLOntology::individualsInSignature).distinct() + .sorted(); + } + + /** + * Gets the referenced anonymous individuals in the signature and optionally the imports + * closure. + * + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return The set of referenced anonymous individuals. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + */ + default Set getReferencedAnonymousIndividuals( + Imports includeImportsClosure) { + return asSet(referencedAnonymousIndividuals(includeImportsClosure)); + } + + /** + * Gets the referenced anonymous individuals in the signature and optionally the imports + * closure. + * + * @param imports if INCLUDED, include imports closure. + * @return The stream of referenced anonymous individuals + */ + default Stream referencedAnonymousIndividuals(Imports imports) { + return imports.stream(this).flatMap(OWLOntology::referencedAnonymousIndividuals).distinct() + .sorted(); + } + + /** + * Gets the referenced anonymous individuals. + * + * @return The set of referenced anonymous individuals. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + */ + default Set getReferencedAnonymousIndividuals() { + return asSet(referencedAnonymousIndividuals()); + } + + /** + * Gets the referenced anonymous individuals. + * + * @return Sorted stream of referenced anonymous individuals + */ + Stream referencedAnonymousIndividuals(); + + /** + * Gets the datatypes in the signature and optionally the imports closure. + * + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return the set of datatypes in the signature of this ontology, optionally including the + * import closure. The set that is returned is a copy; modifications to the returned set + * will not be reflected in this object. + */ + default Set getDatatypesInSignature(Imports includeImportsClosure) { + return asSet(datatypesInSignature(includeImportsClosure)); + } + + /** + * Gets the datatypes in the signature and optionally the imports closure. + * + * @param imports if INCLUDED, include imports closure. + * @return the stream of datatypes in the signature of this ontology, optionally including the + * import closure. + */ + default Stream datatypesInSignature(Imports imports) { + return imports.stream(this).flatMap(OWLOntology::datatypesInSignature).distinct().sorted(); + } + + /** + * Gets the annotation properties in the signature and optionally the imports closure. + * + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return the set of annotation properties in the signature, optionally including the import + * closure. The set that is returned is a copy; modifications to the returned set will + * not be reflected in this object. + */ + default Set getAnnotationPropertiesInSignature( + Imports includeImportsClosure) { + return asSet(annotationPropertiesInSignature(includeImportsClosure)); + } + + /** + * Gets the annotation properties in the signature and optionally the imports closure. + * + * @param imports if INCLUDED, include imports closure. + * @return the stream of annotation properties in the signature, optionally including the import + * closure. + */ + default Stream annotationPropertiesInSignature(Imports imports) { + return imports.stream(this).flatMap(OWLOntology::annotationPropertiesInSignature).distinct() + .sorted(); + } + + /** + * Determines if the signature contains the specified entity. + * + * @param owlEntity The entity + * @param imports if INCLUDED, include imports closure. + * @return {@code true} if the signature or the import closure contains a reference to the + * specified entity. + */ + default boolean containsEntityInSignature(OWLEntity owlEntity, Imports imports) { + return imports.stream(this).anyMatch(o -> o.containsEntityInSignature(owlEntity)); + } + + /** + * Determines if the signature contains an entity with the specified IRI. + * + * @param entityIRI The IRI to test for. + * @param imports if INCLUDED, include imports closure. + * @return true if the signature or the import closure contains an entity with the specified + * IRI. + */ + default boolean containsEntityInSignature(IRI entityIRI, Imports imports) { + return imports.stream(this).anyMatch(o -> o.containsEntityInSignature(entityIRI)); + } + + // Access by IRI + + /** + * Determines if the signature contains an OWLClass that has the specified IRI. + * + * @param owlClassIRI The IRI of the class to check for + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return true if the signature or the import closure contains an entity with the specified + * IRI. + */ + boolean containsClassInSignature(IRI owlClassIRI, Imports includeImportsClosure); + + /** + * Determines if the signature contains an OWLObjectProperty that has the specified IRI. + * + * @param owlObjectPropertyIRI The IRI of the OWLObjectProperty to check for + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return true if the signature or the import closure contains an object property with the + * specified IRI. + */ + boolean containsObjectPropertyInSignature(IRI owlObjectPropertyIRI, + Imports includeImportsClosure); + + /** + * Determines if the signature contains an OWLDataProperty that has the specified IRI. + * + * @param owlDataPropertyIRI The IRI of the OWLDataProperty to check for + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return true if the signature or the import closure contains a data property with the + * specified IRI. + */ + boolean containsDataPropertyInSignature(IRI owlDataPropertyIRI, Imports includeImportsClosure); + + /** + * Determines if the signature contains an OWLAnnotationProperty that has the specified IRI. + * + * @param owlAnnotationPropertyIRI The IRI of the OWLAnnotationProperty to check for + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return true if the signature or the import closure contains an annotation property with the + * specified IRI. + */ + boolean containsAnnotationPropertyInSignature(IRI owlAnnotationPropertyIRI, + Imports includeImportsClosure); + + /** + * Determines if the signature contains an OWLDatatype that has the specified IRI. + * + * @param owlDatatypeIRI The IRI of the OWLDatatype to check for + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return true if the signature or the import closure contains a datatype with the specified + * IRI. + */ + boolean containsDatatypeInSignature(IRI owlDatatypeIRI, Imports includeImportsClosure); + + /** + * Determines if the signature contains an OWLNamedIndividual that has the specified IRI. + * + * @param owlIndividualIRI The IRI of the OWLNamedIndividual to check for + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return true if the signature or the import closure contains an individual with the specified + * IRI. + */ + boolean containsIndividualInSignature(IRI owlIndividualIRI, Imports includeImportsClosure); + + /** + * Determines if the signature contains an OWLDatatype that has the specified IRI. + * + * @param owlDatatypeIRI The IRI of the OWLDatatype to check for + * @return true if the signature or the import closure contains a datatype with the specified + * IRI. + */ + boolean containsDatatypeInSignature(IRI owlDatatypeIRI); + + /** + * Determines if the signature contains an entity with the specified IRI. + * + * @param entityIRI The IRI to test for. + * @return true if the signature or the import closure contains an entity with the specified + * IRI. + */ + default boolean containsEntityInSignature(IRI entityIRI) { + return containsClassInSignature(entityIRI) || containsObjectPropertyInSignature(entityIRI) + || containsDataPropertyInSignature(entityIRI) + || containsIndividualInSignature(entityIRI) || containsDatatypeInSignature(entityIRI) + || containsAnnotationPropertyInSignature(entityIRI); + } + + // Access by IRI + + /** + * Determines if the signature contains an OWLClass that has the specified IRI. + * + * @param owlClassIRI The IRI of the class to check for + * @return true if the signature or the import closure contains an entity with the specified + * IRI. + */ + boolean containsClassInSignature(IRI owlClassIRI); + + /** + * Determines if the signature contains an OWLObjectProperty that has the specified IRI. + * + * @param owlObjectPropertyIRI The IRI of the OWLObjectProperty to check for + * @return true if the signature or the import closure contains an object property with the + * specified IRI. + */ + boolean containsObjectPropertyInSignature(IRI owlObjectPropertyIRI); + + /** + * Determines if the signature contains an OWLDataProperty that has the specified IRI. + * + * @param owlDataPropertyIRI The IRI of the OWLDataProperty to check for + * @return true if the signature or the import closure contains a data property with the + * specified IRI. + */ + boolean containsDataPropertyInSignature(IRI owlDataPropertyIRI); + + /** + * Determines if the signature contains an OWLAnnotationProperty that has the specified IRI. + * + * @param owlAnnotationPropertyIRI The IRI of the OWLAnnotationProperty to check for + * @return true if the signature or the import closure contains an annotation property with the + * specified IRI. + */ + boolean containsAnnotationPropertyInSignature(IRI owlAnnotationPropertyIRI); + + /** + * Determines if the signature contains an OWLNamedIndividual that has the specified IRI. + * + * @param owlIndividualIRI The IRI of the OWLNamedIndividual to check for + * @return true if the signature or the import closure contains an individual with the specified + * IRI. + */ + boolean containsIndividualInSignature(IRI owlIndividualIRI); + + /** + * Determine whether the instance has entities of the specified type in its signature - e.g., + * whether an ontology has classes, object properties, or named individuals in its signature. + * Anonymous individuals are not included. + * + * @param type type of entity to check + * @return true if entities of the specified type are in the signature + */ + default boolean containsEntitiesOfTypeInSignature(EntityType type) { + // default implementation - inefficient but avoids backwards compatibility issues with other + // implementations + if (EntityType.CLASS.equals(type)) { + return classesInSignature().count() > 0; + } + if (EntityType.DATA_PROPERTY.equals(type)) { + return dataPropertiesInSignature().count() > 0; + } + if (EntityType.OBJECT_PROPERTY.equals(type)) { + return objectPropertiesInSignature().count() > 0; + } + if (EntityType.ANNOTATION_PROPERTY.equals(type)) { + return annotationPropertiesInSignature().count() > 0; + } + if (EntityType.DATATYPE.equals(type)) { + return datatypesInSignature().count() > 0; + } + if (EntityType.NAMED_INDIVIDUAL.equals(type)) { + return individualsInSignature().count() > 0; + } + throw new IllegalArgumentException( + "Entity type " + type + " is not valid for entity presence check"); + } + + /** + * Determine whether the instance has entities of the specified type in its signature or in its + * import closure - e.g., whether an ontology has classes, object properties, or named + * individuals in its signature. Anonymous individuals are not included. + * + * @param type type of entity to check + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return true if entities of the specified type are in the signature + */ + default boolean containsEntitiesOfTypeInSignature(EntityType type, + Imports includeImportsClosure) { + return includeImportsClosure.stream(this) + .anyMatch(o -> o.containsEntitiesOfTypeInSignature(type)); + } + + /** + * Gets the entities in the signature that have the specified IRI. + * + * @param iri The IRI of the entities to be retrieved. + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return the set of entities with the specified IRI, optionally including the ones in the + * import closure. The set that is returned is a copy; modifications to the returned set + * will not be reflected in this object. + */ + default Set getEntitiesInSignature(IRI iri, Imports includeImportsClosure) { + return asSet(entitiesInSignature(iri, includeImportsClosure)); + } + + /** + * Gets the entities in the signature that have the specified IRI. + * + * @param iri The IRI of the entities to be retrieved. + * @param imports if INCLUDED, include imports closure. + * @return the stream of entities with the specified IRI, optionally including the ones in the + * import closure. + */ + default Stream entitiesInSignature(IRI iri, Imports imports) { + return imports.stream(this).flatMap(o -> o.entitiesInSignature(iri)).distinct().sorted(); + } + + /** + * Calculates the set of IRIs that are used for more than one entity type. + * + * @param includeImportsClosure if INCLUDED, include imports closure. + * @return punned IRIs. + */ + Set getPunnedIRIs(Imports includeImportsClosure); + + /** + * @param entity entity to check + * @param imports if INCLUDED, include imports closure. + * @return true if entity is referenced + * @deprecated use {@link #containsEntityInSignature(OWLEntity, Imports)} + */ + @Deprecated + default boolean containsReference(OWLEntity entity, Imports imports) { + return imports.stream(this).anyMatch(o -> o.containsReference(entity)); + } + + /** + * @param entity entity to check + * @return true if entity is referenced + * @deprecated use {@link #containsEntityInSignature(OWLEntity)} + */ + @Deprecated + boolean containsReference(OWLEntity entity); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLSignatureBooleanArgs.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLSignatureBooleanArgs.java new file mode 100644 index 0000000000..0e77da030b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLSignatureBooleanArgs.java @@ -0,0 +1,276 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Set; + +import org.semanticweb.owlapi.model.parameters.Imports; + +/** + * Ontology methods related to its signature. This interface differs from OWLSignature because it + * uses boolean arguments to determine import closure inclusion. + * + * @author ignazio + * @since 4.0.0 + */ +public interface OWLSignatureBooleanArgs extends OWLSignature { + + /** + * Gets the classes in the signature and optionally the imports closure. + * + * @param includeImportsClosure if true, include imports closure. + * @return the set of classes in the signature, optionally including the import closure. The set + * that is returned is a copy; modifications to the returned set will not be reflected + * in this object. + * @deprecated use {@link #classesInSignature(Imports)} + */ + @Deprecated + default Set getClassesInSignature(boolean includeImportsClosure) { + return getClassesInSignature(Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Gets the object properties in the signature and optionally the imports closure. + * + * @param includeImportsClosure if true, include imports closure. + * @return the set of object properties in the signature, optionally including the import + * closure. The set that is returned is a copy; modifications to the returned set will + * not be reflected in this object. + * @deprecated use {@link #objectPropertiesInSignature(Imports)} + */ + @Deprecated + default Set getObjectPropertiesInSignature(boolean includeImportsClosure) { + return getObjectPropertiesInSignature(Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Gets the data properties in the signature and optionally the imports closure. + * + * @param includeImportsClosure if true, include imports closure. + * @return the set of data properties in the signature, optionally including the import closure. + * The set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + * @deprecated use {@link #dataPropertiesInSignature(Imports)} + */ + @Deprecated + default Set getDataPropertiesInSignature(boolean includeImportsClosure) { + return getDataPropertiesInSignature(Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Gets the named individuals in the signature and optionally the imports closure. + * + * @param includeImportsClosure if true, include imports closure. + * @return the set of individuals in the signature, optionally including the import closure. The + * set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + * @deprecated use {@link #individualsInSignature(Imports)} + */ + @Deprecated + default Set getIndividualsInSignature(boolean includeImportsClosure) { + return getIndividualsInSignature(Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Gets the referenced anonymous individuals in the signature and optionally the imports + * closure. + * + * @param includeImportsClosure if true, include imports closure. + * @return The set of referenced anonymous individuals. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + * @deprecated use {@link #referencedAnonymousIndividuals(Imports)} + */ + @Deprecated + default Set getReferencedAnonymousIndividuals( + boolean includeImportsClosure) { + return getReferencedAnonymousIndividuals(Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Gets the datatypes in the signature and optionally the imports closure. + * + * @param includeImportsClosure if true, include imports closure. + * @return the set of datatypes in the signature of this ontology, optionally including the + * import closure. The set that is returned is a copy; modifications to the returned set + * will not be reflected in this object. + * @deprecated use {@link #datatypesInSignature(Imports)} + */ + @Deprecated + default Set getDatatypesInSignature(boolean includeImportsClosure) { + return getDatatypesInSignature(Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Gets the annotation properties in the signature and optionally the imports closure. + * + * @param includeImportsClosure if true, include imports closure. + * @return the set of annotation properties in the signature, optionally including the import + * closure. The set that is returned is a copy; modifications to the returned set will + * not be reflected in this object. + * @deprecated use {@link #annotationPropertiesInSignature(Imports)} + */ + @Deprecated + default Set getAnnotationPropertiesInSignature( + boolean includeImportsClosure) { + return getAnnotationPropertiesInSignature(Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Determines if the signature contains the specified entity. + * + * @param owlEntity The entity + * @param includeImportsClosure if true, include imports closure. + * @return {@code true} if the signature or the import closure contains a reference to the + * specified entity. + * @deprecated use {@link #containsEntityInSignature(OWLEntity, Imports)} + */ + @Deprecated + default boolean containsEntityInSignature(OWLEntity owlEntity, boolean includeImportsClosure) { + return containsEntityInSignature(owlEntity, Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Determines if the signature contains an entity with the specified IRI. + * + * @param entityIRI The IRI to test for. + * @param includeImportsClosure if true, include imports closure. + * @return true if the signature or the import closure contains an entity with the specified + * IRI. + * @deprecated use {@link #containsEntityInSignature(IRI, Imports)} + */ + @Deprecated + default boolean containsEntityInSignature(IRI entityIRI, boolean includeImportsClosure) { + return containsEntityInSignature(entityIRI, Imports.fromBoolean(includeImportsClosure)); + } + + // Access by IRI + + /** + * Determines if the signature contains an OWLClass that has the specified IRI. + * + * @param owlClassIRI The IRI of the class to check for + * @param includeImportsClosure if true, include imports closure. + * @return true if the signature or the import closure contains an entity with the specified + * IRI. + * @deprecated use {@link #containsClassInSignature(IRI, Imports)} + */ + @Deprecated + default boolean containsClassInSignature(IRI owlClassIRI, boolean includeImportsClosure) { + return containsClassInSignature(owlClassIRI, Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Determines if the signature contains an OWLObjectProperty that has the specified IRI. + * + * @param owlObjectPropertyIRI The IRI of the OWLObjectProperty to check for + * @param includeImportsClosure if true, include imports closure. + * @return true if the signature or the import closure contains an object property with the + * specified IRI. + * @deprecated use {@link #containsObjectPropertyInSignature(IRI, Imports)} + */ + @Deprecated + default boolean containsObjectPropertyInSignature(IRI owlObjectPropertyIRI, + boolean includeImportsClosure) { + return containsObjectPropertyInSignature(owlObjectPropertyIRI, + Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Determines if the signature contains an OWLDataProperty that has the specified IRI. + * + * @param owlDataPropertyIRI The IRI of the OWLDataProperty to check for + * @param includeImportsClosure if true, include imports closure. + * @return true if the signature or the import closure contains a data property with the + * specified IRI. + * @deprecated use {@link #containsDataPropertyInSignature(IRI, Imports)} + */ + @Deprecated + default boolean containsDataPropertyInSignature(IRI owlDataPropertyIRI, + boolean includeImportsClosure) { + return containsDataPropertyInSignature(owlDataPropertyIRI, + Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Determines if the signature contains an OWLAnnotationProperty that has the specified IRI. + * + * @param owlAnnotationPropertyIRI The IRI of the OWLAnnotationProperty to check for + * @param includeImportsClosure if true, include imports closure. + * @return true if the signature or the import closure contains an annotation property with the + * specified IRI. + * @deprecated use {@link #containsAnnotationPropertyInSignature(IRI, Imports)} + */ + @Deprecated + default boolean containsAnnotationPropertyInSignature(IRI owlAnnotationPropertyIRI, + boolean includeImportsClosure) { + return containsAnnotationPropertyInSignature(owlAnnotationPropertyIRI, + Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Determines if the signature contains an OWLDatatype that has the specified IRI. + * + * @param owlDatatypeIRI The IRI of the OWLDatatype to check for + * @param includeImportsClosure if true, include imports closure. + * @return true if the signature or the import closure contains a datatype with the specified + * IRI. + * @deprecated use {@link #containsDatatypeInSignature(IRI, Imports)} + */ + @Deprecated + default boolean containsDatatypeInSignature(IRI owlDatatypeIRI, boolean includeImportsClosure) { + return containsDatatypeInSignature(owlDatatypeIRI, + Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Determines if the signature contains an OWLNamedIndividual that has the specified IRI. + * + * @param owlIndividualIRI The IRI of the OWLNamedIndividual to check for + * @param includeImportsClosure if true, include imports closure. + * @return true if the signature or the import closure contains an individual with the specified + * IRI. + * @deprecated use {@link #containsIndividualInSignature(IRI, Imports)} + */ + @Deprecated + default boolean containsIndividualInSignature(IRI owlIndividualIRI, + boolean includeImportsClosure) { + return containsIndividualInSignature(owlIndividualIRI, + Imports.fromBoolean(includeImportsClosure)); + } + + /** + * Gets the entities in the signature that have the specified IRI. + * + * @param iri The IRI of the entities to be retrieved. + * @param includeImportsClosure if true, include imports closure. + * @return the set of entities with the specified IRI, optionally including the ones in the + * import closure. The set that is returned is a copy; modifications to the returned set + * will not be reflected in this object. + * @deprecated use {@link #entitiesInSignature(IRI, Imports)} + */ + @Deprecated + default Set getEntitiesInSignature(IRI iri, boolean includeImportsClosure) { + return getEntitiesInSignature(iri, Imports.fromBoolean(includeImportsClosure)); + } + + /** + * @param entity entity to check + * @param includeImportsClosure if true, include imports closure. + * @return true if entity is referenced + * @deprecated use {@link #containsEntityInSignature(OWLEntity, Imports)} + */ + @Deprecated + default boolean containsReference(OWLEntity entity, boolean includeImportsClosure) { + return containsReference(entity, Imports.fromBoolean(includeImportsClosure)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLStorer.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLStorer.java new file mode 100644 index 0000000000..e09cbaaec1 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLStorer.java @@ -0,0 +1,65 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.IOException; +import java.io.Serializable; +import org.semanticweb.owlapi.io.OWLOntologyDocumentTarget; + +/** + * An ontology storer stores an ontology in a particular format at a location + * specified by a particular URI. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLStorer extends Serializable { + + /** + * Determines if this storer can store an ontology in the specified ontology + * format. + * + * @param ontologyFormat The desired ontology format. + * @return {@code true} if this storer can store an ontology in the desired format. + */ + boolean canStoreOntology(OWLDocumentFormat ontologyFormat); + + /** + * Stores an ontology to the specified ontology document IRI in the + * specified format. + * + * @param ontology The ontology to be stored + * @param documentIRI The ontology document IRI where the ontology will be saved to + * @param ontologyFormat The format that the ontology should be stored in @throws + * OWLOntologyStorageException if there was a problem storing the ontology. + * @throws IOException if there was an IOException when storing the ontology + * @throws OWLOntologyStorageException if there was a problem storing the ontology + */ + void storeOntology(OWLOntology ontology, IRI documentIRI, OWLDocumentFormat ontologyFormat) + throws OWLOntologyStorageException, IOException; + + /** + * Stores an ontology to the specified target. This method assumes the + * storer can write the ontology to some stream. + * + * @param ontology The ontology to be stored + * @param target The target which describes the ontology document where the ontology should be + * stored + * @param format The format in which to store the ontology + * @throws OWLOntologyStorageException if there was a problem storing the ontology. + * @throws IOException if there was an IOException when storing the ontology. + */ + void storeOntology(OWLOntology ontology, OWLOntologyDocumentTarget target, + OWLDocumentFormat format) + throws OWLOntologyStorageException, IOException; +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLStorerFactory.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLStorerFactory.java new file mode 100644 index 0000000000..1695b7e59b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLStorerFactory.java @@ -0,0 +1,38 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; +import java.util.function.Supplier; + +/** + * Factory for ontology storers. Provide a priority to allow for sorting of ontology storers. + * Default implementations will have priorities starting at 0 and moving up by increments of one. + * This allows the introduction of more storers at any position in the list: e.g., to insert a new + * storer in the second position, it is sufficient for it to pick a priority value strictly between + * 0 and 1. + */ +public interface OWLStorerFactory extends Serializable, Supplier { + + /** + * Create new storer. + * + * @return new storer + */ + OWLStorer createStorer(); + + /** + * @return format factory for the format parsed by this storer + */ + OWLDocumentFormatFactory getFormatFactory(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLStorerNotFoundException.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLStorerNotFoundException.java new file mode 100644 index 0000000000..426e24f8f5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLStorerNotFoundException.java @@ -0,0 +1,28 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLStorerNotFoundException extends OWLOntologyStorageException { + + /** + * @param format format that cannot be stored + */ + public OWLStorerNotFoundException(OWLDocumentFormat format) { + super("Could not find an ontology storer which can handle the format: " + + format); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLSubAnnotationPropertyOfAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLSubAnnotationPropertyOfAxiom.java new file mode 100644 index 0000000000..c2c9155dad --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLSubAnnotationPropertyOfAxiom.java @@ -0,0 +1,96 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * Represents an + * SubAnnotationPropertyOf axiom in the OWL 2 Specification. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLSubAnnotationPropertyOfAxiom extends OWLAnnotationAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLSubAnnotationPropertyOfAxiom getAxiomWithoutAnnotations(); + + @Override + default Stream components() { + return Stream.of(getSubProperty(), getSuperProperty(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getSubProperty().hashCode()); + hash = OWLObject.hashIteration(hash, getSuperProperty().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getSubProperty(), getSuperProperty()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getSubProperty(), getSuperProperty()); + } + + @Override + default int hashIndex() { + return 829; + } + + /** + * Gets the subproperty of this axiom. + * + * @return The annotation property that represents the subproperty in this axiom. + */ + OWLAnnotationProperty getSubProperty(); + + /** + * Gets the super property of this axiom. + * + * @return The annotation property that represents the super property in this axiom. + */ + OWLAnnotationProperty getSuperProperty(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.SUB_ANNOTATION_PROPERTY_OF; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLSubClassOfAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLSubClassOfAxiom.java new file mode 100644 index 0000000000..f249eded4f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLSubClassOfAxiom.java @@ -0,0 +1,104 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * Represents an SubClassOf axiom in + * the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLSubClassOfAxiom extends OWLClassAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLSubClassOfAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 139; + } + + @Override + default Stream components() { + return Stream.of(getSubClass(), getSuperClass(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getSubClass().hashCode()); + hash = OWLObject.hashIteration(hash, getSuperClass().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getSubClass(), getSuperClass()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getSubClass(), getSuperClass()); + } + + /** + * Gets the subclass in this axiom. + * + * @return The class expression that represents the subclass in this axiom. + */ + OWLClassExpression getSubClass(); + + /** + * Gets the superclass in this axiom. + * + * @return The class expression that represents the superclass in this axiom. + */ + OWLClassExpression getSuperClass(); + + /** + * Determines if this subclass axiom has a subclass that is anonymous. (if the subclass is + * anonymous then the subclass axiom is known as a General Concept Inclusion - GCI). + * + * @return {@code true} if this axiom is a GCI, other wise {@code false}. + */ + boolean isGCI(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.SUBCLASS_OF; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLSubClassOfAxiomSetShortCut.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLSubClassOfAxiomSetShortCut.java new file mode 100644 index 0000000000..823c405921 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLSubClassOfAxiomSetShortCut.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Collection; + +/** + * A marker interface for an axiom that can be represented by a set of + * SubClassOf axioms that is equivalent to this axiom. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +@FunctionalInterface +public interface OWLSubClassOfAxiomSetShortCut { + + /** + * @return the set of axioms equivalent to this expression + */ + Collection asOWLSubClassOfAxioms(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLSubClassOfAxiomShortCut.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLSubClassOfAxiomShortCut.java new file mode 100644 index 0000000000..9e5790e109 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLSubClassOfAxiomShortCut.java @@ -0,0 +1,34 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * A marker interface for axioms that are essentially syntactic shortcuts for + * SubClassOf axioms. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +@FunctionalInterface +public interface OWLSubClassOfAxiomShortCut { + + /** + * Gets this axiom as an + * {@link org.semanticweb.owlapi.model.OWLSubClassOfAxiom}. + * + * @return An {@link org.semanticweb.owlapi.model.OWLSubClassOfAxiom} that is equivalent to this + * axiom. Note that annotations are not copied to the returned {@link + * org.semanticweb.owlapi.model.OWLSubClassOfAxiom} axiom. + */ + OWLSubClassOfAxiom asOWLSubClassOfAxiom(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLSubDataPropertyOfAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLSubDataPropertyOfAxiom.java new file mode 100644 index 0000000000..45d0b17cca --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLSubDataPropertyOfAxiom.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents an + * SubDataPropertyOf axiom in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLSubDataPropertyOfAxiom + extends OWLSubPropertyAxiom, OWLDataPropertyAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLSubDataPropertyOfAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 19; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.SUB_DATA_PROPERTY; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLSubObjectPropertyOfAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLSubObjectPropertyOfAxiom.java new file mode 100644 index 0000000000..ad908e3395 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLSubObjectPropertyOfAxiom.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents + * SubObjectPropertyOf axioms in the OWL 2 specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLSubObjectPropertyOfAxiom + extends OWLSubPropertyAxiom, OWLObjectPropertyAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLSubObjectPropertyOfAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 127; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.SUB_OBJECT_PROPERTY; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLSubPropertyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLSubPropertyAxiom.java new file mode 100644 index 0000000000..1b301b4bb8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLSubPropertyAxiom.java @@ -0,0 +1,56 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * @param

property expression + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLSubPropertyAxiom

extends OWLPropertyAxiom { + + @Override + default Stream components() { + return Stream.of(getSubProperty(), getSuperProperty(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getSubProperty().hashCode()); + hash = OWLObject.hashIteration(hash, getSuperProperty().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getSubProperty(), getSuperProperty()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getSubProperty(), getSuperProperty()); + } + + /** + * @return the sub property + */ + P getSubProperty(); + + /** + * @return the super property + */ + P getSuperProperty(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLSubPropertyChainOfAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLSubPropertyChainOfAxiom.java new file mode 100644 index 0000000000..bb363568a4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLSubPropertyChainOfAxiom.java @@ -0,0 +1,109 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.List; +import java.util.stream.Stream; + +/** + * Represents a + * SubObjectPropertyOf axiom in the OWL 2 Specification where the subproperty is a chain of + * properties. Note that this axiom type is not explicit in the OWL 2 specification, but it is + * included in the OWL API as a convenience to the programmer. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLSubPropertyChainOfAxiom extends OWLObjectPropertyAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLSubPropertyChainOfAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 107; + } + + @Override + default Stream components() { + return Stream.of(getPropertyChain(), getSuperProperty(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getPropertyChain().hashCode()); + hash = OWLObject.hashIteration(hash, getSuperProperty().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getPropertyChain(), getSuperProperty()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getPropertyChain(), getSuperProperty()); + } + + /** + * Gets the chain of properties that represents the subproperty in this axiom. + * + * @return A list of object property expressions that represents the chain of properties that + * represent the subproperty in this axiom. + */ + List getPropertyChain(); + + /** + * Gets the super property of this axiom. + * + * @return The property expression that represents the super property in this expression. + */ + OWLObjectPropertyExpression getSuperProperty(); + + /** + * Determines if this axiom is of the form: P o P -> P, which is an encoding of + * Transitive(P). + * + * @return {@code true} if this encodes that the super property is transitive, otherwise {@code + * false}. + */ + boolean isEncodingOfTransitiveProperty(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.SUB_PROPERTY_CHAIN_OF; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLSymmetricObjectPropertyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLSymmetricObjectPropertyAxiom.java new file mode 100644 index 0000000000..2a28c0c64a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLSymmetricObjectPropertyAxiom.java @@ -0,0 +1,64 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Set; + +/** + * Represents + * SymmetricObjectProperty axioms in the OWL 2 specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLSymmetricObjectPropertyAxiom extends OWLObjectPropertyCharacteristicAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLSymmetricObjectPropertyAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 149; + } + + /** + * @return the set of axioms equivalent to this axiom + */ + Set asSubPropertyAxioms(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.SYMMETRIC_OBJECT_PROPERTY; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLTransitiveObjectPropertyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLTransitiveObjectPropertyAxiom.java new file mode 100644 index 0000000000..6dc113418f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLTransitiveObjectPropertyAxiom.java @@ -0,0 +1,57 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents a + * TransitiveObjectProperty axiom in the OWL 2 Specification. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLTransitiveObjectPropertyAxiom extends OWLObjectPropertyCharacteristicAxiom { + + @Override + @SuppressWarnings("unchecked") + OWLTransitiveObjectPropertyAxiom getAxiomWithoutAnnotations(); + + @Override + default int hashIndex() { + return 151; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.TRANSITIVE_OBJECT_PROPERTY; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLUnaryPropertyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLUnaryPropertyAxiom.java new file mode 100644 index 0000000000..7564eaa9b5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLUnaryPropertyAxiom.java @@ -0,0 +1,46 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * @param

property expression + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface OWLUnaryPropertyAxiom

+ extends OWLPropertyAxiom, HasProperty

{ + + @Override + default Stream components() { + return Stream.of(getProperty(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getProperty().hashCode()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(getProperty()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), getProperty()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLVisitorBase.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLVisitorBase.java new file mode 100644 index 0000000000..062ed35a7f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLVisitorBase.java @@ -0,0 +1,35 @@ +package org.semanticweb.owlapi.model; + +/** + * Base interface for visitors. + */ +public interface OWLVisitorBase { + + /** + * @param object object to visit + * @deprecated use {@code #doDefault(Object)} instead + */ + @Deprecated + default void getDefaultReturnValue(Object object) { + doDefault(object); + } + + /** + * Default action for the visitor. + * + * @param object The object that was visited. + */ + default void doDefault(@SuppressWarnings("unused") Object object) {} + + /** + * default behaviour. Override this method to change the behaviour of all non overridden + * methods. + * + * @param c default parameter + * @deprecated use {@code #doDefault(Object)} instead + */ + @Deprecated + default void handleDefault(Object c) { + doDefault(c); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OWLVisitorExBase.java b/api/src/main/java/org/semanticweb/owlapi/model/OWLVisitorExBase.java new file mode 100644 index 0000000000..311c86c709 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OWLVisitorExBase.java @@ -0,0 +1,21 @@ +package org.semanticweb.owlapi.model; + +/** + * Base interface for visitors that return a value. + * + * @param return value + */ +public interface OWLVisitorExBase { + + /** + * Gets the default return value for this visitor. By default, the default is {@code null} + * + * @param object The object that was visited. + * @param type visited + * @return The default return value + */ + default O doDefault(@SuppressWarnings("unused") T object) { + // no other way to provide a default implementation + return null; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/OntologyConfigurator.java b/api/src/main/java/org/semanticweb/owlapi/model/OntologyConfigurator.java new file mode 100644 index 0000000000..ab32266c59 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/OntologyConfigurator.java @@ -0,0 +1,492 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.ACCEPT_HTTP_COMPRESSION; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.BANNED_PARSERS; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.BANNERS_ENABLED; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.CONNECTION_TIMEOUT; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.FOLLOW_REDIRECTS; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.INDENTING; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.INDENT_SIZE; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.LABELS_AS_BANNER; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.LOAD_ANNOTATIONS; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.MISSING_IMPORT_HANDLING_STRATEGY; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.MISSING_ONTOLOGY_HEADER_STRATEGY; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.OUTPUT_NAMED_GRAPH_IRI; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.PARSE_WITH_STRICT_CONFIGURATION; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.PRIORITY_COLLECTION_SORTING; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.REMAP_IDS; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.REPAIR_ILLEGAL_PUNNINGS; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.REPORT_STACK_TRACES; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.RETRIES_TO_ATTEMPT; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.SAVE_IDS; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.TREAT_DUBLINCORE_AS_BUILTIN; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.USE_NAMESPACE_ENTITIES; + +import java.io.Serializable; +import java.util.EnumMap; +import java.util.HashSet; +import java.util.Set; + +import org.semanticweb.owlapi.model.parameters.ConfigurationOptions; + +/** + * A configuration builder that specifies all available options in the OWL API. Can be used to build + * OWLOntologyLoaderConfiguration and OWLOntologyWriterConfiguration objects + * + * @author Ignazio + * @since 5.0.0 + */ +public class OntologyConfigurator implements Serializable { + + /** + * Set of imports to ignore. + */ + private final Set ignoredImports = new HashSet<>(); + /** + * Local override map. + */ + private final EnumMap overrides = + new EnumMap<>(ConfigurationOptions.class); + + /** + * @param ban list of parser factory class names that should be skipped when attempting ontology + * parsing. The list is space separated. + * @return An {@code OntologyConfigurator} with the new option set. + */ + public OntologyConfigurator withBannedParsers(String ban) { + overrides.put(BANNED_PARSERS, ban); + return this; + } + + /** + * @return list of parser factory class names that should be skipped when attempting ontology + * parsing. The list is space separated. + */ + public String getBannedParsers() { + return BANNED_PARSERS.getValue(String.class, overrides); + } + + /** + * @return the priority collection sorting option + */ + public PriorityCollectionSorting getPriorityCollectionSorting() { + return PRIORITY_COLLECTION_SORTING.getValue(PriorityCollectionSorting.class, overrides); + } + + /** + * Set the priority collection sorting option. + * + * @param sorting the sorting option to be used. + * @return An {@code OntologyConfigurator} with the new sorting option set. + */ + public OntologyConfigurator setPriorityCollectionSorting(PriorityCollectionSorting sorting) { + overrides.put(PRIORITY_COLLECTION_SORTING, sorting); + return this; + } + + /** + * Adds an ontology document IRI to the list of ontology imports that will be ignored during + * ontology loading. + * + * @param ontologyDocumentIRI The ontology document IRI that will be ignored if it is + * encountered as an imported ontology during loading. + * @return An {@code OWLOntologyLoaderConfiguration} with the ignored ontology document IRI set. + */ + public OntologyConfigurator addIgnoredImport(IRI ontologyDocumentIRI) { + ignoredImports.add(ontologyDocumentIRI); + return this; + } + + /** + * Clears all ontology document IRIs from the list of ignored ontology document IRIs. + * + * @return An {@code OWLOntologyLoaderConfiguration} with the list of ignored ontology document + * IRIs set to be empty. + */ + public OntologyConfigurator clearIgnoredImports() { + ignoredImports.clear(); + return this; + } + + /** + * Removes an ontology document IRI from the list of ontology imports that will be ignored + * during ontology loading. + * + * @param ontologyDocumentIRI The ontology document IRI that would be ignored if it is + * encountered as an imported ontology during loading. + * @return An {@code OWLOntologyLoaderConfiguration} with the ignored ontology document IRI + * removed. + */ + public OntologyConfigurator removeIgnoredImport(IRI ontologyDocumentIRI) { + ignoredImports.remove(ontologyDocumentIRI); + return this; + } + + /** + * @param b true if HTTP compression should be accepted + * @return a copy of this configuration with accepting HTTP compression set to the new value + */ + public OntologyConfigurator setAcceptingHTTPCompression(boolean b) { + overrides.put(ACCEPT_HTTP_COMPRESSION, Boolean.valueOf(b)); + return this; + } + + /** + * @return true if HTTP compression should be used + */ + public boolean shouldAcceptHTTPCompression() { + return ACCEPT_HTTP_COMPRESSION.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @return the connection timeout + */ + public int getConnectionTimeout() { + return CONNECTION_TIMEOUT.getValue(Integer.class, overrides).intValue(); + } + + /** + * @param l new timeout Note: the timeout is an int and represents milliseconds. This is + * necessary for use in {@code URLConnection} + * @return A {@code OWLOntologyLoaderConfiguration} with the connection timeout set to the new + * value. + */ + public OntologyConfigurator setConnectionTimeout(int l) { + overrides.put(CONNECTION_TIMEOUT, Integer.valueOf(l)); + return this; + } + + /** + * @param value true if redirects should be followed across protocols, false otherwise. + * @return a copy of the current object with follow redirects set to the new value. + */ + public OntologyConfigurator setFollowRedirects(boolean value) { + overrides.put(FOLLOW_REDIRECTS, Boolean.valueOf(value)); + return this; + } + + /** + * @return follow redirects + */ + public boolean shouldFollowRedirects() { + return FOLLOW_REDIRECTS.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * Specifies whether or not annotation axioms (instances of {@code OWLAnnotationAxiom}) should + * be loaded or whether they should be discarded on loading. By default, the loading of + * annotation axioms is enabled. + * + * @param b {@code true} if annotation axioms should be loaded, or {@code false} if annotation + * axioms should not be loaded and should be discarded on loading. + * @return An {@code OWLOntologyLoaderConfiguration} object with the option set. + */ + public OntologyConfigurator setLoadAnnotationAxioms(boolean b) { + overrides.put(LOAD_ANNOTATIONS, Boolean.valueOf(b)); + return this; + } + + /** + * @return load annotations + */ + public boolean shouldLoadAnnotations() { + return LOAD_ANNOTATIONS.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @return missing import handling strategy + */ + public MissingImportHandlingStrategy getMissingImportHandlingStrategy() { + return MISSING_IMPORT_HANDLING_STRATEGY.getValue(MissingImportHandlingStrategy.class, + overrides); + } + + /** + * Sets the strategy that is used for missing imports handling. See + * {@link MissingImportHandlingStrategy} for the strategies and their descriptions. + * + * @param strategy The strategy to be used. + * @return An {@code OWLOntologyLoaderConfiguration} object with the strategy set. + * @since 3.3 + */ + public OntologyConfigurator setMissingImportHandlingStrategy( + MissingImportHandlingStrategy strategy) { + overrides.put(MISSING_IMPORT_HANDLING_STRATEGY, strategy); + return this; + } + + /** + * @return missing ontology header strategy + */ + public MissingOntologyHeaderStrategy getMissingOntologyHeaderStrategy() { + return MISSING_ONTOLOGY_HEADER_STRATEGY.getValue(MissingOntologyHeaderStrategy.class, + overrides); + } + + /** + * @param strategy new value + * @return a copy of this configuration object with a different strategy + */ + public OntologyConfigurator setMissingOntologyHeaderStrategy( + MissingOntologyHeaderStrategy strategy) { + overrides.put(MISSING_ONTOLOGY_HEADER_STRATEGY, strategy); + return this; + } + + /** + * Set the value for the report stack traces flag. If true, parsing exceptions will have the + * full stack trace for the source exceptions. Default is false. + * + * @param b the new value for the flag + * @return A {@code OWLOntologyLoaderConfiguration} with the report flag set to the new value. + */ + public OntologyConfigurator setReportStackTraces(boolean b) { + overrides.put(REPORT_STACK_TRACES, Boolean.valueOf(b)); + return this; + } + + /** + * @return report stack traces + */ + public boolean shouldReportStackTraces() { + return REPORT_STACK_TRACES.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @return value of retries to attempt + */ + public int getRetriesToAttempt() { + return RETRIES_TO_ATTEMPT.getValue(Integer.class, overrides).intValue(); + } + + /** + * @param retries new value of retries to attempt + * @return copy of this configuration with modified retries attempts. + */ + public OntologyConfigurator setRetriesToAttempt(int retries) { + overrides.put(RETRIES_TO_ATTEMPT, Integer.valueOf(retries)); + return this; + } + + /** + * @param strict new value for strict + * @return copy of the configuration with new strict value + */ + public OntologyConfigurator setStrict(boolean strict) { + overrides.put(PARSE_WITH_STRICT_CONFIGURATION, Boolean.valueOf(strict)); + return this; + } + + /** + * @return true if parsing should be strict + */ + public boolean shouldParseWithStrictConfiguration() { + return PARSE_WITH_STRICT_CONFIGURATION.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @param value true if Dublin Core vocabulary should be treated as built in. + * @return a copy of the current object with treat dublin core as builtIn set to the new value. + */ + public OntologyConfigurator setTreatDublinCoreAsBuiltIn(boolean value) { + overrides.put(TREAT_DUBLINCORE_AS_BUILTIN, Boolean.valueOf(value)); + return this; + } + + /** + * @return true if Dublin Core vocabulary should be treated as built in. + */ + public boolean shouldTreatDublinCoreAsBuiltin() { + return TREAT_DUBLINCORE_AS_BUILTIN.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @return true if illegal punnings should be repaired + */ + public boolean shouldRepairIllegalPunnings() { + return REPAIR_ILLEGAL_PUNNINGS.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @param b if illegal punnings should be repaired + * @return A {@code OWLOntologyLoaderConfiguration} with the repair flag set to the new value. + */ + public OntologyConfigurator withRepairIllegalPunnings(boolean b) { + overrides.put(REPAIR_ILLEGAL_PUNNINGS, Boolean.valueOf(b)); + return this; + } + + /** + * @return a new OWLOntologyLoaderConfiguration from the builder current settings + */ + public OWLOntologyLoaderConfiguration buildLoaderConfiguration() { + return new OWLOntologyLoaderConfiguration() + .setAcceptingHTTPCompression(shouldAcceptHTTPCompression()) + .setConnectionTimeout(getConnectionTimeout()) + .setFollowRedirects(shouldFollowRedirects()) + .setLoadAnnotationAxioms(shouldLoadAnnotations()) + .setMissingImportHandlingStrategy(getMissingImportHandlingStrategy()) + .setMissingOntologyHeaderStrategy(getMissingOntologyHeaderStrategy()) + .setPriorityCollectionSorting(getPriorityCollectionSorting()) + .setReportStackTraces(shouldReportStackTraces()) + .setRetriesToAttempt(getRetriesToAttempt()) + .setStrict(shouldParseWithStrictConfiguration()) + .setTreatDublinCoreAsBuiltIn(shouldTreatDublinCoreAsBuiltin()) + .setBannedParsers(getBannedParsers()) + .setRepairIllegalPunnings(shouldRepairIllegalPunnings()); + } + + /** + * @param b True if ids for blank nodes should always be written (axioms and anonymous + * individuals only). + * @return new config object + */ + public OntologyConfigurator withSaveIdsForAllAnonymousIndividuals(boolean b) { + overrides.put(SAVE_IDS, Boolean.valueOf(b)); + return this; + } + + /** + * @return should save ids + */ + public boolean shouldSaveIds() { + return SAVE_IDS.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @param b True if all anonymous individuals should have their ids remapped after parsing. + * @return new config object + */ + public OntologyConfigurator withRemapAllAnonymousIndividualsIds(boolean b) { + overrides.put(REMAP_IDS, Boolean.valueOf(b)); + return this; + } + + /** + * @return should remap ids + */ + public boolean shouldRemapIds() { + return REMAP_IDS.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @param useEntities True if entities should be used for namespace abbreviations. + * @return new config object + */ + public OntologyConfigurator withUseNamespaceEntities(boolean useEntities) { + overrides.put(USE_NAMESPACE_ENTITIES, Boolean.valueOf(useEntities)); + return this; + } + + /** + * @return should use namespace entities + */ + public boolean shouldUseNamespaceEntities() { + return USE_NAMESPACE_ENTITIES.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @param indent True if indenting should be used when writing out a file. + * @return new config object + */ + public OntologyConfigurator withIndenting(boolean indent) { + overrides.put(INDENTING, Boolean.valueOf(indent)); + return this; + } + + /** + * @return should indent + */ + public boolean shouldIndent() { + return INDENTING.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @param indent Size of indentation between levels. Only used if indenting is set to true. + * @return new config object + */ + public OntologyConfigurator withIndentSize(int indent) { + overrides.put(INDENT_SIZE, Integer.valueOf(indent)); + return this; + } + + /** + * @return indent size + */ + public int getIndentSize() { + return INDENT_SIZE.getValue(Integer.class, overrides).intValue(); + } + + /** + * @param label True if {@code rdfs:labels} should be used for banner comments. + * @return new config object + */ + public OntologyConfigurator withLabelsAsBanner(boolean label) { + overrides.put(LABELS_AS_BANNER, Boolean.valueOf(label)); + return this; + } + + /** + * @return should use labels as banner + */ + public boolean shouldUseLabelsAsBanner() { + return LABELS_AS_BANNER.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @param label True if banner comments should be enabled. + * @return new config object + */ + public OntologyConfigurator withBannersEnabled(boolean label) { + overrides.put(BANNERS_ENABLED, Boolean.valueOf(label)); + return this; + } + + /** + * @return should output banners + */ + public boolean shouldUseBanners() { + return BANNERS_ENABLED.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @param label True if named graph IRIs comments should be enabled. + * @return new config object + */ + public OntologyConfigurator withNamedGraphIRIEnabled(boolean label) { + overrides.put(OUTPUT_NAMED_GRAPH_IRI, Boolean.valueOf(label)); + return this; + } + + /** + * @return should output named graph IRIs + */ + public boolean shouldOutputNamedGraphIRI() { + return OUTPUT_NAMED_GRAPH_IRI.getValue(Boolean.class, overrides).booleanValue(); + } + + /** + * @return a new OWLOntologyWriterConfiguration from the builder current settings + */ + public OWLOntologyWriterConfiguration buildWriterConfiguration() { + return new OWLOntologyWriterConfiguration().withIndenting(shouldIndent()) + .withIndentSize(getIndentSize()).withLabelsAsBanner(shouldUseLabelsAsBanner()) + .withRemapAllAnonymousIndividualsIds(shouldRemapIds()) + .withSaveIdsForAllAnonymousIndividuals(shouldSaveIds()) + .withUseNamespaceEntities(shouldUseNamespaceEntities()) + .withBannersEnabled(shouldUseBanners()) + .withNamedGraphIRIEnabled(shouldOutputNamedGraphIRI()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/PrefixManager.java b/api/src/main/java/org/semanticweb/owlapi/model/PrefixManager.java new file mode 100644 index 0000000000..b88d823f25 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/PrefixManager.java @@ -0,0 +1,171 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.io.Serializable; +import java.util.Map; +import java.util.Set; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.util.StringComparator; + +/** + * A prefix manager than can provide prefixes for prefix names. + * + * @author Matthew Horridge, The University Of Manchester, Information Management Group + * @since 2.2.0 + */ +public interface PrefixManager extends Serializable { + + /** + * @return the prefix comparator currently used by the prefix manager + */ + StringComparator getPrefixComparator(); + + /** + * @param comparator the comparator to use + */ + void setPrefixComparator(StringComparator comparator); + + /** + * Gets the default prefix. The default prefix is denoted by the prefix name ":" + * + * @return The default prefix, or {@code null} if there is no default prefix. + */ + @Nullable + String getDefaultPrefix(); + + /** + * Sets the default namespace. This will also bind the prefix name ":" to this prefix + * + * @param defaultPrefix The namespace to be used as the default namespace. Note that the value + * may be {@code null} in order to clear the default namespace. + */ + void setDefaultPrefix(@Nullable String defaultPrefix); + + /** + * Determines if this manager knows about a given prefix name and it contains a (non-null) + * mapping for the prefix. + * + * @param prefixName The prefix name to be tested for. + * @return {@code true} if the manager knows about this prefix and there is a non-null mapping + * for this prefix. + */ + boolean containsPrefixMapping(String prefixName); + + /** + * Gets the prefix that is bound to a particular prefix name. Note that specifying ":" + * corresponds to requesting the default prefix and will return the same result as a call to the + * {@code getDefaultPrefix()} method. + * + * @param prefixName The prefix name. A string that represents a prefix name of the prefix to be + * retrieved. Note that specifying ":" is the same as asking for the default prefix (see + * the getDefaultPrefix() method). + * @return The prefix, or {@code null} if there is no prefix name bound to this prefix, or the + * prefix name doesn't exist. + */ + @Nullable + String getPrefix(String prefixName); + + /** + * Gets a map that maps prefix names to prefixes. + * + * @return The map of prefix names to prefixes. Note that modifying the contents of this map + * will not change the prefix name - prefix mappings + */ + Map getPrefixName2PrefixMap(); + + /** + * Gets the URI for a given prefix IRI. The prefix IRI must have a prefix name that is + * registered with this manager, or a runtime exception will be thrown. + * + * @param prefixIRI The Prefix IRI + * @return The full IRI. + * @throws OWLRuntimeException if the prefix name of the prefix IRI doesn't have a corresponding + * prefix managed by this manager. + */ + IRI getIRI(String prefixIRI); + + /** + * Gets the prefix IRI given a IRI (URI). + * + * @param iri The IRI whose prefix it to be retrieved + * @return The prefix IRI for this IRI, or {@code null} if a prefix IRI cannot be generated. + */ + @Nullable + String getPrefixIRI(IRI iri); + + /** + * Gets the prefix IRI given a IRI (URI). Does not restrict the response to be a QName + * + * @param iri The IRI whose prefix it to be retrieved + * @return The prefix IRI for this IRI, or {@code null} if a prefix IRI cannot be generated. + */ + @Nullable + String getPrefixIRIIgnoreQName(IRI iri); + + /** + * Gets the prefix names that have a mapping in this prefix manager. + * + * @return The prefix names as a set of strings. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + */ + default Set getPrefixNames() { + return asSet(prefixNames()); + } + + /** + * Gets the prefix names that have a mapping in this prefix manager. + * + * @return The prefix names as a set of strings. + */ + Stream prefixNames(); + + /** + * Adds a prefix name to prefix mapping. + * + * @param prefixName name The prefix name (must end with a colon) + * @param prefix The prefix. + */ + void setPrefix(String prefixName, String prefix); + + /** + * Copies the prefix from another prefix manager into this one. + * + * @param from The manager that the prefixes should be copied from + */ + void copyPrefixesFrom(PrefixManager from); + + /** + * Copies the prefix from another prefix manager into this one. + * + * @param from The map containing the prefixes + */ + void copyPrefixesFrom(Map from); + + /** + * Removes a previously registered prefix namespace mapping. + * + * @param namespace The namespace to be removed. + */ + void unregisterNamespace(String namespace); + + /** + * Clear the map. + */ + void clear(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/PrimitiveType.java b/api/src/main/java/org/semanticweb/owlapi/model/PrimitiveType.java new file mode 100644 index 0000000000..d3a1743826 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/PrimitiveType.java @@ -0,0 +1,64 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5.0 + */ +public enum PrimitiveType implements Serializable, HasShortForm { + //@formatter:off + /** CLASS. */ CLASS (EntityType.CLASS), + /** OBJECT_PROPERTY. */ OBJECT_PROPERTY (EntityType.OBJECT_PROPERTY), + /** DATA_PROPERTY. */ DATA_PROPERTY (EntityType.DATA_PROPERTY), + /** ANNOTATION_PROPERTY. */ ANNOTATION_PROPERTY (EntityType.ANNOTATION_PROPERTY), + /** DATATYPE. */ DATATYPE (EntityType.DATATYPE), + /** NAMED_INDIVIDUAL. */ NAMED_INDIVIDUAL (EntityType.NAMED_INDIVIDUAL), + /** LITERAL. */ LITERAL ("Literal", "Literal", "Literals"), + /** IRI. */ IRI ("IRI", "IRI", "IRIs"); + //@formatter:on + private final String shortForm; + private final String printName; + private final String pluralPrintName; + + PrimitiveType(EntityType entityType) { + this(entityType.getShortForm(), entityType.getPrintName(), entityType.getPluralPrintName()); + } + + PrimitiveType(String shortForm, String printName, String pluralPrintName) { + this.shortForm = shortForm; + this.printName = printName; + this.pluralPrintName = pluralPrintName; + } + + @Override + public String getShortForm() { + return shortForm; + } + + /** + * @return print name for user consumption + */ + public String getPrintName() { + return printName; + } + + /** + * @return plural of the print name + */ + public String getPluralPrintName() { + return pluralPrintName; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/PriorityCollectionSorting.java b/api/src/main/java/org/semanticweb/owlapi/model/PriorityCollectionSorting.java new file mode 100644 index 0000000000..3e86e1b5dd --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/PriorityCollectionSorting.java @@ -0,0 +1,95 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.Collections; +import java.util.List; + +import org.semanticweb.owlapi.util.HasPriorityComparator; + +/** + * Specifies how PriorityCollection should sort its entries. + * + * @author Ignazio + * @since 4.0.2 + */ +public enum PriorityCollectionSorting implements ByName { + /** + * Always keep the collection sorted by HasPriority annotation values. + */ + ALWAYS { + @Override + public List sort(List list) { + Collections.sort(list, new HasPriorityComparator<>()); + return list; + } + + @Override + public List sortInputSet(List list) { + return sort(list); + } + }, + /** + * Only sort according to HasPriority annotation when a Set is passed in, do not sort otherwise. + * This allows for fine tuning of the order in which entries appear, but does not lose the + * default prioritisation. This is important for parsers. When this sorting is used, addition of + * new elements causes the elements to be added at the front of the collection (First In, First + * Out) + */ + ON_SET_INJECTION_ONLY { + @Override + public List sort(List list) { + return list; + } + + @Override + public List sortInputSet(List list) { + Collections.sort(list, new HasPriorityComparator<>()); + return list; + } + }, + /** + * Sorting of entries is disabled. When this sorting is used, addition of new elements causes + * the elements to be added at the front of the collection (First In, First Out) + */ + NEVER { + @Override + public List sort(List list) { + return list; + } + + @Override + public List sortInputSet(List list) { + return list; + } + }; + + /** + * @param list list to sort + * @param type of elements + * @return sorted list + */ + public abstract List sort(List list); + + /** + * @param list list to sort + * @param type of elements + * @return sorted list + */ + public abstract List sortInputSet(List list); + + @Override + public PriorityCollectionSorting byName(CharSequence name) { + return valueOf(name.toString()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/RemoveAxiom.java b/api/src/main/java/org/semanticweb/owlapi/model/RemoveAxiom.java new file mode 100644 index 0000000000..117c3eaf18 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/RemoveAxiom.java @@ -0,0 +1,77 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import javax.annotation.Nullable; +import org.semanticweb.owlapi.change.RemoveAxiomData; + +/** + * Represents an ontology change were an axiom will be removed from an ontology + * if the change is applied to an ontology. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class RemoveAxiom extends OWLAxiomChange { + + /** + * @param ont the ontology to which the change is to be applied + * @param axiom the axiom to be removed + */ + public RemoveAxiom(OWLOntology ont, OWLAxiom axiom) { + super(ont, axiom); + } + + @Override + public RemoveAxiomData getChangeData() { + return new RemoveAxiomData(getAxiom()); + } + + @Override + public int hashCode() { + return 37 + getOntology().hashCode() * 13 + getAxiom().hashCode() * 13; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof RemoveAxiom)) { + return false; + } + RemoveAxiom other = (RemoveAxiom) obj; + return other.getOntology().equals(getOntology()) && other.getAxiom().equals(getAxiom()); + } + + @Override + public void accept(OWLOntologyChangeVisitor visitor) { + visitor.visit(this); + } + + @Override + public O accept(OWLOntologyChangeVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return String + .format("RemoveAxiom(%s OntologyID(%s))", getAxiom(), getOntology().getOntologyID()); + } + + @Override + public OWLOntologyChange reverseChange() { + return new AddAxiom(getOntology(), getAxiom()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/RemoveImport.java b/api/src/main/java/org/semanticweb/owlapi/model/RemoveImport.java new file mode 100644 index 0000000000..8a848beca9 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/RemoveImport.java @@ -0,0 +1,73 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import javax.annotation.Nullable; +import org.semanticweb.owlapi.change.RemoveImportData; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class RemoveImport extends ImportChange { + + /** + * @param ont the ontology to which the change is to be applied + * @param importDeclaration the import declaration + */ + public RemoveImport(OWLOntology ont, OWLImportsDeclaration importDeclaration) { + super(ont, importDeclaration); + } + + @Override + public RemoveImportData getChangeData() { + return new RemoveImportData(getImportDeclaration()); + } + + @Override + public int hashCode() { + return getOntology().hashCode() * 37 + getImportDeclaration().hashCode() + 3; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof RemoveImport)) { + return false; + } + RemoveImport other = (RemoveImport) obj; + return getImportDeclaration().equals(other.getImportDeclaration()); + } + + @Override + public String toString() { + return String.format("RemoveImport(%s)", getImportDeclaration()); + } + + @Override + public void accept(OWLOntologyChangeVisitor visitor) { + visitor.visit(this); + } + + @Override + public O accept(OWLOntologyChangeVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public OWLOntologyChange reverseChange() { + return new AddImport(getOntology(), getImportDeclaration()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/RemoveOntologyAnnotation.java b/api/src/main/java/org/semanticweb/owlapi/model/RemoveOntologyAnnotation.java new file mode 100644 index 0000000000..87a535a1fb --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/RemoveOntologyAnnotation.java @@ -0,0 +1,79 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import javax.annotation.Nullable; +import org.semanticweb.owlapi.change.OWLOntologyChangeData; +import org.semanticweb.owlapi.change.RemoveOntologyAnnotationData; + +/** + * Represents an ontology change where an annotation is removed from an + * ontology. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class RemoveOntologyAnnotation extends AnnotationChange { + + /** + * @param ont the ontology to which the change is to be applied + * @param annotation the annotation + */ + public RemoveOntologyAnnotation(OWLOntology ont, OWLAnnotation annotation) { + super(ont, annotation); + } + + @Override + public OWLOntologyChangeData getChangeData() { + return new RemoveOntologyAnnotationData(getAnnotation()); + } + + @Override + public void accept(OWLOntologyChangeVisitor visitor) { + visitor.visit(this); + } + + @Override + public O accept(OWLOntologyChangeVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public int hashCode() { + return 23 + getOntology().hashCode() + getAnnotation().hashCode(); + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof RemoveOntologyAnnotation)) { + return false; + } + RemoveOntologyAnnotation other = (RemoveOntologyAnnotation) obj; + return getAnnotation().equals(other.getAnnotation()) && getOntology() + .equals(other.getOntology()); + } + + @Override + public String toString() { + return String.format("RemoveOntologyAnnotation(%s OntologyID(%s))", getAnnotation(), + getOntology().getOntologyID()); + } + + @Override + public OWLOntologyChange reverseChange() { + return new AddOntologyAnnotation(getOntology(), getAnnotation()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLArgument.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLArgument.java new file mode 100644 index 0000000000..d9ea47cc64 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLArgument.java @@ -0,0 +1,24 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents an object in an atom (either a data object or and individual + * object). + * + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public interface SWRLArgument extends SWRLObject { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLAtom.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLAtom.java new file mode 100644 index 0000000000..ae49e2abb5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLAtom.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.Collection; +import java.util.stream.Stream; + +/** + * Represents an atom in a rule. Atoms can either be in the head (consequent) or body (antecedent) + * of the rule. Atoms hold objects which are either data objects or individual objects. + * + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public interface SWRLAtom extends SWRLObject { + + /** + * Gets the predicate of this atom. + * + * @return The atom predicate + */ + SWRLPredicate getPredicate(); + + /** + * Gets all of the arguments in this atom. + * + * @return The collection of arguments in this atom The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + */ + default Collection getAllArguments() { + return asList(allArguments()); + } + + /** + * @return The stream of all arguments in this atom + */ + public Stream allArguments(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLBinaryAtom.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLBinaryAtom.java new file mode 100644 index 0000000000..9d693e177d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLBinaryAtom.java @@ -0,0 +1,53 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * Represents an atom with two ordered arguments. + * + * @param type of first argument + * @param type of second argument + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public interface SWRLBinaryAtom extends SWRLAtom { + + @Override + default Stream components() { + return Stream.of(getFirstArgument(), getSecondArgument(), getPredicate()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getFirstArgument().hashCode()); + hash = OWLObject.hashIteration(hash, getSecondArgument().hashCode()); + return OWLObject.hashIteration(hash, getPredicate().hashCode()); + } + + /** + * Gets the first argument. + * + * @return The second argument + */ + A getFirstArgument(); + + /** + * Gets the second argument. + * + * @return The second argument + */ + B getSecondArgument(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLBuiltInAtom.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLBuiltInAtom.java new file mode 100644 index 0000000000..224978b435 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLBuiltInAtom.java @@ -0,0 +1,89 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.List; +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public interface SWRLBuiltInAtom extends SWRLAtom { + + @Override + default Stream components() { + return Stream.of(getArguments(), getPredicate()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getArguments().hashCode()); + return OWLObject.hashIteration(hash, getPredicate().hashCode()); + } + + @Override + default int hashIndex() { + return 659; + } + + @Override + default int typeIndex() { + return 6005; + } + + @Override + IRI getPredicate(); + + /** + * @return list of arguments + */ + default List getArguments() { + return asList(arguments()); + } + + /** + * @return list of arguments + */ + Stream arguments(); + + /** + * Determines if the predicate of this atom is is a core builtin. + * + * @return {@code true} if this is a core builtin, otherwise {@code false} + */ + boolean isCoreBuiltIn(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(SWRLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(SWRLObjectVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLClassAtom.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLClassAtom.java new file mode 100644 index 0000000000..ba6b4d592f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLClassAtom.java @@ -0,0 +1,67 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public interface SWRLClassAtom extends SWRLUnaryAtom { + + @Override + default Stream components() { + return Stream.of(getArgument(), getPredicate()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getArgument().hashCode()); + return OWLObject.hashIteration(hash, getPredicate().hashCode()); + } + + @Override + default int hashIndex() { + return 641; + } + + @Override + default int typeIndex() { + return 6001; + } + + @Override + OWLClassExpression getPredicate(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(SWRLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(SWRLObjectVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLDArgument.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLDArgument.java new file mode 100644 index 0000000000..fd9723166c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLDArgument.java @@ -0,0 +1,25 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents arguments in {@link org.semanticweb.owlapi.model.SWRLAtom}s that + * are either {@link OWLLiteral}s or variables for individuals + * {@link SWRLLiteralArgument}. + * + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public interface SWRLDArgument extends SWRLArgument { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLDataPropertyAtom.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLDataPropertyAtom.java new file mode 100644 index 0000000000..a679b95ea5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLDataPropertyAtom.java @@ -0,0 +1,53 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public interface SWRLDataPropertyAtom extends SWRLBinaryAtom { + + @Override + default int hashIndex() { + return 653; + } + + @Override + default int typeIndex() { + return 6004; + } + + @Override + OWLDataPropertyExpression getPredicate(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(SWRLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(SWRLObjectVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLDataRangeAtom.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLDataRangeAtom.java new file mode 100644 index 0000000000..bdb0d73411 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLDataRangeAtom.java @@ -0,0 +1,67 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public interface SWRLDataRangeAtom extends SWRLUnaryAtom { + + @Override + default Stream components() { + return Stream.of(getArgument(), getPredicate()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + hash = OWLObject.hashIteration(hash, getArgument().hashCode()); + return OWLObject.hashIteration(hash, getPredicate().hashCode()); + } + + @Override + default int hashIndex() { + return 643; + } + + @Override + default int typeIndex() { + return 6002; + } + + @Override + OWLDataRange getPredicate(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(SWRLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(SWRLObjectVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLDifferentIndividualsAtom.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLDifferentIndividualsAtom.java new file mode 100644 index 0000000000..8616386570 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLDifferentIndividualsAtom.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface SWRLDifferentIndividualsAtom extends SWRLBinaryAtom { + + @Override + default int hashIndex() { + return 797; + } + + @Override + default int typeIndex() { + return 6010; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(SWRLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(SWRLObjectVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLIArgument.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLIArgument.java new file mode 100644 index 0000000000..bbfe35d812 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLIArgument.java @@ -0,0 +1,25 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * Represents arguments in {@link org.semanticweb.owlapi.model.SWRLAtom}s that + * are either {@link org.semanticweb.owlapi.model.OWLIndividual}s or variables + * for individuals {@link SWRLIndividualArgument}. + * + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public interface SWRLIArgument extends SWRLArgument { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLIndividualArgument.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLIndividualArgument.java new file mode 100644 index 0000000000..bc3c1c9a62 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLIndividualArgument.java @@ -0,0 +1,67 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public interface SWRLIndividualArgument extends SWRLIArgument { + + @Override + default Stream components() { + return Stream.of(getIndividual()); + } + + @Override + default int initHashCode() { + return OWLObject.hashIteration(hashIndex(), getIndividual().hashCode()); + } + + @Override + default int hashIndex() { + return 677; + } + + @Override + default int typeIndex() { + return 6007; + } + + /** + * @return the wrapped individual + */ + OWLIndividual getIndividual(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(SWRLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(SWRLObjectVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLLiteralArgument.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLLiteralArgument.java new file mode 100644 index 0000000000..56006c81f3 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLLiteralArgument.java @@ -0,0 +1,69 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.util.stream.Stream; + +/** + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public interface SWRLLiteralArgument extends SWRLDArgument { + + @Override + default Stream components() { + return Stream.of(getLiteral()); + } + + @Override + default int initHashCode() { + return OWLObject.hashIteration(hashIndex(), getLiteral().hashCode()); + } + + @Override + default int hashIndex() { + return 683; + } + + @Override + default int typeIndex() { + return 6008; + } + + /** + * Gets the literal for this argument. + * + * @return The literal + */ + OWLLiteral getLiteral(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(SWRLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(SWRLObjectVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLObject.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLObject.java new file mode 100644 index 0000000000..48ade13587 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLObject.java @@ -0,0 +1,32 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public interface SWRLObject extends OWLObject { + + /** + * @param visitor visitor to accept + */ + void accept(SWRLObjectVisitor visitor); + + /** + * @param visitor visitor to accept + * @param visitor return type + * @return visitor value + */ + O accept(SWRLObjectVisitorEx visitor); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLObjectPropertyAtom.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLObjectPropertyAtom.java new file mode 100644 index 0000000000..63a9bff7b5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLObjectPropertyAtom.java @@ -0,0 +1,63 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public interface SWRLObjectPropertyAtom extends SWRLBinaryAtom { + + @Override + default int hashIndex() { + return 647; + } + + @Override + default int typeIndex() { + return 6003; + } + + @Override + OWLObjectPropertyExpression getPredicate(); + + /** + * Gets a simplified form of this atom. This basically creates and returns a + * new atom where the predicate is not an inverse object property. If the + * atom is of the form P(x, y) then P(x, y) is returned. If the atom is of + * the form inverseOf(P)(x, y) then P(y, x) is returned. + * + * @return This atom in a simplified form + */ + SWRLObjectPropertyAtom getSimplified(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(SWRLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(SWRLObjectVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLObjectVisitor.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLObjectVisitor.java new file mode 100644 index 0000000000..c51e920ae8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLObjectVisitor.java @@ -0,0 +1,110 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public interface SWRLObjectVisitor extends SWRLRuleVisitorBase { + + /** + * visit SWRLClassAtom type + * + * @param node node to visit + */ + default void visit(SWRLClassAtom node) { + doDefault(node); + } + + /** + * visit SWRLDataRangeAtom type + * + * @param node node to visit + */ + default void visit(SWRLDataRangeAtom node) { + doDefault(node); + } + + /** + * visit SWRLObjectPropertyAtom type + * + * @param node node to visit + */ + default void visit(SWRLObjectPropertyAtom node) { + doDefault(node); + } + + /** + * visit SWRLDataPropertyAtom type + * + * @param node node to visit + */ + default void visit(SWRLDataPropertyAtom node) { + doDefault(node); + } + + /** + * visit SWRLBuiltInAtom type + * + * @param node node to visit + */ + default void visit(SWRLBuiltInAtom node) { + doDefault(node); + } + + /** + * visit SWRLVariable type + * + * @param node node to visit + */ + default void visit(SWRLVariable node) { + doDefault(node); + } + + /** + * visit SWRLIndividualArgument type + * + * @param node node to visit + */ + default void visit(SWRLIndividualArgument node) { + doDefault(node); + } + + /** + * visit SWRLLiteralArgument type + * + * @param node node to visit + */ + default void visit(SWRLLiteralArgument node) { + doDefault(node); + } + + /** + * visit SWRLSameIndividualAtom type + * + * @param node node to visit + */ + default void visit(SWRLSameIndividualAtom node) { + doDefault(node); + } + + /** + * visit SWRLDifferentIndividualsAtom type + * + * @param node node to visit + */ + default void visit(SWRLDifferentIndividualsAtom node) { + doDefault(node); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLObjectVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLObjectVisitorEx.java new file mode 100644 index 0000000000..8e546ac893 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLObjectVisitorEx.java @@ -0,0 +1,121 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param visitor type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public interface SWRLObjectVisitorEx extends OWLVisitorExBase, SWRLRuleVisitorExBase { + + /** + * visit SWRLClassAtom type + * + * @param node node to visit + * @return visitor value + */ + default O visit(SWRLClassAtom node) { + return doDefault(node); + } + + /** + * visit SWRLDataRangeAtom type + * + * @param node node to visit + * @return visitor value + */ + default O visit(SWRLDataRangeAtom node) { + return doDefault(node); + } + + /** + * visit SWRLObjectPropertyAtom type + * + * @param node node to visit + * @return visitor value + */ + default O visit(SWRLObjectPropertyAtom node) { + return doDefault(node); + } + + /** + * visit SWRLDataPropertyAtom type + * + * @param node node to visit + * @return visitor value + */ + default O visit(SWRLDataPropertyAtom node) { + return doDefault(node); + } + + /** + * visit SWRLBuiltInAtom type + * + * @param node node to visit + * @return visitor value + */ + default O visit(SWRLBuiltInAtom node) { + return doDefault(node); + } + + /** + * visit SWRLVariable type + * + * @param node node to visit + * @return visitor value + */ + default O visit(SWRLVariable node) { + return doDefault(node); + } + + /** + * visit SWRLIndividualArgument type + * + * @param node node to visit + * @return visitor value + */ + default O visit(SWRLIndividualArgument node) { + return doDefault(node); + } + + /** + * visit SWRLLiteralArgument type + * + * @param node node to visit + * @return visitor value + */ + default O visit(SWRLLiteralArgument node) { + return doDefault(node); + } + + /** + * visit SWRLSameIndividualAtom type + * + * @param node node to visit + * @return visitor value + */ + default O visit(SWRLSameIndividualAtom node) { + return doDefault(node); + } + + /** + * visit SWRLDifferentIndividualsAtom type + * + * @param node node to visit + * @return visitor value + */ + default O visit(SWRLDifferentIndividualsAtom node) { + return doDefault(node); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLPredicate.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLPredicate.java new file mode 100644 index 0000000000..05f243aaa8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLPredicate.java @@ -0,0 +1,23 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface SWRLPredicate extends Serializable { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLRule.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLRule.java new file mode 100644 index 0000000000..68e05f41a0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLRule.java @@ -0,0 +1,193 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.List; +import java.util.Set; +import java.util.stream.Stream; + +/** + * Represent a rule. A rule consists of a head and a body. Both the head and the body consist of a + * conjunction of atoms. + * + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public interface SWRLRule extends OWLLogicalAxiom, SWRLObject { + + @Override + default Stream components() { + return Stream.of(bodyList(), headList(), annotationsAsList()); + } + + @Override + default int initHashCode() { + int hash = hashIndex(); + // head and body have an order that cannot be changed but it must not affect equals() and + // hashCode() + hash = OWLObject.hashIteration(hash, body().mapToInt(Object::hashCode).sum()); + hash = OWLObject.hashIteration(hash, head().mapToInt(Object::hashCode).sum()); + return OWLObject.hashIteration(hash, annotationsAsList().hashCode()); + } + + @Override + default Stream componentsWithoutAnnotations() { + return Stream.of(bodyList(), headList()); + } + + @Override + default Stream componentsAnnotationsFirst() { + return Stream.of(annotationsAsList(), bodyList(), headList()); + } + + @Override + default int hashIndex() { + return 631; + } + + /** + * Gets the atoms in the body of the rule. + * + * @return A set of {@code SWRLAtom}s, which represent the atoms in the body of the rule. The + * set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + */ + default Set getBody() { + return asSet(body()); + } + + /** @return body as list */ + default List bodyList() { + return asList(body()); + } + + /** @return head as list */ + default List headList() { + return asList(head()); + } + + /** + * @return stream of the atoms in the body of the rule. + */ + Stream body(); + + /** + * Gets the atoms in the head of the rule. + * + * @return A set of {@code SWRLAtom}s, which represent the atoms in the head of the rule. The + * set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + */ + default Set getHead() { + return asSet(head()); + } + + /** + * @return stream of the atoms in the head of the rule + */ + Stream head(); + + /** + * If this rule contains atoms that have predicates that are inverse object properties, then + * this method creates and returns a rule where the arguments of these atoms are flipped over + * and the predicate is the inverse (simplified) property. + * + * @return The rule such that any atoms of the form inverseOf(p)(x, y) are transformed to p(x, + * y). + */ + SWRLRule getSimplified(); + + /** + * Gets the variables that appear in this rule. + * + * @return A set of variables that appear in this rule. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + */ + default Set getVariables() { + return asSet(variables()); + } + + /** + * @return stream of variables that appear in this rule. + */ + Stream variables(); + + /** + * Determines if this rule uses anonymous class expressions in class atoms. + * + * @return {@code true} if this rule contains anonymous class expression in class atoms, + * otherwise {@code false}. + */ + boolean containsAnonymousClassExpressions(); + + /** + * Gets the predicates of class atoms. + * + * @return A set of class expressions that represent the class class expressions that are + * predicates of class atoms. The set that is returned is a copy; modifications to the + * returned set will not be reflected in this object. + */ + default Set getClassAtomPredicates() { + return asSet(classAtomPredicates()); + } + + /** + * Gets the predicates of class atoms. + * + * @return stream of class expressions that represent the class class expressions that are + * predicates of class atoms. + */ + Stream classAtomPredicates(); + + @Override + @SuppressWarnings("unchecked") + SWRLRule getAxiomWithoutAnnotations(); + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(SWRLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(SWRLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(OWLAxiomVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLAxiomVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default AxiomType getAxiomType() { + return AxiomType.SWRL_RULE; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLRuleVisitorBase.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLRuleVisitorBase.java new file mode 100644 index 0000000000..e2da606201 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLRuleVisitorBase.java @@ -0,0 +1,29 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public interface SWRLRuleVisitorBase extends OWLVisitorBase { + + /** + * visit SWRLRule type + * + * @param node node to visit + */ + default void visit(SWRLRule node) { + doDefault(node); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLRuleVisitorExBase.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLRuleVisitorExBase.java new file mode 100644 index 0000000000..ff775561ee --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLRuleVisitorExBase.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param visitor type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public interface SWRLRuleVisitorExBase extends OWLVisitorExBase { + + /** + * visit SWRLRule type + * + * @param node node to visit + * @return visitor value + */ + default O visit(SWRLRule node) { + return doDefault(node); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLSameIndividualAtom.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLSameIndividualAtom.java new file mode 100644 index 0000000000..b4a2fed1bc --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLSameIndividualAtom.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface SWRLSameIndividualAtom extends SWRLBinaryAtom { + + @Override + default int hashIndex() { + return 811; + } + + @Override + default int typeIndex() { + return 6009; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(SWRLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(SWRLObjectVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLUnaryAtom.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLUnaryAtom.java new file mode 100644 index 0000000000..e66a5bd5f6 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLUnaryAtom.java @@ -0,0 +1,26 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @param the type of argument + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public interface SWRLUnaryAtom extends SWRLAtom { + + /** + * @return the argument + */ + A getArgument(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SWRLVariable.java b/api/src/main/java/org/semanticweb/owlapi/model/SWRLVariable.java new file mode 100644 index 0000000000..dbd873e799 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SWRLVariable.java @@ -0,0 +1,66 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import java.io.Serializable; +import java.util.stream.Stream; + +/** + * Represents a variable that can appear in an atom. Variable can either be place holders for + * individuals or literals. Variables are named with IRIs. + * + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public interface SWRLVariable extends SWRLIArgument, SWRLDArgument, HasIRI, Serializable { + + @Override + default Stream components() { + return Stream.of(getIRI()); + } + + @Override + default int initHashCode() { + return OWLObject.hashIteration(hashIndex(), getIRI().hashCode()); + } + + @Override + default int hashIndex() { + return 661; + } + + @Override + default int typeIndex() { + return 6006; + } + + @Override + default void accept(OWLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(OWLObjectVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + default void accept(SWRLObjectVisitor visitor) { + visitor.visit(this); + } + + @Override + default O accept(SWRLObjectVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SetOntologyID.java b/api/src/main/java/org/semanticweb/owlapi/model/SetOntologyID.java new file mode 100644 index 0000000000..17fb379f1c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SetOntologyID.java @@ -0,0 +1,119 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import javax.annotation.Nullable; +import org.semanticweb.owlapi.change.SetOntologyIDData; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class SetOntologyID extends OWLOntologyChange { + + private static final String ONTOLOGY_ID_CANNOT_BE_NULL = "ontology id cannot be null"; + private final OWLOntologyID ontologyID; + private final OWLOntologyID newOntologyID; + + /** + * Creates a set ontology id change, which will set the ontology id to the + * new one. + * + * @param ont The ontology whose id is to be changed + * @param ontologyID The ontology ID + */ + public SetOntologyID(OWLOntology ont, OWLOntologyID ontologyID) { + super(ont); + this.ontologyID = checkNotNull(ont.getOntologyID(), ONTOLOGY_ID_CANNOT_BE_NULL); + newOntologyID = checkNotNull(ontologyID, ONTOLOGY_ID_CANNOT_BE_NULL); + } + + SetOntologyID(OWLOntology ont, OWLOntologyID ontologyID, OWLOntologyID newOntologyID) { + super(ont); + this.ontologyID = checkNotNull(ontologyID, ONTOLOGY_ID_CANNOT_BE_NULL); + this.newOntologyID = checkNotNull(newOntologyID, ONTOLOGY_ID_CANNOT_BE_NULL); + } + + /** + * Creates a set ontology id change using the ontologyIRI, which will set + * the ontology id to the new one. + * + * @param ont The ontology whose id is to be changed + * @param ontologyIRI The ontology iri + */ + public SetOntologyID(OWLOntology ont, IRI ontologyIRI) { + this(ont, new OWLOntologyID(optional(ontologyIRI), emptyOptional(IRI.class))); + } + + @Override + public SetOntologyIDData getChangeData() { + return new SetOntologyIDData(newOntologyID); + } + + /** + * Gets the original ID of the ontology whose URI was changed. + * + * @return The original ID + */ + public OWLOntologyID getOriginalOntologyID() { + return ontologyID; + } + + /** + * @return the new URI - i.e. the URI of the ontology after the change was applied. + */ + public OWLOntologyID getNewOntologyID() { + return newOntologyID; + } + + @Override + public void accept(OWLOntologyChangeVisitor visitor) { + visitor.visit(this); + } + + @Override + public O accept(OWLOntologyChangeVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return String.format("SetOntologyID(%s OntologyID(%s))", newOntologyID, ontologyID); + } + + @Override + public int hashCode() { + return 57 + ontologyID.hashCode() + newOntologyID.hashCode() * 3; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SetOntologyID)) { + return false; + } + SetOntologyID change = (SetOntologyID) obj; + return change.ontologyID.equals(ontologyID) && change.newOntologyID.equals(newOntologyID); + } + + @Override + public OWLOntologyChange reverseChange() { + return new SetOntologyID(getOntology(), newOntologyID, getOntology().getOntologyID()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/SpecificOntologyChangeBroadcastStrategy.java b/api/src/main/java/org/semanticweb/owlapi/model/SpecificOntologyChangeBroadcastStrategy.java new file mode 100644 index 0000000000..ca4bc1d5e8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/SpecificOntologyChangeBroadcastStrategy.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.List; + +/** + * A change broadcast strategy that broadcasts changes that have been applied to + * a specific ontology. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class SpecificOntologyChangeBroadcastStrategy implements OWLOntologyChangeBroadcastStrategy { + + private final OWLOntology ontology; + + /** + * Constructs a change broadcast strategy which only causes changes that + * have been applied to the specific ontology to be broadcast. + * + * @param ontology The ontology. + */ + public SpecificOntologyChangeBroadcastStrategy(OWLOntology ontology) { + this.ontology = checkNotNull(ontology, "ontology cannot be null"); + } + + @Override + public void broadcastChanges(OWLOntologyChangeListener listener, + List changes) { + checkNotNull(listener, "listener cannot be null"); + checkNotNull(changes, "changes cannot be null"); + List broadcastChanges = asList( + changes.stream().filter(c -> c.getOntology().equals( + ontology)), OWLOntologyChange.class); + listener.ontologiesChanged(broadcastChanges); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/UnknownOWLOntologyException.java b/api/src/main/java/org/semanticweb/owlapi/model/UnknownOWLOntologyException.java new file mode 100644 index 0000000000..7899ef4d4d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/UnknownOWLOntologyException.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class UnknownOWLOntologyException extends OWLRuntimeException { + + /** + * @param ontologyID the unknown ontology id + */ + public UnknownOWLOntologyException(OWLOntologyID ontologyID) { + super("Unknown ontology: " + ontologyID); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/UnloadableImportException.java b/api/src/main/java/org/semanticweb/owlapi/model/UnloadableImportException.java new file mode 100644 index 0000000000..07570ed734 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/UnloadableImportException.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class UnloadableImportException extends OWLRuntimeException { + + private final OWLImportsDeclaration importsDeclaration; + private final OWLOntologyCreationException ontologyCreationException; + + /** + * @param e exception + * @param importsDeclaration imports declaration + */ + public UnloadableImportException(OWLOntologyCreationException e, + OWLImportsDeclaration importsDeclaration) { + super("Could not load imported ontology: " + importsDeclaration.getIRI().toQuotedString() + + " Cause: " + + e.getMessage(), e); + this.importsDeclaration = importsDeclaration; + ontologyCreationException = e; + } + + /** + * @return imports declaration + */ + public OWLImportsDeclaration getImportsDeclaration() { + return importsDeclaration; + } + + /** + * @return creation exception + */ + public OWLOntologyCreationException getOntologyCreationException() { + return ontologyCreationException; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/DeclarationAxiomProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/DeclarationAxiomProvider.java new file mode 100644 index 0000000000..92aed9f332 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/DeclarationAxiomProvider.java @@ -0,0 +1,90 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.axiomproviders; + +import java.util.Collection; +import java.util.Collections; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * Declaration provider interface. + */ +public interface DeclarationAxiomProvider { + + /** + * Gets a declaration for an entity + * + * @param owlEntity The declared entity. + * @return The declaration axiom for the specified entity. + */ + default OWLDeclarationAxiom getOWLDeclarationAxiom(OWLEntity owlEntity) { + return getOWLDeclarationAxiom(owlEntity, Collections.emptySet()); + } + + /** + * Gets a declaration with zero or more annotations for an entity + * + * @param owlEntity The declared entity. + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return The declaration axiom for the specified entity which is annotated with the specified + * annotations + */ + OWLDeclarationAxiom getOWLDeclarationAxiom(OWLEntity owlEntity, + Collection annotations); + + /** + * @param datatype data type + * @param dataRange data Range + * @return a datatype definition axiom + */ + default OWLDatatypeDefinitionAxiom getOWLDatatypeDefinitionAxiom(OWLDatatype datatype, + OWLDataRange dataRange) { + return getOWLDatatypeDefinitionAxiom(datatype, dataRange, Collections.emptySet()); + } + + /** + * @param datatype data type + * @param dataRange data Range + * @param annotations A set of annotations. + * @return a datatype definition axiom with annotations + */ + OWLDatatypeDefinitionAxiom getOWLDatatypeDefinitionAxiom(OWLDatatype datatype, + OWLDataRange dataRange, + Collection annotations); + + /** + * @param datatype data type + * @param dataRange data Range + * @return a datatype definition axiom + */ + default OWLDatatypeDefinitionAxiom getOWLDatatypeDefinitionAxiom(OWLDatatype datatype, + OWL2Datatype dataRange) { + return getOWLDatatypeDefinitionAxiom(datatype, dataRange, Collections.emptySet()); + } + + /** + * @param datatype data type + * @param dataRange data Range + * @param annotations A set of annotations. + * @return a datatype definition axiom with annotations + */ + OWLDatatypeDefinitionAxiom getOWLDatatypeDefinitionAxiom(OWLDatatype datatype, + OWL2Datatype dataRange, + Collection annotations); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/DisjointAxiomProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/DisjointAxiomProvider.java new file mode 100644 index 0000000000..e11b9ad9fa --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/DisjointAxiomProvider.java @@ -0,0 +1,174 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.axiomproviders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkIterableNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; + +/** + * Disjoint classes and properties provider. + */ +public interface DisjointAxiomProvider { + + /** + * @param classExpressions Disjoint classes. Cannot be null or contain nulls. + * @return a disjoint class axiom with no annotations + */ + default OWLDisjointClassesAxiom getOWLDisjointClassesAxiom( + Collection classExpressions) { + return getOWLDisjointClassesAxiom(classExpressions, Collections.emptySet()); + } + + /** + * @param classExpressions Disjoint classes. Cannot be null or contain nulls. + * @return a disjoint class axiom with no annotations + */ + default OWLDisjointClassesAxiom getOWLDisjointClassesAxiom( + OWLClassExpression... classExpressions) { + checkIterableNotNull(classExpressions, "classExpressions cannot be null", true); + return getOWLDisjointClassesAxiom(Arrays.asList(classExpressions)); + } + + /** + * @param classExpressions Disjoint classes. Cannot be null or contain nulls. + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a disjoint class axiom with annotations + */ + OWLDisjointClassesAxiom getOWLDisjointClassesAxiom( + Collection classExpressions, + Collection annotations); + + /** + * @param classA Disjoint class. + * @param classB Disjoint class. + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a disjoint class axiom with annotations + */ + default OWLDisjointClassesAxiom getOWLDisjointClassesAxiom(OWLClassExpression classA, + OWLClassExpression classB, Collection annotations) { + return getOWLDisjointClassesAxiom(Arrays.asList(classA, classB), annotations); + } + + /** + * @param classExpressions Disjoint classes. Cannot be null or contain nulls. + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a disjoint class axiom with annotations + */ + default OWLDisjointClassesAxiom getOWLDisjointClassesAxiom( + Stream classExpressions, + Collection annotations) { + return getOWLDisjointClassesAxiom(asList(classExpressions), annotations); + } + + /** + * @param classExpressions Disjoint classes. Cannot be null or contain nulls. + * @return a disjoint class axiom with annotations + */ + default OWLDisjointClassesAxiom getOWLDisjointClassesAxiom( + Stream classExpressions) { + return getOWLDisjointClassesAxiom(asList(classExpressions), Collections.emptySet()); + } + + /** + * @param properties Cannot be null or contain nulls. + * @return a disjoint object properties axiom with specified properties + */ + default OWLDisjointObjectPropertiesAxiom getOWLDisjointObjectPropertiesAxiom( + Collection properties) { + return getOWLDisjointObjectPropertiesAxiom(properties, Collections.emptySet()); + } + + /** + * @param properties Cannot be null or contain nulls. + * @return a disjoint object properties axiom with specified properties + */ + default OWLDisjointObjectPropertiesAxiom getOWLDisjointObjectPropertiesAxiom( + OWLObjectPropertyExpression... properties) { + checkIterableNotNull(properties, "properties cannot be null", true); + return getOWLDisjointObjectPropertiesAxiom(Arrays.asList(properties)); + } + + /** + * @param properties Cannot be null or contain nulls. + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a disjoint object properties axiom with specified properties and annotations + */ + OWLDisjointObjectPropertiesAxiom getOWLDisjointObjectPropertiesAxiom( + Collection properties, + Collection annotations); + + /** + * @param p Disjoint property + * @param q Disjoint property + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a disjoint object properties axiom with specified properties and annotations + */ + default OWLDisjointObjectPropertiesAxiom getOWLDisjointObjectPropertiesAxiom( + OWLObjectPropertyExpression p, OWLObjectPropertyExpression q, + Collection annotations) { + return getOWLDisjointObjectPropertiesAxiom(Arrays.asList(p, q), annotations); + } + + /** + * @param dataProperties Cannot be null or contain nulls. + * @return a disjoint data properties axiom with specified properties + */ + default OWLDisjointDataPropertiesAxiom getOWLDisjointDataPropertiesAxiom( + OWLDataPropertyExpression... dataProperties) { + checkIterableNotNull(dataProperties, "properties cannot be null", true); + return getOWLDisjointDataPropertiesAxiom(Arrays.asList(dataProperties)); + } + + /** + * @param properties Cannot be null or contain nulls. + * @return a disjoint data properties axiom with specified properties + */ + default OWLDisjointDataPropertiesAxiom getOWLDisjointDataPropertiesAxiom( + Collection properties) { + return getOWLDisjointDataPropertiesAxiom(properties, Collections.emptySet()); + } + + /** + * @param properties Cannot be null or contain nulls. + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a disjoint data properties axiom with specified properties and annotations + */ + OWLDisjointDataPropertiesAxiom getOWLDisjointDataPropertiesAxiom( + Collection properties, + Collection annotations); + + /** + * @param p Disjoint property + * @param q Disjoint property + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a disjoint data properties axiom with specified properties and annotations + */ + default OWLDisjointDataPropertiesAxiom getOWLDisjointDataPropertiesAxiom( + OWLDataPropertyExpression p, OWLDataPropertyExpression q, + Collection annotations) { + return getOWLDisjointDataPropertiesAxiom(Arrays.asList(p, q), annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/DisjointUnionAxiomProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/DisjointUnionAxiomProvider.java new file mode 100644 index 0000000000..945c2ac7b6 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/DisjointUnionAxiomProvider.java @@ -0,0 +1,70 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.axiomproviders; + +import java.util.Collection; +import java.util.Collections; +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; + +/** + * Disjoint union provider. + */ +@FunctionalInterface +public interface DisjointUnionAxiomProvider { + + /** + * @param owlClass left hand side of the axiom. + * @param classExpressions right hand side of the axiom. Cannot be null or contain nulls. + * @return a disjoint union axiom + */ + default OWLDisjointUnionAxiom getOWLDisjointUnionAxiom(OWLClass owlClass, + Collection classExpressions) { + return getOWLDisjointUnionAxiom(owlClass, classExpressions, Collections.emptySet()); + } + + /** + * @param owlClass left hand side of the axiom. Cannot be null. + * @param classExpressions right hand side of the axiom. Cannot be null or contain nulls. + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a disjoint union axiom with annotations + */ + default OWLDisjointUnionAxiom getOWLDisjointUnionAxiom(OWLClass owlClass, + Collection classExpressions, + Collection annotations) { + return getOWLDisjointUnionAxiom(owlClass, classExpressions.stream(), annotations); + } + + /** + * @param owlClass left hand side of the axiom. + * @param classExpressions right hand side of the axiom. Cannot be null or contain nulls. + * @return a disjoint union axiom + */ + default OWLDisjointUnionAxiom getOWLDisjointUnionAxiom(OWLClass owlClass, + Stream classExpressions) { + return getOWLDisjointUnionAxiom(owlClass, classExpressions, Collections.emptySet()); + } + + /** + * @param owlClass left hand side of the axiom. Cannot be null. + * @param classExpressions right hand side of the axiom. Cannot be null or contain nulls. + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a disjoint union axiom with annotations + */ + OWLDisjointUnionAxiom getOWLDisjointUnionAxiom(OWLClass owlClass, + Stream classExpressions, + Collection annotations); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/DomainAxiomProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/DomainAxiomProvider.java new file mode 100644 index 0000000000..a06ba18c17 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/DomainAxiomProvider.java @@ -0,0 +1,93 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.axiomproviders; + +import java.util.Collection; +import java.util.Collections; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; + +/** + * Annotation, datatype and object property domain provider. + */ +public interface DomainAxiomProvider { + + /** + * @param property property + * @param classExpression class Expression + * @return an object property domain axiom + */ + default OWLObjectPropertyDomainAxiom getOWLObjectPropertyDomainAxiom( + OWLObjectPropertyExpression property, + OWLClassExpression classExpression) { + return getOWLObjectPropertyDomainAxiom(property, classExpression, Collections.emptySet()); + } + + /** + * @param property property + * @param classExpression class Expression + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return an object property domain axiom with annotations + */ + OWLObjectPropertyDomainAxiom getOWLObjectPropertyDomainAxiom( + OWLObjectPropertyExpression property, + OWLClassExpression classExpression, Collection annotations); + + /** + * @param property property + * @param domain domain + * @return a data property domain axiom + */ + default OWLDataPropertyDomainAxiom getOWLDataPropertyDomainAxiom( + OWLDataPropertyExpression property, + OWLClassExpression domain) { + return getOWLDataPropertyDomainAxiom(property, domain, Collections.emptySet()); + } + + /** + * @param property property + * @param domain domain + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a data property domain axiom with annotations + */ + OWLDataPropertyDomainAxiom getOWLDataPropertyDomainAxiom(OWLDataPropertyExpression property, + OWLClassExpression domain, Collection annotations); + + /** + * @param prop prop + * @param domain domain + * @return an annotation property domain assertion + */ + default OWLAnnotationPropertyDomainAxiom getOWLAnnotationPropertyDomainAxiom( + OWLAnnotationProperty prop, + IRI domain) { + return getOWLAnnotationPropertyDomainAxiom(prop, domain, Collections.emptySet()); + } + + /** + * @param prop prop + * @param domain domain + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return an annotation property domain assertion with annotations + */ + OWLAnnotationPropertyDomainAxiom getOWLAnnotationPropertyDomainAxiom(OWLAnnotationProperty prop, + IRI domain, + Collection annotations); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/EquivalentAxiomProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/EquivalentAxiomProvider.java new file mode 100644 index 0000000000..cd52d9abbd --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/EquivalentAxiomProvider.java @@ -0,0 +1,197 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.axiomproviders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkIterableNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; + +/** + * Equivalent classes and properties provider. + */ +public interface EquivalentAxiomProvider { + + /** + * @param classExpressions equivalent classes. Cannot be null or contain nulls. + * @return an equivalent classes axiom with specified operands and no annotations + */ + default OWLEquivalentClassesAxiom getOWLEquivalentClassesAxiom( + Collection classExpressions) { + return getOWLEquivalentClassesAxiom(classExpressions, Collections.emptySet()); + } + + /** + * @param classExpressions equivalent classes. Cannot be null or contain nulls. + * @return an equivalent classes axiom with specified operands and no annotations + */ + default OWLEquivalentClassesAxiom getOWLEquivalentClassesAxiom( + Stream classExpressions) { + return getOWLEquivalentClassesAxiom(asList(classExpressions), Collections.emptySet()); + } + + /** + * @param classExpressions equivalent classes. Cannot be null or contain nulls. + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return an equivalent classes axiom with specified operands and annotations + */ + OWLEquivalentClassesAxiom getOWLEquivalentClassesAxiom( + Collection classExpressions, + Collection annotations); + + /** + * @param classExpressions equivalent classes. Cannot be null or contain nulls. + * @return an equivalent classes axiom with specified operands and no annotations + */ + default OWLEquivalentClassesAxiom getOWLEquivalentClassesAxiom( + OWLClassExpression... classExpressions) { + checkIterableNotNull(classExpressions, "classExpressions cannot be null", true); + return getOWLEquivalentClassesAxiom(Arrays.asList(classExpressions)); + } + + /** + * @param clsA one class for equivalence + * @param clsB one class for equivalence + * @return an equivalent classes axiom with specified operands and no annotations (special case + * with only two operands) + */ + default OWLEquivalentClassesAxiom getOWLEquivalentClassesAxiom(OWLClassExpression clsA, + OWLClassExpression clsB) { + return getOWLEquivalentClassesAxiom(clsA, clsB, Collections.emptySet()); + } + + /** + * @param clsA one class for equivalence + * @param clsB one class for equivalence + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return an equivalent classes axiom with specified operands and annotations (special case + * with only two operands) + */ + default OWLEquivalentClassesAxiom getOWLEquivalentClassesAxiom(OWLClassExpression clsA, + OWLClassExpression clsB, Collection annotations) { + return getOWLEquivalentClassesAxiom(Arrays.asList(clsA, clsB), annotations); + } + + /** + * @param properties Cannot be null or contain nulls. + * @return an equivalent properties axiom with specified properties + */ + default OWLEquivalentObjectPropertiesAxiom getOWLEquivalentObjectPropertiesAxiom( + Collection properties) { + return getOWLEquivalentObjectPropertiesAxiom(properties, Collections.emptySet()); + } + + /** + * @param properties Cannot be null or contain nulls. + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return an equivalent properties axiom with specified properties and annotations + */ + OWLEquivalentObjectPropertiesAxiom getOWLEquivalentObjectPropertiesAxiom( + Collection properties, + Collection annotations); + + /** + * @param properties Cannot be null or contain nulls. + * @return an equivalent properties axiom with specified properties + */ + default OWLEquivalentObjectPropertiesAxiom getOWLEquivalentObjectPropertiesAxiom( + OWLObjectPropertyExpression... properties) { + checkIterableNotNull(properties, "properties cannot be null", true); + return getOWLEquivalentObjectPropertiesAxiom(Arrays.asList(properties)); + } + + /** + * @param propertyA property A + * @param propertyB property B + * @return an equivalent properties axiom with specified properties + */ + default OWLEquivalentObjectPropertiesAxiom getOWLEquivalentObjectPropertiesAxiom( + OWLObjectPropertyExpression propertyA, OWLObjectPropertyExpression propertyB) { + return getOWLEquivalentObjectPropertiesAxiom(propertyA, propertyB, Collections.emptySet()); + } + + /** + * @param propertyA property A + * @param propertyB property B + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return an equivalent properties axiom with specified properties and annotations + */ + default OWLEquivalentObjectPropertiesAxiom getOWLEquivalentObjectPropertiesAxiom( + OWLObjectPropertyExpression propertyA, OWLObjectPropertyExpression propertyB, + Collection annotations) { + return getOWLEquivalentObjectPropertiesAxiom(Arrays.asList(propertyA, propertyB), + annotations); + } + + /** + * @param properties Cannot be null or contain nulls. + * @return an equivalent data properties axiom + */ + default OWLEquivalentDataPropertiesAxiom getOWLEquivalentDataPropertiesAxiom( + Collection properties) { + return getOWLEquivalentDataPropertiesAxiom(properties, Collections.emptySet()); + } + + /** + * @param properties properties + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return an equivalent data properties axiom with annotations + */ + OWLEquivalentDataPropertiesAxiom getOWLEquivalentDataPropertiesAxiom( + Collection properties, + Collection annotations); + + /** + * @param properties Cannot be null or contain nulls. + * @return an equivalent data properties axiom + */ + default OWLEquivalentDataPropertiesAxiom getOWLEquivalentDataPropertiesAxiom( + OWLDataPropertyExpression... properties) { + checkIterableNotNull(properties, "properties cannot be null", true); + return getOWLEquivalentDataPropertiesAxiom(Arrays.asList(properties)); + } + + /** + * @param propertyA property A + * @param propertyB property B + * @return an equivalent data properties axiom + */ + default OWLEquivalentDataPropertiesAxiom getOWLEquivalentDataPropertiesAxiom( + OWLDataPropertyExpression propertyA, OWLDataPropertyExpression propertyB) { + return getOWLEquivalentDataPropertiesAxiom(propertyA, propertyB, Collections.emptySet()); + } + + /** + * @param propertyA property A + * @param propertyB property B + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return an equivalent data properties axiom with annotations + */ + default OWLEquivalentDataPropertiesAxiom getOWLEquivalentDataPropertiesAxiom( + OWLDataPropertyExpression propertyA, OWLDataPropertyExpression propertyB, + Collection annotations) { + return getOWLEquivalentDataPropertiesAxiom(Arrays.asList(propertyA, propertyB), + annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/HasKeyAxiomProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/HasKeyAxiomProvider.java new file mode 100644 index 0000000000..f0556cb19e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/HasKeyAxiomProvider.java @@ -0,0 +1,62 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.axiomproviders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkIterableNotNull; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; + +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLHasKeyAxiom; +import org.semanticweb.owlapi.model.OWLPropertyExpression; + +/** + * HasKey provider interface. + */ +@FunctionalInterface +public interface HasKeyAxiomProvider { + + /** + * @param ce class expression + * @param properties Cannot be null or contain nulls. + * @return a hasKey axiom on given arguments + */ + default OWLHasKeyAxiom getOWLHasKeyAxiom(OWLClassExpression ce, + Collection properties) { + return getOWLHasKeyAxiom(ce, properties, Collections.emptySet()); + } + + /** + * @param ce class expression + * @param properties Cannot be null or contain nulls. + * @return a hasKey axiom on given arguments + */ + default OWLHasKeyAxiom getOWLHasKeyAxiom(OWLClassExpression ce, + OWLPropertyExpression... properties) { + checkIterableNotNull(properties, "properties cannot be null", true); + return getOWLHasKeyAxiom(ce, Arrays.asList(properties)); + } + + /** + * @param ce class expression + * @param objectProperties Cannot be null or contain nulls. + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a hasKey axiom on given arguments and annotations + */ + OWLHasKeyAxiom getOWLHasKeyAxiom(OWLClassExpression ce, + Collection objectProperties, + Collection annotations); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/InverseAxiomProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/InverseAxiomProvider.java new file mode 100644 index 0000000000..f8c02c1769 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/InverseAxiomProvider.java @@ -0,0 +1,47 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.axiomproviders; + +import java.util.Collection; +import java.util.Collections; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; + +/** + * Inverse axiom provider interface. + */ +@FunctionalInterface +public interface InverseAxiomProvider { + + /** + * @param forwardProperty forward Property + * @param inverseProperty inverse Property + * @return an inverse object property axiom + */ + default OWLInverseObjectPropertiesAxiom getOWLInverseObjectPropertiesAxiom( + OWLObjectPropertyExpression forwardProperty, OWLObjectPropertyExpression inverseProperty) { + return getOWLInverseObjectPropertiesAxiom(forwardProperty, inverseProperty, + Collections.emptySet()); + } + + /** + * @param forwardProperty forward Property + * @param inverseProperty inverse Property + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return an inverse object property axiom with annotations + */ + OWLInverseObjectPropertiesAxiom getOWLInverseObjectPropertiesAxiom( + OWLObjectPropertyExpression forwardProperty, + OWLObjectPropertyExpression inverseProperty, Collection annotations); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/PropertyChainAxiomProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/PropertyChainAxiomProvider.java new file mode 100644 index 0000000000..0254bc34eb --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/PropertyChainAxiomProvider.java @@ -0,0 +1,48 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.axiomproviders; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; + +/** + * Annotation, datatype and object property range provider. + */ +@FunctionalInterface +public interface PropertyChainAxiomProvider { + + /** + * @param chain Chain of properties. Cannot be null or contain nulls. + * @param superProperty super property + * @return a subproperty chain axiom + */ + default OWLSubPropertyChainOfAxiom getOWLSubPropertyChainOfAxiom( + List chain, + OWLObjectPropertyExpression superProperty) { + return getOWLSubPropertyChainOfAxiom(chain, superProperty, Collections.emptySet()); + } + + /** + * @param chain Chain of properties. Cannot be null or contain nulls. + * @param superProperty super property + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a subproperty chain axiom + */ + OWLSubPropertyChainOfAxiom getOWLSubPropertyChainOfAxiom( + List chain, + OWLObjectPropertyExpression superProperty, Collection annotations); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/PropertyCharacteristicAxiomProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/PropertyCharacteristicAxiomProvider.java new file mode 100644 index 0000000000..2a7618b98d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/PropertyCharacteristicAxiomProvider.java @@ -0,0 +1,170 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.axiomproviders; + +import java.util.Collection; +import java.util.Collections; + +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; + +/** + * Property characteristic axioms provider (functional, transitive, etc.). + */ +public interface PropertyCharacteristicAxiomProvider { + + /** + * @param property property + * @return a functional object property axiom + */ + default OWLFunctionalObjectPropertyAxiom getOWLFunctionalObjectPropertyAxiom( + OWLObjectPropertyExpression property) { + return getOWLFunctionalObjectPropertyAxiom(property, Collections.emptySet()); + } + + /** + * @param property property + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a functional object property axiom with annotations + */ + OWLFunctionalObjectPropertyAxiom getOWLFunctionalObjectPropertyAxiom( + OWLObjectPropertyExpression property, Collection annotations); + + /** + * @param property property + * @return an inverse functional object property axiom + */ + default OWLInverseFunctionalObjectPropertyAxiom getOWLInverseFunctionalObjectPropertyAxiom( + OWLObjectPropertyExpression property) { + return getOWLInverseFunctionalObjectPropertyAxiom(property, Collections.emptySet()); + } + + /** + * @param property property + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return an inverse functional object property axiom with annotations + */ + OWLInverseFunctionalObjectPropertyAxiom getOWLInverseFunctionalObjectPropertyAxiom( + OWLObjectPropertyExpression property, Collection annotations); + + /** + * @param property property + * @return a reflexive object property axiom + */ + default OWLReflexiveObjectPropertyAxiom getOWLReflexiveObjectPropertyAxiom( + OWLObjectPropertyExpression property) { + return getOWLReflexiveObjectPropertyAxiom(property, Collections.emptySet()); + } + + /** + * @param property property + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a reflexive object property axiom with annotations + */ + OWLReflexiveObjectPropertyAxiom getOWLReflexiveObjectPropertyAxiom( + OWLObjectPropertyExpression property, Collection annotations); + + /** + * @param property property + * @return an irreflexive object property axiom + */ + default OWLIrreflexiveObjectPropertyAxiom getOWLIrreflexiveObjectPropertyAxiom( + OWLObjectPropertyExpression property) { + return getOWLIrreflexiveObjectPropertyAxiom(property, Collections.emptySet()); + } + + /** + * @param property property + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return an irreflexive object property axiom with annotations + */ + OWLIrreflexiveObjectPropertyAxiom getOWLIrreflexiveObjectPropertyAxiom( + OWLObjectPropertyExpression property, Collection annotations); + + /** + * @param property property + * @return a symmetric property axiom + */ + default OWLSymmetricObjectPropertyAxiom getOWLSymmetricObjectPropertyAxiom( + OWLObjectPropertyExpression property) { + return getOWLSymmetricObjectPropertyAxiom(property, Collections.emptySet()); + } + + /** + * @param property property + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a symmetric property axiom with annotations + */ + OWLSymmetricObjectPropertyAxiom getOWLSymmetricObjectPropertyAxiom( + OWLObjectPropertyExpression property, Collection annotations); + + /** + * @param propertyExpression property expression + * @return an asymmetric object property axiom on the specified argument + */ + default OWLAsymmetricObjectPropertyAxiom getOWLAsymmetricObjectPropertyAxiom( + OWLObjectPropertyExpression propertyExpression) { + return getOWLAsymmetricObjectPropertyAxiom(propertyExpression, Collections.emptySet()); + } + + /** + * @param propertyExpression property expression + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return an asymmetric object property axiom on the specified argument with annotations + */ + OWLAsymmetricObjectPropertyAxiom getOWLAsymmetricObjectPropertyAxiom( + OWLObjectPropertyExpression propertyExpression, Collection annotations); + + /** + * @param property property + * @return a transitive object property axiom on the specified argument + */ + default OWLTransitiveObjectPropertyAxiom getOWLTransitiveObjectPropertyAxiom( + OWLObjectPropertyExpression property) { + return getOWLTransitiveObjectPropertyAxiom(property, Collections.emptySet()); + } + + /** + * @param property property + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a transitive object property axiom on the specified argument with annotations + */ + OWLTransitiveObjectPropertyAxiom getOWLTransitiveObjectPropertyAxiom( + OWLObjectPropertyExpression property, Collection annotations); + + /** + * @param property property + * @return a functional data property axiom + */ + default OWLFunctionalDataPropertyAxiom getOWLFunctionalDataPropertyAxiom( + OWLDataPropertyExpression property) { + return getOWLFunctionalDataPropertyAxiom(property, Collections.emptySet()); + } + + /** + * @param property property + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a functional data property axiom with annotations + */ + OWLFunctionalDataPropertyAxiom getOWLFunctionalDataPropertyAxiom( + OWLDataPropertyExpression property, Collection annotations); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/RangeAxiomProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/RangeAxiomProvider.java new file mode 100644 index 0000000000..df8ba59f25 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/RangeAxiomProvider.java @@ -0,0 +1,113 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.axiomproviders; + +import java.util.Collection; +import java.util.Collections; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * Annotation, datatype and object property range provider. + */ +public interface RangeAxiomProvider { + + /** + * @param property property + * @param range range + * @return an object property range axiom + */ + default OWLObjectPropertyRangeAxiom getOWLObjectPropertyRangeAxiom( + OWLObjectPropertyExpression property, + OWLClassExpression range) { + return getOWLObjectPropertyRangeAxiom(property, range, Collections.emptySet()); + } + + /** + * @param property property + * @param range range + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return an object property range axiom with annotations + */ + OWLObjectPropertyRangeAxiom getOWLObjectPropertyRangeAxiom(OWLObjectPropertyExpression property, + OWLClassExpression range, Collection annotations); + + /** + * @param property property + * @param owlDataRange data range + * @return a data property range axiom + */ + default OWLDataPropertyRangeAxiom getOWLDataPropertyRangeAxiom( + OWLDataPropertyExpression property, + OWLDataRange owlDataRange) { + return getOWLDataPropertyRangeAxiom(property, owlDataRange, Collections.emptySet()); + } + + /** + * @param property property + * @param owlDataRange data range + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a data property range axiom with annotations + */ + OWLDataPropertyRangeAxiom getOWLDataPropertyRangeAxiom(OWLDataPropertyExpression property, + OWLDataRange owlDataRange, Collection annotations); + + /** + * @param property property + * @param owlDataRange data range + * @return a data property range axiom + */ + default OWLDataPropertyRangeAxiom getOWLDataPropertyRangeAxiom( + OWLDataPropertyExpression property, + OWL2Datatype owlDataRange) { + return getOWLDataPropertyRangeAxiom(property, owlDataRange, Collections.emptySet()); + } + + /** + * @param property property + * @param owlDataRange data range + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a data property range axiom with annotations + */ + OWLDataPropertyRangeAxiom getOWLDataPropertyRangeAxiom(OWLDataPropertyExpression property, + OWL2Datatype owlDataRange, Collection annotations); + + /** + * @param prop prop + * @param range range + * @return an annotation property range assertion + */ + default OWLAnnotationPropertyRangeAxiom getOWLAnnotationPropertyRangeAxiom( + OWLAnnotationProperty prop, IRI range) { + return getOWLAnnotationPropertyRangeAxiom(prop, range, Collections.emptySet()); + } + + /** + * @param prop prop + * @param range range + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return an annotation property range assertion with annotations + */ + OWLAnnotationPropertyRangeAxiom getOWLAnnotationPropertyRangeAxiom(OWLAnnotationProperty prop, + IRI range, + Collection annotations); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/SubAxiomProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/SubAxiomProvider.java new file mode 100644 index 0000000000..d1fabba2d0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/SubAxiomProvider.java @@ -0,0 +1,112 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.axiomproviders; + +import java.util.Collection; +import java.util.Collections; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; + +/** + * Annotation, datatype and object property range provider. + */ +public interface SubAxiomProvider { + + /** + * @param subClass sub class + * @param superClass super class + * @return a subclass axiom with no annotations + */ + default OWLSubClassOfAxiom getOWLSubClassOfAxiom(OWLClassExpression subClass, + OWLClassExpression superClass) { + return getOWLSubClassOfAxiom(subClass, superClass, Collections.emptySet()); + } + + /** + * @param subClass sub class + * @param superClass super class + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a subclass axiom with specified annotations + */ + OWLSubClassOfAxiom getOWLSubClassOfAxiom(OWLClassExpression subClass, + OWLClassExpression superClass, + Collection annotations); + + /** + * @param subProperty sub property + * @param superProperty super property + * @return a subproperty axiom + */ + default OWLSubObjectPropertyOfAxiom getOWLSubObjectPropertyOfAxiom( + OWLObjectPropertyExpression subProperty, + OWLObjectPropertyExpression superProperty) { + return getOWLSubObjectPropertyOfAxiom(subProperty, superProperty, Collections.emptySet()); + } + + /** + * @param subProperty sub Property + * @param superProperty super Property + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a subproperty axiom with annotations + */ + OWLSubObjectPropertyOfAxiom getOWLSubObjectPropertyOfAxiom( + OWLObjectPropertyExpression subProperty, + OWLObjectPropertyExpression superProperty, Collection annotations); + + /** + * @param subProperty sub Property + * @param superProperty super Property + * @return a subproperty axiom + */ + default OWLSubDataPropertyOfAxiom getOWLSubDataPropertyOfAxiom( + OWLDataPropertyExpression subProperty, + OWLDataPropertyExpression superProperty) { + return getOWLSubDataPropertyOfAxiom(subProperty, superProperty, Collections.emptySet()); + } + + /** + * @param subProperty sub Property + * @param superProperty super Property + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a subproperty axiom with annotations + */ + OWLSubDataPropertyOfAxiom getOWLSubDataPropertyOfAxiom(OWLDataPropertyExpression subProperty, + OWLDataPropertyExpression superProperty, Collection annotations); + + /** + * @param sub sub property + * @param sup super property + * @return a sub annotation property axiom with specified properties + */ + default OWLSubAnnotationPropertyOfAxiom getOWLSubAnnotationPropertyOfAxiom( + OWLAnnotationProperty sub, + OWLAnnotationProperty sup) { + return getOWLSubAnnotationPropertyOfAxiom(sub, sup, Collections.emptySet()); + } + + /** + * @param sub sub property + * @param sup super property + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a sub annotation property axiom with specified properties and annotations + */ + OWLSubAnnotationPropertyOfAxiom getOWLSubAnnotationPropertyOfAxiom(OWLAnnotationProperty sub, + OWLAnnotationProperty sup, Collection annotations); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/package-info.java b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/package-info.java new file mode 100644 index 0000000000..94532c91c9 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Axiom provider classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.model.axiomproviders; diff --git a/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/packageinfo b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/packageinfo new file mode 100644 index 0000000000..7c7a9efd9c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/axiomproviders/packageinfo @@ -0,0 +1 @@ +version 5.1.0 diff --git a/api/src/main/java/org/semanticweb/owlapi/model/package-info.java b/api/src/main/java/org/semanticweb/owlapi/model/package-info.java new file mode 100644 index 0000000000..7a5012b0af --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Main API classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.model; diff --git a/api/src/main/java/org/semanticweb/owlapi/model/packageinfo b/api/src/main/java/org/semanticweb/owlapi/model/packageinfo new file mode 100644 index 0000000000..baa1c4d206 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/packageinfo @@ -0,0 +1 @@ +version 5.4.0 diff --git a/api/src/main/java/org/semanticweb/owlapi/model/parameters/AxiomAnnotations.java b/api/src/main/java/org/semanticweb/owlapi/model/parameters/AxiomAnnotations.java new file mode 100644 index 0000000000..b90740e899 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/parameters/AxiomAnnotations.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.parameters; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * Search options. + * + * @author ignazio + * @since 4.0.0 + */ +public enum AxiomAnnotations { + /** + * Search for axioms ignoring annotations. + */ + IGNORE_AXIOM_ANNOTATIONS { + @Override + public boolean contains(OWLOntology o, OWLAxiom ax) { + return o.containsAxiomIgnoreAnnotations(ax); + } + }, + /** + * Search for axioms taking annotations into account. + */ + CONSIDER_AXIOM_ANNOTATIONS { + @Override + public boolean contains(OWLOntology o, OWLAxiom ax) { + return o.containsAxiom(ax); + } + }; + + /** + * @param o ontology to check + * @param ax axiom to check + * @return true if the ontology contains the axiom, considering or disregarding annotations + * depending on the axiom annotation value. + */ + public abstract boolean contains(OWLOntology o, OWLAxiom ax); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/parameters/ChangeApplied.java b/api/src/main/java/org/semanticweb/owlapi/model/parameters/ChangeApplied.java new file mode 100644 index 0000000000..e9abec0e2e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/parameters/ChangeApplied.java @@ -0,0 +1,34 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.parameters; + +/** + * An enum for change application success. + * + * @author ignazio + * @since 4.0.0 + */ +public enum ChangeApplied { + /** + * Change applied successfully. + */ + SUCCESSFULLY, + /** + * Change not applied. + */ + UNSUCCESSFULLY, + /** + * No operation carried out (change had no effect) + */ + NO_OPERATION +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/parameters/ConfigurationOptions.java b/api/src/main/java/org/semanticweb/owlapi/model/parameters/ConfigurationOptions.java new file mode 100644 index 0000000000..b1494b0908 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/parameters/ConfigurationOptions.java @@ -0,0 +1,205 @@ +package org.semanticweb.owlapi.model.parameters; + +import java.io.IOException; +import java.io.InputStream; +import java.util.EnumMap; +import java.util.Map; +import java.util.Properties; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.ByName; +import org.semanticweb.owlapi.model.MissingImportHandlingStrategy; +import org.semanticweb.owlapi.model.MissingOntologyHeaderStrategy; +import org.semanticweb.owlapi.model.PriorityCollectionSorting; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This enum handles default values and config file or system property overrides. The config file + * name is {@code owlapi.properties}; to enable, make sure the file is in the classpath. The + * property names are {@code "org.semanticweb.owlapi.model.parameters.ConfigurationOptions."+name()} + * , both in the properties file and in the system properties. + */ +public enum ConfigurationOptions { + //@formatter:off + /** True if HTTP compression should be used. */ + ACCEPT_HTTP_COMPRESSION(Boolean.TRUE), + /** Timeout for connections. */ + CONNECTION_TIMEOUT(Integer.valueOf(20000)), + /** True if redirects should be followed across protocols. */ + FOLLOW_REDIRECTS(Boolean.TRUE), + /** True if annotations should be loaded, false if skipped. */ + LOAD_ANNOTATIONS(Boolean.TRUE), + /** Missing imports handling strategy. */ + MISSING_IMPORT_HANDLING_STRATEGY(MissingImportHandlingStrategy.THROW_EXCEPTION), + /** Default missing ontology strategy. */ + MISSING_ONTOLOGY_HEADER_STRATEGY(MissingOntologyHeaderStrategy.INCLUDE_GRAPH), + /** Flag to enable stack traces on parsing exceptions. */ + REPORT_STACK_TRACES(Boolean.TRUE), + /** Number of retries to attempt when retrieving an ontology from a remote URL. Defaults to 5. */ + RETRIES_TO_ATTEMPT(Integer.valueOf(5)), + /** True if strict parsing should be used. */ + PARSE_WITH_STRICT_CONFIGURATION(Boolean.FALSE), + /** True if Dublin Core. */ + TREAT_DUBLINCORE_AS_BUILTIN(Boolean.TRUE), + /** sort configuration for priority collections */ + PRIORITY_COLLECTION_SORTING(PriorityCollectionSorting.ON_SET_INJECTION_ONLY), + // Save options + /** True if ids for blank nodes should always be written (axioms and anonymous individuals only). */ + SAVE_IDS(Boolean.FALSE), + /** True if all anonymous individuals should have their ids remapped after parsing. */ + REMAP_IDS(Boolean.TRUE), + /** True if entities should be used for namespace abbreviations. */ + USE_NAMESPACE_ENTITIES(Boolean.FALSE), + /** True if indenting should be used when writing out a file. */ + INDENTING(Boolean.TRUE), + /** Size of indentation between levels. Only used if indenting is to true. */ + INDENT_SIZE(Integer.valueOf(4)), + /** True if rdfs:label values are to be used as banners in text output. */ + LABELS_AS_BANNER(Boolean.FALSE), + /** True if banners for ontology sections and entity comments should be output. */ + BANNERS_ENABLED(Boolean.TRUE), + /** List of banned parsers keys. */ + BANNED_PARSERS(""), + /** Entity expansion limit for XML parsing. */ + ENTITY_EXPANSION_LIMIT("100000000"), + /** Repair illegal punnings + * automatically. */ + REPAIR_ILLEGAL_PUNNINGS(Boolean.TRUE), + /** Authorization + * header Value. */ + AUTHORIZATION_VALUE (""), + /**True if ontologies should + * be trimmed to size after load. + * If set to false, trim will + * only happen on explicit call.*/ + TRIM_TO_SIZE (Boolean.TRUE), + /** True if annotations on entities + * included in modules should be + * skipped. By default annotations + * are included.*/ + SKIP_MODULE_ANNOTATIONS (Boolean.FALSE), + /** False if collections used in + * constructs such as equivalent + * classes and properties should be + * duplicate free. Some systems + * might need to allow this, e.g., + * reasoners which require the creation + * of a tautology like + * {@code Equivalent(A, A)}.*/ + ALLOW_DUPLICATES_IN_CONSTRUCT_SETS (Boolean.FALSE), + /**Max number of elements for caches.*/ + CACHE_SIZE (Integer.valueOf(2048)), + /** False if named graph IRIs should + * not be created for formats like + * TriG and RDF/JSON. This is the + * historic behaviour of the API. + * Switch to true to always use the + * ontology IRI as graph IRI for + * named ontologies. The named + * graph IRI can be set independently + * or overridden with + * {@code OWLDocumentFormat::setParameter("namedGraphOverride", "desired value")}.*/ + OUTPUT_NAMED_GRAPH_IRI (Boolean.FALSE); + //@formatter:on + private static final String PREFIX = + "org.semanticweb.owlapi.model.parameters.ConfigurationOptions."; + private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationOptions.class); + private static final EnumMap owlapiProperties = loadProperties(); + private Object defaultValue; + + ConfigurationOptions(Object o) { + defaultValue = o; + } + + private static EnumMap loadProperties() { + EnumMap map = new EnumMap<>(ConfigurationOptions.class); + Properties props = new Properties(); + try (InputStream stream = + ConfigurationOptions.class.getResourceAsStream("/owlapi.properties")) { + if (stream != null) { + props.load(stream); + } + } catch (IOException e) { + LOGGER.error("Properties cannot be loaded", e); + } + props.forEach((name, value) -> { + ConfigurationOptions option = find(name.toString()); + if (option != null) { + map.put(option, value); + } + }); + return map; + } + + /** + * @param parameterName parameter name - by default the full name of this enumeration plus the + * enum member name + * @return matching ConfigurationOptions member, or null if none found + */ + @Nullable + public static ConfigurationOptions find(String parameterName) { + if (!parameterName.startsWith(PREFIX)) { + return null; + } + return valueOf(parameterName.substring(PREFIX.length())); + } + + /** + * @param value value to parse according to the enum default value + * @param type type of the returned value + * @param type + * @return parsed value + */ + protected T parse(Object value, Class type) { + if (Boolean.class.equals(type)) { + return type.cast(Boolean.valueOf(value.toString())); + } + if (Long.class.equals(type)) { + return type.cast(Long.valueOf(value.toString())); + } + if (Integer.class.equals(type)) { + return type.cast(Integer.valueOf(value.toString())); + } + if (defaultValue instanceof ByName) { + return type.cast(((ByName) defaultValue).byName(value.toString())); + } + return type.cast(value); + } + + /** + * @param type type for this value + * @param overrides local overrides + * @param type + * @return value for this configuration option. Values are evaluated as follows: first, check + * overrides; if no overrides are present, check if a system property with the expected + * name is set; if not, check the config file; if no value is set in the config file, + * use the default defined in this enumeration. + */ + public T getValue(Class type, Map overrides) { + Object override = overrides.get(this); + if (override != null) { + return parse(override, type); + } + // first system properties + Object fromSystemProperties = System.getProperty(PREFIX + name()); + if (fromSystemProperties != null) { + return parse(fromSystemProperties, type); + } + Object fromConfigFile = owlapiProperties.get(this); + if (fromConfigFile != null) { + return parse(fromConfigFile, type); + } + return type.cast(defaultValue); + } + + /** + * @param type type to cast to + * @param type + * @return default value + */ + public T getDefaultValue(Class type) { + return type.cast(defaultValue); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/parameters/Imports.java b/api/src/main/java/org/semanticweb/owlapi/model/parameters/Imports.java new file mode 100644 index 0000000000..ae4f554770 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/parameters/Imports.java @@ -0,0 +1,65 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.parameters; + +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.HasImportsClosure; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * An enumeration for human readable values to include/exclude imports from + * searches. + * + * @author ignazio + * @since 4.0.0 + */ +public enum Imports { + /** + * Imports are included. + */ + INCLUDED { + @Override + public Stream stream(HasImportsClosure o) { + return o.importsClosure(); + } + }, + /** + * Imports are excluded. + */ + EXCLUDED { + @Override + public Stream stream(HasImportsClosure o) { + return Stream.of((OWLOntology) o); + } + }; + + /** + * Transform a boolean arg in an Imports arg. True means INCLUDED + * + * @param b boolean argument + * @return INCLUDED for true, EXCLUDED for false. + */ + public static Imports fromBoolean(boolean b) { + if (b) { + return INCLUDED; + } + return EXCLUDED; + } + + /** + * @param o input ontology + * @return if the import closure should be included, return a sorted stream with all the ontologies in + * the imports closure. Otherwise, return a stream with a single ontology - the input ontology. + */ + public abstract Stream stream(HasImportsClosure o); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/parameters/Navigation.java b/api/src/main/java/org/semanticweb/owlapi/model/parameters/Navigation.java new file mode 100644 index 0000000000..60a48d71f9 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/parameters/Navigation.java @@ -0,0 +1,17 @@ +package org.semanticweb.owlapi.model.parameters; + +/** + * Parameters for navigating class or property hierarchies. + */ +public enum Navigation { + /** + * search for entities in sub position (for subclasses, subproperties + * axioms). + */ + IN_SUB_POSITION, + /** + * search for entities in super position (for subclasses, subproperties + * axioms). + */ + IN_SUPER_POSITION +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/parameters/OntologyCopy.java b/api/src/main/java/org/semanticweb/owlapi/model/parameters/OntologyCopy.java new file mode 100644 index 0000000000..34e87b349f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/parameters/OntologyCopy.java @@ -0,0 +1,38 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.parameters; + +/** + * Parameters for ontology copying across managers. + * + * @since 4.0.0 + */ +public enum OntologyCopy { + /** + * the ontology copy will create a new OWLOntology instance with same + * ontology annotations, same ID and same axioms. Format, document IRI will + * not be copied over. + */ + SHALLOW, + /** + * the ontology copy will create a new OWLOntology instance with same + * ontology annotations, same ID and same axioms. Format, document IRI will + * be copied over. + */ + DEEP, + /** + * the ontology copy will remove the ontology from the previous manager. + * Format, document IRI will be removed from the previous manager. + */ + MOVE +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/parameters/package-info.java b/api/src/main/java/org/semanticweb/owlapi/model/parameters/package-info.java new file mode 100644 index 0000000000..ebee83213b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/parameters/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Parameter classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.model.parameters; diff --git a/api/src/main/java/org/semanticweb/owlapi/model/parameters/packageinfo b/api/src/main/java/org/semanticweb/owlapi/model/parameters/packageinfo new file mode 100644 index 0000000000..36562a62cd --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/parameters/packageinfo @@ -0,0 +1 @@ +version 6.2.0 diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/AnnotationAssertionProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/AnnotationAssertionProvider.java new file mode 100644 index 0000000000..ea740f908c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/AnnotationAssertionProvider.java @@ -0,0 +1,81 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import java.util.Collection; +import java.util.Collections; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationSubject; +import org.semanticweb.owlapi.model.OWLAnnotationValue; + +/** + * Annotation assertion provider. + */ +public interface AnnotationAssertionProvider extends LiteralProvider { + + /** + * @param property property + * @param subject subject + * @param value value + * @return an annotation assertion axiom + */ + default OWLAnnotationAssertionAxiom getOWLAnnotationAssertionAxiom( + OWLAnnotationProperty property, + OWLAnnotationSubject subject, OWLAnnotationValue value) { + return getOWLAnnotationAssertionAxiom(property, subject, value, Collections.emptySet()); + } + + /** + * @param subject subject + * @param annotation annotation + * @return an annotation assertion axiom + */ + OWLAnnotationAssertionAxiom getOWLAnnotationAssertionAxiom(OWLAnnotationSubject subject, + OWLAnnotation annotation); + + /** + * @param property property + * @param subject subject + * @param value value + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return an annotation assertion axiom - with annotations + */ + OWLAnnotationAssertionAxiom getOWLAnnotationAssertionAxiom(OWLAnnotationProperty property, + OWLAnnotationSubject subject, OWLAnnotationValue value, + Collection annotations); + + /** + * @param subject subject + * @param annotation annotation + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return an annotation assertion axiom - with annotations + */ + OWLAnnotationAssertionAxiom getOWLAnnotationAssertionAxiom(OWLAnnotationSubject subject, + OWLAnnotation annotation, + Collection annotations); + + /** + * Gets an annotation assertion that specifies that an IRI is deprecated. + * The annotation property is owl:deprecated and the value of the annotation + * is {@code "true"^^xsd:boolean}. (See Annotation Properties in the OWL 2 Specification + * + * @param subject The IRI to be deprecated. + * @return The annotation assertion that deprecates the specified IRI. + */ + OWLAnnotationAssertionAxiom getDeprecatedOWLAnnotationAssertionAxiom(IRI subject); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/AnnotationPropertyProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/AnnotationPropertyProvider.java new file mode 100644 index 0000000000..4aeabb6e06 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/AnnotationPropertyProvider.java @@ -0,0 +1,102 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.model.PrefixManager; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 5.0.0 + */ +@FunctionalInterface +public interface AnnotationPropertyProvider { + + /** + * Gets an instance of {@link OWLAnnotationProperty} that has the specified + * {@code IRI}. + * + * @param iri The IRI. + * @return An {@link OWLAnnotationProperty} that has the specified IRI. + */ + OWLAnnotationProperty getOWLAnnotationProperty(IRI iri); + + /** + * Gets an instance of {@link OWLAnnotationProperty} with the same IRI as + * the input. + * + * @param iri The HasIRI instance. + * @return An {@link OWLAnnotationProperty} that has iri.getIRI() as IRI. + */ + default OWLAnnotationProperty getOWLAnnotationProperty(HasIRI iri) { + return getOWLAnnotationProperty(iri.getIRI()); + } + + /** + * Gets an instance of {@link OWLAnnotationProperty} that has the specified + * {@code IRI}. This is the same as + * {@code getOWLAnnotationProperty(IRI.create(iri))}. + * + * @param iri The IRI string. + * @return An {@link OWLAnnotationProperty} that has the specified IRI. + */ + default OWLAnnotationProperty getOWLAnnotationProperty(String iri) { + return getOWLAnnotationProperty(IRI.create(iri)); + } + + /** + * Gets an instance of {@link OWLAnnotationProperty} that has the specified + * {@code IRI}. This is the same as + * {@code getOWLAnnotationProperty(IRI.create(namespace, remainder))}. + * + * @param namespace The IRI namespace. + * @param remainder optional remainder or local name + * @return An {@link OWLAnnotationProperty} that has the specified IRI. + */ + default OWLAnnotationProperty getOWLAnnotationProperty(String namespace, + @Nullable String remainder) { + return getOWLAnnotationProperty(IRI.create(namespace, remainder)); + } + + /** + * Gets an OWLAnnotationProperty that has an IRI that is obtained by + * expanding an abbreviated name using an appropriate prefix mapping. See + * The + * OWL 2 Structural Specification for more details. + * + * @param abbreviatedIRI The abbreviated IRI, which is of the form PREFIX_NAME:RC, where + * PREFIX_NAME may be the empty string (the default prefix). Note that abbreviated IRIs always + * contain a colon as a delimiter, even if the prefix name is the empty string. + * @param prefixManager The prefix manager that is responsible for mapping prefix names to + * prefix IRIs. + * @return An OWLAnnotationProperty that has the IRI obtained by expanding the specified + * abbreviated IRI using the specified prefix manager.
For example, suppose "m:Cat" was + * specified as the abbreviated IRI, the prefix manager would be used to obtain the IRI prefix + * for the "m:" prefix name, this prefix would then be concatenated with "Cat" to obtain the + * full IRI which would be the IRI of the OWLAnnotationProperty obtained by this method. + * @throws OWLRuntimeException if the prefix name in the specified abbreviated IRI does not have + * a mapping to a prefix in the specified prefix manager. + */ + default OWLAnnotationProperty getOWLAnnotationProperty(String abbreviatedIRI, + PrefixManager prefixManager) { + checkNotNull(abbreviatedIRI, "abbreviatedIRI cannot be null"); + checkNotNull(prefixManager, "prefixManager cannot be null"); + return getOWLAnnotationProperty(prefixManager.getIRI(abbreviatedIRI)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/AnnotationProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/AnnotationProvider.java new file mode 100644 index 0000000000..87e87d8e43 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/AnnotationProvider.java @@ -0,0 +1,77 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import java.util.Collection; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationValue; + +/** + * Annotation provider interface. + */ +public interface AnnotationProvider { + + // Annotations + + /** + * Gets an annotation + * + * @param property the annotation property. + * @param value The annotation value. + * @return The annotation on the specified property with the specified value + */ + OWLAnnotation getOWLAnnotation(OWLAnnotationProperty property, OWLAnnotationValue value); + + /** + * Gets an annotation + * + * @param property the annotation property. + * @param value The annotation value. + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return The annotation on the specified property with the specified value + */ + default OWLAnnotation getOWLAnnotation(OWLAnnotationProperty property, OWLAnnotationValue value, + Collection annotations) { + if (annotations.isEmpty()) { + return getOWLAnnotation(property, value); + } + return getOWLAnnotation(property, value, annotations.stream()); + } + + /** + * Gets an annotation + * + * @param property the annotation property. + * @param value The annotation value. + * @param annotation Annotation on this annotation. Cannot be null or contain nulls. + * @return The annotation on the specified property with the specified value + */ + default OWLAnnotation getOWLAnnotation(OWLAnnotationProperty property, OWLAnnotationValue value, + OWLAnnotation annotation) { + return getOWLAnnotation(property, value, Stream.of(annotation)); + } + + /** + * Gets an annotation + * + * @param property the annotation property. + * @param value The annotation value. + * @param annotations A stream of annotations. Cannot be null or contain nulls. + * @return The annotation on the specified property with the specified value + */ + public OWLAnnotation getOWLAnnotation(OWLAnnotationProperty property, OWLAnnotationValue value, + Stream annotations); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/AnonymousIndividualByIdProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/AnonymousIndividualByIdProvider.java new file mode 100644 index 0000000000..f0308fbff0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/AnonymousIndividualByIdProvider.java @@ -0,0 +1,38 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import org.semanticweb.owlapi.model.NodeID; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; + +/** + * An interface to an object that can provide instances of + * {@link OWLAnonymousIndividual}. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 5.0.0 + */ +@FunctionalInterface +public interface AnonymousIndividualByIdProvider { + + /** + * Gets an {@link OWLAnonymousIndividual} that has a specific {@link NodeID} + * . + * + * @param nodeId A String that represents the {@link NodeID} of the generated {@link + * OWLAnonymousIndividual}. Note: {@code nodeId} will be prefixed with "_:" if it is not + * specified with an "_:" prefix. + * @return An instance of {@link OWLAnonymousIndividual} + */ + OWLAnonymousIndividual getOWLAnonymousIndividual(String nodeId); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/AnonymousIndividualProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/AnonymousIndividualProvider.java new file mode 100644 index 0000000000..53ce2cd526 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/AnonymousIndividualProvider.java @@ -0,0 +1,40 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import java.io.Serializable; +import org.semanticweb.owlapi.model.NodeID; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; + +/** + * An interface to an object that can provide instances if + * {@link OWLAnonymousIndividual}. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 5.0.0 + */ +@FunctionalInterface +public interface AnonymousIndividualProvider extends Serializable { + + /** + * Gets an {@link OWLAnonymousIndividual}. The {@link NodeID} for the + * individual will be generated automatically. Successive invocations of + * this method (on this object) will result in instances of + * {@link OWLAnonymousIndividual} that do not have {@link NodeID}s that have + * been used previously. + * + * @return The instance of {@link OWLAnonymousIndividual}. + * @see AnonymousIndividualByIdProvider + */ + OWLAnonymousIndividual getOWLAnonymousIndividual(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/CardinalityRestrictionProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/CardinalityRestrictionProvider.java new file mode 100644 index 0000000000..d8c974a51d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/CardinalityRestrictionProvider.java @@ -0,0 +1,162 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import javax.annotation.Nonnegative; + +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * Cardinality restriction provider interface. + */ +public interface CardinalityRestrictionProvider { + + /** + * @param cardinality Cannot be negative + * @param property The property that the restriction acts along. + * @return an ExactCardinality on the specified property + */ + OWLDataExactCardinality getOWLDataExactCardinality(@Nonnegative int cardinality, + OWLDataPropertyExpression property); + + /** + * @param cardinality Cannot be negative + * @param property The property that the restriction acts along. + * @return an ExactCardinality on the specified property + */ + OWLDataMaxCardinality getOWLDataMaxCardinality(@Nonnegative int cardinality, + OWLDataPropertyExpression property); + + /** + * @param cardinality Cannot be negative + * @param property The property that the restriction acts along. + * @param dataRange data range for restriction + * @return an ExactCardinality on the specified property + */ + OWLDataExactCardinality getOWLDataExactCardinality(@Nonnegative int cardinality, + OWLDataPropertyExpression property, OWLDataRange dataRange); + + /** + * @param cardinality Cannot be negative + * @param property The property that the restriction acts along. + * @param dataRange data range for restriction + * @return an ExactCardinality on the specified property + */ + OWLDataMaxCardinality getOWLDataMaxCardinality(@Nonnegative int cardinality, + OWLDataPropertyExpression property, OWLDataRange dataRange); + + /** + * @param cardinality Cannot be negative. + * @param property The property that the restriction acts along. + * @param dataRange data range for restriction + * @return an ExactCardinality on the specified property + */ + OWLDataMinCardinality getOWLDataMinCardinality(@Nonnegative int cardinality, + OWLDataPropertyExpression property, OWLDataRange dataRange); + + /** + * @param cardinality Cannot be negative + * @param property The property that the restriction acts along. + * @param dataRange data range for restriction + * @return an ExactCardinality on the specified property + */ + OWLDataExactCardinality getOWLDataExactCardinality(@Nonnegative int cardinality, + OWLDataPropertyExpression property, OWL2Datatype dataRange); + + /** + * @param cardinality Cannot be negative + * @param property The property that the restriction acts along. + * @param dataRange data range for restriction + * @return an ExactCardinality on the specified property + */ + OWLDataMaxCardinality getOWLDataMaxCardinality(@Nonnegative int cardinality, + OWLDataPropertyExpression property, OWL2Datatype dataRange); + + /** + * @param cardinality Cannot be negative. + * @param property The property that the restriction acts along. + * @param dataRange data range for restriction + * @return an ExactCardinality on the specified property + */ + OWLDataMinCardinality getOWLDataMinCardinality(@Nonnegative int cardinality, + OWLDataPropertyExpression property, OWL2Datatype dataRange); + + /** + * @param cardinality Cannot be negative + * @param property The property that the restriction acts along. + * @return an ExactCardinality on the specified property + */ + OWLDataMinCardinality getOWLDataMinCardinality(@Nonnegative int cardinality, + OWLDataPropertyExpression property); + + /** + * @param cardinality Cannot be negative. + * @param property The property that the restriction acts along. + * @return an ExactCardinality on the specified property + */ + OWLObjectExactCardinality getOWLObjectExactCardinality(@Nonnegative int cardinality, + OWLObjectPropertyExpression property); + + /** + * @param cardinality Cannot be negative. + * @param property The property that the restriction acts along. + * @param classExpression class expression for restriction + * @return an ExactCardinality on the specified property + */ + OWLObjectExactCardinality getOWLObjectExactCardinality(@Nonnegative int cardinality, + OWLObjectPropertyExpression property, OWLClassExpression classExpression); + + /** + * @param cardinality Cannot be negative. + * @param property The property that the restriction acts along. + * @return an ExactCardinality on the specified property + */ + OWLObjectMinCardinality getOWLObjectMinCardinality(@Nonnegative int cardinality, + OWLObjectPropertyExpression property); + + /** + * @param cardinality Cannot be negative. + * @param property The property that the restriction acts along. + * @param classExpression class expression for restriction + * @return an ExactCardinality on the specified property + */ + OWLObjectMinCardinality getOWLObjectMinCardinality(@Nonnegative int cardinality, + OWLObjectPropertyExpression property, OWLClassExpression classExpression); + + /** + * @param cardinality Cannot be negative. + * @param property The property that the restriction acts along. + * @return an ExactCardinality on the specified property + */ + OWLObjectMaxCardinality getOWLObjectMaxCardinality(@Nonnegative int cardinality, + OWLObjectPropertyExpression property); + + /** + * @param cardinality Cannot be negative. + * @param property The property that the restriction acts along. + * @param classExpression class expression for restriction + * @return an ExactCardinality on the specified property + */ + OWLObjectMaxCardinality getOWLObjectMaxCardinality(@Nonnegative int cardinality, + OWLObjectPropertyExpression property, OWLClassExpression classExpression); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/ClassAssertionProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/ClassAssertionProvider.java new file mode 100644 index 0000000000..4046ba79ec --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/ClassAssertionProvider.java @@ -0,0 +1,46 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import java.util.Collection; +import java.util.Collections; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLIndividual; + +/** + * Class assertion provider. + */ +public interface ClassAssertionProvider extends LiteralProvider { + + /** + * @param classExpression class Expression + * @param individual individual + * @return a class assertion axiom + */ + default OWLClassAssertionAxiom getOWLClassAssertionAxiom(OWLClassExpression classExpression, + OWLIndividual individual) { + return getOWLClassAssertionAxiom(classExpression, individual, Collections.emptySet()); + } + + /** + * @param classExpression class Expression + * @param individual individual + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a class assertion axiom with annotations + */ + OWLClassAssertionAxiom getOWLClassAssertionAxiom(OWLClassExpression classExpression, + OWLIndividual individual, + Collection annotations); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/ClassProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/ClassProvider.java new file mode 100644 index 0000000000..3e5ac008de --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/ClassProvider.java @@ -0,0 +1,100 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.io.Serializable; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.model.PrefixManager; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 5.0.0 + */ +@FunctionalInterface +public interface ClassProvider extends Serializable { + + /** + * Gets an instance of {@link OWLClass} that has the specified {@code IRI}. + * + * @param iri The IRI. + * @return An {@link OWLClass} that has the specified IRI. + */ + OWLClass getOWLClass(IRI iri); + + /** + * Gets an instance of {@link OWLClass} with the same IRI as the input. + * + * @param iri The HasIRI instance. + * @return An {@link OWLClass} that has iri.getIRI() as IRI. + */ + default OWLClass getOWLClass(HasIRI iri) { + return getOWLClass(iri.getIRI()); + } + + /** + * Gets an instance of {@link OWLClass} that has the specified {@code IRI}. + * This is the same as calling {@code getOWLClass(IRI.create(iri))}. No + * prefix resolution is attempted. + * + * @param iri The IRI string + * @return An {@link OWLClass} that has the specified IRI. + */ + default OWLClass getOWLClass(String iri) { + return getOWLClass(IRI.create(iri)); + } + + /** + * Gets an instance of {@link OWLClass} that has an IRI composed of the + * provided namespace and remainder. This is the same as calling + * {@code getOWLClass(IRI.create(namespace, remainder))}. No prefix + * resolution is attempted. + * + * @param namespace The IRI namespace + * @param remainder optional remainder or local name (can be null) + * @return An {@link OWLClass} that has the specified IRI. + */ + default OWLClass getOWLClass(String namespace, @Nullable String remainder) { + return getOWLClass(IRI.create(namespace, remainder)); + } + + /** + * Gets an OWLClass that has an IRI that is obtained by expanding an + * abbreviated name using an appropriate prefix mapping. See + * The + * OWL 2 Structural Specification for more details. + * + * @param abbreviatedIRI The abbreviated IRI, which is of the form PREFIX_NAME:RC, where + * PREFIX_NAME may be the empty string (the default prefix).
Note that abbreviated IRIs + * always contain a colon as a delimiter, even if the prefix name is the empty string. + * @param prefixManager The prefix manager that is responsible for mapping prefix names to + * prefix IRIs. + * @return An OWLClass that has the IRI obtained by expanding the specified abbreviated IRI + * using the specified prefix manager.
For example, suppose "m:Cat" was specified as the + * abbreviated IRI, the prefix manager would be used to obtain the IRI prefix for the "m:" + * prefix name, this prefix would then be concatenated with "Cat" to obtain the full IRI which + * would be the IRI of the OWLClass obtained by this method. + * @throws OWLRuntimeException if the prefix name in the specified abbreviated IRI does not have + * a mapping to a prefix in the specified prefix manager. + */ + default OWLClass getOWLClass(String abbreviatedIRI, PrefixManager prefixManager) { + checkNotNull(abbreviatedIRI, "iri cannot be null"); + checkNotNull(prefixManager, "prefixManager cannot be null"); + return getOWLClass(prefixManager.getIRI(abbreviatedIRI)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/ComplementProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/ComplementProvider.java new file mode 100644 index 0000000000..56e5ccdef8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/ComplementProvider.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataComplementOf; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * Complement provider interface. + */ +public interface ComplementProvider { + + /** + * Gets an + * OWLDataComplementOf + * + * @param dataRange The data range to be complemented. + * @return An OWLDataComplementOf of the specified data range + */ + OWLDataComplementOf getOWLDataComplementOf(OWLDataRange dataRange); + + /** + * Gets an + * OWLDataComplementOf + * + * @param dataRange The data range to be complemented. + * @return An OWLDataComplementOf of the specified data range + */ + OWLDataComplementOf getOWLDataComplementOf(OWL2Datatype dataRange); + + /** + * @param operand class expression to complement + * @return the complement of the specified argument + */ + OWLObjectComplementOf getOWLObjectComplementOf(OWLClassExpression operand); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/DataAssertionProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/DataAssertionProvider.java new file mode 100644 index 0000000000..64296203df --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/DataAssertionProvider.java @@ -0,0 +1,139 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import java.util.Collection; +import java.util.Collections; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; + +/** + * Data property assertion provider. + */ +public interface DataAssertionProvider extends LiteralProvider { + + /** + * @param property property + * @param subject subject + * @param object object + * @return a data property assertion + */ + default OWLDataPropertyAssertionAxiom getOWLDataPropertyAssertionAxiom( + OWLDataPropertyExpression property, + OWLIndividual subject, OWLLiteral object) { + return getOWLDataPropertyAssertionAxiom(property, subject, object, Collections.emptySet()); + } + + /** + * @param property property + * @param subject subject + * @param object object + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a data property assertion with annotations + */ + OWLDataPropertyAssertionAxiom getOWLDataPropertyAssertionAxiom( + OWLDataPropertyExpression property, + OWLIndividual subject, OWLLiteral object, Collection annotations); + + /** + * @param property property + * @param subject subject + * @param value value + * @return a data property assertion + */ + default OWLDataPropertyAssertionAxiom getOWLDataPropertyAssertionAxiom( + OWLDataPropertyExpression property, + OWLIndividual subject, int value) { + return getOWLDataPropertyAssertionAxiom(property, subject, getOWLLiteral(value), + Collections.emptySet()); + } + + /** + * @param property property + * @param subject subject + * @param value value + * @return a data property assertion + */ + default OWLDataPropertyAssertionAxiom getOWLDataPropertyAssertionAxiom( + OWLDataPropertyExpression property, + OWLIndividual subject, double value) { + return getOWLDataPropertyAssertionAxiom(property, subject, getOWLLiteral(value), + Collections.emptySet()); + } + + /** + * @param property property + * @param subject subject + * @param value value + * @return a data property assertion + */ + default OWLDataPropertyAssertionAxiom getOWLDataPropertyAssertionAxiom( + OWLDataPropertyExpression property, + OWLIndividual subject, float value) { + return getOWLDataPropertyAssertionAxiom(property, subject, getOWLLiteral(value), + Collections.emptySet()); + } + + /** + * @param property property + * @param subject subject + * @param value value + * @return a data property assertion + */ + default OWLDataPropertyAssertionAxiom getOWLDataPropertyAssertionAxiom( + OWLDataPropertyExpression property, + OWLIndividual subject, boolean value) { + return getOWLDataPropertyAssertionAxiom(property, subject, getOWLLiteral(value), + Collections.emptySet()); + } + + /** + * @param property property + * @param subject subject + * @param value value + * @return a data property assertion + */ + default OWLDataPropertyAssertionAxiom getOWLDataPropertyAssertionAxiom( + OWLDataPropertyExpression property, + OWLIndividual subject, String value) { + return getOWLDataPropertyAssertionAxiom(property, subject, getOWLLiteral(value), + Collections.emptySet()); + } + + /** + * @param property property + * @param subject subject + * @param object object + * @return a negative property assertion axiom on given arguments + */ + default OWLNegativeDataPropertyAssertionAxiom getOWLNegativeDataPropertyAssertionAxiom( + OWLDataPropertyExpression property, OWLIndividual subject, OWLLiteral object) { + return getOWLNegativeDataPropertyAssertionAxiom(property, subject, object, + Collections.emptySet()); + } + + /** + * @param property property + * @param subject subject + * @param object object + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a negative property assertion axiom on given arguments with annotations + */ + OWLNegativeDataPropertyAssertionAxiom getOWLNegativeDataPropertyAssertionAxiom( + OWLDataPropertyExpression property, + OWLIndividual subject, OWLLiteral object, Collection annotations); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/DataPropertyProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/DataPropertyProvider.java new file mode 100644 index 0000000000..fc7facada5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/DataPropertyProvider.java @@ -0,0 +1,101 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.io.Serializable; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.model.PrefixManager; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 5.0.0 + */ +@FunctionalInterface +public interface DataPropertyProvider extends Serializable { + + /** + * Gets an instance of {@link OWLDataProperty} that has the specified + * {@code IRI}. + * + * @param iri The IRI. + * @return An {@link OWLDataProperty} that has the specified IRI. + */ + OWLDataProperty getOWLDataProperty(IRI iri); + + /** + * Gets an instance of {@link OWLDataProperty} with the same IRI as the + * input. + * + * @param iri The HasIRI instance. + * @return An {@link OWLDataProperty} that has iri.getIRI() as IRI. + */ + default OWLDataProperty getOWLDataProperty(HasIRI iri) { + return getOWLDataProperty(iri.getIRI()); + } + + /** + * Gets an instance of {@link OWLDataProperty} that has the specified + * {@code IRI}. This is the same as + * {@code getOWLDataProperty(IRI.create(iri))}. + * + * @param iri The IRI string. + * @return An {@link OWLDataProperty} that has the specified IRI. + */ + default OWLDataProperty getOWLDataProperty(String iri) { + return getOWLDataProperty(IRI.create(iri)); + } + + /** + * Gets an instance of {@link OWLDataProperty} that has the specified + * {@code IRI}. This is the same as + * {@code getOWLDataProperty(IRI.create(namespace, remainder))}. + * + * @param namespace The IRI namespace. + * @param remainder optional remainder or local name + * @return An {@link OWLDataProperty} that has the specified IRI. + */ + default OWLDataProperty getOWLDataProperty(String namespace, @Nullable String remainder) { + return getOWLDataProperty(IRI.create(namespace, remainder)); + } + + /** + * Gets an OWLDataProperty that has an IRI that is obtained by expanding an + * abbreviated name using an appropriate prefix mapping. See + * The + * OWL 2 Structural Specification for more details. + * + * @param abbreviatedIRI The abbreviated IRI, which is of the form PREFIX_NAME:RC, where + * PREFIX_NAME may be the empty string (the default prefix). Note that abbreviated IRIs always + * contain a colon as a delimiter, even if the prefix name is the empty string. + * @param prefixManager The prefix manager that is responsible for mapping prefix names to + * prefix IRIs. + * @return An OWLDataProperty that has the IRI obtained by expanding the specified abbreviated + * IRI using the specified prefix manager.
For example, suppose "m:Cat" was specified as + * the abbreviated IRI, the prefix manager would be used to obtain the IRI prefix for the "m:" + * prefix name, this prefix would then be concatenated with "Cat" to obtain the full IRI which + * would be the IRI of the OWLDataProperty obtained by this method. + * @throws OWLRuntimeException if the prefix name in the specified abbreviated IRI does not have + * a mapping to a prefix in the specified prefix manager. + */ + default OWLDataProperty getOWLDataProperty(String abbreviatedIRI, PrefixManager prefixManager) { + checkNotNull(abbreviatedIRI, "curi canno be null"); + checkNotNull(prefixManager, "prefixManager cannot be null"); + return getOWLDataProperty(prefixManager.getIRI(abbreviatedIRI)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/DatatypeExpressionProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/DatatypeExpressionProvider.java new file mode 100644 index 0000000000..0e51f421b6 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/DatatypeExpressionProvider.java @@ -0,0 +1,306 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkIterableNotNull; + +import java.util.Arrays; +import java.util.Collection; + +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.vocab.OWLFacet; + +/** + * Datatype expression and facet expression provider. + */ +public interface DatatypeExpressionProvider extends LiteralProvider, OWLVocabularyProvider { + + /** + * OWLDatatypeRestriction see + * specification + * + * @param dataType datatype for the restriction + * @param facetRestrictions facet restrictions. Cannot contain nulls. + * @return an OWLDatatypeRestriction for the specified data type and restrictions + */ + OWLDatatypeRestriction getOWLDatatypeRestriction(OWLDatatype dataType, + Collection facetRestrictions); + + /** + * OWLDatatypeRestriction see + * specification + * + * @param dataType datatype for the restriction + * @param facet facet for restriction + * @param typedLiteral literal for facet. + * @return an OWLDatatypeRestriction with given value for the specified facet + */ + OWLDatatypeRestriction getOWLDatatypeRestriction(OWLDatatype dataType, OWLFacet facet, + OWLLiteral typedLiteral); + + /** + * @param dataType datatype for the restriction + * @param facetRestrictions facet restrictions. Cannot contain nulls. + * @return an OWLDatatypeRestriction for the specified data type and restrictions + */ + default OWLDatatypeRestriction getOWLDatatypeRestriction(OWLDatatype dataType, + OWLFacetRestriction... facetRestrictions) { + checkIterableNotNull(facetRestrictions, "facetRestrictions cannot be null", true); + return getOWLDatatypeRestriction(dataType, Arrays.asList(facetRestrictions)); + } + + /** + * Creates a datatype restriction on xsd:integer with a minInclusive facet restriction + * + * @param minInclusive The value of the min inclusive facet restriction that will be applied to + * the {@code xsd:integer} datatype + * @return An {@code OWLDatatypeRestriction} that restricts the {@code xsd:integer} + * {@link org.semanticweb.owlapi.model.OWLDatatype} with a + * {@link org.semanticweb.owlapi.vocab.OWLFacet#MIN_INCLUSIVE} facet value specified by + * the {@code minInclusive} parameter. + */ + default OWLDatatypeRestriction getOWLDatatypeMinInclusiveRestriction(int minInclusive) { + return getOWLDatatypeRestriction(getIntegerOWLDatatype(), OWLFacet.MIN_INCLUSIVE, + getOWLLiteral(minInclusive)); + } + + /** + * Creates a datatype restriction on xsd:integer with a maxInclusive facet restriction + * + * @param maxInclusive The value of the max inclusive facet restriction that will be applied to + * the {@code xsd:integer} datatype + * @return An {@code OWLDatatypeRestriction} that restricts the {@code xsd:integer} + * {@link org.semanticweb.owlapi.model.OWLDatatype} with a + * {@link org.semanticweb.owlapi.vocab.OWLFacet#MAX_INCLUSIVE} facet value specified by + * the {@code maxInclusive} parameter. + */ + default OWLDatatypeRestriction getOWLDatatypeMaxInclusiveRestriction(double maxInclusive) { + return getOWLDatatypeRestriction(getDoubleOWLDatatype(), OWLFacet.MAX_INCLUSIVE, + getOWLLiteral(maxInclusive)); + } + + /** + * Creates a datatype restriction on xsd:integer with min and max inclusive facet restrictions + * + * @param minInclusive The value of the max inclusive facet restriction that will be applied to + * the {@code xsd:integer} datatype. + * @param maxInclusive The value of the max inclusive facet restriction that will be applied to + * the {@code xsd:integer} datatype + * @return An {@code OWLDatatypeRestriction} that restricts the {@code xsd:integer} + * {@link org.semanticweb.owlapi.model.OWLDatatype} with a + * {@link org.semanticweb.owlapi.vocab.OWLFacet#MIN_INCLUSIVE} facet value specified by + * the {@code minInclusive} parameter and a + * {@link org.semanticweb.owlapi.vocab.OWLFacet#MAX_INCLUSIVE} facet value specified by + * the {@code + * maxInclusive} parameter. + */ + default OWLDatatypeRestriction getOWLDatatypeMinMaxInclusiveRestriction(int minInclusive, + int maxInclusive) { + return getOWLDatatypeRestriction(getIntegerOWLDatatype(), + getOWLFacetRestriction(OWLFacet.MIN_INCLUSIVE, getOWLLiteral(minInclusive)), + getOWLFacetRestriction(OWLFacet.MAX_INCLUSIVE, maxInclusive)); + } + + /** + * Creates a datatype restriction on xsd:integer with a minExclusive facet restriction + * + * @param minExclusive The value of the min exclusive facet restriction that will be applied to + * the {@code xsd:integer} datatype + * @return An {@code OWLDatatypeRestriction} that restricts the {@code xsd:integer} + * {@link org.semanticweb.owlapi.model.OWLDatatype} with a + * {@link org.semanticweb.owlapi.vocab.OWLFacet#MIN_EXCLUSIVE} facet value specified by + * the {@code minExclusive} parameter. + */ + default OWLDatatypeRestriction getOWLDatatypeMinExclusiveRestriction(int minExclusive) { + return getOWLDatatypeRestriction(getIntegerOWLDatatype(), OWLFacet.MIN_EXCLUSIVE, + getOWLLiteral(minExclusive)); + } + + /** + * Creates a datatype restriction on xsd:integer with a maxExclusive facet restriction + * + * @param maxExclusive The value of the max exclusive facet restriction that will be applied to + * the {@code xsd:integer} datatype + * @return An {@code OWLDatatypeRestriction} that restricts the {@code xsd:integer} + * {@link org.semanticweb.owlapi.model.OWLDatatype} with a + * {@link org.semanticweb.owlapi.vocab.OWLFacet#MAX_EXCLUSIVE} facet value specified by + * the {@code maxExclusive} parameter. + */ + default OWLDatatypeRestriction getOWLDatatypeMaxExclusiveRestriction(int maxExclusive) { + return getOWLDatatypeRestriction(getIntegerOWLDatatype(), OWLFacet.MAX_EXCLUSIVE, + getOWLLiteral(maxExclusive)); + } + + /** + * Creates a datatype restriction on xsd:integer with min and max exclusive facet restrictions + * + * @param minExclusive The value of the max exclusive facet restriction that will be applied to + * the {@code xsd:integer} datatype. + * @param maxExclusive The value of the max exclusive facet restriction that will be applied to + * the {@code xsd:integer} datatype + * @return An {@code OWLDatatypeRestriction} that restricts the {@code xsd:integer} + * {@link org.semanticweb.owlapi.model.OWLDatatype} with a + * {@link org.semanticweb.owlapi.vocab.OWLFacet#MIN_EXCLUSIVE} facet value specified by + * the {@code minExclusive} parameter and a + * {@link org.semanticweb.owlapi.vocab.OWLFacet#MAX_EXCLUSIVE} facet value specified by + * the {@code + * maxExclusive} parameter. + */ + default OWLDatatypeRestriction getOWLDatatypeMinMaxExclusiveRestriction(int minExclusive, + int maxExclusive) { + return getOWLDatatypeRestriction(getIntegerOWLDatatype(), + getOWLFacetRestriction(OWLFacet.MIN_EXCLUSIVE, getOWLLiteral(minExclusive)), + getOWLFacetRestriction(OWLFacet.MAX_EXCLUSIVE, maxExclusive)); + } + + /** + * Creates a datatype restriction on xsd:double with a minInclusive facet restriction + * + * @param minInclusive The value of the min inclusive facet restriction that will be applied to + * the {@code xsd:double} datatype + * @return An {@code OWLDatatypeRestriction} that restricts the {@code xsd:double} + * {@link org.semanticweb.owlapi.model.OWLDatatype} with a + * {@link org.semanticweb.owlapi.vocab.OWLFacet#MIN_INCLUSIVE} facet value specified by + * the {@code minInclusive} parameter. + */ + default OWLDatatypeRestriction getOWLDatatypeMinInclusiveRestriction(double minInclusive) { + return getOWLDatatypeRestriction(getDoubleOWLDatatype(), OWLFacet.MIN_INCLUSIVE, + getOWLLiteral(minInclusive)); + } + + /** + * Creates a datatype restriction on xsd:double with min and max inclusive facet restrictions + * + * @param minInclusive The value of the max inclusive facet restriction that will be applied to + * the {@code xsd:double} datatype. + * @param maxInclusive The value of the max inclusive facet restriction that will be applied to + * the {@code xsd:double} datatype + * @return An {@code OWLDatatypeRestriction} that restricts the {@code xsd:double} + * {@link org.semanticweb.owlapi.model.OWLDatatype} with a + * {@link org.semanticweb.owlapi.vocab.OWLFacet#MIN_INCLUSIVE} facet value specified by + * the {@code minInclusive} parameter and a + * {@link org.semanticweb.owlapi.vocab.OWLFacet#MAX_INCLUSIVE} facet value specified by + * the {@code + * maxInclusive} parameter. + */ + default OWLDatatypeRestriction getOWLDatatypeMinMaxInclusiveRestriction(double minInclusive, + double maxInclusive) { + return getOWLDatatypeRestriction(getDoubleOWLDatatype(), + getOWLFacetRestriction(OWLFacet.MIN_INCLUSIVE, getOWLLiteral(minInclusive)), + getOWLFacetRestriction(OWLFacet.MAX_INCLUSIVE, maxInclusive)); + } + + /** + * Creates a datatype restriction on xsd:double with a minExclusive facet restriction + * + * @param minExclusive The value of the min exclusive facet restriction that will be applied to + * the {@code xsd:double} datatype + * @return An {@code OWLDatatypeRestriction} that restricts the {@code xsd:double} + * {@link org.semanticweb.owlapi.model.OWLDatatype} with a + * {@link org.semanticweb.owlapi.vocab.OWLFacet#MIN_EXCLUSIVE} facet value specified by + * the {@code minExclusive} parameter. + */ + default OWLDatatypeRestriction getOWLDatatypeMinExclusiveRestriction(double minExclusive) { + return getOWLDatatypeRestriction(getDoubleOWLDatatype(), OWLFacet.MIN_EXCLUSIVE, + getOWLLiteral(minExclusive)); + } + + /** + * Creates a datatype restriction on xsd:integer with a maxInclusive facet restriction + * + * @param maxInclusive The value of the max inclusive facet restriction that will be applied to + * the {@code xsd:integer} datatype + * @return An {@code OWLDatatypeRestriction} that restricts the {@code xsd:integer} + * {@link org.semanticweb.owlapi.model.OWLDatatype} with a + * {@link org.semanticweb.owlapi.vocab.OWLFacet#MAX_INCLUSIVE} facet value specified by + * the {@code maxInclusive} parameter. + */ + default OWLDatatypeRestriction getOWLDatatypeMaxInclusiveRestriction(int maxInclusive) { + return getOWLDatatypeRestriction(getIntegerOWLDatatype(), OWLFacet.MAX_INCLUSIVE, + getOWLLiteral(maxInclusive)); + } + + /** + * Creates a datatype restriction on xsd:double with a maxExclusive facet restriction + * + * @param maxExclusive The value of the max exclusive facet restriction that will be applied to + * the {@code xsd:double} datatype + * @return An {@code OWLDatatypeRestriction} that restricts the {@code xsd:double} + * {@link org.semanticweb.owlapi.model.OWLDatatype} with a + * {@link org.semanticweb.owlapi.vocab.OWLFacet#MAX_EXCLUSIVE} facet value specified by + * the {@code maxExclusive} parameter. + */ + default OWLDatatypeRestriction getOWLDatatypeMaxExclusiveRestriction(double maxExclusive) { + return getOWLDatatypeRestriction(getDoubleOWLDatatype(), OWLFacet.MAX_EXCLUSIVE, + getOWLLiteral(maxExclusive)); + } + + /** + * Creates a datatype restriction on xsd:double with min and max exclusive facet restrictions + * + * @param minExclusive The value of the max exclusive facet restriction that will be applied to + * the {@code xsd:double} datatype. + * @param maxExclusive The value of the max exclusive facet restriction that will be applied to + * the {@code xsd:double} datatype + * @return An {@code OWLDatatypeRestriction} that restricts the {@code xsd:double} + * {@link org.semanticweb.owlapi.model.OWLDatatype} with a + * {@link org.semanticweb.owlapi.vocab.OWLFacet#MIN_EXCLUSIVE} facet value specified by + * the {@code minExclusive} parameter and a + * {@link org.semanticweb.owlapi.vocab.OWLFacet#MAX_EXCLUSIVE} facet value specified by + * the {@code + * maxExclusive} parameter. + */ + default OWLDatatypeRestriction getOWLDatatypeMinMaxExclusiveRestriction(double minExclusive, + double maxExclusive) { + return getOWLDatatypeRestriction(getDoubleOWLDatatype(), + getOWLFacetRestriction(OWLFacet.MIN_EXCLUSIVE, getOWLLiteral(minExclusive)), + getOWLFacetRestriction(OWLFacet.MAX_EXCLUSIVE, maxExclusive)); + } + + /** + * @param facet facet for restriction. + * @param facetValue literal for restriction. + * @return an OWLFacetRestriction on specified facet and value + */ + OWLFacetRestriction getOWLFacetRestriction(OWLFacet facet, OWLLiteral facetValue); + + /** + * @param facet facet for restriction. + * @param facetValue facet value + * @return an OWLFacetRestriction on specified facet and value + */ + default OWLFacetRestriction getOWLFacetRestriction(OWLFacet facet, int facetValue) { + return getOWLFacetRestriction(facet, getOWLLiteral(facetValue)); + } + + /** + * @param facet facet for restriction + * @param facetValue facet value. + * @return an OWLFacetRestriction on specified facet and value + */ + default OWLFacetRestriction getOWLFacetRestriction(OWLFacet facet, double facetValue) { + return getOWLFacetRestriction(facet, getOWLLiteral(facetValue)); + } + + /** + * @param facet facet for restriction + * @param facetValue facet value. + * @return an OWLFacetRestriction on specified facet and value + */ + default OWLFacetRestriction getOWLFacetRestriction(OWLFacet facet, float facetValue) { + return getOWLFacetRestriction(facet, getOWLLiteral(facetValue)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/DatatypeProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/DatatypeProvider.java new file mode 100644 index 0000000000..d5ce9737a7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/DatatypeProvider.java @@ -0,0 +1,99 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.io.Serializable; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.model.PrefixManager; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 5.0.0 + */ +@FunctionalInterface +public interface DatatypeProvider extends Serializable { + + /** + * Gets an instance of {@link OWLDatatype} that has the specified + * {@code IRI}. + * + * @param iri The IRI. + * @return An {@link OWLDatatype} that has the specified IRI. + */ + OWLDatatype getOWLDatatype(IRI iri); + + /** + * Gets an instance of {@link OWLDatatype} with the same IRI as the input. + * + * @param iri The HasIRI instance. + * @return An {@link OWLDatatype} that has iri.getIRI() as IRI. + */ + default OWLDatatype getOWLDatatype(HasIRI iri) { + return getOWLDatatype(iri.getIRI()); + } + + /** + * Gets an instance of {@link OWLDatatype} that has the specified + * {@code IRI}. This is the same as {@code getOWLDatatype(IRI.create(iri)}. + * + * @param iri The IRI. + * @return An {@link OWLDatatype} that has the specified IRI. + */ + default OWLDatatype getOWLDatatype(String iri) { + return getOWLDatatype(IRI.create(iri)); + } + + /** + * Gets an instance of {@link OWLDatatype} that has the specified + * {@code IRI}. This is the same as + * {@code getOWLDatatype(IRI.create(namespace, remainder)} + * + * @param namespace The IRI namespace. + * @param remainder optional reminder or local name + * @return An {@link OWLDatatype} that has the specified IRI. + */ + default OWLDatatype getOWLDatatype(String namespace, @Nullable String remainder) { + return getOWLDatatype(IRI.create(namespace, remainder)); + } + + /** + * Gets an OWLDatatype that has an IRI that is obtained by expanding an + * abbreviated name using an appropriate prefix mapping. See + * The + * OWL 2 Structural Specification for more details. + * + * @param abbreviatedIRI The abbreviated IRI, which is of the form PREFIX_NAME:RC, where + * PREFIX_NAME may be the empty string (the default prefix). Note that abbreviated IRIs always + * contain a colon as a delimiter, even if the prefix name is the empty string. + * @param prefixManager The prefix manager that is responsible for mapping prefix names to + * prefix IRIs. + * @return An OWLDatatype that has the IRI obtained by expanding the specified abbreviated IRI + * using the specified prefix manager.
For example, suppose "m:Cat" was specified as the + * abbreviated IRI, the prefix manager would be used to obtain the IRI prefix for the "m:" + * prefix name, this prefix would then be concatenated with "Cat" to obtain the full IRI which + * would be the IRI of the OWLDatatype obtained by this method. + * @throws OWLRuntimeException if the prefix name in the specified abbreviated IRI does not have + * a mapping to a prefix in the specified prefix manager. + */ + default OWLDatatype getOWLDatatype(String abbreviatedIRI, PrefixManager prefixManager) { + checkNotNull(abbreviatedIRI, "abbreviatedIRI cannot be null"); + checkNotNull(prefixManager, "prefixManager cannot be null"); + return getOWLDatatype(prefixManager.getIRI(abbreviatedIRI)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/EntityByTypeProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/EntityByTypeProvider.java new file mode 100644 index 0000000000..6ca62d0641 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/EntityByTypeProvider.java @@ -0,0 +1,35 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import org.semanticweb.owlapi.model.EntityType; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLEntity; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +@FunctionalInterface +public interface EntityByTypeProvider { + + /** + * Gets an entity that has the specified IRI and is of the specified type. + * + * @param entityType The type of the entity that will be returned. + * @param iri The IRI of the entity that will be returned. + * @param type class + * @return An entity that has the same IRI as this entity and is of the specified type. + */ + E getOWLEntity(EntityType entityType, IRI iri); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/EntityProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/EntityProvider.java new file mode 100644 index 0000000000..f823c59aab --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/EntityProvider.java @@ -0,0 +1,24 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +public interface EntityProvider extends ClassProvider, + ObjectPropertyProvider, DataPropertyProvider, + NamedIndividualProvider, DatatypeProvider, + AnnotationPropertyProvider { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/ExistentialProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/ExistentialProvider.java new file mode 100644 index 0000000000..d1586ef6ad --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/ExistentialProvider.java @@ -0,0 +1,60 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * Existential provider interface. + */ +public interface ExistentialProvider { + + /** + * Gets an OWLDataSomeValuesFrom restriction + * + * @param property The property that the restriction acts along. + * @param dataRange The data range that is the filler. + * @return An OWLDataSomeValuesFrom restriction that acts along the specified property and has + * the specified filler + */ + OWLDataSomeValuesFrom getOWLDataSomeValuesFrom(OWLDataPropertyExpression property, + OWLDataRange dataRange); + + /** + * Gets an OWLDataSomeValuesFrom restriction + * + * @param property The property that the restriction acts along. + * @param dataRange The data range that is the filler. + * @return An OWLDataSomeValuesFrom restriction that acts along the specified property and has + * the specified filler + */ + OWLDataSomeValuesFrom getOWLDataSomeValuesFrom(OWLDataPropertyExpression property, + OWL2Datatype dataRange); + + /** + * Gets an OWLObjectSomeValuesFrom restriction + * + * @param property The object property that the restriction acts along. + * @param classExpression The class expression that is the filler. + * @return An OWLObjectSomeValuesFrom restriction along the specified property with the + * specified filler + */ + OWLObjectSomeValuesFrom getOWLObjectSomeValuesFrom(OWLObjectPropertyExpression property, + OWLClassExpression classExpression); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/HasSelfProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/HasSelfProvider.java new file mode 100644 index 0000000000..bb24f7b17f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/HasSelfProvider.java @@ -0,0 +1,29 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; + +/** + * Object has self restriction provider. + */ +@FunctionalInterface +public interface HasSelfProvider { + + /** + * @param property The property that the restriction acts along. + * @return a ObjectHasSelf class expression on the specified property + */ + OWLObjectHasSelf getOWLObjectHasSelf(OWLObjectPropertyExpression property); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/HasValueProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/HasValueProvider.java new file mode 100644 index 0000000000..751d2ad64d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/HasValueProvider.java @@ -0,0 +1,41 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; + +/** + * Object and datatype hasvalue provider. + */ +public interface HasValueProvider { + + /** + * @param property The property that the restriction acts along. + * @param value value for restriction + * @return a HasValue restriction with specified property and value + */ + OWLDataHasValue getOWLDataHasValue(OWLDataPropertyExpression property, OWLLiteral value); + + /** + * @param property The property that the restriction acts along. + * @param individual individual for restriction + * @return a HasValue restriction with specified property and value + */ + OWLObjectHasValue getOWLObjectHasValue(OWLObjectPropertyExpression property, + OWLIndividual individual); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/IndividualAssertionProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/IndividualAssertionProvider.java new file mode 100644 index 0000000000..6fda22ad2a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/IndividualAssertionProvider.java @@ -0,0 +1,104 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkIterableNotNull; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; + +/** + * Individual (sameAs and differentFrom) assertion provider. + */ +public interface IndividualAssertionProvider extends LiteralProvider { + + /** + * @param individuals Cannot be null or contain nulls. + * @return a same individuals axiom with specified individuals + */ + default OWLSameIndividualAxiom getOWLSameIndividualAxiom( + Collection individuals) { + return getOWLSameIndividualAxiom(individuals, Collections.emptySet()); + } + + /** + * @param individual individual + * @return a same individuals axiom with specified individuals + */ + default OWLSameIndividualAxiom getOWLSameIndividualAxiom(OWLIndividual... individual) { + checkIterableNotNull(individual, "individuals cannot be null", true); + return getOWLSameIndividualAxiom(Arrays.asList(individual)); + } + + /** + * @param individuals Cannot be null or contain nulls. + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a same individuals axiom with specified individuals and annotations + */ + OWLSameIndividualAxiom getOWLSameIndividualAxiom( + Collection individuals, Collection annotations); + + /** + * @param i same individual + * @param j same individual + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a same individuals axiom with specified individuals and annotations + */ + default OWLSameIndividualAxiom getOWLSameIndividualAxiom(OWLIndividual i, OWLIndividual j, + Collection annotations) { + return getOWLSameIndividualAxiom(Arrays.asList(i, j), annotations); + } + + /** + * @param individuals Cannot be null or contain nulls. + * @return a different individuals axiom with specified individuals + */ + default OWLDifferentIndividualsAxiom getOWLDifferentIndividualsAxiom( + Collection individuals) { + return getOWLDifferentIndividualsAxiom(individuals, Collections.emptySet()); + } + + /** + * @param individuals Cannot be null or contain nulls. + * @return a different individuals axiom with specified individuals + */ + default OWLDifferentIndividualsAxiom getOWLDifferentIndividualsAxiom( + OWLIndividual... individuals) { + checkIterableNotNull(individuals, "individuals cannot be null", true); + return getOWLDifferentIndividualsAxiom(Arrays.asList(individuals)); + } + + /** + * @param individuals Cannot be null or contain nulls. + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a different individuals axiom with specified individuals and annotations + */ + OWLDifferentIndividualsAxiom getOWLDifferentIndividualsAxiom( + Collection individuals, Collection annotations); + + /** + * @param i different individual + * @param j different individual + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a different individuals axiom with specified individuals and annotations + */ + default OWLDifferentIndividualsAxiom getOWLDifferentIndividualsAxiom(OWLIndividual i, + OWLIndividual j, Collection annotations) { + return getOWLDifferentIndividualsAxiom(Arrays.asList(i, j), annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/IntersectionProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/IntersectionProvider.java new file mode 100644 index 0000000000..d99a1faf8e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/IntersectionProvider.java @@ -0,0 +1,80 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkIterableNotNull; + +import java.util.Arrays; +import java.util.Collection; +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataIntersectionOf; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.util.CollectionFactory; + +/** + * Object and datatype intersection provider. + */ +public interface IntersectionProvider { + + /** + * @param dataRanges data ranges for intersection. Cannot be null or contain nulls. + * @return an OWLDataIntersectionOf on the specified dataranges + */ + default OWLDataIntersectionOf getOWLDataIntersectionOf( + Collection dataRanges) { + checkIterableNotNull(dataRanges, "dataRanges cannot be null", true); + return getOWLDataIntersectionOf(dataRanges.stream()); + } + + /** + * @param dataRanges data ranges for intersection. Cannot be null or contain nulls. + * @return an OWLDataIntersectionOf on the specified dataranges + */ + OWLDataIntersectionOf getOWLDataIntersectionOf(Stream dataRanges); + + /** + * @param dataRanges data ranges for intersection. Cannot be null or contain nulls. + * @return an OWLDataIntersectionOf on the specified dataranges + */ + default OWLDataIntersectionOf getOWLDataIntersectionOf(OWLDataRange... dataRanges) { + checkIterableNotNull(dataRanges, "dataRange cannot be nulls", true); + return getOWLDataIntersectionOf(Arrays.asList(dataRanges)); + } + + /** + * @param operands class expressions for intersection. Cannot be null or contain nulls. + * @return an OWLObjectIntersectionOf on the specified operands + */ + OWLObjectIntersectionOf getOWLObjectIntersectionOf( + Stream operands); + + /** + * @param operands class expressions for intersection. Cannot be null or contain nulls. + * @return an OWLObjectIntersectionOf on the specified operands + */ + default OWLObjectIntersectionOf getOWLObjectIntersectionOf( + Collection operands) { + return getOWLObjectIntersectionOf(operands.stream()); + } + + /** + * @param operands class expressions for intersection. Cannot be null or contain nulls. + * @return an OWLObjectIntersectionOf on the specified operands + */ + default OWLObjectIntersectionOf getOWLObjectIntersectionOf(OWLClassExpression... operands) { + checkIterableNotNull(operands, "operands cannot be null", true); + return getOWLObjectIntersectionOf(CollectionFactory.createList(operands)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/InverseProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/InverseProvider.java new file mode 100644 index 0000000000..45822a09d5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/InverseProvider.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import org.semanticweb.owlapi.model.OWLObjectInverseOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; + +/** + * Inverse object provider. + */ +@FunctionalInterface +public interface InverseProvider { + + /** + * Gets the inverse of an object property. + * + * @param property The property of which the inverse will be returned + * @return The inverse of the specified object property + */ + OWLObjectInverseOf getOWLObjectInverseOf(OWLObjectProperty property); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/LiteralProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/LiteralProvider.java new file mode 100644 index 0000000000..394665dbf7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/LiteralProvider.java @@ -0,0 +1,122 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * Provider for OWLLiteral construction. + */ +public interface LiteralProvider extends DatatypeProvider { + + // Literals + + /** + * Gets an {@code OWLLiteral}, which has the specified lexical value, and is typed with the + * specified datatype. + * + * @param lexicalValue The lexical value. + * @param datatype The datatype. + * @return An OWLLiteral with the specified lexical value and specified datatype. If the + * datatype is {@code rdf:PlainLiteral}, and the lexical value contains a language tag + * then the language tag will be parsed out of the lexical value. For example, + * "abc@en"^^rdf:PlainLiteral would be parsed into a lexical value of "abc" and a + * language tag of "en". + */ + OWLLiteral getOWLLiteral(String lexicalValue, OWLDatatype datatype); + + /** + * Gets an {@code OWLLiteral}, which has the specified lexical value, and is typed with the + * specified datatype. + * + * @param lexicalValue The lexical value. + * @param datatype The datatype. + * @return An OWLLiteral with the specified lexical value and specified datatype. If the + * datatype is {@code rdf:PlainLiteral}, and the lexical value contains a language tag + * then the language tag will be parsed out of the lexical value. For example, + * "abc@en"^^rdf:PlainLiteral would be parsed into a lexical value of "abc" and a + * language tag of "en". + */ + default OWLLiteral getOWLLiteral(String lexicalValue, OWL2Datatype datatype) { + checkNotNull(datatype, "datatype cannot be null"); + return getOWLLiteral(lexicalValue, getOWLDatatype(datatype)); + } + + /** + * Convenience method that obtains a literal typed as an integer. + * + * @param value The value of the literal + * @return An {@code OWLLiteral} whose literal is the lexical value of the integer, and whose + * data type is xsd:integer. + */ + OWLLiteral getOWLLiteral(int value); + + /** + * Convenience method that obtains a literal typed as a double. + * + * @param value The value of the literal + * @return An {@code OWLLiteral} whose literal is the lexical value of the double, and whose + * data type is xsd:double. + */ + OWLLiteral getOWLLiteral(double value); + + /** + * Convenience method that obtains a literal typed as a boolean. + * + * @param value The value of the literal + * @return An {@code OWLLiteral} whose literal is the lexical value of the boolean, and whose + * data type is xsd:boolean. + */ + OWLLiteral getOWLLiteral(boolean value); + + /** + * Convenience method that obtains a literal typed as a float. + * + * @param value The value of the literal + * @return An {@code OWLLiteral} whose literal is the lexical value of the float, and whose data + * type is xsd:float. + */ + OWLLiteral getOWLLiteral(float value); + + /** + * Gets a literal that has the specified lexical value, and has the datatype xsd:string. The + * literal will not have a language tag. + * + * @param value The lexical value of the literal. + * @return A literal (without a language tag) that has a datatype of xsd:string. + */ + OWLLiteral getOWLLiteral(String value); + + /** + * Gets an OWLLiteral with a language tag. The datatype of this literal will have an IRI of + * rdf:PlainLiteral ( {@link org.semanticweb.owlapi.vocab.OWLRDFVocabulary#RDF_PLAIN_LITERAL}). + * + * @param literal The string literal. + * @param lang The language tag. The empty string may be specified to indicate an empty language + * tag. Leading and trailing white space will be removed from the tag and the tag will be + * normalised to LOWER CASE. If {@code lang} is {@code null} then {@code lang} will be + * converted to the empty string (for backwards compatibility). If not empty, the tag is + * formed according to BCP47 + * but the OWL API will not check that the tag conforms to this specification - it is up + * to the caller to ensure this. + * @return The OWLLiteral that represents the string literal with a (possibly empty) language + * tag. + */ + OWLLiteral getOWLLiteral(String literal, @Nullable String lang); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/NamedIndividualProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/NamedIndividualProvider.java new file mode 100644 index 0000000000..2c6fb7ecef --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/NamedIndividualProvider.java @@ -0,0 +1,102 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.io.Serializable; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.model.PrefixManager; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +@FunctionalInterface +public interface NamedIndividualProvider extends Serializable { + + /** + * Gets an instance of {@link OWLNamedIndividual} that has the specified + * {@code IRI}. + * + * @param iri The IRI. + * @return An {@link OWLNamedIndividual} that has the specified IRI. + */ + OWLNamedIndividual getOWLNamedIndividual(IRI iri); + + /** + * Gets an instance of {@link OWLNamedIndividual} with the same IRI as the + * input. + * + * @param iri The HasIRI instance. + * @return An {@link OWLNamedIndividual} that has iri.getIRI() as IRI. + */ + default OWLNamedIndividual getOWLNamedIndividual(HasIRI iri) { + return getOWLNamedIndividual(iri.getIRI()); + } + + /** + * Gets an instance of {@link OWLNamedIndividual} that has the specified + * {@code IRI}. This is the same as + * {@code getOWLNamedIndividual(IRI.create(iri))}. + * + * @param iri The IRI string. + * @return An {@link OWLNamedIndividual} that has the specified IRI. + */ + default OWLNamedIndividual getOWLNamedIndividual(String iri) { + return getOWLNamedIndividual(IRI.create(iri)); + } + + /** + * Gets an instance of {@link OWLNamedIndividual} that has the specified + * {@code IRI}. This is the same as + * {@code getOWLNamedIndividual(IRI.create(namespace, remainder))}. + * + * @param namespace The IRI namespace. + * @param remainder optional remainder or local name + * @return An {@link OWLNamedIndividual} that has the specified IRI. + */ + default OWLNamedIndividual getOWLNamedIndividual(String namespace, @Nullable String remainder) { + return getOWLNamedIndividual(IRI.create(namespace, remainder)); + } + + /** + * Gets an OWLNamedIndividual that has an IRI that is obtained by expanding + * an abbreviated name using an appropriate prefix mapping. See + * The + * OWL 2 Structural Specification for more details. + * + * @param abbreviatedIRI The abbreviated IRI, which is of the form PREFIX_NAME:RC, where + * PREFIX_NAME may be the empty string (the default prefix). Note that abbreviated IRIs always + * contain a colon as a delimiter, even if the prefix name is the empty string. + * @param prefixManager The prefix manager that is responsible for mapping prefix names to + * prefix IRIs. + * @return An OWLNamedIndividual that has the IRI obtained by expanding the specified + * abbreviated IRI using the specified prefix manager.
For example, suppose "m:Cat" was + * specified as the abbreviated IRI, the prefix manager would be used to obtain the IRI prefix + * for the "m:" prefix name, this prefix would then be concatenated with "Cat" to obtain the + * full IRI which would be the IRI of the OWLNamedIndividual obtained by this method. + * @throws OWLRuntimeException if the prefix name in the specified abbreviated IRI does not have + * a mapping to a prefix in the specified prefix manager. + */ + default OWLNamedIndividual getOWLNamedIndividual(String abbreviatedIRI, + PrefixManager prefixManager) { + checkNotNull(abbreviatedIRI, "curi canno be null"); + checkNotNull(prefixManager, "prefixManager cannot be null"); + return getOWLNamedIndividual(prefixManager.getIRI(abbreviatedIRI)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/NominalProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/NominalProvider.java new file mode 100644 index 0000000000..872b85895c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/NominalProvider.java @@ -0,0 +1,87 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkIterableNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.Collection; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObjectOneOf; + +/** + * Nominal provider interface. + */ +public interface NominalProvider { + + /** + * Gets an OWLDataOneOf + * + * @param values The set of values that the data one of should contain. + * @return A data one of that enumerates the specified set of values + */ + OWLDataOneOf getOWLDataOneOf(Stream values); + + /** + * Gets an OWLDataOneOf + * + * @param values The set of values that the data one of should contain. + * @return A data one of that enumerates the specified set of values + */ + default OWLDataOneOf getOWLDataOneOf(Collection values) { + checkIterableNotNull(values, "values cannot be null or contain null or empty", false); + return getOWLDataOneOf(values.stream()); + } + + /** + * Gets an OWLDataOneOf + * + * @param values The set of values that the data one of should contain. Cannot be null or + * contain null values. + * @return A data one of that enumerates the specified set of values + */ + default OWLDataOneOf getOWLDataOneOf(OWLLiteral... values) { + checkIterableNotNull(values, "values cannot be null", true); + return getOWLDataOneOf(Stream.of(values)); + } + + /** + * @param values individuals for restriction. Cannot be null or contain nulls. + * @return a OneOf expression on specified individuals + */ + OWLObjectOneOf getOWLObjectOneOf(Stream values); + + /** + * @param values individuals for restriction. Cannot be null or contain nulls. + * @return a OneOf expression on specified individuals + */ + default OWLObjectOneOf getOWLObjectOneOf(Collection values) { + return getOWLObjectOneOf(checkNotNull(values, "values cannot be null").stream()); + } + + /** + * @param individuals individuals for restriction. Cannot be null or contain nulls. + * @return a OneOf expression on specified individuals + */ + default OWLObjectOneOf getOWLObjectOneOf(OWLIndividual... individuals) { + checkNotNull(individuals, "individuals cannot be null"); + return getOWLObjectOneOf(Stream.of(individuals)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/OWLVocabularyProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/OWLVocabularyProvider.java new file mode 100644 index 0000000000..155ff16afe --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/OWLVocabularyProvider.java @@ -0,0 +1,186 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLObjectProperty; + +/** + * Utility shortcuts for OWL basic entities. For the sake of convenience, this + * also includes RDF/RDFS and XSD entities. + */ +public interface OWLVocabularyProvider { + + // Entities and data stuff + + /** + * Gets the built in owl:Thing class, which has a URI of + * <http://www.w3.org/2002/07/owl#Thing> + * + * @return The OWL Class corresponding to owl:Thing + */ + OWLClass getOWLThing(); + + /** + * Gets the built in owl:Nothing class, which has a URI of + * <http://www.w3.org/2002/07/owl#Nothing> + * + * @return The OWL Class corresponding to owl:Nothing + */ + OWLClass getOWLNothing(); + + /** + * @return the built in top object property + */ + OWLObjectProperty getOWLTopObjectProperty(); + + /** + * @return the built in top data property + */ + OWLDataProperty getOWLTopDataProperty(); + + /** + * @return The OWL Datatype corresponding to the top data type (rdfs:Literal, with a URI of + * $lt;http://www.w3.org/2000/01/rdf-schema#>). + */ + OWLDatatype getTopDatatype(); + + /** + * @return the built in bottom object property + */ + OWLObjectProperty getOWLBottomObjectProperty(); + + /** + * @return the built in bottom data property + */ + OWLDataProperty getOWLBottomDataProperty(); + + /** + * Gets an annotation property that has an IRI corresponding to + * {@code rdfs:label}. + * + * @return An annotation property with an IRI of {@code rdfs:label}. + */ + OWLAnnotationProperty getRDFSLabel(); + + /** + * Gets an annotation property that has an IRI corresponding to + * {@code rdfs:comment}. + * + * @return An annotation property with an IRI of {@code rdfs:comment}. + */ + OWLAnnotationProperty getRDFSComment(); + + /** + * Gets an annotation property that has an IRI corresponding to + * {@code rdfs:seeAlso}. + * + * @return An annotation property with an IRI of {@code rdfs:seeAlso}. + */ + OWLAnnotationProperty getRDFSSeeAlso(); + + /** + * Gets an annotation property that has an IRI corresponding to + * {@code rdfs:isDefinedBy}. + * + * @return An annotation property with an IRI of {@code rdfs:isDefinedBy}. + */ + OWLAnnotationProperty getRDFSIsDefinedBy(); + + /** + * Gets an annotation property that has an IRI corresponding to + * {@code owl:versionInfo}. + * + * @return An annotation property with an IRI of {@code owl:versionInfo}. + */ + OWLAnnotationProperty getOWLVersionInfo(); + + /** + * Gets an annotation property that has an IRI corresponding to + * {@code owl:backwardCompatibleWith}. + * + * @return An annotation property with an IRI of {@code owl:backwardCompatibleWith}. + */ + OWLAnnotationProperty getOWLBackwardCompatibleWith(); + + /** + * Gets an annotation property that has an IRI corresponding to + * {@code owl:incompatibleWith}. + * + * @return An annotation property with an IRI of {@code owl:incompatibleWith}. + */ + OWLAnnotationProperty getOWLIncompatibleWith(); + + /** + * Gets an annotation property that has an IRI corresponding to + * {@code owl:backwardCompatibleWith}. + * + * @return An annotation property with an IRI of {@code owl:backwardCompatibleWith}. + */ + OWLAnnotationProperty getOWLDeprecated(); + + /** + * Gets the rdf:PlainLiteral datatype. + * + * @return The datatype with an IRI of {@code rdf:PlainLiteral} + */ + OWLDatatype getRDFPlainLiteral(); + + /** + * A convenience method that obtains the datatype that represents integers. + * This datatype will have the URI of + * <http://www.w3.org/2001/XMLSchema#integer> + * + * @return An object representing an integer datatype. + */ + OWLDatatype getIntegerOWLDatatype(); + + /** + * A convenience method that obtains the datatype that represents floats. + * This datatype will have the URI of + * <http://www.w3.org/2001/XMLSchema#float> + * + * @return An object representing the float datatype. + */ + OWLDatatype getFloatOWLDatatype(); + + /** + * A convenience method that obtains the datatype that represents doubles. + * This datatype will have the URI of + * <http://www.w3.org/2001/XMLSchema#double> + * + * @return An object representing a double datatype. + */ + OWLDatatype getDoubleOWLDatatype(); + + /** + * A convenience method that obtains the datatype that represents the + * boolean datatype. This datatype will have the URI of + * <http://www.w3.org/2001/XMLSchema#boolean> + * + * @return An object representing the boolean datatype. + */ + OWLDatatype getBooleanOWLDatatype(); + + /** + * A convenience method that obtains the datatype that represents the string + * datatype. This datatype will have the URI of + * <http://www.w3.org/2001/XMLSchema#string> + * + * @return An object representing the string datatype. + */ + OWLDatatype getStringOWLDatatype(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/ObjectAssertionProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/ObjectAssertionProvider.java new file mode 100644 index 0000000000..c736e37fc2 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/ObjectAssertionProvider.java @@ -0,0 +1,74 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import java.util.Collection; +import java.util.Collections; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; + +/** + * Object property assertion provider. + */ +public interface ObjectAssertionProvider extends LiteralProvider { + + /** + * @param property property + * @param individual individual + * @param object object + * @return an object property assertion + */ + default OWLObjectPropertyAssertionAxiom getOWLObjectPropertyAssertionAxiom( + OWLObjectPropertyExpression property, + OWLIndividual individual, OWLIndividual object) { + return getOWLObjectPropertyAssertionAxiom(property, individual, object, + Collections.emptySet()); + } + + /** + * @param property property + * @param individual individual + * @param object object + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return an object property assertion with annotations + */ + OWLObjectPropertyAssertionAxiom getOWLObjectPropertyAssertionAxiom( + OWLObjectPropertyExpression property, + OWLIndividual individual, OWLIndividual object, Collection annotations); + + /** + * @param property property + * @param subject subject + * @param object object + * @return a negative property assertion axiom on given arguments + */ + default OWLNegativeObjectPropertyAssertionAxiom getOWLNegativeObjectPropertyAssertionAxiom( + OWLObjectPropertyExpression property, OWLIndividual subject, OWLIndividual object) { + return getOWLNegativeObjectPropertyAssertionAxiom(property, subject, object, + Collections.emptySet()); + } + + /** + * @param property property + * @param subject subject + * @param object object + * @param annotations A set of annotations. Cannot be null or contain nulls. + * @return a negative property assertion axiom on given arguments with annotations + */ + OWLNegativeObjectPropertyAssertionAxiom getOWLNegativeObjectPropertyAssertionAxiom( + OWLObjectPropertyExpression property, OWLIndividual subject, OWLIndividual object, + Collection annotations); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/ObjectPropertyProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/ObjectPropertyProvider.java new file mode 100644 index 0000000000..8c8db7735f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/ObjectPropertyProvider.java @@ -0,0 +1,102 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.io.Serializable; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.model.PrefixManager; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + */ +@FunctionalInterface +public interface ObjectPropertyProvider extends Serializable { + + /** + * Gets an instance of {@link OWLObjectProperty} that has the specified + * {@code IRI}. + * + * @param iri The IRI. + * @return An {@link OWLObjectProperty} that has the specified IRI. + */ + OWLObjectProperty getOWLObjectProperty(IRI iri); + + /** + * Gets an instance of {@link OWLObjectProperty} with the same IRI as the + * input. + * + * @param iri The HasIRI instance. + * @return An {@link OWLObjectProperty} that has iri.getIRI() as IRI. + */ + default OWLObjectProperty getOWLObjectProperty(HasIRI iri) { + return getOWLObjectProperty(iri.getIRI()); + } + + /** + * Gets an instance of {@link OWLObjectProperty} that has the specified + * {@code IRI}. This is the same as + * {@code getOWLObjectProperty(IRI.create(iri))}. + * + * @param iri The IRI string. + * @return An {@link OWLObjectProperty} that has the specified IRI. + */ + default OWLObjectProperty getOWLObjectProperty(String iri) { + return getOWLObjectProperty(IRI.create(iri)); + } + + /** + * Gets an instance of {@link OWLObjectProperty} that has the specified + * {@code IRI}. This is the same as + * {@code getOWLObjectProperty(IRI.create(namespace, remainder))}. + * + * @param namespace The IRI namespace + * @param remainder optional remainder or local name + * @return An {@link OWLObjectProperty} that has the specified IRI. + */ + default OWLObjectProperty getOWLObjectProperty(String namespace, @Nullable String remainder) { + return getOWLObjectProperty(IRI.create(namespace, remainder)); + } + + /** + * Gets an OWLObjectProperty that has an IRI that is obtained by expanding + * an abbreviated name using an appropriate prefix mapping. See + * The + * OWL 2 Structural Specification for more details. + * + * @param abbreviatedIRI The abbreviated IRI, which is of the form PREFIX_NAME:RC, where + * PREFIX_NAME may be the empty string (the default prefix). Note that abbreviated IRIs always + * contain a colon as a delimiter, even if the prefix name is the empty string. + * @param prefixManager The prefix manager that is responsible for mapping prefix names to + * prefix IRIs. + * @return An OWLObjectProperty that has the IRI obtained by expanding the specified abbreviated + * IRI using the specified prefix manager.
For example, suppose "m:Cat" was specified as + * the abbreviated IRI, the prefix manager would be used to obtain the IRI prefix for the "m:" + * prefix name, this prefix would then be concatenated with "Cat" to obtain the full IRI which + * would be the IRI of the OWLObjectProperty obtained by this method. + * @throws OWLRuntimeException if the prefix name in the specified abbreviated IRI does not have + * a mapping to a prefix in the specified prefix manager. + */ + default OWLObjectProperty getOWLObjectProperty(String abbreviatedIRI, + PrefixManager prefixManager) { + checkNotNull(abbreviatedIRI, "curi canno be null"); + checkNotNull(prefixManager, "prefixManager cannot be null"); + return getOWLObjectProperty(prefixManager.getIRI(abbreviatedIRI)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/SWRLProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/SWRLProvider.java new file mode 100644 index 0000000000..b6ad057217 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/SWRLProvider.java @@ -0,0 +1,212 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import java.util.Collection; +import java.util.List; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.SWRLAtom; +import org.semanticweb.owlapi.model.SWRLBuiltInAtom; +import org.semanticweb.owlapi.model.SWRLClassAtom; +import org.semanticweb.owlapi.model.SWRLDArgument; +import org.semanticweb.owlapi.model.SWRLDataPropertyAtom; +import org.semanticweb.owlapi.model.SWRLDataRangeAtom; +import org.semanticweb.owlapi.model.SWRLDifferentIndividualsAtom; +import org.semanticweb.owlapi.model.SWRLIArgument; +import org.semanticweb.owlapi.model.SWRLIndividualArgument; +import org.semanticweb.owlapi.model.SWRLLiteralArgument; +import org.semanticweb.owlapi.model.SWRLObjectPropertyAtom; +import org.semanticweb.owlapi.model.SWRLRule; +import org.semanticweb.owlapi.model.SWRLSameIndividualAtom; +import org.semanticweb.owlapi.model.SWRLVariable; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * An interface to a factory that can create SWRL objects. + * + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public interface SWRLProvider { + + /** + * Gets an anonymous SWRL Rule. + * + * @param body The atoms that make up the body + * @param head The atoms that make up the head + * @return An anonymous rule with the specified body and head + */ + SWRLRule getSWRLRule(Collection body, Collection head); + + /** + * Gets an anonymous SWRL Rule. + * + * @param body The atoms that make up the body + * @param head The atoms that make up the head + * @param annotations The annotations for the rule (may be an empty set) + * @return An anonymous rule with the specified body and head + */ + SWRLRule getSWRLRule(Collection body, Collection head, + Collection annotations); + + /** + * Gets a SWRL atom where the predicate is a class expression i.e. C(x) where C is a class + * expression and x is either an individual or a variable for an individual + * + * @param predicate The class expression that represents the predicate of the atom + * @param arg The argument (x) + * @return The class atom with the specified class expression predicate and the specified + * argument. + */ + SWRLClassAtom getSWRLClassAtom(OWLClassExpression predicate, SWRLIArgument arg); + + /** + * Gets a SWRL atom where the predicate is a data range, i.e. D(x) where D is an OWL data range + * and x is either a literal or variable for a literal + * + * @param predicate The data range that represents the predicate of the atom + * @param arg The argument (x) + * @return An atom with the specified data range predicate and the specified argument + */ + SWRLDataRangeAtom getSWRLDataRangeAtom(OWLDataRange predicate, SWRLDArgument arg); + + /** + * Gets a SWRL atom where the predicate is a data range, i.e. D(x) where D is an OWL data range + * and x is either a literal or variable for a literal + * + * @param predicate The data range that represents the predicate of the atom + * @param arg The argument (x) + * @return An atom with the specified data range predicate and the specified argument + */ + SWRLDataRangeAtom getSWRLDataRangeAtom(OWL2Datatype predicate, SWRLDArgument arg); + + /** + * Gets a SWRL object property atom, i.e. P(x, y) where P is an OWL object property (expression) + * and x and y are are either individuals or variables for individuals. + * + * @param property The property (P) representing the atom predicate + * @param arg0 The first argument (x) + * @param arg1 The second argument (y) + * @return A SWRLObjectPropertyAtom that has the specified predicate and the specified arguments + */ + SWRLObjectPropertyAtom getSWRLObjectPropertyAtom(OWLObjectPropertyExpression property, + SWRLIArgument arg0, SWRLIArgument arg1); + + /** + * Gets a SWRL data property atom, i.e. R(x, y) where R is an OWL data property (expression) and + * x and y are are either literals or variables for literals + * + * @param property The property (P) that represents the atom predicate + * @param arg0 The first argument (x) + * @param arg1 The second argument (y) + * @return A SWRLDataPropertyAtom that has the specified predicate and the specified arguments + */ + SWRLDataPropertyAtom getSWRLDataPropertyAtom(OWLDataPropertyExpression property, + SWRLIArgument arg0, SWRLDArgument arg1); + + /** + * Creates a SWRL Built-In atom. Builtins have predicates that are identified by IRIs. SWRL + * provides a core set of builtins, which are described in the OWL API by the + * {@link org.semanticweb.owlapi.vocab.SWRLBuiltInsVocabulary}. + * + * @param builtInIRI The builtin predicate IRI + * @param args A non-empty set of SWRL Arguments. + * @return A SWRLBuiltInAtom whose predicate is identified by the specified builtin IRI and that + * has the specified arguments + * @throws IllegalArgumentException if the list of arguments is empty + */ + SWRLBuiltInAtom getSWRLBuiltInAtom(IRI builtInIRI, List args); + + /** + * Gets a SWRLVariable. + * + * @param var The id (IRI) of the variable + * @return A SWRLVariable that has the name specified by the IRI + */ + SWRLVariable getSWRLVariable(IRI var); + + /** + * Gets a SWRLVariable. + * + * @param iri The IRI of the variable + * @return A SWRLVariable that has the name specified by the IRI + */ + default SWRLVariable getSWRLVariable(String iri) { + return getSWRLVariable(IRI.create(iri)); + } + + /** + * Gets a SWRLVariable. + * + * @param namespace The IRI namespace + * @param remainder optional remainder or local name + * @return A SWRLVariable that has the name specified by the IRI + */ + default SWRLVariable getSWRLVariable(String namespace, @Nullable String remainder) { + return getSWRLVariable(IRI.create(namespace, remainder)); + } + + /** + * Gets a SWRLVariable with the same IRI as the input. + * + * @param var an HasIRI instance. The variable will have the same IRI + * @return A SWRLVariable that has the name specified by the IRI + */ + default SWRLVariable getSWRLVariable(HasIRI var) { + return getSWRLVariable(var.getIRI()); + } + + /** + * Gets a SWRLIndividualArgument, which is used to wrap and OWLIndividual as an argument for an + * atom. + * + * @param individual The individual that is the object argument + * @return A SWRLIndividualArgument that wraps the specified individual + */ + SWRLIndividualArgument getSWRLIndividualArgument(OWLIndividual individual); + + /** + * Gets a SWRLLiteralArgument, which is used to wrap an OWLLiteral to provide an argument for an + * atom. + * + * @param literal The constant that is the object argument + * @return A SWRLLiteralArgument that wraps the specified literal + */ + SWRLLiteralArgument getSWRLLiteralArgument(OWLLiteral literal); + + /** + * @param arg0 first individual + * @param arg1 second individual + * @return a sameindividual atom + */ + SWRLSameIndividualAtom getSWRLSameIndividualAtom(SWRLIArgument arg0, SWRLIArgument arg1); + + /** + * @param arg0 first individual + * @param arg1 second individual + * @return a different individual atom + */ + SWRLDifferentIndividualsAtom getSWRLDifferentIndividualsAtom(SWRLIArgument arg0, + SWRLIArgument arg1); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/UnionProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/UnionProvider.java new file mode 100644 index 0000000000..cf1199021c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/UnionProvider.java @@ -0,0 +1,78 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkIterableNotNull; + +import java.util.Arrays; +import java.util.Collection; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLDataUnionOf; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; + +/** + * Object and datatype union provider. + */ +public interface UnionProvider { + + /** + * @param dataRanges data ranges for union. Cannot be null or contain nulls. + * @return an OWLDataUnionOf on the specified dataranges + */ + default OWLDataUnionOf getOWLDataUnionOf(Collection dataRanges) { + checkIterableNotNull(dataRanges, "dataRanges cannot be null", true); + return getOWLDataUnionOf(dataRanges.stream()); + } + + /** + * @param dataRanges data ranges for union. Cannot be null or contain nulls. + * @return an OWLDataUnionOf on the specified dataranges + */ + OWLDataUnionOf getOWLDataUnionOf(Stream dataRanges); + + /** + * @param dataRanges data ranges for union. Cannot be null or contain nulls. + * @return an OWLDataUnionOf on the specified dataranges + */ + default OWLDataUnionOf getOWLDataUnionOf(OWLDataRange... dataRanges) { + checkIterableNotNull(dataRanges, "dataRanges cannot be null", true); + return getOWLDataUnionOf(Arrays.asList(dataRanges)); + } + + /** + * @param operands class expressions for union + * @return a class union over the specified arguments + */ + OWLObjectUnionOf getOWLObjectUnionOf(Stream operands); + + /** + * @param operands class expressions for union + * @return a class union over the specified arguments + */ + default OWLObjectUnionOf getOWLObjectUnionOf( + Collection operands) { + return getOWLObjectUnionOf(operands.stream()); + } + + /** + * @param operands class expressions for union + * @return a class union over the specified arguments + */ + default OWLObjectUnionOf getOWLObjectUnionOf(OWLClassExpression... operands) { + checkIterableNotNull(operands, "operands cannot be null", true); + return getOWLObjectUnionOf(Arrays.asList(operands)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/UniversalProvider.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/UniversalProvider.java new file mode 100644 index 0000000000..a933c713a2 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/UniversalProvider.java @@ -0,0 +1,53 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model.providers; + +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * Universal provider interface. + */ +public interface UniversalProvider { + + /** + * @param property The property that the restriction acts along. + * @param dataRange The data range that is the filler. + * @return An OWLDataAllValuesFrom restriction that acts along the specified property and has + * the specified filler + */ + OWLDataAllValuesFrom getOWLDataAllValuesFrom(OWLDataPropertyExpression property, + OWLDataRange dataRange); + + /** + * @param property The property that the restriction acts along. + * @param dataRange The data range that is the filler. + * @return An OWLDataAllValuesFrom restriction that acts along the specified property and has + * the specified filler + */ + OWLDataAllValuesFrom getOWLDataAllValuesFrom(OWLDataPropertyExpression property, + OWL2Datatype dataRange); + + /** + * @param property The property that the restriction acts along. + * @param classExpression the class expression for the restriction + * @return an AllValuesFrom on specified property and class expression + */ + OWLObjectAllValuesFrom getOWLObjectAllValuesFrom(OWLObjectPropertyExpression property, + OWLClassExpression classExpression); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/package-info.java b/api/src/main/java/org/semanticweb/owlapi/model/providers/package-info.java new file mode 100644 index 0000000000..69a292972d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Provider interfaces. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.model.providers; diff --git a/api/src/main/java/org/semanticweb/owlapi/model/providers/packageinfo b/api/src/main/java/org/semanticweb/owlapi/model/providers/packageinfo new file mode 100644 index 0000000000..7c7a9efd9c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/model/providers/packageinfo @@ -0,0 +1 @@ +version 5.1.0 diff --git a/api/src/main/java/org/semanticweb/owlapi/packageinfo b/api/src/main/java/org/semanticweb/owlapi/packageinfo new file mode 100644 index 0000000000..e7206311ed --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/packageinfo @@ -0,0 +1 @@ +version 5.0.2 diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/OWL2DLProfile.java b/api/src/main/java/org/semanticweb/owlapi/profiles/OWL2DLProfile.java new file mode 100644 index 0000000000..269f96eee4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/OWL2DLProfile.java @@ -0,0 +1,37 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class OWL2DLProfile implements OWLProfile { + + @Override + public OWLProfileReport checkOntology(OWLOntology ontology) { + return checkOntologyClosureInProfiles(ontology, Profiles.OWL2_DL); + } + + @Override + public IRI getIRI() { + return Profiles.OWL2_DL.getIRI(); + } + + @Override + public String getName() { + return "OWL 2 DL"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/OWL2ELProfile.java b/api/src/main/java/org/semanticweb/owlapi/profiles/OWL2ELProfile.java new file mode 100644 index 0000000000..b631151dbf --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/OWL2ELProfile.java @@ -0,0 +1,38 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class OWL2ELProfile implements OWLProfile { + + + @Override + public OWLProfileReport checkOntology(OWLOntology ontology) { + return checkOntologyClosureInProfiles(ontology, Profiles.OWL2_DL, Profiles.OWL2_EL); + } + + @Override + public IRI getIRI() { + return Profiles.OWL2_EL.getIRI(); + } + + @Override + public String getName() { + return "OWL 2 EL"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/OWL2Profile.java b/api/src/main/java/org/semanticweb/owlapi/profiles/OWL2Profile.java new file mode 100644 index 0000000000..47e0d8b253 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/OWL2Profile.java @@ -0,0 +1,42 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * Checks to see if an ontology and its imports closure fall into the OWL 2 FULL profile. An + * ontology is OWL Full if any of the global structural restrictions are violated, if there is + * punning between object and data properties. Failing this profile means the ontology is not valid + * OWL. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class OWL2Profile implements OWLProfile { + + @Override + public OWLProfileReport checkOntology(OWLOntology ontology) { + return checkOntologyClosureInProfiles(ontology); + } + + @Override + public IRI getIRI() { + return Profiles.OWL2_FULL.getIRI(); + } + + @Override + public String getName() { + return "OWL 2 Full"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/OWL2ProfileReport.java b/api/src/main/java/org/semanticweb/owlapi/profiles/OWL2ProfileReport.java new file mode 100644 index 0000000000..66ca686801 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/OWL2ProfileReport.java @@ -0,0 +1,68 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles; + +import java.util.Set; +import java.util.TreeSet; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class OWL2ProfileReport extends OWLProfileReport { + + private final Set nonSimpleRoles; + private final Set simpleRoles; + + /** + * @param profile the profile + * @param disallowedConstructs the constructs not allowed + * @param nonSimpleRoles the collection of non simple roles + * @param simpleRoles the collection of simple roles + */ + public OWL2ProfileReport(OWLProfile profile, Set disallowedConstructs, + Set nonSimpleRoles, + Set simpleRoles) { + super(profile, disallowedConstructs); + this.nonSimpleRoles = new TreeSet<>(nonSimpleRoles); + this.simpleRoles = new TreeSet<>(simpleRoles); + } + + private static void wrap(StringBuilder sb, OWLObjectPropertyExpression p) { + sb.append('\t').append(p).append('\n'); + } + + /** + * @return the non simple roles + */ + public Set getNonSimpleRoles() { + return nonSimpleRoles; + } + + /** + * @return he simple roles + */ + public Set getSimpleRoles() { + return simpleRoles; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(1000); + sb.append(super.toString()).append("\n[Simple properties]\n"); + simpleRoles.forEach(p -> wrap(sb, p)); + sb.append("\n[Non-simple properties]\n"); + nonSimpleRoles.forEach(p -> wrap(sb, p)); + return sb.toString(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/OWL2QLProfile.java b/api/src/main/java/org/semanticweb/owlapi/profiles/OWL2QLProfile.java new file mode 100644 index 0000000000..2ef8a3a7d5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/OWL2QLProfile.java @@ -0,0 +1,37 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class OWL2QLProfile implements OWLProfile { + + @Override + public OWLProfileReport checkOntology(OWLOntology ontology) { + return checkOntologyClosureInProfiles(ontology, Profiles.OWL2_DL, Profiles.OWL2_QL); + } + + @Override + public IRI getIRI() { + return Profiles.OWL2_QL.getIRI(); + } + + @Override + public String getName() { + return "OWL 2 QL"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/OWL2RLProfile.java b/api/src/main/java/org/semanticweb/owlapi/profiles/OWL2RLProfile.java new file mode 100644 index 0000000000..00748ad8f3 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/OWL2RLProfile.java @@ -0,0 +1,37 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class OWL2RLProfile implements OWLProfile { + + @Override + public OWLProfileReport checkOntology(OWLOntology ontology) { + return checkOntologyClosureInProfiles(ontology, Profiles.OWL2_DL, Profiles.OWL2_RL); + } + + @Override + public IRI getIRI() { + return Profiles.OWL2_RL.getIRI(); + } + + @Override + public String getName() { + return "OWL 2 RL"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/OWLOntologyProfileWalker.java b/api/src/main/java/org/semanticweb/owlapi/profiles/OWLOntologyProfileWalker.java new file mode 100644 index 0000000000..abe9f60062 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/OWLOntologyProfileWalker.java @@ -0,0 +1,84 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.Collection; +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.util.OWLObjectWalker; +import org.semanticweb.owlapi.util.OWLOntologyWalker; +import org.semanticweb.owlapi.util.StructureWalker; + +/** + * A specialized walker that skips visiting annotation assertion literals. This + * is used by profile checkers to skip literals in annotations. + * + * @author ignazio + */ +public class OWLOntologyProfileWalker extends OWLOntologyWalker { + + /** + * @param objects ontologies to walk + */ + public OWLOntologyProfileWalker(Stream objects) { + this(asList(objects)); + } + + /** + * @param objects ontologies to walk + */ + public OWLOntologyProfileWalker(Collection objects) { + super(objects); + setStructureWalker(new ProfileWalker(this)); + } + + class ProfileWalker extends StructureWalker { + + ProfileWalker(OWLObjectWalker owlObjectWalker) { + super(owlObjectWalker); + } + + @Override + public void visit(OWLAnnotationAssertionAxiom axiom) { + process(axiom); + if (axiom.getSubject().isIRI()) { + // do not visit anonymous nodes from annotations + axiom.getSubject().accept(this); + } + axiom.getAnnotation().accept(this); + } + + @Override + public void visit(OWLAnnotation node) { + process(node); + node.getProperty().accept(this); + // only visit IRIs + if (node.getValue().isIRI()) { + node.getValue().accept(this); + } + } + + @Override + public void visit(OWLDeclarationAxiom axiom) { + process(axiom); + walkerCallback.setAxiom(axiom); + // do not visit entities from declarations, only their IRIs + axiom.getEntity().getIRI().accept(this); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/OWLProfile.java b/api/src/main/java/org/semanticweb/owlapi/profiles/OWLProfile.java new file mode 100644 index 0000000000..6197c42f84 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/OWLProfile.java @@ -0,0 +1,59 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles; + +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.Set; + +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public interface OWLProfile extends HasIRI { + + /** + * Gets the name of the profile. + * + * @return A string that represents the name of the profile + */ + String getName(); + + /** + * Checks an ontology and its import closure to see if it is within this + * profile. + * + * @param ontology The ontology to be checked. + * @return An {@code OWLProfileReport} that describes whether or not the ontology is within this + * profile. + */ + OWLProfileReport checkOntology(OWLOntology ontology); + + /** + * Checks an ontology and its import closure to see if it is within the specified profiles. + * + * @param ontology The ontology to be checked. + * @param profiles the profiles to check + * @return An {@code OWLProfileReport} that describes whether or not the ontology is within the + * specified profiles. + */ + default OWLProfileReport checkOntologyClosureInProfiles(OWLOntology ontology, + Profiles... profiles) { + Set violations = new LinkedHashSet<>(); + OWLOntologyProfileWalker walker = new OWLOntologyProfileWalker(ontology.importsClosure()); + walker.walkStructure(new ProfileVisitor(walker, violations, Arrays.asList(profiles))); + return new OWLProfileReport(this, violations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/OWLProfileReport.java b/api/src/main/java/org/semanticweb/owlapi/profiles/OWLProfileReport.java new file mode 100644 index 0000000000..0f16d96279 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/OWLProfileReport.java @@ -0,0 +1,101 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class OWLProfileReport { + + private final OWLProfile profile; + private final List violations; + + /** + * @param profile the profile used + * @param violations the set of violations + */ + public OWLProfileReport(OWLProfile profile, Collection violations) { + this.profile = profile; + this.violations = new ArrayList<>(violations); + } + + /** + * @return the profile used + */ + public OWLProfile getProfile() { + return profile; + } + + /** + * @return true if there are no violations + */ + public boolean isInProfile() { + return violations.isEmpty(); + } + + /** + * @return the violations found + */ + public List getViolations() { + return violations; + } + + /** + * @param o ontology of interest + * @return the violations found, filtered by ontology + */ + public List getViolations(OWLOntology o) { + return asList(violations.stream().filter(v -> Objects.equals(v.getOntology(), o))); + } + + /** + * @param e entity of interest + * @return the violations found, filtered by entity + */ + public List getViolations(OWLEntity e) { + return asList(violations.stream().filter(v -> Objects.equals(v.getExpression(), e))); + } + + /** + * @param ax axiom of interest + * @return the violations found, filtered by axiom + */ + public List getViolations(OWLAxiom ax) { + return asList(violations.stream().filter(v -> Objects.equals(v.getAxiom(), ax))); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(profile.getName()); + sb.append(" Profile Report: "); + if (isInProfile()) { + sb.append("[Ontology and imports closure in profile]\n"); + } else { + sb.append( + "Ontology and imports closure NOT in profile. The following violations are present:\n"); + } + violations.forEach(v -> sb.append(v).append('\n')); + return sb.toString(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/OWLProfileViolation.java b/api/src/main/java/org/semanticweb/owlapi/profiles/OWLProfileViolation.java new file mode 100644 index 0000000000..41914ffff0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/OWLProfileViolation.java @@ -0,0 +1,133 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.RemoveAxiom; +import org.semanticweb.owlapi.util.CollectionFactory; + +/** + * Describes a violation of an OWLProfile by an axiom. Ultimately, there may be + * part of the axiom that violates the profile rather than the complete axiom. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 4.0.0 + */ +public abstract class OWLProfileViolation { + + protected final OWLOntology ontology; + protected final OWLDataFactory df; + @Nullable + protected final OWLAxiom axiom; + @Nullable + protected final Object expression; + + /** + * @param ontology the ontology with the violation + * @param axiom the axiom with the violation + * @param o violation expression + */ + public OWLProfileViolation(OWLOntology ontology, @Nullable OWLAxiom axiom, @Nullable Object o) { + this.axiom = axiom; + this.ontology = ontology; + df = ontology.getOWLOntologyManager().getOWLDataFactory(); + expression = o; + } + + /** + * @return ontology id + */ + public OWLOntologyID getOntologyID() { + return ontology.getOntologyID(); + } + + /** + * @return ontology + */ + public OWLOntology getOntology() { + return ontology; + } + + /** + * @return the expression object of this violation + */ + public Object getExpression() { + return verifyNotNull(expression); + } + + /** + * @return the offending axiom + */ + public OWLAxiom getAxiom() { + return verifyNotNull(axiom); + } + + /** + * @return a set of changes to fix the violation - it might be just an axiom removal, or a + * rewrite, or addition of other needed axioms. + */ + public List repair() { + // default fix is to drop the axiom + if (axiom != null) { + return list(new RemoveAxiom(ontology, getAxiom())); + } + return Collections.emptyList(); + } + + protected AddAxiom addDeclaration(OWLEntity e) { + return new AddAxiom(ontology, df.getOWLDeclarationAxiom(e)); + } + + /** + * Visitor accept method. + * + * @param visitor visitor + */ + public abstract void accept(OWLProfileViolationVisitor visitor); + + /** + * @param visitor visitor + * @param visitor return type + * @return visitor return value + */ + public abstract Optional accept(OWLProfileViolationVisitorEx visitor); + + protected String toString(String template) { + return String.format(template + " [%s in %s]", axiom, ontology.getOntologyID()); + } + + protected String toString(String template, Object object) { + return String.format(template + " [%s in %s]", object, axiom, ontology.getOntologyID()); + } + + protected String toString(String template, Object object1, Object object2) { + return String + .format(template + " [%s in %s]", object1, object2, axiom, ontology.getOntologyID()); + } + + protected List list(OWLOntologyChange... changes) { + return CollectionFactory.list(changes); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/OWLProfileViolationVisitor.java b/api/src/main/java/org/semanticweb/owlapi/profiles/OWLProfileViolationVisitor.java new file mode 100644 index 0000000000..33e4045d15 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/OWLProfileViolationVisitor.java @@ -0,0 +1,414 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles; + +import org.semanticweb.owlapi.profiles.violations.CycleInDatatypeDefinition; +import org.semanticweb.owlapi.profiles.violations.DatatypeIRIAlsoUsedAsClassIRI; +import org.semanticweb.owlapi.profiles.violations.EmptyOneOfAxiom; +import org.semanticweb.owlapi.profiles.violations.IllegalPunning; +import org.semanticweb.owlapi.profiles.violations.InsufficientIndividuals; +import org.semanticweb.owlapi.profiles.violations.InsufficientOperands; +import org.semanticweb.owlapi.profiles.violations.InsufficientPropertyExpressions; +import org.semanticweb.owlapi.profiles.violations.LastPropertyInChainNotInImposedRange; +import org.semanticweb.owlapi.profiles.violations.LexicalNotInLexicalSpace; +import org.semanticweb.owlapi.profiles.violations.OntologyIRINotAbsolute; +import org.semanticweb.owlapi.profiles.violations.OntologyVersionIRINotAbsolute; +import org.semanticweb.owlapi.profiles.violations.UseOfAnonymousIndividual; +import org.semanticweb.owlapi.profiles.violations.UseOfBuiltInDatatypeInDatatypeDefinition; +import org.semanticweb.owlapi.profiles.violations.UseOfDefinedDatatypeInDatatypeRestriction; +import org.semanticweb.owlapi.profiles.violations.UseOfDefinedDatatypeInLiteral; +import org.semanticweb.owlapi.profiles.violations.UseOfIllegalAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfIllegalClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfIllegalDataRange; +import org.semanticweb.owlapi.profiles.violations.UseOfIllegalFacetRestriction; +import org.semanticweb.owlapi.profiles.violations.UseOfNonAbsoluteIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfNonAtomicClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfNonEquivalentClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInCardinalityRestriction; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInDisjointPropertiesAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInFunctionalPropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInIrreflexivePropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInObjectHasSelf; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSubClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSuperClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfObjectPropertyInverse; +import org.semanticweb.owlapi.profiles.violations.UseOfPropertyInChainCausesCycle; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForAnnotationPropertyIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForClassIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForDataPropertyIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForIndividualIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForObjectPropertyIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForOntologyIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForVersionIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfTopDataPropertyAsSubPropertyInSubPropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredAnnotationProperty; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredClass; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredDataProperty; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredDatatype; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredObjectProperty; +import org.semanticweb.owlapi.profiles.violations.UseOfUnknownDatatype; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public interface OWLProfileViolationVisitor { + + /** + * @param object object to visit + * @deprecated use {@code #doDefault(Object)} instead + */ + @Deprecated + default void getDefaultReturnValue(OWLProfileViolation object) { + doDefault(object); + } + + /** + * Default action for the visitor. + * + * @param object The object that was visited. + */ + default void doDefault(@SuppressWarnings("unused") OWLProfileViolation object) { + // default is to do nothing + } + + /** + * @param v IllegalPunning to visit + */ + default void visit(IllegalPunning v) { + doDefault(v); + } + + /** + * @param v CycleInDatatypeDefinition to visit + */ + default void visit(CycleInDatatypeDefinition v) { + doDefault(v); + } + + /** + * @param v UseOfBuiltInDatatypeInDatatypeDefinition to visit + */ + default void visit(UseOfBuiltInDatatypeInDatatypeDefinition v) { + doDefault(v); + } + + /** + * @param v DatatypeIRIAlsoUsedAsClassIRI to visit + */ + default void visit(DatatypeIRIAlsoUsedAsClassIRI v) { + doDefault(v); + } + + /** + * @param v UseOfNonSimplePropertyInAsymmetricObjectPropertyAxiom to visit + */ + default void visit(UseOfNonSimplePropertyInAsymmetricObjectPropertyAxiom v) { + doDefault(v); + } + + /** + * @param v UseOfNonSimplePropertyInCardinalityRestriction to visit + */ + default void visit(UseOfNonSimplePropertyInCardinalityRestriction v) { + doDefault(v); + } + + /** + * @param v UseOfNonSimplePropertyInDisjointPropertiesAxiom to visit + */ + default void visit(UseOfNonSimplePropertyInDisjointPropertiesAxiom v) { + doDefault(v); + } + + /** + * @param v UseOfNonSimplePropertyInFunctionalPropertyAxiom to visit + */ + default void visit(UseOfNonSimplePropertyInFunctionalPropertyAxiom v) { + doDefault(v); + } + + /** + * @param v UseOfNonSimplePropertyInInverseFunctionalObjectPropertyAxiom to visit + */ + default void visit(UseOfNonSimplePropertyInInverseFunctionalObjectPropertyAxiom v) { + doDefault(v); + } + + /** + * @param v UseOfNonSimplePropertyInIrreflexivePropertyAxiom to visit + */ + default void visit(UseOfNonSimplePropertyInIrreflexivePropertyAxiom v) { + doDefault(v); + } + + /** + * @param v UseOfNonSimplePropertyInObjectHasSelf to visit + */ + default void visit(UseOfNonSimplePropertyInObjectHasSelf v) { + doDefault(v); + } + + /** + * @param v UseOfPropertyInChainCausesCycle to visit + */ + default void visit(UseOfPropertyInChainCausesCycle v) { + doDefault(v); + } + + /** + * @param v UseOfReservedVocabularyForAnnotationPropertyIRI to visit + */ + default void visit(UseOfReservedVocabularyForAnnotationPropertyIRI v) { + doDefault(v); + } + + /** + * @param v UseOfReservedVocabularyForClassIRI to visit + */ + default void visit(UseOfReservedVocabularyForClassIRI v) { + doDefault(v); + } + + /** + * @param v UseOfReservedVocabularyForDataPropertyIRI to visit + */ + default void visit(UseOfReservedVocabularyForDataPropertyIRI v) { + doDefault(v); + } + + /** + * @param v UseOfReservedVocabularyForIndividualIRI to visit + */ + default void visit(UseOfReservedVocabularyForIndividualIRI v) { + doDefault(v); + } + + /** + * @param v UseOfReservedVocabularyForObjectPropertyIRI to visit + */ + default void visit(UseOfReservedVocabularyForObjectPropertyIRI v) { + doDefault(v); + } + + /** + * @param v UseOfReservedVocabularyForOntologyIRI to visit + */ + default void visit(UseOfReservedVocabularyForOntologyIRI v) { + doDefault(v); + } + + /** + * @param v UseOfReservedVocabularyForVersionIRI to visit + */ + default void visit(UseOfReservedVocabularyForVersionIRI v) { + doDefault(v); + } + + /** + * @param v UseOfTopDataPropertyAsSubPropertyInSubPropertyAxiom to visit + */ + default void visit(UseOfTopDataPropertyAsSubPropertyInSubPropertyAxiom v) { + doDefault(v); + } + + /** + * @param v UseOfUndeclaredAnnotationProperty to visit + */ + default void visit(UseOfUndeclaredAnnotationProperty v) { + doDefault(v); + } + + /** + * @param v UseOfUndeclaredClass to visit + */ + default void visit(UseOfUndeclaredClass v) { + doDefault(v); + } + + /** + * @param v UseOfUndeclaredDataProperty to visit + */ + default void visit(UseOfUndeclaredDataProperty v) { + doDefault(v); + } + + /** + * @param v UseOfUndeclaredDatatype to visit + */ + default void visit(UseOfUndeclaredDatatype v) { + doDefault(v); + } + + /** + * @param v UseOfUndeclaredObjectProperty to visit + */ + default void visit(UseOfUndeclaredObjectProperty v) { + doDefault(v); + } + + /** + * @param v InsufficientPropertyExpressions to visit + */ + default void visit(InsufficientPropertyExpressions v) { + doDefault(v); + } + + /** + * @param v InsufficientIndividuals to visit + */ + default void visit(InsufficientIndividuals v) { + doDefault(v); + } + + /** + * @param v InsufficientOperands to visit + */ + default void visit(InsufficientOperands v) { + doDefault(v); + } + + /** + * @param v EmptyOneOfAxiom to visit + */ + default void visit(EmptyOneOfAxiom v) { + doDefault(v); + } + + /** + * @param v LastPropertyInChainNotInImposedRange to visit + */ + default void visit(LastPropertyInChainNotInImposedRange v) { + doDefault(v); + } + + /** + * @param v OntologyIRINotAbsolute to visit + */ + default void visit(OntologyIRINotAbsolute v) { + doDefault(v); + } + + /** + * @param v UseOfDefinedDatatypeInDatatypeRestriction to visit + */ + default void visit(UseOfDefinedDatatypeInDatatypeRestriction v) { + doDefault(v); + } + + /** + * @param v UseOfDefinedDatatypeInLiteral to visit + */ + default void visit(UseOfDefinedDatatypeInLiteral v) { + doDefault(v); + } + + /** + * @param v UseOfIllegalClassExpression to visit + */ + default void visit(UseOfIllegalClassExpression v) { + doDefault(v); + } + + /** + * @param v UseOfIllegalDataRange to visit + */ + default void visit(UseOfIllegalDataRange v) { + doDefault(v); + } + + /** + * @param v UseOfUnknownDatatype to visit + */ + default void visit(UseOfUnknownDatatype v) { + doDefault(v); + } + + /** + * @param v UseOfObjectPropertyInverse to visit + */ + default void visit(UseOfObjectPropertyInverse v) { + doDefault(v); + } + + /** + * @param v UseOfNonSuperClassExpression to visit + */ + default void visit(UseOfNonSuperClassExpression v) { + doDefault(v); + } + + /** + * @param v UseOfNonSubClassExpression to visit + */ + default void visit(UseOfNonSubClassExpression v) { + doDefault(v); + } + + /** + * @param v UseOfNonEquivalentClassExpression to visit + */ + default void visit(UseOfNonEquivalentClassExpression v) { + doDefault(v); + } + + /** + * @param v UseOfNonAtomicClassExpression to visit + */ + default void visit(UseOfNonAtomicClassExpression v) { + doDefault(v); + } + + /** + * @param v LexicalNotInLexicalSpace to visit + */ + default void visit(LexicalNotInLexicalSpace v) { + doDefault(v); + } + + /** + * @param v OntologyVersionIRINotAbsolute to visit + */ + default void visit(OntologyVersionIRINotAbsolute v) { + doDefault(v); + } + + /** + * @param v UseOfAnonymousIndividual to visit + */ + default void visit(UseOfAnonymousIndividual v) { + doDefault(v); + } + + /** + * @param v UseOfIllegalAxiom to visit + */ + default void visit(UseOfIllegalAxiom v) { + doDefault(v); + } + + /** + * @param v UseOfIllegalFacetRestriction to visit + */ + default void visit(UseOfIllegalFacetRestriction v) { + doDefault(v); + } + + /** + * @param v UseOfNonAbsoluteIRI to visit + */ + default void visit(UseOfNonAbsoluteIRI v) { + doDefault(v); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/OWLProfileViolationVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/profiles/OWLProfileViolationVisitorEx.java new file mode 100644 index 0000000000..5eebeb2762 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/OWLProfileViolationVisitorEx.java @@ -0,0 +1,458 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; + +import java.util.Optional; +import org.semanticweb.owlapi.profiles.violations.CycleInDatatypeDefinition; +import org.semanticweb.owlapi.profiles.violations.DatatypeIRIAlsoUsedAsClassIRI; +import org.semanticweb.owlapi.profiles.violations.EmptyOneOfAxiom; +import org.semanticweb.owlapi.profiles.violations.IllegalPunning; +import org.semanticweb.owlapi.profiles.violations.InsufficientIndividuals; +import org.semanticweb.owlapi.profiles.violations.InsufficientOperands; +import org.semanticweb.owlapi.profiles.violations.InsufficientPropertyExpressions; +import org.semanticweb.owlapi.profiles.violations.LastPropertyInChainNotInImposedRange; +import org.semanticweb.owlapi.profiles.violations.LexicalNotInLexicalSpace; +import org.semanticweb.owlapi.profiles.violations.OntologyIRINotAbsolute; +import org.semanticweb.owlapi.profiles.violations.OntologyVersionIRINotAbsolute; +import org.semanticweb.owlapi.profiles.violations.UseOfAnonymousIndividual; +import org.semanticweb.owlapi.profiles.violations.UseOfBuiltInDatatypeInDatatypeDefinition; +import org.semanticweb.owlapi.profiles.violations.UseOfDefinedDatatypeInDatatypeRestriction; +import org.semanticweb.owlapi.profiles.violations.UseOfDefinedDatatypeInLiteral; +import org.semanticweb.owlapi.profiles.violations.UseOfIllegalAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfIllegalClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfIllegalDataRange; +import org.semanticweb.owlapi.profiles.violations.UseOfIllegalFacetRestriction; +import org.semanticweb.owlapi.profiles.violations.UseOfNonAbsoluteIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfNonAtomicClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfNonEquivalentClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInCardinalityRestriction; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInDisjointPropertiesAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInFunctionalPropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInIrreflexivePropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInObjectHasSelf; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSubClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSuperClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfObjectPropertyInverse; +import org.semanticweb.owlapi.profiles.violations.UseOfPropertyInChainCausesCycle; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForAnnotationPropertyIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForClassIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForDataPropertyIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForIndividualIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForObjectPropertyIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForOntologyIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForVersionIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfTopDataPropertyAsSubPropertyInSubPropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredAnnotationProperty; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredClass; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredDataProperty; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredDatatype; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredObjectProperty; +import org.semanticweb.owlapi.profiles.violations.UseOfUnknownDatatype; + +/** + * @param return type + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 4.0.0 + */ +public interface OWLProfileViolationVisitorEx { + + /** + * Gets the default return value for this visitor. + * + * @param object The object that was visited. + * @return The default return value + */ + default Optional doDefault(@SuppressWarnings("unused") OWLProfileViolation object) { + return emptyOptional(); + } + + /** + * @param v IllegalPunning to visit + * @return visitor return value + */ + default Optional visit(IllegalPunning v) { + return doDefault(v); + } + + /** + * @param v CycleInDatatypeDefinition to visit + * @return visitor return value + */ + default Optional visit(CycleInDatatypeDefinition v) { + return doDefault(v); + } + + /** + * @param v UseOfBuiltInDatatypeInDatatypeDefinition to visit + * @return visitor return value + */ + default Optional visit(UseOfBuiltInDatatypeInDatatypeDefinition v) { + return doDefault(v); + } + + /** + * @param v DatatypeIRIAlsoUsedAsClassIRI to visit + * @return visitor return value + */ + default Optional visit(DatatypeIRIAlsoUsedAsClassIRI v) { + return doDefault(v); + } + + /** + * @param v UseOfNonSimplePropertyInAsymmetricObjectPropertyAxiom to visit + * @return visitor return value + */ + default Optional visit(UseOfNonSimplePropertyInAsymmetricObjectPropertyAxiom v) { + return doDefault(v); + } + + /** + * @param v UseOfNonSimplePropertyInCardinalityRestriction to visit + * @return visitor return value + */ + default Optional visit(UseOfNonSimplePropertyInCardinalityRestriction v) { + return doDefault(v); + } + + /** + * @param v UseOfNonSimplePropertyInDisjointPropertiesAxiom to visit + * @return visitor return value + */ + default Optional visit(UseOfNonSimplePropertyInDisjointPropertiesAxiom v) { + return doDefault(v); + } + + /** + * @param v UseOfNonSimplePropertyInFunctionalPropertyAxiom to visit + * @return visitor return value + */ + default Optional visit(UseOfNonSimplePropertyInFunctionalPropertyAxiom v) { + return doDefault(v); + } + + /** + * @param v UseOfNonSimplePropertyInInverseFunctionalObjectPropertyAxiom to visit + * @return visitor return value + */ + default Optional visit(UseOfNonSimplePropertyInInverseFunctionalObjectPropertyAxiom v) { + return doDefault(v); + } + + /** + * @param v UseOfNonSimplePropertyInIrreflexivePropertyAxiom to visit + * @return visitor return value + */ + default Optional visit(UseOfNonSimplePropertyInIrreflexivePropertyAxiom v) { + return doDefault(v); + } + + /** + * @param v UseOfNonSimplePropertyInObjectHasSelf to visit + * @return visitor return value + */ + default Optional visit(UseOfNonSimplePropertyInObjectHasSelf v) { + return doDefault(v); + } + + /** + * @param v UseOfPropertyInChainCausesCycle to visit + * @return visitor return value + */ + default Optional visit(UseOfPropertyInChainCausesCycle v) { + return doDefault(v); + } + + /** + * @param v UseOfReservedVocabularyForAnnotationPropertyIRI to visit + * @return visitor return value + */ + default Optional visit(UseOfReservedVocabularyForAnnotationPropertyIRI v) { + return doDefault(v); + } + + /** + * @param v UseOfReservedVocabularyForClassIRI to visit + * @return visitor return value + */ + default Optional visit(UseOfReservedVocabularyForClassIRI v) { + return doDefault(v); + } + + /** + * @param v UseOfReservedVocabularyForDataPropertyIRI to visit + * @return visitor return value + */ + default Optional visit(UseOfReservedVocabularyForDataPropertyIRI v) { + return doDefault(v); + } + + /** + * @param v UseOfReservedVocabularyForIndividualIRI to visit + * @return visitor return value + */ + default Optional visit(UseOfReservedVocabularyForIndividualIRI v) { + return doDefault(v); + } + + /** + * @param v UseOfReservedVocabularyForObjectPropertyIRI to visit + * @return visitor return value + */ + default Optional visit(UseOfReservedVocabularyForObjectPropertyIRI v) { + return doDefault(v); + } + + /** + * @param v UseOfReservedVocabularyForOntologyIRI to visit + * @return visitor return value + */ + default Optional visit(UseOfReservedVocabularyForOntologyIRI v) { + return doDefault(v); + } + + /** + * @param v UseOfReservedVocabularyForVersionIRI to visit + * @return visitor return value + */ + default Optional visit(UseOfReservedVocabularyForVersionIRI v) { + return doDefault(v); + } + + /** + * @param v UseOfTopDataPropertyAsSubPropertyInSubPropertyAxiom to visit + * @return visitor return value + */ + default Optional visit(UseOfTopDataPropertyAsSubPropertyInSubPropertyAxiom v) { + return doDefault(v); + } + + /** + * @param v UseOfUndeclaredAnnotationProperty to visit + * @return visitor return value + */ + default Optional visit(UseOfUndeclaredAnnotationProperty v) { + return doDefault(v); + } + + /** + * @param v UseOfUndeclaredClass to visit + * @return visitor return value + */ + default Optional visit(UseOfUndeclaredClass v) { + return doDefault(v); + } + + /** + * @param v UseOfUndeclaredDataProperty to visit + * @return visitor return value + */ + default Optional visit(UseOfUndeclaredDataProperty v) { + return doDefault(v); + } + + /** + * @param v UseOfUndeclaredDatatype to visit + * @return visitor return value + */ + default Optional visit(UseOfUndeclaredDatatype v) { + return doDefault(v); + } + + /** + * @param v UseOfUndeclaredObjectProperty to visit + * @return visitor return value + */ + default Optional visit(UseOfUndeclaredObjectProperty v) { + return doDefault(v); + } + + /** + * @param v InsufficientPropertyExpressions to visit + * @return visitor return value + */ + default Optional visit(InsufficientPropertyExpressions v) { + return doDefault(v); + } + + /** + * @param v InsufficientIndividuals to visit + * @return visitor return value + */ + default Optional visit(InsufficientIndividuals v) { + return doDefault(v); + } + + /** + * @param v InsufficientOperands to visit + * @return visitor return value + */ + default Optional visit(InsufficientOperands v) { + return doDefault(v); + } + + /** + * @param v EmptyOneOfAxiom to visit + * @return visitor return value + */ + default Optional visit(EmptyOneOfAxiom v) { + return doDefault(v); + } + + /** + * @param v LastPropertyInChainNotInImposedRange to visit + * @return visitor return value + */ + default Optional visit(LastPropertyInChainNotInImposedRange v) { + return doDefault(v); + } + + /** + * @param v OntologyIRINotAbsolute to visit + * @return visitor return value + */ + default Optional visit(OntologyIRINotAbsolute v) { + return doDefault(v); + } + + /** + * @param v UseOfDefinedDatatypeInDatatypeRestriction to visit + * @return visitor return value + */ + default Optional visit(UseOfDefinedDatatypeInDatatypeRestriction v) { + return doDefault(v); + } + + /** + * @param v UseOfDefinedDatatypeInLiteral to visit + * @return visitor return value + */ + default Optional visit(UseOfDefinedDatatypeInLiteral v) { + return doDefault(v); + } + + /** + * @param v UseOfIllegalClassExpression to visit + * @return visitor return value + */ + default Optional visit(UseOfIllegalClassExpression v) { + return doDefault(v); + } + + /** + * @param v UseOfIllegalDataRange to visit + * @return visitor return value + */ + default Optional visit(UseOfIllegalDataRange v) { + return doDefault(v); + } + + /** + * @param v UseOfUnknownDatatype to visit + * @return visitor return value + */ + default Optional visit(UseOfUnknownDatatype v) { + return doDefault(v); + } + + /** + * @param v UseOfObjectPropertyInverse to visit + * @return visitor return value + */ + default Optional visit(UseOfObjectPropertyInverse v) { + return doDefault(v); + } + + /** + * @param v UseOfNonSuperClassExpression to visit + * @return visitor return value + */ + default Optional visit(UseOfNonSuperClassExpression v) { + return doDefault(v); + } + + /** + * @param v UseOfNonSubClassExpression to visit + * @return visitor return value + */ + default Optional visit(UseOfNonSubClassExpression v) { + return doDefault(v); + } + + /** + * @param v UseOfNonEquivalentClassExpression to visit + * @return visitor return value + */ + default Optional visit(UseOfNonEquivalentClassExpression v) { + return doDefault(v); + } + + /** + * @param v UseOfNonAtomicClassExpression to visit + * @return visitor return value + */ + default Optional visit(UseOfNonAtomicClassExpression v) { + return doDefault(v); + } + + /** + * @param v LexicalNotInLexicalSpace to visit + * @return visitor return value + */ + default Optional visit(LexicalNotInLexicalSpace v) { + return doDefault(v); + } + + /** + * @param v OntologyVersionIRINotAbsolute to visit + * @return visitor return value + */ + default Optional visit(OntologyVersionIRINotAbsolute v) { + return doDefault(v); + } + + /** + * @param v UseOfAnonymousIndividual to visit + * @return visitor return value + */ + default Optional visit(UseOfAnonymousIndividual v) { + return doDefault(v); + } + + /** + * @param v UseOfIllegalAxiom to visit + * @return visitor return value + */ + default Optional visit(UseOfIllegalAxiom v) { + return doDefault(v); + } + + /** + * @param v UseOfIllegalFacetRestriction to visit + * @return visitor return value + */ + default Optional visit(UseOfIllegalFacetRestriction v) { + return doDefault(v); + } + + /** + * @param v UseOfNonAbsoluteIRI to visit + * @return visitor return value + */ + default Optional visit(UseOfNonAbsoluteIRI v) { + return doDefault(v); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/ProfileVisitor.java b/api/src/main/java/org/semanticweb/owlapi/profiles/ProfileVisitor.java new file mode 100644 index 0000000000..7a28a48416 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/ProfileVisitor.java @@ -0,0 +1,499 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles; + +import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED; + +import java.util.Collection; + +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataComplementOf; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataIntersectionOf; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataUnionOf; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLHasKeyAxiom; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectInverseOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.SWRLRule; +import org.semanticweb.owlapi.util.OWLOntologyWalker; + +/** + * Profile visitor - walks the imports closure and adds all violations found to the violation + * collection. This class is public for use in extensions of the profile detection framework. Any + * other use should be through the OWLProfile implementations. See Profiles for convenience methods. + * + * @author ignazio + * + */ +public class ProfileVisitor extends ProfileVisitorBase { + + /** + * @param walker ontology walker to use + * @param violations collection of violations; the collection is modified during the visit + * @param profiles the profiles to check. An empty collection means OWL 2 FULL will be the + * profile used. + */ + public ProfileVisitor(OWLOntologyWalker walker, Collection violations, + Collection profiles) { + super(walker, violations, profiles); + } + + @Override + public void visit(IRI iri) { + relativeIRI(iri); + } + + @Override + public void visit(OWLDatatypeDefinitionAxiom axiom) { + // The datatype MUST be declared + undeclaredDatatype(axiom.getDatatype()); + dl(() -> reservedForDatatype(axiom), () -> cycleInDefinition(axiom)); + rl(() -> illegalAxiom()); + } + + @Override + public void visit(OWLDatatypeRestriction node) { + // The datatype should not be defined with a datatype definition + // axiom + OWLDatatype datatype = node.getDatatype(); + getCurrentOntology().importsClosure().flatMap(o -> o.axioms(AxiomType.DATATYPE_DEFINITION)) + .filter(ax -> datatype.equals(ax.getDatatype())).forEach(ax -> definedDatatype(node)); + // All facets must be allowed for the restricted datatype + node.facetRestrictions().forEach(r -> illegalFacet(node, datatype, r)); + el(() -> illegalDataRange(node)); + ql(() -> illegalDataRange(node)); + rl(() -> illegalDataRange(node)); + } + + @Override + public void visit(OWLLiteral node) { + notInLexicalSpace(node); + } + + @Override + public void visit(OWLOntology ontology) { + propertyManager = null; + // The ontology IRI and version IRI must be absolute and must not be + // from the reserved vocab + OWLOntologyID id = ontology.getOntologyID(); + if (id.isNamed()) { + ontologyIRINotAbsolute(id); + versionNotAbsolute(id); + } + dl(() -> reservedForOntologyIRI(ontology.getOntologyID()), + () -> reservedForVersionIRI(ontology.getOntologyID())); + } + + @Override + public void visit(OWLAnnotationProperty property) { + dl(() -> reservedForAnnotation(property), () -> undeclaredAnnotation(property), + () -> punningAnnotation(property)); + } + + @Override + public void visit(OWLAsymmetricObjectPropertyAxiom axiom) { + dl(() -> asymmetricNonSimple(axiom)); + el(() -> illegalAxiom()); + } + + @Override + public void visit(OWLClass ce) { + dl(() -> reservedForClass(ce), () -> undeclaredClass(ce), + () -> punningDatatypeAndClass(ce)); + } + + @Override + public void visit(OWLDataIntersectionOf node) { + dl(() -> insufficientOperands(node)); + } + + @Override + public void visit(OWLDataOneOf node) { + dl(() -> emptyOneOf(node)); + el(() -> multipleOneOf(node)); + ql(() -> illegalDataRange(node)); + rl(() -> illegalDataRange(node)); + } + + @Override + public void visit(OWLDataProperty property) { + dl(() -> reservedForDataProperty(property), () -> undeclaredDataProperty(property), + () -> illegalDataPropertyPunning(property)); + } + + @Override + public void visit(OWLDatatype node) { + // Each datatype MUST statisfy the following: + // An IRI used to identify a datatype MUST + // - Identify a datatype in the OWL 2 datatype map (Section 4.1 + // lists them), or + // - Have the xsd: prefix, or + // - Be rdfs:Literal, or + // - Not be in the reserved vocabulary of OWL 2 + dl(() -> unknownDatatype(node), () -> undeclaredDatatype(node), + () -> punningDatatypeAndClass(node)); + el(() -> elDataRange(node)); + ql(() -> illegalQLDatatype(node)); + rl(() -> illegalRLDatatype(node)); + } + + @Override + public void visit(OWLDataUnionOf node) { + dl(() -> insufficientOperands(node)); + el(() -> illegalDataRange(node)); + ql(() -> illegalDataRange(node)); + rl(() -> illegalDataRange(node)); + } + + @Override + public void visit(OWLDifferentIndividualsAxiom axiom) { + dl(() -> insufficientIndividuals(axiom)); + } + + @Override + public void visit(OWLDisjointClassesAxiom axiom) { + dl(() -> insufficientOperands(axiom)); + ql(() -> axiom.classExpressions().filter(ce -> !isOWL2QLSubClassExpression(ce)) + .forEach(this::nonSubclass)); + rl(() -> axiom.classExpressions() + .filter(ce -> !ce.accept(equivalentClassExpressionChecker).booleanValue()) + .forEach(this::nonSubclass)); + } + + @Override + public void visit(OWLDisjointDataPropertiesAxiom axiom) { + dl(() -> insufficientProperties(axiom)); + el(() -> illegalAxiom()); + } + + @Override + public void visit(OWLDisjointObjectPropertiesAxiom axiom) { + dl(() -> insufficientProperties(axiom), () -> axiom.properties() + .filter(getPropertyManager()::isNonSimple).forEach(this::disjointNonSimple)); + el(() -> illegalAxiom()); + } + + @Override + public void visit(OWLDisjointUnionAxiom axiom) { + dl(() -> insufficientOperands(axiom)); + el(() -> illegalAxiom()); + ql(() -> illegalAxiom()); + rl(() -> illegalAxiom()); + } + + @Override + public void visit(OWLEquivalentClassesAxiom axiom) { + dl(() -> insufficientOperands(axiom)); + ql(() -> axiom.classExpressions().filter(ce -> !isOWL2QLSubClassExpression(ce)) + .forEach(this::nonSubclass)); + rl(() -> axiom.classExpressions() + .filter(ce -> !ce.accept(equivalentClassExpressionChecker).booleanValue()) + .forEach(this::nonEquivalentClass)); + } + + @Override + public void visit(OWLEquivalentDataPropertiesAxiom axiom) { + dl(() -> insufficientProperties(axiom)); + } + + @Override + public void visit(OWLEquivalentObjectPropertiesAxiom axiom) { + dl(() -> insufficientProperties(axiom)); + } + + @Override + public void visit(OWLFunctionalObjectPropertyAxiom axiom) { + dl(() -> functionalNonSimple(axiom)); + el(() -> illegalAxiom()); + ql(() -> illegalAxiom()); + } + + @Override + public void visit(OWLHasKeyAxiom axiom) { + dl(() -> emptyProperties(axiom)); + ql(() -> illegalAxiom()); + rl(() -> nonSubClassRL(axiom.getClassExpression())); + } + + @Override + public void visit(OWLInverseFunctionalObjectPropertyAxiom axiom) { + dl(() -> inverseFunctionalNonSimple(axiom)); + el(() -> illegalAxiom()); + ql(() -> illegalAxiom()); + } + + @Override + public void visit(OWLIrreflexiveObjectPropertyAxiom axiom) { + dl(() -> irreflexiveNonSimple(axiom)); + el(() -> illegalAxiom()); + } + + @Override + public void visit(OWLReflexiveObjectPropertyAxiom axiom) { + rl(() -> illegalAxiom()); + } + + @Override + public void visit(OWLNamedIndividual individual) { + dl(() -> reservedForIndividual(individual)); + } + + @Override + public void visit(OWLObjectExactCardinality ce) { + dl(() -> nonSimple(ce)); + el(() -> illegalClass(ce)); + } + + @Override + public void visit(OWLObjectHasSelf ce) { + dl(() -> hasSelfNonSimple(ce)); + } + + @Override + public void visit(OWLObjectIntersectionOf ce) { + dl(() -> insufficientOperands(ce)); + } + + @Override + public void visit(OWLObjectMaxCardinality ce) { + dl(() -> nonSimple(ce)); + el(() -> illegalClass(ce)); + } + + @Override + public void visit(OWLObjectMinCardinality ce) { + dl(() -> nonSimple(ce)); + el(() -> illegalClass(ce)); + } + + @Override + public void visit(OWLObjectOneOf ce) { + dl(() -> emptyOneOf(ce)); + el(() -> multipleOneOf(ce)); + } + + @Override + public void visit(OWLObjectProperty property) { + dl(() -> reservedForObjectProperty(property), () -> undeclaredObjectProperty(property), + () -> illegalObjectPropertyPunning(property)); + } + + @Override + public void visit(OWLObjectUnionOf ce) { + dl(() -> insufficientOperands(ce)); + el(() -> illegalClass(ce)); + } + + @Override + public void visit(OWLSameIndividualAxiom axiom) { + dl(() -> insufficientIndividuals(axiom)); + ql(() -> illegalAxiom()); + } + + @Override + public void visit(OWLSubDataPropertyOfAxiom axiom) { + dl(() -> topAsSubProperty(axiom)); + } + + @Override + public void visit(OWLSubPropertyChainOfAxiom axiom) { + // Restriction on the Property Hierarchy. A strict partial order + // (i.e., an irreflexive and transitive relation) < on AllOPE(Ax) + // exists that fulfills the following conditions: + // + // OP1 < OP2 if and only if INV(OP1) < OP2 for all object properties + // OP1 and OP2 occurring in AllOPE(Ax). + // If OPE1 < OPE2 holds, then OPE2 ->* OPE1 does not hold. + // Each axiom in Ax of the form SubObjectPropertyOf( + // ObjectPropertyChain( OPE1 ... OPEn ) OPE ) with n => 2 fulfills + // the following conditions: + // OPE is equal to owl:topObjectProperty, or [TOP] + // n = 2 and OPE1 = OPE2 = OPE, or [TRANSITIVE_PROP] + // OPEi < OPE for each 1 <= i <= n, or [ALL_SMALLER] + // OPE1 = OPE and OPEi < OPE for each 2 <= i <= n, or [FIRST_EQUAL] + // OPEn = OPE and OPEi < OPE for each 1 <= i <= n-1. [LAST_EQUAL] + dl(() -> insufficientProperties(axiom), () -> chainCycle(axiom)); + // Do we have a range restriction imposed on our super property? + el(() -> getCurrentOntology().axioms(AxiomType.OBJECT_PROPERTY_RANGE, INCLUDED) + .forEach(this::chainRange)); + ql(() -> illegalAxiom()); + } + + @Override + public void visit(OWLAnonymousIndividual individual) { + el(() -> anonIndividual(individual)); + ql(() -> anonIndividual(individual)); + } + + @Override + public void visit(OWLClassAssertionAxiom axiom) { + el(() -> axiom.getClassExpression().accept(this)); + ql(() -> nonAtomic(axiom)); + rl(() -> nonSuperClassRL(axiom.getClassExpression())); + } + + @Override + public void visit(OWLDataAllValuesFrom ce) { + el(() -> illegalClass(ce)); + } + + @Override + public void visit(OWLDataComplementOf node) { + el(() -> illegalDataRange(node)); + ql(() -> illegalDataRange(node)); + rl(() -> illegalDataRange(node)); + } + + @Override + public void visit(OWLDataExactCardinality ce) { + el(() -> illegalClass(ce)); + } + + @Override + public void visit(OWLDataMaxCardinality ce) { + el(() -> illegalClass(ce)); + } + + @Override + public void visit(OWLDataMinCardinality ce) { + el(() -> illegalClass(ce)); + } + + @Override + public void visit(OWLInverseObjectPropertiesAxiom axiom) { + el(() -> illegalAxiom()); + } + + @Override + public void visit(OWLObjectAllValuesFrom ce) { + el(() -> illegalClass(ce)); + } + + @Override + public void visit(OWLObjectComplementOf ce) { + el(() -> illegalClass(ce)); + } + + @Override + public void visit(OWLObjectInverseOf property) { + el(() -> inverse(property)); + } + + @Override + public void visit(OWLSymmetricObjectPropertyAxiom axiom) { + el(() -> illegalAxiom()); + } + + @Override + public void visit(SWRLRule rule) { + el(() -> illegalAxiom()); + ql(() -> illegalAxiom()); + rl(() -> illegalAxiom()); + } + + @Override + public void visit(OWLDataPropertyDomainAxiom axiom) { + ql(() -> nonSuperClassQL(axiom.getDomain())); + rl(() -> nonSuperClassRL(axiom.getDomain())); + } + + @Override + public void visit(OWLFunctionalDataPropertyAxiom axiom) { + ql(() -> illegalAxiom()); + } + + @Override + public void visit(OWLNegativeDataPropertyAssertionAxiom axiom) { + ql(() -> illegalAxiom()); + } + + @Override + public void visit(OWLNegativeObjectPropertyAssertionAxiom axiom) { + ql(() -> illegalAxiom()); + } + + @Override + public void visit(OWLObjectPropertyDomainAxiom axiom) { + ql(() -> nonSuperClassQL(axiom.getDomain())); + rl(() -> nonSuperClassRL(axiom.getDomain())); + } + + @Override + public void visit(OWLObjectPropertyRangeAxiom axiom) { + ql(() -> nonSuperClassQL(axiom.getRange())); + rl(() -> nonSuperClassRL(axiom.getRange())); + } + + @Override + public void visit(OWLSubClassOfAxiom axiom) { + ql(() -> nonSubClassQL(axiom), () -> nonSuperClassQL(axiom.getSuperClass())); + rl(() -> nonSubClassRL(axiom.getSubClass()), () -> nonSuperClassRL(axiom.getSuperClass())); + } + + @Override + public void visit(OWLTransitiveObjectPropertyAxiom axiom) { + ql(() -> illegalAxiom()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/ProfileVisitorBase.java b/api/src/main/java/org/semanticweb/owlapi/profiles/ProfileVisitorBase.java new file mode 100644 index 0000000000..d8898b6500 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/ProfileVisitorBase.java @@ -0,0 +1,908 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles; + +import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.Collection; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.HasOperands; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectCardinalityRestriction; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectInverseOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.model.parameters.Imports; +import org.semanticweb.owlapi.profiles.violations.CycleInDatatypeDefinition; +import org.semanticweb.owlapi.profiles.violations.DatatypeIRIAlsoUsedAsClassIRI; +import org.semanticweb.owlapi.profiles.violations.EmptyOneOfAxiom; +import org.semanticweb.owlapi.profiles.violations.IllegalPunning; +import org.semanticweb.owlapi.profiles.violations.InsufficientIndividuals; +import org.semanticweb.owlapi.profiles.violations.InsufficientOperands; +import org.semanticweb.owlapi.profiles.violations.InsufficientPropertyExpressions; +import org.semanticweb.owlapi.profiles.violations.LastPropertyInChainNotInImposedRange; +import org.semanticweb.owlapi.profiles.violations.LexicalNotInLexicalSpace; +import org.semanticweb.owlapi.profiles.violations.OntologyIRINotAbsolute; +import org.semanticweb.owlapi.profiles.violations.OntologyVersionIRINotAbsolute; +import org.semanticweb.owlapi.profiles.violations.UseOfAnonymousIndividual; +import org.semanticweb.owlapi.profiles.violations.UseOfBuiltInDatatypeInDatatypeDefinition; +import org.semanticweb.owlapi.profiles.violations.UseOfDataOneOfWithMultipleLiterals; +import org.semanticweb.owlapi.profiles.violations.UseOfDefinedDatatypeInDatatypeRestriction; +import org.semanticweb.owlapi.profiles.violations.UseOfDefinedDatatypeInLiteral; +import org.semanticweb.owlapi.profiles.violations.UseOfIllegalAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfIllegalClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfIllegalDataRange; +import org.semanticweb.owlapi.profiles.violations.UseOfIllegalFacetRestriction; +import org.semanticweb.owlapi.profiles.violations.UseOfNonAbsoluteIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfNonAtomicClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfNonEquivalentClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInCardinalityRestriction; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInDisjointPropertiesAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInFunctionalPropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInIrreflexivePropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInObjectHasSelf; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSubClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSuperClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfObjectOneOfWithMultipleIndividuals; +import org.semanticweb.owlapi.profiles.violations.UseOfObjectPropertyInverse; +import org.semanticweb.owlapi.profiles.violations.UseOfPropertyInChainCausesCycle; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForAnnotationPropertyIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForClassIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForDataPropertyIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForIndividualIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForObjectPropertyIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForOntologyIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForVersionIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfTopDataPropertyAsSubPropertyInSubPropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredAnnotationProperty; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredClass; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredDataProperty; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredDatatype; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredObjectProperty; +import org.semanticweb.owlapi.profiles.violations.UseOfUnknownDatatype; +import org.semanticweb.owlapi.util.OWLObjectPropertyManager; +import org.semanticweb.owlapi.util.OWLOntologyWalker; +import org.semanticweb.owlapi.util.OWLOntologyWalkerVisitor; +import org.semanticweb.owlapi.vocab.Namespaces; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * Base class for profile violation visitors. + * + * Separates the visiting code from the utility methods used in the visit. + * + * @author ignazio + * + */ +public class ProfileVisitorBase extends OWLOntologyWalkerVisitor { + private static final OWLClassExpressionVisitorEx superClassExpressionChecker = + new OWLClassExpressionVisitorEx() { + @Override + public Boolean doDefault(T object) { + return Boolean.FALSE; + } + + @Override + public Boolean visit(OWLClass ce) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLDataSomeValuesFrom ce) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLObjectComplementOf ce) { + return Boolean.valueOf(isOWL2QLSubClassExpression(ce.getOperand())); + } + + @Override + public Boolean visit(OWLObjectIntersectionOf ce) { + return Boolean + .valueOf(ce.operands().noneMatch(e -> e.accept(this) == Boolean.FALSE)); + } + + @Override + public Boolean visit(OWLObjectSomeValuesFrom ce) { + return Boolean.valueOf(!ce.getFiller().isAnonymous()); + } + }; + + private static final OWLClassExpressionVisitorEx subClassExpressionChecker = + new OWLClassExpressionVisitorEx() { + + @Override + public Boolean doDefault(T o) { + return Boolean.FALSE; + } + + @Override + public Boolean visit(OWLClass ce) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLDataSomeValuesFrom ce) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLObjectSomeValuesFrom ce) { + return Boolean.valueOf(ce.getFiller().isOWLThing()); + } + }; + static final OWLClassExpressionVisitorEx subClassRLExpressionChecker = + new OWLClassExpressionVisitorEx() { + + @Override + public Boolean doDefault(T o) { + return Boolean.FALSE; + } + + @Override + public Boolean visit(OWLClass ce) { + return Boolean.valueOf(!ce.isOWLThing()); + } + + @Override + public Boolean visit(OWLDataHasValue ce) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLDataSomeValuesFrom ce) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLObjectHasValue ce) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLObjectIntersectionOf ce) { + return Boolean + .valueOf(ce.operands().allMatch(op -> isOWL2RLSubClassExpression(op))); + } + + @Override + public Boolean visit(OWLObjectOneOf ce) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLObjectSomeValuesFrom ce) { + return Boolean.valueOf( + ce.getFiller().isOWLThing() || isOWL2RLSubClassExpression(ce.getFiller())); + } + + @Override + public Boolean visit(OWLObjectUnionOf ce) { + return Boolean + .valueOf(ce.operands().allMatch(op -> isOWL2RLSubClassExpression(op))); + } + }; + + static final OWLClassExpressionVisitorEx superClassRLExpressionChecker = + new OWLClassExpressionVisitorEx() { + + @Override + public Boolean doDefault(T o) { + return Boolean.FALSE; + } + + @Override + public Boolean visit(OWLClass ce) { + return Boolean.valueOf(!ce.isOWLThing()); + } + + @Override + public Boolean visit(OWLDataAllValuesFrom ce) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLDataHasValue ce) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLDataMaxCardinality ce) { + return Boolean.valueOf(ce.getCardinality() == 0 || ce.getCardinality() == 1); + } + + @Override + public Boolean visit(OWLObjectAllValuesFrom ce) { + return ce.getFiller().accept(this); + } + + // XXX difference in subclass and superclass - correct? + @Override + public Boolean visit(OWLObjectComplementOf ce) { + return Boolean.valueOf(isOWL2RLSubClassExpression(ce.getOperand())); + } + + @Override + public Boolean visit(OWLObjectHasValue ce) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLObjectIntersectionOf ce) { + return Boolean.valueOf(ce.operands().allMatch(e -> e.accept(this).booleanValue())); + } + + @Override + public Boolean visit(OWLObjectMaxCardinality ce) { + return Boolean.valueOf((ce.getCardinality() == 0 || ce.getCardinality() == 1) + && (ce.getFiller().isOWLThing() || isOWL2RLSubClassExpression(ce.getFiller()))); + } + }; + + static final OWLClassExpressionVisitorEx equivalentClassExpressionChecker = + new OWLClassExpressionVisitorEx() { + + @Override + public Boolean doDefault(T o) { + return Boolean.FALSE; + } + + @Override + public Boolean visit(OWLClass ce) { + return Boolean.valueOf(!ce.isOWLThing()); + } + + @Override + public Boolean visit(OWLDataHasValue ce) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLObjectHasValue ce) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLObjectIntersectionOf ce) { + return Boolean.valueOf(ce.operands().allMatch(e -> e.accept(this).booleanValue())); + } + }; + + protected static boolean isOWL2QLSubClassExpression(OWLClassExpression ce) { + return ce.accept(subClassExpressionChecker).booleanValue(); + } + + protected static boolean isOWL2QLSuperClassExpression(OWLClassExpression ce) { + return ce.accept(superClassExpressionChecker).booleanValue(); + } + + protected static boolean isOWL2RLSubClassExpression(OWLClassExpression ce) { + return ce.accept(subClassRLExpressionChecker).booleanValue(); + } + + protected static boolean isOWL2RLSuperClassExpression(OWLClassExpression ce) { + return ce.accept(superClassRLExpressionChecker).booleanValue(); + } + + protected static final Set ALLOWED_RL_DATATYPES = + asUnorderedSet(OWL2Datatype.RL_DATATYPES.stream().map(HasIRI::getIRI)); + protected static final Set ALLOWED_EL_DATATYPES = + asUnorderedSet(OWL2Datatype.EL_DATATYPES.stream().map(HasIRI::getIRI)); + + protected static final Set ALLOWED_QL_DATATYPES = + asUnorderedSet(OWL2Datatype.EL_DATATYPES.stream().map(HasIRI::getIRI)); + + protected final Set validating; + protected Collection violations; + @Nullable + protected OWLObjectPropertyManager propertyManager = null; + + /** + * @param walker ontology walker to use + * @param violations collection of violations; the collection is modified during the visit + * @param profiles the profiles to check. An empty collection means OWL 2 FULL will be the + * profile used. + */ + protected ProfileVisitorBase(OWLOntologyWalker walker, + Collection violations, Collection profiles) { + super(walker); + this.violations = violations; + validating = new HashSet<>(profiles); + } + + protected void dl(Runnable... runnables) { + if (validating.contains(Profiles.OWL2_DL)) { + for (Runnable r : runnables) { + r.run(); + } + } + } + + protected void ql(Runnable... runnables) { + if (validating.contains(Profiles.OWL2_QL)) { + for (Runnable r : runnables) { + r.run(); + } + } + } + + protected void el(Runnable... runnables) { + if (validating.contains(Profiles.OWL2_EL)) { + for (Runnable r : runnables) { + r.run(); + } + } + } + + protected void rl(Runnable... runnables) { + if (validating.contains(Profiles.OWL2_RL)) { + for (Runnable r : runnables) { + r.run(); + } + } + } + + protected OWLObjectPropertyManager getPropertyManager() { + if (propertyManager == null) { + propertyManager = new OWLObjectPropertyManager(getCurrentOntology()); + } + return verifyNotNull(propertyManager); + } + + protected void illegalRLDatatype(OWLDatatype node) { + if (!ALLOWED_RL_DATATYPES.contains(node.getIRI())) { + illegalDataRange(node); + } + } + + protected void illegalQLDatatype(OWLDatatype node) { + if (!ALLOWED_QL_DATATYPES.contains(node.getIRI())) { + illegalDataRange(node); + } + } + + protected void nonSuperClassRL(OWLClassExpression ce) { + if (!isOWL2RLSuperClassExpression(ce)) { + nonSuper(ce); + } + } + + protected void nonSubClassRL(OWLClassExpression ce) { + if (!isOWL2RLSubClassExpression(ce)) { + nonSubclass(ce); + } + } + + protected void nonSuperClassQL(OWLClassExpression ce) { + if (!isOWL2QLSuperClassExpression(ce)) { + nonSuper(ce); + } + } + + protected void nonSubClassQL(OWLSubClassOfAxiom axiom) { + if (!isOWL2QLSubClassExpression(axiom.getSubClass())) { + nonSubclass(axiom.getSubClass()); + } + } + + protected void elDataRange(OWLDatatype node) { + if (!ALLOWED_EL_DATATYPES.contains(node.getIRI())) { + illegalDataRange(node); + } + } + + protected void illegalClass(OWLClassExpression ce) { + violations + .add(new UseOfIllegalClassExpression(getCurrentOntology(), getCurrentAxiom(), ce)); + } + + protected void illegalPunning(HasIRI p) { + violations.add(new IllegalPunning(getCurrentOntology(), getCurrentAxiom(), p.getIRI())); + } + + protected void insufficientOperands(HasOperands node) { + if (node.getOperandsAsList().size() < 2) { + violations.add(new InsufficientOperands(getCurrentOntology(), getCurrentAxiom(), + (OWLObject) node)); + } + } + + protected void insufficientProperties(HasOperands node) { + if (node.getOperandsAsList().size() < 2) { + violations + .add(new InsufficientPropertyExpressions(getCurrentOntology(), getCurrentAxiom())); + } + } + + protected void emptyProperties(HasOperands node) { + if (node.getOperandsAsList().isEmpty()) { + violations + .add(new InsufficientPropertyExpressions(getCurrentOntology(), getCurrentAxiom())); + } + } + + protected void illegalAxiom() { + violations + .add(new UseOfIllegalAxiom(getCurrentOntology(), verifyNotNull(getCurrentAxiom()))); + } + + protected void illegalDataRange(OWLDataRange node) { + violations.add(new UseOfIllegalDataRange(getCurrentOntology(), getCurrentAxiom(), node)); + } + + protected void nonSimple(OWLObjectCardinalityRestriction ce) { + if (getPropertyManager().isNonSimple(ce.getProperty())) { + violations.add(new UseOfNonSimplePropertyInCardinalityRestriction(getCurrentOntology(), + getCurrentAxiom(), ce)); + } + } + + protected boolean nonSubclass(OWLClassExpression ce) { + return violations.add(new UseOfNonSubClassExpression(getCurrentOntology(), + verifyNotNull(getCurrentAxiom()), ce)); + } + + protected void nonSuper(OWLClassExpression ce) { + violations.add(new UseOfNonSuperClassExpression(getCurrentOntology(), + verifyNotNull(getCurrentAxiom()), ce)); + } + + protected void chainCycle(OWLObjectPropertyExpression last) { + violations.add(new UseOfPropertyInChainCausesCycle(getCurrentOntology(), + verifyNotNull(getCurrentAxiom()), last)); + } + + protected void undeclaredDatatype(OWLDatatype dt) { + if (!dt.isTopDatatype() && !dt.isBuiltIn() + && !getCurrentOntology().isDeclared(dt, INCLUDED)) { + violations + .add(new UseOfUndeclaredDatatype(getCurrentOntology(), getCurrentAxiom(), dt)); + } + } + + protected boolean rangePresent(OWLClassExpression imposedRange, + OWLObjectPropertyExpression lastProperty) { + return getCurrentOntology().importsClosure() + .flatMap(o -> o.objectPropertyRangeAxioms(lastProperty)) + .anyMatch(l -> l.getRange().equals(imposedRange)); + } + + protected void anonIndividual(OWLAnonymousIndividual individual) { + violations + .add(new UseOfAnonymousIndividual(getCurrentOntology(), getCurrentAxiom(), individual)); + } + + protected void nonAtomic(OWLClassAssertionAxiom axiom) { + if (axiom.getClassExpression().isAnonymous()) { + violations.add(new UseOfNonAtomicClassExpression(getCurrentOntology(), axiom, + axiom.getClassExpression())); + } + } + + protected boolean nonEquivalentClass(OWLClassExpression ce) { + return violations.add(new UseOfNonEquivalentClassExpression(getCurrentOntology(), + verifyNotNull(getCurrentAxiom()), ce)); + } + + protected void ontologyIRINotAbsolute(OWLOntologyID id) { + id.getOntologyIRI().filter(o -> !o.isAbsolute()) + .ifPresent(x -> violations.add(new OntologyIRINotAbsolute(getCurrentOntology(), id))); + } + + protected void versionNotAbsolute(OWLOntologyID id) { + id.getVersionIRI().filter(v -> !v.isAbsolute()).ifPresent( + x -> violations.add(new OntologyVersionIRINotAbsolute(getCurrentOntology(), id))); + } + + protected boolean definedDatatype(OWLDatatypeRestriction node) { + return violations.add(new UseOfDefinedDatatypeInDatatypeRestriction(getCurrentOntology(), + getCurrentAxiom(), node)); + } + + protected void illegalFacet(OWLDatatypeRestriction node, OWLDatatype datatype, + OWLFacetRestriction r) { + OWL2Datatype dt = datatype.getBuiltInDatatype(); + if (!dt.getFacets().contains(r.getFacet())) { + violations.add(new UseOfIllegalFacetRestriction(getCurrentOntology(), getCurrentAxiom(), + node, r.getFacet())); + } + } + + protected boolean isBuiltin(OWLLiteral node) { + return node.getDatatype().isBuiltIn() + && !node.getDatatype().getBuiltInDatatype().isInLexicalSpace(node.getLiteral()); + } + + protected void chainRange(OWLObjectPropertyRangeAxiom rngAx) { + OWLSubPropertyChainOfAxiom axiom = + (OWLSubPropertyChainOfAxiom) verifyNotNull(getCurrentAxiom()); + if (getPropertyManager().isSubPropertyOf(axiom.getSuperProperty(), rngAx.getProperty())) { + // Imposed range restriction! + OWLClassExpression imposedRange = rngAx.getRange(); + // There must be an axiom that imposes a + // range on the last + // prop in the chain + List chain = axiom.getPropertyChain(); + if (!chain.isEmpty()) { + OWLObjectPropertyExpression lastProperty = chain.get(chain.size() - 1); + boolean rngPresent = rangePresent(imposedRange, lastProperty); + if (!rngPresent) { + violations.add(new LastPropertyInChainNotInImposedRange(getCurrentOntology(), + axiom, rngAx)); + } + } + } + } + + protected void relativeIRI(IRI iri) { + if (!iri.isAbsolute()) { + violations.add(new UseOfNonAbsoluteIRI(getCurrentOntology(), getCurrentAxiom(), iri)); + } + } + + protected void notInLexicalSpace(OWLLiteral node) { + if (!node.getDatatype().isBuiltIn()) { + violations.add( + new UseOfDefinedDatatypeInLiteral(getCurrentOntology(), getCurrentAxiom(), node)); + } + // Check that the lexical value of the literal is in the lexical + // space of the literal datatype + if (isBuiltin(node)) { + violations + .add(new LexicalNotInLexicalSpace(getCurrentOntology(), getCurrentAxiom(), node)); + } + } + + protected void multipleOneOf(OWLObjectOneOf ce) { + if (ce.getOperandsAsList().size() != 1) { + violations.add(new UseOfObjectOneOfWithMultipleIndividuals(getCurrentOntology(), + getCurrentAxiom(), ce)); + } + } + + protected void multipleOneOf(OWLDataOneOf node) { + if (node.getOperandsAsList().size() != 1) { + violations.add(new UseOfDataOneOfWithMultipleLiterals(getCurrentOntology(), + getCurrentAxiom(), node)); + } + } + + protected void insufficientProperties(OWLSubPropertyChainOfAxiom axiom) { + if (axiom.getPropertyChain().size() < 2) { + violations.add(new InsufficientPropertyExpressions(getCurrentOntology(), axiom)); + } + } + + protected void topAsSubProperty(OWLSubDataPropertyOfAxiom axiom) { + if (axiom.getSubProperty().isOWLTopDataProperty()) { + violations.add(new UseOfTopDataPropertyAsSubPropertyInSubPropertyAxiom( + getCurrentOntology(), axiom)); + } + } + + protected void inverse(OWLObjectInverseOf property) { + violations + .add(new UseOfObjectPropertyInverse(getCurrentOntology(), getCurrentAxiom(), property)); + } + + protected void insufficientIndividuals(HasOperands axiom) { + if (axiom.getOperandsAsList().size() < 2) { + violations.add(new InsufficientIndividuals(getCurrentOntology(), getCurrentAxiom())); + } + } + + protected void punningAnnotation(OWLAnnotationProperty property) { + if (getCurrentOntology().containsObjectPropertyInSignature(property.getIRI(), INCLUDED)) { + illegalPunning(property); + } + if (getCurrentOntology().containsDataPropertyInSignature(property.getIRI(), INCLUDED)) { + illegalPunning(property); + } + } + + protected void undeclaredAnnotation(OWLAnnotationProperty property) { + if (!property.isBuiltIn() && !property.getIRI().isReservedVocabulary() + && !getCurrentOntology().isDeclared(property, INCLUDED)) { + violations.add(new UseOfUndeclaredAnnotationProperty(getCurrentOntology(), + getCurrentAxiom(), getCurrentAnnotation(), property)); + } + } + + protected void reservedForAnnotation(OWLAnnotationProperty property) { + if (!property.isBuiltIn() && property.getIRI().isReservedVocabulary()) { + violations.add(new UseOfReservedVocabularyForAnnotationPropertyIRI(getCurrentOntology(), + getCurrentAxiom(), property)); + } + } + + protected void punningDatatypeAndClass(HasIRI ce) { + if (getCurrentOntology().containsClassInSignature(ce.getIRI(), INCLUDED) + && getCurrentOntology().containsDatatypeInSignature(ce.getIRI(), INCLUDED)) { + violations.add(new DatatypeIRIAlsoUsedAsClassIRI(getCurrentOntology(), + getCurrentAxiom(), ce.getIRI())); + } + } + + protected void undeclaredClass(OWLClass ce) { + if (!ce.isBuiltIn() && !ce.getIRI().isReservedVocabulary() + && !getCurrentOntology().isDeclared(ce, INCLUDED)) { + violations.add(new UseOfUndeclaredClass(getCurrentOntology(), getCurrentAxiom(), ce)); + } + } + + protected void reservedForClass(OWLClass ce) { + if (!ce.isBuiltIn() && ce.getIRI().isReservedVocabulary()) { + violations.add(new UseOfReservedVocabularyForClassIRI(getCurrentOntology(), + getCurrentAxiom(), ce)); + } + } + + protected void emptyOneOf(HasOperands node) { + if (node.getOperandsAsList().size() < 1) { + violations.add(new EmptyOneOfAxiom(getCurrentOntology(), getCurrentAxiom())); + } + } + + protected void illegalDataPropertyPunning(OWLDataProperty property) { + if (getCurrentOntology().containsObjectPropertyInSignature(property.getIRI(), INCLUDED)) { + illegalPunning(property); + } + if (getCurrentOntology().containsAnnotationPropertyInSignature(property.getIRI(), + INCLUDED)) { + illegalPunning(property); + } + } + + protected void undeclaredDataProperty(OWLDataProperty property) { + if (!property.isBuiltIn() && !property.getIRI().isReservedVocabulary() + && !getCurrentOntology().isDeclared(property, INCLUDED)) { + violations.add( + new UseOfUndeclaredDataProperty(getCurrentOntology(), getCurrentAxiom(), property)); + } + } + + protected void reservedForDataProperty(OWLDataProperty property) { + if (!property.isOWLTopDataProperty() && !property.isOWLBottomDataProperty() + && property.getIRI().isReservedVocabulary()) { + violations.add(new UseOfReservedVocabularyForDataPropertyIRI(getCurrentOntology(), + getCurrentAxiom(), property)); + } + } + + protected void unknownDatatype(OWLDatatype node) { + if (!Namespaces.XSD.inNamespace(node.getIRI()) && !node.isBuiltIn() && !node.isTopDatatype() + && node.getIRI().isReservedVocabulary()) { + violations.add(new UseOfUnknownDatatype(getCurrentOntology(), getCurrentAxiom(), node)); + } + } + + protected void reservedForDatatype(OWLDatatypeDefinitionAxiom axiom) { + if (axiom.getDatatype().getIRI().isReservedVocabulary()) { + violations + .add(new UseOfBuiltInDatatypeInDatatypeDefinition(getCurrentOntology(), axiom)); + } + } + + protected void cycleInDefinition(OWLDatatypeDefinitionAxiom axiom) { + // Check for cycles + Set datatypes = new HashSet<>(); + Set axioms = new LinkedHashSet<>(); + axioms.add(axiom); + getDatatypesInSignature(datatypes, axiom.getDataRange(), axioms); + if (datatypes.contains(axiom.getDatatype())) { + violations.add(new CycleInDatatypeDefinition(getCurrentOntology(), axiom)); + } + } + + private void getDatatypesInSignature(Set datatypes, OWLObject obj, + Set axioms) { + Consumer addAndRecurse = ax -> { + axioms.add(ax); + getDatatypesInSignature(datatypes, ax.getDataRange(), axioms); + }; + obj.datatypesInSignature().filter(datatypes::add) + .forEach(dt -> datatypeDefinitions(dt).forEach(addAndRecurse)); + } + + protected Stream datatypeDefinitions(OWLDatatype dt) { + return Imports.INCLUDED.stream(getCurrentOntology()) + .flatMap(o -> o.datatypeDefinitions(dt)); + } + + protected boolean disjointNonSimple(OWLObjectPropertyExpression p) { + return violations.add(new UseOfNonSimplePropertyInDisjointPropertiesAxiom( + getCurrentOntology(), verifyNotNull(getCurrentAxiom()), p)); + } + + protected void functionalNonSimple(OWLFunctionalObjectPropertyAxiom axiom) { + if (getPropertyManager().isNonSimple(axiom.getProperty())) { + violations.add( + new UseOfNonSimplePropertyInFunctionalPropertyAxiom(getCurrentOntology(), axiom)); + } + } + + protected void inverseFunctionalNonSimple(OWLInverseFunctionalObjectPropertyAxiom axiom) { + if (getPropertyManager().isNonSimple(axiom.getProperty())) { + violations.add(new UseOfNonSimplePropertyInInverseFunctionalObjectPropertyAxiom( + getCurrentOntology(), axiom)); + } + } + + protected void irreflexiveNonSimple(OWLIrreflexiveObjectPropertyAxiom axiom) { + if (getPropertyManager().isNonSimple(axiom.getProperty())) { + violations.add( + new UseOfNonSimplePropertyInIrreflexivePropertyAxiom(getCurrentOntology(), axiom)); + } + } + + protected void reservedForIndividual(OWLNamedIndividual individual) { + if (individual.isNamed() && individual.getIRI().isReservedVocabulary()) { + violations.add(new UseOfReservedVocabularyForIndividualIRI(getCurrentOntology(), + getCurrentAxiom(), individual)); + } + } + + protected void hasSelfNonSimple(OWLObjectHasSelf ce) { + if (getPropertyManager().isNonSimple(ce.getProperty())) { + violations.add(new UseOfNonSimplePropertyInObjectHasSelf(getCurrentOntology(), + getCurrentAxiom(), ce)); + } + } + + protected void illegalObjectPropertyPunning(OWLObjectProperty property) { + if (getCurrentOntology().containsDataPropertyInSignature(property.getIRI(), INCLUDED)) { + illegalPunning(property); + } + if (getCurrentOntology().containsAnnotationPropertyInSignature(property.getIRI(), + INCLUDED)) { + illegalPunning(property); + } + } + + protected void undeclaredObjectProperty(OWLObjectProperty property) { + if (!property.isBuiltIn() && !property.getIRI().isReservedVocabulary() + && !getCurrentOntology().isDeclared(property, INCLUDED)) { + violations.add(new UseOfUndeclaredObjectProperty(getCurrentOntology(), + getCurrentAxiom(), property)); + } + } + + protected void reservedForVersionIRI(OWLOntologyID id) { + if (id.isAnonymous()) { + return; + } + Optional vIRI = id.getVersionIRI(); + if (vIRI.isPresent() && vIRI.get().isReservedVocabulary()) { + violations.add(new UseOfReservedVocabularyForVersionIRI(getCurrentOntology())); + } + } + + protected void reservedForOntologyIRI(OWLOntologyID id) { + if (id.isAnonymous()) { + return; + } + Optional oIRI = id.getOntologyIRI(); + if (oIRI.isPresent() && oIRI.get().isReservedVocabulary()) { + violations.add(new UseOfReservedVocabularyForOntologyIRI(getCurrentOntology())); + } + } + + protected void reservedForObjectProperty(OWLObjectProperty property) { + if (!property.isOWLTopObjectProperty() && !property.isOWLBottomObjectProperty() + && property.getIRI().isReservedVocabulary()) { + violations.add(new UseOfReservedVocabularyForObjectPropertyIRI(getCurrentOntology(), + getCurrentAxiom(), property)); + } + } + + protected void chainCycle(OWLSubPropertyChainOfAxiom axiom) { + OWLObjectPropertyExpression superProp = axiom.getSuperProperty(); + if (superProp.isOWLTopObjectProperty() || axiom.isEncodingOfTransitiveProperty()) { + // TOP or TRANSITIVE_PROP: no violation can occur + return; + } + List chain = axiom.getPropertyChain(); + OWLObjectPropertyExpression first = chain.get(0); + OWLObjectPropertyExpression last = chain.get(chain.size() - 1); + checkCenter(superProp, chain); + checkExtremes(superProp, first, last); + checkExtremes(superProp, last, first); + } + + protected void asymmetricNonSimple(OWLAsymmetricObjectPropertyAxiom axiom) { + if (getPropertyManager().isNonSimple(axiom.getProperty())) { + violations.add(new UseOfNonSimplePropertyInAsymmetricObjectPropertyAxiom( + getCurrentOntology(), axiom)); + } + } + + protected void checkCenter(OWLObjectPropertyExpression superProp, + List chain) { + // center part of the chain must be smaller in any case + for (int i = 1; i < chain.size() - 1; i++) { + if (getPropertyManager().isLessThan(superProp, chain.get(i))) { + chainCycle(chain.get(i)); + } + } + } + + protected void checkExtremes(OWLObjectPropertyExpression superProp, + OWLObjectPropertyExpression first, OWLObjectPropertyExpression last) { + if (first.equals(superProp)) { + // first equals, last must be smaller + if (getPropertyManager().isLessThan(superProp, last)) { + chainCycle(last); + } + } else { + // first not equal, it must be smaller + if (getPropertyManager().isLessThan(superProp, first)) { + chainCycle(first); + } + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/Profiles.java b/api/src/main/java/org/semanticweb/owlapi/profiles/Profiles.java new file mode 100644 index 0000000000..6dbf5bdcde --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/Profiles.java @@ -0,0 +1,136 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; +import org.semanticweb.owlapi.util.CollectionFactory; + +/** + * This enumeration includes all currently implemented profile checkers and known information about + * available reasoners for those profiles. Note that reasoner capabilities might be out of date, + * since they are independent projects. Therefore, there might be reasoners not listed here and the + * reasoners listed might have changed.
+ * The use case for this class was suggested by Peter Ansell, see + * patch set 1 and + * patch set 2.
+ * Notice that the OWLProfiles referred here are stateless, therefore only one instance needs to be + * created and can be reused across threads. + * + * @author ignazio + */ +public enum Profiles implements HasIRI, KnownFactories, OWLProfile { + //@formatter:off + /** http://www.w3.org/ns/owl-profile/DL. **/ OWL2_DL ("DL", FaCTPlusPlus, HermiT, JFact, TrOWL, Pellet, MORe){ @Override public OWLProfile getOWLProfile() { return new OWL2DLProfile();} }, + /** http://www.w3.org/ns/owl-profile/QL. **/ OWL2_QL ("QL", FaCTPlusPlus, HermiT, JFact, TrOWL, Pellet, MORe){ @Override public OWLProfile getOWLProfile() { return new OWL2QLProfile();} }, + /** http://www.w3.org/ns/owl-profile/EL. **/ OWL2_EL ("EL", Elk, Snorocket, FaCTPlusPlus, HermiT, JFact, TrOWL, Pellet, MORe){ @Override public OWLProfile getOWLProfile() { return new OWL2ELProfile();} }, + /** http://www.w3.org/ns/owl-profile/RL. **/ OWL2_RL ("RL", FaCTPlusPlus, HermiT, JFact, TrOWL, Pellet, MORe){ @Override public OWLProfile getOWLProfile() { return new OWL2RLProfile();} }, + /** http://www.w3.org/ns/owl-profile/Full. **/ OWL2_FULL ("Full", FaCTPlusPlus, HermiT, JFact, TrOWL, Pellet, MORe){ @Override public OWLProfile getOWLProfile() { return new OWL2Profile(); } }; + //@formatter:on + private final IRI iri; + private final List supportingFactories; + + Profiles(String name, String... supportingFactories) { + iri = IRI.create("http://www.w3.org/ns/owl-profile/", name); + this.supportingFactories = CollectionFactory.list(supportingFactories); + } + + /** + * @param factoryClassName class name to instantiate + * @return an OWLReasonerFactory if the class name represents an OWLReasonerFactory + * implementation available on the classpath. Any exception raised by {@code + * Class.forName(factoryClassName)} is wrapped by an OWLRuntimeException. + */ + public static OWLReasonerFactory instantiateFactory(String factoryClassName) { + try { + Class c = Class.forName(factoryClassName); + if (OWLReasonerFactory.class.isAssignableFrom(c)) { + return (OWLReasonerFactory) c.newInstance(); + } + throw new OWLRuntimeException( + "Reasoner factory cannot be instantiated: " + factoryClassName); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { + throw new OWLRuntimeException( + "Reasoner factory cannot be instantiated: " + factoryClassName, e); + } + } + + /** + * @param i IRI to match + * @return Profiles with matching IRI, or null if none is found + */ + public static Profiles valueForIRI(IRI i) { + return Stream.of(values()).filter(p -> p.iri.equals(i)).findAny().orElse(null); + } + + @Override + public String getName() { + return getOWLProfile().getName(); + } + + @Override + public OWLProfileReport checkOntology(OWLOntology ontology) { + return getOWLProfile().checkOntology(ontology); + } + + @Override + public IRI getIRI() { + return iri; + } + + /** + * Factory method for OWLProfile checkers. + * + * @return profile checker for this profile + */ + public abstract OWLProfile getOWLProfile(); + + /** + * @return collection of OWLReasonerFactory class names known to support the expressivity of + * this profile. The factories can be instantiated through {@code instantiateFactory()} + * if the reasoner classes are on the classpath. Note that this list is provided for + * information only, and might be incorrect or incomplete due to changes in the reasoner + * implementations.
+ * Should you know of a reasoner not mentioned here, or find an error in the reported + * supported profiles, please raise a bug about it. + */ + public Collection supportingReasoners() { + return supportingFactories; + } +} + + +/* + * Not a pretty pattern but I didn't want to have long strings repeated across constructors, and no + * static constants are allowed before members declaration in an enum. + */ +interface KnownFactories { + + String FaCTPlusPlus = "uk.ac.manchester.cs.factplusplus.owlapiv3.FaCTPlusPlusReasonerFactory"; + String HermiT = "org.semanticweb.HermiT.Reasoner.ReasonerFactory"; + String JFact = "uk.ac.manchester.cs.jfact.JFactFactory"; + String TrOWL = "eu.trowl.owlapi3.rel.reasoner.dl.RELReasonerFactory"; + String Pellet = "com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory"; + String MORe = "org.semanticweb.more.MOReRLrewReasonerFactory"; + String Elk = "org.semanticweb.elk.owlapi.ElkReasonerFactory"; + String Snorocket = "au.csiro.snorocket.owlapi.SnorocketReasonerFactory"; +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/package-info.java b/api/src/main/java/org/semanticweb/owlapi/profiles/package-info.java new file mode 100644 index 0000000000..c9429158e8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Profile classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.profiles; diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/packageinfo b/api/src/main/java/org/semanticweb/owlapi/profiles/packageinfo new file mode 100644 index 0000000000..ab839f1af2 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/packageinfo @@ -0,0 +1 @@ +version 5.0.3 diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/CycleInDatatypeDefinition.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/CycleInDatatypeDefinition.java new file mode 100644 index 0000000000..653ba30cdf --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/CycleInDatatypeDefinition.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class CycleInDatatypeDefinition extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + */ + public CycleInDatatypeDefinition(OWLOntology ontology, @Nullable OWLAxiom axiom) { + super(ontology, axiom, null); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Cycle in datatype definition"); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/DatatypeIRIAlsoUsedAsClassIRI.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/DatatypeIRIAlsoUsedAsClassIRI.java new file mode 100644 index 0000000000..9193c1dd08 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/DatatypeIRIAlsoUsedAsClassIRI.java @@ -0,0 +1,73 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.List; +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.RemoveAxiom; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * Specifies that an IRI that is used for a datatype is also used for a class + * IRI. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class DatatypeIRIAlsoUsedAsClassIRI extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param iri iri + */ + public DatatypeIRIAlsoUsedAsClassIRI(OWLOntology ontology, @Nullable OWLAxiom axiom, IRI iri) { + super(ontology, checkNotNull(axiom), iri); + } + + @Override + public IRI getExpression() { + return (IRI) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Datatype IRI also used as Class IRI: %s", getExpression()); + } + + @Override + public List repair() { + // XXX arbitrary decision: drop the axiom + // better fix would be to look for usage and remove the smallest number + // of axioms + return list(new RemoveAxiom(ontology, getAxiom())); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/EmptyOneOfAxiom.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/EmptyOneOfAxiom.java new file mode 100644 index 0000000000..5dbc82fb95 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/EmptyOneOfAxiom.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author ignazio + */ +public class EmptyOneOfAxiom extends OWLProfileViolation { + + /** + * @param ontology the ontology with the violation + * @param axiom the axiom with the violation + */ + public EmptyOneOfAxiom(OWLOntology ontology, @Nullable OWLAxiom axiom) { + super(ontology, axiom, null); + } + + @Override + public String toString() { + return toString("Empty OneOf: at least one value needed"); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/IllegalPunning.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/IllegalPunning.java new file mode 100644 index 0000000000..27aa69dd0f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/IllegalPunning.java @@ -0,0 +1,61 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * Punning between properties is not allowed. + * + * @author ignazio + */ +public class IllegalPunning extends OWLProfileViolation { + + /** + * @param currentOntology ontology + * @param node axiom + * @param iri iri + */ + public IllegalPunning(OWLOntology currentOntology, @Nullable OWLAxiom node, IRI iri) { + super(currentOntology, node, checkNotNull(iri)); + } + + @Override + public IRI getExpression() { + return (IRI) super.getExpression(); + } + + @Override + public String toString() { + return toString("Cannot pun between properties: %s", getExpression().toQuotedString()); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/InsufficientIndividuals.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/InsufficientIndividuals.java new file mode 100644 index 0000000000..72cd0a58a4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/InsufficientIndividuals.java @@ -0,0 +1,52 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author ignazio + */ +public class InsufficientIndividuals extends OWLProfileViolation { + + /** + * @param currentOntology current ontology + * @param node node + */ + public InsufficientIndividuals(OWLOntology currentOntology, @Nullable OWLAxiom node) { + super(currentOntology, node, null); + } + + @Override + public String toString() { + return toString("Not enough individuals; at least two needed"); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/InsufficientOperands.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/InsufficientOperands.java new file mode 100644 index 0000000000..ad0c4a4c4e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/InsufficientOperands.java @@ -0,0 +1,59 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author ignazio + */ +public class InsufficientOperands extends OWLProfileViolation { + + /** + * @param currentOntology current ontology + * @param node node + * @param c c + */ + public InsufficientOperands(OWLOntology currentOntology, @Nullable OWLAxiom node, OWLObject c) { + super(currentOntology, node, c); + } + + @Override + public OWLObject getExpression() { + return (OWLObject) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public String toString() { + return toString("Not enough operands; at least two needed: %s", getExpression()); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/InsufficientPropertyExpressions.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/InsufficientPropertyExpressions.java new file mode 100644 index 0000000000..a38a6d081c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/InsufficientPropertyExpressions.java @@ -0,0 +1,56 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author ignazio + */ +public class InsufficientPropertyExpressions extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + */ + public InsufficientPropertyExpressions(OWLOntology ontology, @Nullable OWLAxiom axiom) { + super(ontology, axiom, null); + } + + @Override + public OWLObject getExpression() { + return (OWLObject) super.getExpression(); + } + + @Override + public String toString() { + return toString("Not enough property expressions; at least two needed"); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/LastPropertyInChainNotInImposedRange.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/LastPropertyInChainNotInImposedRange.java new file mode 100644 index 0000000000..4482838cf0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/LastPropertyInChainNotInImposedRange.java @@ -0,0 +1,61 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class LastPropertyInChainNotInImposedRange extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param rangeAxiom range axiom + */ + public LastPropertyInChainNotInImposedRange(OWLOntology ontology, + @Nullable OWLSubPropertyChainOfAxiom axiom, OWLObjectPropertyRangeAxiom rangeAxiom) { + super(ontology, axiom, rangeAxiom); + } + + @Override + public OWLObjectPropertyRangeAxiom getExpression() { + return (OWLObjectPropertyRangeAxiom) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Last property in chain not in imposed data range for data range: %s", + getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/LexicalNotInLexicalSpace.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/LexicalNotInLexicalSpace.java new file mode 100644 index 0000000000..abe7d248c9 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/LexicalNotInLexicalSpace.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class LexicalNotInLexicalSpace extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param literal literal + */ + public LexicalNotInLexicalSpace(OWLOntology ontology, @Nullable OWLAxiom axiom, + OWLLiteral literal) { + super(ontology, axiom, literal); + } + + @Override + public OWLLiteral getExpression() { + return (OWLLiteral) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Literal lexical value not in lexical space: %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/OntologyIRINotAbsolute.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/OntologyIRINotAbsolute.java new file mode 100644 index 0000000000..2520a33ab7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/OntologyIRINotAbsolute.java @@ -0,0 +1,72 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.List; +import java.util.Optional; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.SetOntologyID; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class OntologyIRINotAbsolute extends OWLProfileViolation { + + /** + * @param ontology ontology + */ + public OntologyIRINotAbsolute(OWLOntology ontology) { + this(ontology, ontology.getOntologyID()); + } + + /** + * @param ontology ontology + * @param id id + */ + public OntologyIRINotAbsolute(OWLOntology ontology, OWLOntologyID id) { + super(ontology, null, id); + } + + @Override + public OWLOntologyID getExpression() { + return (OWLOntologyID) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Ontology IRI not absolute: %s", getExpression()); + } + + @Override + public List repair() { + // XXX arbitrary choice + return list( + new SetOntologyID(ontology, IRI.create("urn:profilesrepair:ontology#", "replaced"))); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/OntologyVersionIRINotAbsolute.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/OntologyVersionIRINotAbsolute.java new file mode 100644 index 0000000000..00377ad205 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/OntologyVersionIRINotAbsolute.java @@ -0,0 +1,75 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.util.List; +import java.util.Optional; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.SetOntologyID; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class OntologyVersionIRINotAbsolute extends OWLProfileViolation { + + /** + * @param ontology ontology + */ + public OntologyVersionIRINotAbsolute(OWLOntology ontology) { + this(ontology, ontology.getOntologyID()); + } + + /** + * @param ontology ontology + * @param id id + */ + public OntologyVersionIRINotAbsolute(OWLOntology ontology, OWLOntologyID id) { + super(ontology, null, id); + } + + @Override + public OWLOntologyID getExpression() { + return (OWLOntologyID) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Ontology version IRI not absolute: %s", getExpression()); + } + + @Override + public List repair() { + // XXX arbitrary choice + return list(new SetOntologyID(ontology, + new OWLOntologyID(optional(IRI.create("urn:profilesrepair:ontology#", "replaced")), + optional(IRI.create("urn:profilesrepair:ontology#", "replaced1"))))); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UndeclaredEntityViolation.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UndeclaredEntityViolation.java new file mode 100644 index 0000000000..abb3127939 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UndeclaredEntityViolation.java @@ -0,0 +1,34 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * Entity not declared. + * + * @author ignazio + */ +public interface UndeclaredEntityViolation { + + /** + * @return entity not declared + */ + OWLEntity getEntity(); + + /** + * @return ontology + */ + OWLOntology getOntology(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfAnonymousIndividual.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfAnonymousIndividual.java new file mode 100644 index 0000000000..691c3f8eda --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfAnonymousIndividual.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfAnonymousIndividual extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param individual individual + */ + public UseOfAnonymousIndividual(OWLOntology ontology, @Nullable OWLAxiom axiom, + OWLAnonymousIndividual individual) { + super(ontology, axiom, individual); + } + + @Override + public OWLAnonymousIndividual getExpression() { + return (OWLAnonymousIndividual) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of anonymous individual: %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfBuiltInDatatypeInDatatypeDefinition.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfBuiltInDatatypeInDatatypeDefinition.java new file mode 100644 index 0000000000..11a25a283d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfBuiltInDatatypeInDatatypeDefinition.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfBuiltInDatatypeInDatatypeDefinition extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + */ + public UseOfBuiltInDatatypeInDatatypeDefinition(OWLOntology ontology, + @Nullable OWLDatatypeDefinitionAxiom axiom) { + super(ontology, axiom, null); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of OWL 2 builtin datatype in datatype definition"); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfDataOneOfWithMultipleLiterals.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfDataOneOfWithMultipleLiterals.java new file mode 100644 index 0000000000..17f05e6b91 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfDataOneOfWithMultipleLiterals.java @@ -0,0 +1,54 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfDataOneOfWithMultipleLiterals extends UseOfIllegalDataRange { + + /** + * @param ontology ontology + * @param axiom axiom + * @param dataOneOf one of data restriction + */ + public UseOfDataOneOfWithMultipleLiterals(OWLOntology ontology, @Nullable OWLAxiom axiom, + OWLDataOneOf dataOneOf) { + super(ontology, axiom, dataOneOf); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of DataOneOf with multiple literals %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfDefinedDatatypeInDatatypeRestriction.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfDefinedDatatypeInDatatypeRestriction.java new file mode 100644 index 0000000000..9ec88fc8ad --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfDefinedDatatypeInDatatypeRestriction.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfDefinedDatatypeInDatatypeRestriction extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param restriction restriction + */ + public UseOfDefinedDatatypeInDatatypeRestriction(OWLOntology ontology, @Nullable OWLAxiom axiom, + OWLDatatypeRestriction restriction) { + super(ontology, axiom, restriction); + } + + @Override + public OWLDatatypeRestriction getExpression() { + return (OWLDatatypeRestriction) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of defined datatype in datatype restriction %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfDefinedDatatypeInLiteral.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfDefinedDatatypeInLiteral.java new file mode 100644 index 0000000000..745cd57d64 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfDefinedDatatypeInLiteral.java @@ -0,0 +1,60 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfDefinedDatatypeInLiteral extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param literal literal + */ + public UseOfDefinedDatatypeInLiteral(OWLOntology ontology, @Nullable OWLAxiom axiom, + OWLLiteral literal) { + super(ontology, axiom, literal); + } + + @Override + public OWLLiteral getExpression() { + return (OWLLiteral) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of defined datatype in datatype restriction %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfIllegalAxiom.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfIllegalAxiom.java new file mode 100644 index 0000000000..306bddcdf2 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfIllegalAxiom.java @@ -0,0 +1,55 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfIllegalAxiom extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + */ + public UseOfIllegalAxiom(OWLOntology ontology, OWLAxiom axiom) { + super(ontology, axiom, axiom.getAxiomType()); + } + + @Override + public AxiomType getExpression() { + return (AxiomType) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Axiom type not allowed in profile"); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfIllegalClassExpression.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfIllegalClassExpression.java new file mode 100644 index 0000000000..a9cdb244c7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfIllegalClassExpression.java @@ -0,0 +1,65 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.Optional; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * Indicates that a class expression in an axiom is not in the profile. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfIllegalClassExpression extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param classExpression class expression + */ + public UseOfIllegalClassExpression(OWLOntology ontology, @Nullable OWLAxiom axiom, + OWLClassExpression classExpression) { + super(ontology, axiom, checkNotNull(classExpression)); + } + + @Override + public OWLClassExpression getExpression() { + return (OWLClassExpression) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Class expressions not allowed in profile: %s", + getExpression().getClassExpressionType().getName()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfIllegalDataRange.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfIllegalDataRange.java new file mode 100644 index 0000000000..e58be7556f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfIllegalDataRange.java @@ -0,0 +1,60 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfIllegalDataRange extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param dataRange data range + */ + public UseOfIllegalDataRange(OWLOntology ontology, @Nullable OWLAxiom axiom, + OWLDataRange dataRange) { + super(ontology, axiom, dataRange); + } + + @Override + public OWLDataRange getExpression() { + return (OWLDataRange) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of data range not in profile: %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfIllegalFacetRestriction.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfIllegalFacetRestriction.java new file mode 100644 index 0000000000..d000edfdd6 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfIllegalFacetRestriction.java @@ -0,0 +1,67 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; +import org.semanticweb.owlapi.vocab.OWLFacet; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfIllegalFacetRestriction extends OWLProfileViolation { + + private final OWLDatatypeRestriction datatypeRestriction; + + /** + * @param ontology ontology + * @param axiom axiom + * @param dtr datatype restriction + * @param facet facet + */ + public UseOfIllegalFacetRestriction(OWLOntology ontology, @Nullable OWLAxiom axiom, + OWLDatatypeRestriction dtr, OWLFacet facet) { + super(ontology, axiom, facet); + datatypeRestriction = dtr; + } + + @Override + public OWLFacet getExpression() { + return (OWLFacet) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString( + "Facet in datatype restriction does not belong to restricted datatype: %s in %s", + getExpression(), datatypeRestriction); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonAbsoluteIRI.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonAbsoluteIRI.java new file mode 100644 index 0000000000..b2243fcdc1 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonAbsoluteIRI.java @@ -0,0 +1,57 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfNonAbsoluteIRI extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param iri iri + */ + public UseOfNonAbsoluteIRI(OWLOntology ontology, @Nullable OWLAxiom axiom, IRI iri) { + super(ontology, axiom, iri); + } + + @Override + public IRI getExpression() { + return (IRI) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("IRI is relative: %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonAtomicClassExpression.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonAtomicClassExpression.java new file mode 100644 index 0000000000..d45e9ec5e8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonAtomicClassExpression.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfNonAtomicClassExpression extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param classExpression class expression + */ + public UseOfNonAtomicClassExpression(OWLOntology ontology, OWLAxiom axiom, + OWLClassExpression classExpression) { + super(ontology, axiom, classExpression); + } + + @Override + public OWLClassExpression getExpression() { + return (OWLClassExpression) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of non-atomic class expression: %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonEquivalentClassExpression.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonEquivalentClassExpression.java new file mode 100644 index 0000000000..dd597ee2fd --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonEquivalentClassExpression.java @@ -0,0 +1,60 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfNonEquivalentClassExpression extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param classExpression class expression + */ + public UseOfNonEquivalentClassExpression(OWLOntology ontology, OWLAxiom axiom, + OWLClassExpression classExpression) { + super(ontology, axiom, classExpression); + } + + @Override + public OWLClassExpression getExpression() { + return (OWLClassExpression) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString( + "Use of non-equivalent class expression in position that requires an equivalent class expression: %s", + getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInAsymmetricObjectPropertyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInAsymmetricObjectPropertyAxiom.java new file mode 100644 index 0000000000..f8b9cdac38 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInAsymmetricObjectPropertyAxiom.java @@ -0,0 +1,56 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfNonSimplePropertyInAsymmetricObjectPropertyAxiom extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + */ + public UseOfNonSimplePropertyInAsymmetricObjectPropertyAxiom(OWLOntology ontology, + OWLAsymmetricObjectPropertyAxiom axiom) { + super(ontology, axiom, axiom.getProperty()); + } + + @Override + public OWLObjectPropertyExpression getExpression() { + return (OWLObjectPropertyExpression) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of non-simple property in asymmetric object property axiom"); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInCardinalityRestriction.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInCardinalityRestriction.java new file mode 100644 index 0000000000..9fa23a3e2a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInCardinalityRestriction.java @@ -0,0 +1,59 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLObjectCardinalityRestriction; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfNonSimplePropertyInCardinalityRestriction extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param restriction restriction + */ + public UseOfNonSimplePropertyInCardinalityRestriction(OWLOntology ontology, + @Nullable OWLAxiom axiom, + OWLObjectCardinalityRestriction restriction) { + super(ontology, axiom, restriction); + } + + @Override + public OWLObjectCardinalityRestriction getExpression() { + return (OWLObjectCardinalityRestriction) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of non-simple property in a restriction: %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInDisjointPropertiesAxiom.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInDisjointPropertiesAxiom.java new file mode 100644 index 0000000000..3c293c6fb7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInDisjointPropertiesAxiom.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfNonSimplePropertyInDisjointPropertiesAxiom extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param prop prop + */ + public UseOfNonSimplePropertyInDisjointPropertiesAxiom(OWLOntology ontology, OWLAxiom axiom, + OWLObjectPropertyExpression prop) { + super(ontology, axiom, prop); + } + + @Override + public OWLObjectPropertyExpression getExpression() { + return (OWLObjectPropertyExpression) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of non-simple property in an axiom %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInFunctionalPropertyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInFunctionalPropertyAxiom.java new file mode 100644 index 0000000000..c023a1f1ae --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInFunctionalPropertyAxiom.java @@ -0,0 +1,56 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfNonSimplePropertyInFunctionalPropertyAxiom extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + */ + public UseOfNonSimplePropertyInFunctionalPropertyAxiom(OWLOntology ontology, + OWLFunctionalObjectPropertyAxiom axiom) { + super(ontology, axiom, axiom.getProperty()); + } + + @Override + public OWLObjectPropertyExpression getExpression() { + return (OWLObjectPropertyExpression) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of non-simple property in functional axiom %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInInverseFunctionalObjectPropertyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInInverseFunctionalObjectPropertyAxiom.java new file mode 100644 index 0000000000..94d723add2 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInInverseFunctionalObjectPropertyAxiom.java @@ -0,0 +1,57 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfNonSimplePropertyInInverseFunctionalObjectPropertyAxiom extends + OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + */ + public UseOfNonSimplePropertyInInverseFunctionalObjectPropertyAxiom(OWLOntology ontology, + OWLInverseFunctionalObjectPropertyAxiom axiom) { + super(ontology, axiom, axiom.getProperty()); + } + + @Override + public OWLObjectPropertyExpression getExpression() { + return (OWLObjectPropertyExpression) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of non-simple property in functional axiom %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInIrreflexivePropertyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInIrreflexivePropertyAxiom.java new file mode 100644 index 0000000000..49fc818643 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInIrreflexivePropertyAxiom.java @@ -0,0 +1,57 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfNonSimplePropertyInIrreflexivePropertyAxiom extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + */ + public UseOfNonSimplePropertyInIrreflexivePropertyAxiom(OWLOntology ontology, + OWLIrreflexiveObjectPropertyAxiom axiom) { + super(ontology, axiom, axiom.getProperty()); + } + + @Override + public OWLObjectPropertyExpression getExpression() { + return (OWLObjectPropertyExpression) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of non-simple property in irreflexive property axiom %s", + getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInObjectHasSelf.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInObjectHasSelf.java new file mode 100644 index 0000000000..8e25dfe58a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSimplePropertyInObjectHasSelf.java @@ -0,0 +1,62 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.ClassExpressionType; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfNonSimplePropertyInObjectHasSelf extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param hasSelf has self restriction + */ + public UseOfNonSimplePropertyInObjectHasSelf(OWLOntology ontology, @Nullable OWLAxiom axiom, + OWLObjectHasSelf hasSelf) { + super(ontology, axiom, hasSelf); + } + + @Override + public OWLObjectHasSelf getExpression() { + return (OWLObjectHasSelf) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of non-simple property in %s restriction: %s", + ClassExpressionType.OBJECT_HAS_SELF.getName(), getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSubClassExpression.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSubClassExpression.java new file mode 100644 index 0000000000..5289e0ae15 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSubClassExpression.java @@ -0,0 +1,60 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfNonSubClassExpression extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param classExpression class expression + */ + public UseOfNonSubClassExpression(OWLOntology ontology, OWLAxiom axiom, + OWLClassExpression classExpression) { + super(ontology, axiom, classExpression); + } + + @Override + public OWLClassExpression getExpression() { + return (OWLClassExpression) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString( + "Use of non-subclass expression in position that requires a subclass expression: %s", + getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSuperClassExpression.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSuperClassExpression.java new file mode 100644 index 0000000000..0941a578c7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfNonSuperClassExpression.java @@ -0,0 +1,60 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfNonSuperClassExpression extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param classExpression class expression + */ + public UseOfNonSuperClassExpression(OWLOntology ontology, OWLAxiom axiom, + OWLClassExpression classExpression) { + super(ontology, axiom, classExpression); + } + + @Override + public OWLClassExpression getExpression() { + return (OWLClassExpression) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString( + "Use of non-superclass expression in position that requires a superclass expression: %s", + getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfObjectOneOfWithMultipleIndividuals.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfObjectOneOfWithMultipleIndividuals.java new file mode 100644 index 0000000000..4675ec84e0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfObjectOneOfWithMultipleIndividuals.java @@ -0,0 +1,52 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfObjectOneOfWithMultipleIndividuals extends UseOfIllegalClassExpression { + + /** + * @param ontology ontology + * @param axiom axiom + * @param oneOf oneOf + */ + public UseOfObjectOneOfWithMultipleIndividuals(OWLOntology ontology, @Nullable OWLAxiom axiom, + OWLObjectOneOf oneOf) { + super(ontology, axiom, oneOf); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of ObjectOneOf with multiple individuals %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfObjectPropertyInverse.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfObjectPropertyInverse.java new file mode 100644 index 0000000000..fa44b2618a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfObjectPropertyInverse.java @@ -0,0 +1,60 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfObjectPropertyInverse extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param propertyExpression property expression + */ + public UseOfObjectPropertyInverse(OWLOntology ontology, @Nullable OWLAxiom axiom, + OWLObjectPropertyExpression propertyExpression) { + super(ontology, axiom, propertyExpression); + } + + @Override + public OWLObjectPropertyExpression getExpression() { + return (OWLObjectPropertyExpression) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of inverse property: %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfPropertyInChainCausesCycle.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfPropertyInChainCausesCycle.java new file mode 100644 index 0000000000..8df1262cb7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfPropertyInChainCausesCycle.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfPropertyInChainCausesCycle extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param property property + */ + public UseOfPropertyInChainCausesCycle(OWLOntology ontology, OWLAxiom axiom, + OWLObjectPropertyExpression property) { + super(ontology, axiom, property); + } + + @Override + public OWLObjectPropertyExpression getExpression() { + return (OWLObjectPropertyExpression) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of property in chain causes cycle: %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForAnnotationPropertyIRI.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForAnnotationPropertyIRI.java new file mode 100644 index 0000000000..81796e0ea3 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForAnnotationPropertyIRI.java @@ -0,0 +1,60 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfReservedVocabularyForAnnotationPropertyIRI extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param property property + */ + public UseOfReservedVocabularyForAnnotationPropertyIRI(OWLOntology ontology, + @Nullable OWLAxiom axiom, + OWLAnnotationProperty property) { + super(ontology, axiom, property); + } + + @Override + public OWLAnnotationProperty getExpression() { + return (OWLAnnotationProperty) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of reserved vocabulary for annotation property IRI: %s", + getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForClassIRI.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForClassIRI.java new file mode 100644 index 0000000000..1227100fdb --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForClassIRI.java @@ -0,0 +1,60 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfReservedVocabularyForClassIRI extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param cls class + */ + public UseOfReservedVocabularyForClassIRI(OWLOntology ontology, @Nullable OWLAxiom axiom, + OWLClass cls) { + super(ontology, axiom, cls); + } + + @Override + public OWLClass getExpression() { + return (OWLClass) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of reserved vocabulary for class IRI: %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForDataPropertyIRI.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForDataPropertyIRI.java new file mode 100644 index 0000000000..32f4f6bedb --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForDataPropertyIRI.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfReservedVocabularyForDataPropertyIRI extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param property property + */ + public UseOfReservedVocabularyForDataPropertyIRI(OWLOntology ontology, @Nullable OWLAxiom axiom, + OWLDataProperty property) { + super(ontology, axiom, property); + } + + @Override + public OWLDataProperty getExpression() { + return (OWLDataProperty) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of reserved vocabulary for data property IRI: %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForIndividualIRI.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForIndividualIRI.java new file mode 100644 index 0000000000..1ad4cb056d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForIndividualIRI.java @@ -0,0 +1,60 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfReservedVocabularyForIndividualIRI extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param ind individual + */ + public UseOfReservedVocabularyForIndividualIRI(OWLOntology ontology, @Nullable OWLAxiom axiom, + OWLNamedIndividual ind) { + super(ontology, axiom, ind); + } + + @Override + public OWLNamedIndividual getExpression() { + return (OWLNamedIndividual) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of reserved vocabulary for individual IRI: %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForObjectPropertyIRI.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForObjectPropertyIRI.java new file mode 100644 index 0000000000..d6952b1365 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForObjectPropertyIRI.java @@ -0,0 +1,59 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfReservedVocabularyForObjectPropertyIRI extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param property property + */ + public UseOfReservedVocabularyForObjectPropertyIRI(OWLOntology ontology, + @Nullable OWLAxiom axiom, + OWLObjectProperty property) { + super(ontology, axiom, property); + } + + @Override + public OWLObjectProperty getExpression() { + return (OWLObjectProperty) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of reserved vocabulary for object property IRI: %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForOntologyIRI.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForOntologyIRI.java new file mode 100644 index 0000000000..9780e85097 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForOntologyIRI.java @@ -0,0 +1,63 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.List; +import java.util.Optional; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.SetOntologyID; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfReservedVocabularyForOntologyIRI extends OWLProfileViolation { + + /** + * @param ontology ontology + */ + public UseOfReservedVocabularyForOntologyIRI(OWLOntology ontology) { + super(ontology, null, ontology.getOntologyID().getOntologyIRI().get()); + } + + @Override + public IRI getExpression() { + return (IRI) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of reserved vocabulary for ontology IRI: %s", getExpression()); + } + + @Override + public List repair() { + // XXX arbitrary replacement + return list( + new SetOntologyID(ontology, IRI.create("urn:profilesrepair:ontology#", "renamed"))); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForVersionIRI.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForVersionIRI.java new file mode 100644 index 0000000000..0cf49ceced --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfReservedVocabularyForVersionIRI.java @@ -0,0 +1,67 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.util.List; +import java.util.Optional; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.SetOntologyID; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfReservedVocabularyForVersionIRI extends OWLProfileViolation { + + /** + * @param ontology ontology + */ + public UseOfReservedVocabularyForVersionIRI(OWLOntology ontology) { + super(ontology, null, ontology.getOntologyID().getVersionIRI().get()); + } + + @Override + public IRI getExpression() { + return (IRI) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of reserved vocabulary for ontology version IRI: %s", getExpression()); + } + + @Override + public List repair() { + // XXX arbitrary replacement + return list(new SetOntologyID(ontology, + new OWLOntologyID(optional(IRI.create("urn:profilesrepair:ontology#", "renamed")), + optional(IRI.create("urn:profilesrepair:ontology#", "renamed1"))))); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfTopDataPropertyAsSubPropertyInSubPropertyAxiom.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfTopDataPropertyAsSubPropertyInSubPropertyAxiom.java new file mode 100644 index 0000000000..25555ba46d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfTopDataPropertyAsSubPropertyInSubPropertyAxiom.java @@ -0,0 +1,55 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfTopDataPropertyAsSubPropertyInSubPropertyAxiom extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + */ + public UseOfTopDataPropertyAsSubPropertyInSubPropertyAxiom(OWLOntology ontology, + OWLSubDataPropertyOfAxiom axiom) { + super(ontology, axiom, axiom); + } + + @Override + public OWLSubDataPropertyOfAxiom getExpression() { + return (OWLSubDataPropertyOfAxiom) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of owl:topDataProperty as sub-property in SubDataPropertyOf axiom"); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfUndeclaredAnnotationProperty.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfUndeclaredAnnotationProperty.java new file mode 100644 index 0000000000..4977e3e4d0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfUndeclaredAnnotationProperty.java @@ -0,0 +1,87 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.List; +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfUndeclaredAnnotationProperty extends OWLProfileViolation implements + UndeclaredEntityViolation { + + @Nullable + private final OWLAnnotation annotation; + + /** + * @param ontology ontology + * @param axiom axiom + * @param annotation annotation + * @param prop prop + */ + public UseOfUndeclaredAnnotationProperty(OWLOntology ontology, @Nullable OWLAxiom axiom, + @Nullable OWLAnnotation annotation, OWLAnnotationProperty prop) { + super(ontology, axiom, checkNotNull(prop)); + this.annotation = annotation; + } + + @Override + public OWLAnnotationProperty getExpression() { + return (OWLAnnotationProperty) super.getExpression(); + } + + @Override + public OWLEntity getEntity() { + return getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of undeclared annotation property: %s in annotation", getExpression(), + nullSafeAnnotation()); + } + + @SuppressWarnings("null") + protected String nullSafeAnnotation() { + return annotation == null ? "" : annotation.toString(); + } + + @Override + public List repair() { + return list(new AddAxiom(ontology, df.getOWLDeclarationAxiom(getExpression()))); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfUndeclaredClass.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfUndeclaredClass.java new file mode 100644 index 0000000000..cbd0b0576b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfUndeclaredClass.java @@ -0,0 +1,74 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.List; +import java.util.Optional; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfUndeclaredClass extends OWLProfileViolation implements UndeclaredEntityViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param cls class + */ + public UseOfUndeclaredClass(OWLOntology ontology, @Nullable OWLAxiom axiom, OWLClass cls) { + super(ontology, axiom, checkNotNull(cls)); + } + + @Override + public OWLEntity getEntity() { + return getExpression(); + } + + @Override + public OWLClass getExpression() { + return (OWLClass) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of undeclared class: %s", getExpression()); + } + + @Override + public List repair() { + return list(addDeclaration(getExpression())); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfUndeclaredDataProperty.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfUndeclaredDataProperty.java new file mode 100644 index 0000000000..7d7db51e3c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfUndeclaredDataProperty.java @@ -0,0 +1,74 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.List; +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfUndeclaredDataProperty extends OWLProfileViolation implements + UndeclaredEntityViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param prop prop + */ + public UseOfUndeclaredDataProperty(OWLOntology ontology, @Nullable OWLAxiom axiom, + OWLDataProperty prop) { + super(ontology, axiom, checkNotNull(prop)); + } + + @Override + public OWLEntity getEntity() { + return getExpression(); + } + + @Override + public OWLDataProperty getExpression() { + return (OWLDataProperty) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of undeclared data property: %s", getExpression()); + } + + @Override + public List repair() { + return list(addDeclaration(getExpression())); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfUndeclaredDatatype.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfUndeclaredDatatype.java new file mode 100644 index 0000000000..844c8f7eba --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfUndeclaredDatatype.java @@ -0,0 +1,76 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.List; +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * Specifies that a datatype is not declared. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfUndeclaredDatatype extends OWLProfileViolation implements + UndeclaredEntityViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param datatype datatype + */ + public UseOfUndeclaredDatatype(OWLOntology ontology, @Nullable OWLAxiom axiom, + OWLDatatype datatype) { + super(ontology, axiom, checkNotNull(datatype)); + } + + @Override + public OWLEntity getEntity() { + return getExpression(); + } + + @Override + public OWLDatatype getExpression() { + return (OWLDatatype) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public List repair() { + return list(addDeclaration(getExpression())); + } + + @Override + public String toString() { + return toString("Use of undeclared datatype: %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfUndeclaredObjectProperty.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfUndeclaredObjectProperty.java new file mode 100644 index 0000000000..d2dcad88fd --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfUndeclaredObjectProperty.java @@ -0,0 +1,74 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.List; +import java.util.Optional; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfUndeclaredObjectProperty extends OWLProfileViolation implements + UndeclaredEntityViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param prop prop + */ + public UseOfUndeclaredObjectProperty(OWLOntology ontology, @Nullable OWLAxiom axiom, + OWLObjectProperty prop) { + super(ontology, axiom, checkNotNull(prop)); + } + + @Override + public OWLEntity getEntity() { + return getExpression(); + } + + @Override + public OWLObjectProperty getExpression() { + return (OWLObjectProperty) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of undeclared object property: %s", getExpression()); + } + + @Override + public List repair() { + return list(addDeclaration(getExpression())); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfUnknownDatatype.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfUnknownDatatype.java new file mode 100644 index 0000000000..ddcc9d0bae --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/UseOfUnknownDatatype.java @@ -0,0 +1,64 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles.violations; + +import java.util.Optional; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitor; +import org.semanticweb.owlapi.profiles.OWLProfileViolationVisitorEx; + +/** + * Use of an unknown datatype. That is, the datatype isn't in the OWL 2 datatype map, the datatype + * IRI does not begin with the {@code xsd:} prefix, the datatype isn't rdfs:Literal, and the + * datatype isn't defined with a DatatypeDefinition axiom. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + */ +public class UseOfUnknownDatatype extends OWLProfileViolation { + + /** + * @param ontology ontology + * @param axiom axiom + * @param datatype datatype + */ + public UseOfUnknownDatatype(OWLOntology ontology, @Nullable OWLAxiom axiom, + OWLDatatype datatype) { + super(ontology, axiom, datatype); + } + + @Override + public OWLDatatype getExpression() { + return (OWLDatatype) super.getExpression(); + } + + @Override + public void accept(OWLProfileViolationVisitor visitor) { + visitor.visit(this); + } + + @Override + public Optional accept(OWLProfileViolationVisitorEx visitor) { + return visitor.visit(this); + } + + @Override + public String toString() { + return toString("Use of unknown datatype: %s", getExpression()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/package-info.java b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/package-info.java new file mode 100644 index 0000000000..b0a61fe3c6 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Violation classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.profiles.violations; diff --git a/api/src/main/java/org/semanticweb/owlapi/profiles/violations/packageinfo b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/packageinfo new file mode 100644 index 0000000000..7c7a9efd9c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/profiles/violations/packageinfo @@ -0,0 +1 @@ +version 5.1.0 diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/AxiomNotInProfileException.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/AxiomNotInProfileException.java new file mode 100644 index 0000000000..d9452351e5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/AxiomNotInProfileException.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAxiom; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class AxiomNotInProfileException extends OWLReasonerRuntimeException { + + private final OWLAxiom axiom; + private final IRI profile; + + /** + * @param axiom wrong axiom + * @param profile profile + */ + public AxiomNotInProfileException(OWLAxiom axiom, IRI profile) { + this.axiom = axiom; + this.profile = profile; + } + + /** + * @return wrong axiom + */ + public OWLAxiom getAxiom() { + return axiom; + } + + /** + * @return profile + */ + public IRI getProfile() { + return profile; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/BufferingMode.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/BufferingMode.java new file mode 100644 index 0000000000..cd68d064b7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/BufferingMode.java @@ -0,0 +1,34 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +/** + * Used to indicate the buffering mode of a reasoner. See + * {@link OWLReasoner#getBufferingMode()}. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public enum BufferingMode { + /** + * Represents a mode where ontology changes are buffered inside an + * OWLReasoner. The reasoner only considers the changes when the buffer is + * flushed with the {@link OWLReasoner#flush()} method. + */ + BUFFERING, + /** + * Represents a mode where ontology changes are not buffered inside an + * OWLReasoner. The reasoner considers all changes immediately. + */ + NON_BUFFERING +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/ClassExpressionNotInProfileException.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/ClassExpressionNotInProfileException.java new file mode 100644 index 0000000000..1ff0b31d27 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/ClassExpressionNotInProfileException.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLClassExpression; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class ClassExpressionNotInProfileException extends + OWLReasonerRuntimeException { + + private final OWLClassExpression classExpression; + private final IRI profile; + + /** + * @param classExpression wrong class expression + * @param profile profile + */ + public ClassExpressionNotInProfileException( + OWLClassExpression classExpression, IRI profile) { + this.classExpression = classExpression; + this.profile = profile; + } + + /** + * @return wrong expression + */ + public OWLClassExpression getClassExpression() { + return classExpression; + } + + /** + * @return profile + */ + public IRI getProfile() { + return profile; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/ConsoleProgressMonitor.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/ConsoleProgressMonitor.java new file mode 100644 index 0000000000..c7b4555f18 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/ConsoleProgressMonitor.java @@ -0,0 +1,55 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +import java.io.Serializable; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class ConsoleProgressMonitor implements ReasonerProgressMonitor, + Serializable { + + private int lastPercentage; + + @Override + public void reasonerTaskStarted(String taskName) { + System.out.print(taskName); + System.out.println(" ..."); + } + + @Override + public void reasonerTaskStopped() { + System.out.println(" ... finished"); + lastPercentage = 0; + } + + @Override + public void reasonerTaskProgressChanged(int value, int max) { + if (max > 0) { + int percent = value * 100 / max; + if (lastPercentage != percent) { + System.out.print(" "); + System.out.print(percent); + System.out.println("%"); + lastPercentage = percent; + } + } + } + + @Override + public void reasonerTaskBusy() { + System.out.println(" busy ..."); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/FreshEntitiesException.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/FreshEntitiesException.java new file mode 100644 index 0000000000..a83d2a3f6b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/FreshEntitiesException.java @@ -0,0 +1,78 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +import java.util.Collection; +import java.util.Collections; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLEntity; + +/** + * Indicates that a query whose signature contained fresh entities was posed to + * the reasoner. This exception is only thrown if the fresh entity policy is set + * appropriately. (See {@link FreshEntityPolicy} and + * {@link org.semanticweb.owlapi.reasoner.OWLReasonerConfiguration}. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class FreshEntitiesException extends OWLReasonerRuntimeException { + + private final Collection entities; + + /** + * @param entities fresh entities + */ + public FreshEntitiesException(Collection entities) { + this(entities, null); + } + + /** + * @param entities entities + * @param t cause + */ + public FreshEntitiesException(Collection entities, @Nullable Throwable t) { + super(t); + this.entities = entities; + } + + /** + * @param entity fresh entity + */ + public FreshEntitiesException(OWLEntity entity) { + this(Collections.singletonList(entity)); + } + + /** + * @param entity fresh entity + * @param t cause + */ + public FreshEntitiesException(OWLEntity entity, @Nullable Throwable t) { + this(Collections.singletonList(entity), t); + } + + /** + * Gets the entities. + * + * @return The entities, none of which are contained in the signature of the union of a set of + * ontologies. + */ + public Collection getEntities() { + return entities; + } + + @Override + public String getMessage() { + return entities + " not in signature"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/FreshEntityPolicy.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/FreshEntityPolicy.java new file mode 100644 index 0000000000..c877051beb --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/FreshEntityPolicy.java @@ -0,0 +1,36 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +/** + * A fresh entity is an entity that is not a built in entity (see + * {@link org.semanticweb.owlapi.model.OWLEntity#isBuiltIn()} and is not contained within the + * signature of the root ontology imports closure. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @see org.semanticweb.owlapi.reasoner.OWLReasonerConfiguration + * @since 3.0.0 + */ +public enum FreshEntityPolicy { + /** + * Specifies that fresh entities are allowed when they are encountered in the signature of + * {@code OWLObject} instances in queries to a reasoner. + */ + ALLOW, + /** + * Specifies that fresh entities are not disallowed. When a fresh entity is encountered in the + * signature of an OWLObject that is used in a query to a reasoner an + * {@link FreshEntitiesException} will be thrown in the calling thread. + */ + DISALLOW +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/IllegalConfigurationException.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/IllegalConfigurationException.java new file mode 100644 index 0000000000..cf186f8422 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/IllegalConfigurationException.java @@ -0,0 +1,60 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class IllegalConfigurationException extends OWLReasonerRuntimeException { + + private final OWLReasonerConfiguration configuration; + + /** + * @param cause exception cause + * @param configuration loading configuration + */ + public IllegalConfigurationException(Throwable cause, + OWLReasonerConfiguration configuration) { + super(cause); + this.configuration = configuration; + } + + /** + * @param message exception message + * @param configuration reasoner configuration + */ + public IllegalConfigurationException(String message, + OWLReasonerConfiguration configuration) { + super(message); + this.configuration = configuration; + } + + /** + * @param cause exception cause + * @param message exception message + * @param configuration reasoner configuration + */ + public IllegalConfigurationException(String message, Throwable cause, + OWLReasonerConfiguration configuration) { + super(message, cause); + this.configuration = configuration; + } + + /** + * @return reasoner configuration + */ + public OWLReasonerConfiguration getConfiguration() { + return configuration; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/ImportsClosureNotInProfileException.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/ImportsClosureNotInProfileException.java new file mode 100644 index 0000000000..e1d9b55527 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/ImportsClosureNotInProfileException.java @@ -0,0 +1,47 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +import org.semanticweb.owlapi.model.IRI; + +/** + * This exception indicates that the reasoner cannot handle the set of axioms + * that are in the imports closure of the root ontology because the axioms fall + * outside of the "largest" OWL profile (i.e. OWL2DL or OWL2EL or OWL2QL or + * OWL2RL) that the reasoner can handle. The reasoner will indicate in this + * exception which profile it expects the axioms to be in. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class ImportsClosureNotInProfileException extends + OWLReasonerRuntimeException { + + private final IRI profile; + + /** + * @param profile profile + */ + public ImportsClosureNotInProfileException(IRI profile) { + this.profile = profile; + } + + /** + * Gets the profile which the reasoner can handle. + * + * @return The profile. + */ + public IRI getProfile() { + return profile; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/InconsistentOntologyException.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/InconsistentOntologyException.java new file mode 100644 index 0000000000..f0637990a9 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/InconsistentOntologyException.java @@ -0,0 +1,57 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +import javax.annotation.Nullable; + +/** + * This type of exception is thrown by an + * {@link org.semanticweb.owlapi.reasoner.OWLReasoner} to indicate that the + * imports closure of the root ontology (returned by + * {@link org.semanticweb.owlapi.reasoner.OWLReasoner#getRootOntology()}) is + * inconsistent. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class InconsistentOntologyException extends OWLReasonerRuntimeException { + + /** + * Default constructor. + */ + public InconsistentOntologyException() { + super("Inconsistent ontology"); + } + + /** + * @param cause error cause + */ + public InconsistentOntologyException(@Nullable Throwable cause) { + super(cause); + } + + /** + * @param message error message + */ + public InconsistentOntologyException(String message) { + super(message); + } + + /** + * @param message error message + * @param cause error cause + */ + public InconsistentOntologyException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/IndividualNodeSetPolicy.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/IndividualNodeSetPolicy.java new file mode 100644 index 0000000000..a60ca3b198 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/IndividualNodeSetPolicy.java @@ -0,0 +1,65 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.OWLNamedIndividual; + +/** + * The policy of how a reasoner will return {@code NodeSet}s of individuals for queries that return + * node sets of named individuals such as + * {@link org.semanticweb.owlapi.reasoner.OWLReasoner#getTypes(org.semanticweb.owlapi.model.OWLNamedIndividual, boolean)} + * or + * {@link org.semanticweb.owlapi.reasoner.OWLReasoner#getInstances(org.semanticweb.owlapi.model.OWLClassExpression, boolean)} + * . + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public enum IndividualNodeSetPolicy { + /** + * Indicates that {@code NodeSet}s of named individuals returned by the reasoner will contain + * {@code Node}s that group individuals which are entailed to be the same as each other. For + * example, if {@code i}, {@code j} and {@code k} are individuals, and they are instances of + * {@code C}, and {@code i} is entailed to be the same as {@code j} then asking for the + * instances of {@code A} will return a {@code NodeSet} containing two {@code Node}s, one + * containing {@code i} and {@code j} and the other containing {@code k}. + */ + BY_SAME_AS { + @Override + public Stream filter(NodeSet nodes) { + return nodes.nodes().map(Node::getRepresentativeElement); + } + }, + /** + * Indicates that {@code NodeSet}s of named individuals will always contain singleton + * {@code Node}s and individuals that are the same as each other will not be grouped together in + * one {@code Node} within the {@code NodeSet}.For example, if {@code i}, {@code j} and + * {@code k} are individuals, and they are instances of {@code C}, and {@code i} is entailed to + * be the same as {@code j} then asking for the instances of {@code A} will return a + * {@code NodeSet} containing three {@code Node}s, one containing {@code i}, one + * containing {@code j} and the third containing {@code k}. + */ + BY_NAME { + @Override + public Stream filter(NodeSet nodes) { + return nodes.entities(); + } + }; + /** + * @param nodes node set to filter + * @return filtered individual stream + */ + public abstract Stream filter(NodeSet nodes); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/InferenceDepth.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/InferenceDepth.java new file mode 100644 index 0000000000..8cdc7b2e3c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/InferenceDepth.java @@ -0,0 +1,45 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +/** + * An enumeration that denotes depth of inference: direct or indirect relations, + * e.g., all subclasses or only direct subclasses. + * + * @since 5.0.0 + */ +public enum InferenceDepth { + /** + * Only direct relations will be returned. E.g., only direct subclasses for + * subclasses requests. + */ + DIRECT(true), + /** + * All relations will be returned, direct and indirect. E.g., all subclasses + * of a concept for subclasses requests. + */ + ALL(false); + + private final boolean direct; + + InferenceDepth(boolean direct) { + this.direct = direct; + } + + /** + * @return true if only direct relations should be retrieved, false otherwise. + */ + public boolean isDirectOnly() { + return direct; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/InferenceType.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/InferenceType.java new file mode 100644 index 0000000000..dbaac1afb6 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/InferenceType.java @@ -0,0 +1,79 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +/** + * An enumeration that denotes various types of inference task. Each inference + * task has a name that is associated with it - reasoners may use these names + * when reporting progress. + * + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +public enum InferenceType { + /** + * Denotes the computation of the class hierarchy. + */ + CLASS_HIERARCHY("class hierarchy"), + /** + * Denotes the computation of the object property hierarchy. + */ + OBJECT_PROPERTY_HIERARCHY("object property hierarchy"), + /** + * Denotes the computation of the data property hierarchy. + */ + DATA_PROPERTY_HIERARCHY("data property hierarchy"), + /** + * Denotes the computation of the direct types of individuals for each + * individual in the signature of the imports closure of the root ontology. + */ + CLASS_ASSERTIONS("class assertions"), + /** + * Denotes the computation of relationships between individuals in the + * signature of the imports closure of the root ontology. + */ + OBJECT_PROPERTY_ASSERTIONS("object property assertions"), + /** + * Denotes the computation of relationships between individuals and data + * property values for each individual in the signature of the imports + * closure of the root ontology. + */ + DATA_PROPERTY_ASSERTIONS("data property assertions"), + /** + * Denotes the computation of individuals that are interpreted as the same + * object for each individual in the imports closure of the root ontology. + */ + SAME_INDIVIDUAL("same individuals"), + /** + * Denotes the computation of sets of individuals that are different from + * each individual in the signature of the imports closure of the root + * ontology. + */ + DIFFERENT_INDIVIDUALS("different individuals"), + /** + * Denotes the computation of sets of classes that are disjoint for each + * class in the signature of the imports closure of the root ontology. + */ + DISJOINT_CLASSES("disjoint classes"); + + private final String name; + + InferenceType(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/Node.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/Node.java new file mode 100644 index 0000000000..19fa3ea23b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/Node.java @@ -0,0 +1,172 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.OWLObject; + +/** + * Represents a node (set) of entities. The entities in a node are equivalent to each other.
+ *

Nodes in hierarchies

In the OWL API, a reasoner treats a class hierarchy, an object + * property hierarchy or a data property hierarchy as a hierarchy (directed acyclic graph - DAG) of + * {@code Nodes}. Each node contains entities that are equivalent to each other. A hierarchy + * contains a top node, which is the ancestor of all nodes in the hierarchy, and a bottom + * node In a class hierarchy, the nodes contain {@code OWLClass} objects. The top node contains + * {@code owl:Thing} (and any other named classes that are equivalent to {@code owl:Thing}). The + * bottom node contains {@code owl:Nothing} (and any other named classes that are equivalent to + * {@code owl:Nothing} - these classes are unsatisfiable In an object property hierarchy, the + * nodes contain {@code OWLObjectProperty} objects. The top node contains + * {@code owl:topObjectProperty} (and any other named object properties that are equivalent to + * {@code owl:topObjectProperty}). The bottom node contains {@code owl:bottomObjectProperty} (and + * any other named object properties that are equivalent to {@code owl:bottomObjectProperty}).
+ * In a data property hierarchy, the nodes contain {@code OWLDataProperty} objects. The top node + * contains {@code owl:topDataProperty} (and any other data properties that are equivalent to + * {@code owl:topDataProperty}). The bottom node contains {@code owl:bottomDataProperty} (and any + * other data properties that are equivalent to {@code owl:bottomDataProperty}).
+ *

Class Hierarchy Example

The figure below shows an example class hierarchy. Each box in + * the hierarchy represents a {@code Node}. In this case the top node contains {@code owl:Thing} and + * the bottom node contains {@code owl:Nothing} because the nodes in the hierarchy are + * {@code OWLClass} nodes. In this case, class {@code G} is equivalent to {@code owl:Thing} so it + * appears as an entity in the top node. Similarly, class {@code K} is unsatisfiable, so it is + * equivalent to {@code owl:Nothing} and therefore appears in the bottom node containing + * {@code owl:Nothing}.
+ * hierarchy + * + * @param the type of elements represented in the Node + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface Node extends Iterable { + + /** + * Determines if this node represents the top node (in a hierarchy). For a named class node, the + * top node is the node that contains {@code owl:Thing}. For an object property node, the top + * node is the node that contains {@code owl:topObjectProperty}. For a data property node, the + * top node is the node that contains {@code owl:topDataProperty} + * + * @return {@code true} if this node is an {@code OWLClass} node and it contains {@code + * owl:Thing}.
+ * {@code true} if this node is an {@code OWLObjectProperty} node and it contains + * {@code owl:topObjectProperty}.
+ * {@code true} if this node is an {@code + * OWLDataProperty} node and it contains {@code owl:topDataProperty}.
+ * {@code false} if none of the above. + */ + boolean isTopNode(); + + /** + * Determines if this node represents the bottom node (in a hierarchy). For a named class node, + * the bottom node is the node that contains {@code owl:Nothing}. For an object property node, + * the bottom node is the node that contains {@code owl:bottomObjectProperty}. For a data + * property node, the bottom node is the node that contains {@code owl:bottomDataProperty} + * + * @return {@code true} if this node is an {@code OWLClass} node and it contains {@code + * owl:Nothing}.
+ * {@code true} if this node is an {@code OWLObjectProperty} node and it contains + * {@code owl:bottomObjectProperty}.
+ * {@code true} if this node is an {@code + * OWLDataProperty} node and it contains {@code owl:bottomDataProperty}.
+ * {@code false} if none of the above. + */ + boolean isBottomNode(); + + /** + * Gets the entities contained in this node. The entities are equivalent to each other. + * + * @return The set of entities contained in this {@code Node}. The set that is returned is a + * copy; modifications to the returned set will not be reflected in this object. + */ + default Set getEntities() { + return asSet(entities()); + } + + /** + * Gets the entities contained in this node. The entities are equivalent to each other. + * + * @return stream of entities contained in this {@code Node}. + */ + Stream entities(); + + /** + * Gets the number of entities contained in this {@code Node}. + * + * @return The number of entities contained in this node. + */ + int getSize(); + + /** + * Determines if this node contains the specified entity. + * + * @param entity The entity to check for + * @return {@code true} if this node contains {@code entity}, or {@code false} if this node does + * not contain {@code entity} + */ + boolean contains(E entity); + + /** + * Gets the entities contained in this node minus the specified entity {@code e}. This + * essentially returns the entities that are returned by {@link #getEntities()} minus the + * specified entity {@code e} + * + * @param e The entity that, is contained within this node, but should not be included in the + * return set. + * @return The set of entities that are contained in this node minus the specified entity, + * {@code e}. If {@code e} is not contained within this node then the full set of + * entities returned is the same as that returned by {@link #getEntities()} + */ + Set getEntitiesMinus(E e); + + /** + * Gets the entities contained in this node minus the top entity. For a node of named classes + * the top entity is {@code owl:Thing}. For a node of object properties the top entity is + * {@code owl:topObjectProperty}. For a node of data properties the top entity is + * {@code owl:topDataProperty} + * + * @return The set of entities contained within this node minus the top entity. If this node + * does not contain the top entity then the set of entities returned is the same as that + * returned by {@link #getEntities()}. + */ + Set getEntitiesMinusTop(); + + /** + * Gets the entities contained in this node minus the bottom entity. For a node of named classes + * the bottom entity is {@code owl:Nothing}. For a node of object properties the bottom entity + * is {@code owl:bottomObjectProperty}. For a node of data properties the bottom entity is + * {@code owl:bottomDataProperty} + * + * @return The set of entities contained within this node minus the bottom entity. If this node + * does not contain the bottom entity then the set of entities returned is the same as + * that returned by {@link #getEntities()}. + */ + Set getEntitiesMinusBottom(); + + /** + * Determines if this {@code Node} contains just one entity. + * + * @return {@code true} if this {@code Node} contains just one entity, otherwise {@code false} + */ + boolean isSingleton(); + + /** + * Gets one of the entities contained in this entity set. If this is a singleton set it will be + * the one and only entity. + * + * @return An entity from the set of entities contained within this node + * @throws RuntimeException if this node is empty (it does not contain any entities). + */ + E getRepresentativeElement(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/NodeSet.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/NodeSet.java new file mode 100644 index 0000000000..b219b6ae98 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/NodeSet.java @@ -0,0 +1,110 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.OWLObject; + +/** + * A set of {@link Node}s. + * + * @param the type of elements in the node set + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface NodeSet extends Iterable> { + + /** + * A convenience method that gets all of the entities contained in the {@code Nodes} in this + * {@code NodeSet}. + * + * @return The union of the entities contained in the {@code Nodes} in this {@code NodeSet}. The + * set that is returned is a copy; modifications to the returned set will not be + * reflected in this object. + */ + default Set getFlattened() { + return asSet(entities()); + } + + /** + * A convenience method that gets all of the entities contained in the {@code Nodes} in this + * {@code NodeSet}. + * + * @return The union of the entities contained in the {@code Nodes} in this {@code NodeSet}. + */ + Stream entities(); + + /** + * @return true if the node set is empty + */ + boolean isEmpty(); + + /** + * A convenience method that determines if this {@code NodeSet} contains a specific entity. + * + * @param e The entity to test for + * @return {@code true} if this {@code NodeSet} contains a {@code Node} that contains the + * entity, {@code e}, and {@code false} if this {@code NodeSet} does not contain a + * {@code Node} that contains the entity, {@code e}. + */ + boolean containsEntity(E e); + + /** + * Determines if this {@code NodeSet} is a singleton. A {@code NodeSet} is a singleton if it + * contains only one {@code Node}. + * + * @return {@code true} if this {@code NodeSet} is a singleton, otherwise {@code false}. + */ + boolean isSingleton(); + + /** + * Determines if this {@code NodeSet} is a singleton node that only contains the top node (in a + * hierarchy). + * + * @return {@code true} if this {@code NodeSet} is a singleton that contains only the top node, + * and {@code false} otherwise. + * @see org.semanticweb.owlapi.reasoner.Node#isTopNode() + */ + boolean isTopSingleton(); + + /** + * Determines if this {@code NodeSet} is a singleton that only contains the bottom node (in a + * hierarchy). + * + * @return {@code true} if this {@code NodeSet} is a singleton that only contains a node that is + * the bottom node, otherwise {@code false} + * @see org.semanticweb.owlapi.reasoner.Node#isBottomNode() + */ + boolean isBottomSingleton(); + + /** + * Gets the {@code Node}s contained in this {@code NodeSet}. + * + * @return The set of {@code Node}s contained in this {@code NodeSet}. The set that is returned + * is a copy; modifications to the returned set will not be reflected in this object. + */ + default Set> getNodes() { + return asSet(nodes()); + } + + /** + * Gets the {@code Node}s contained in this {@code NodeSet}. + * + * @return stream of {@code Node}s contained in this {@code NodeSet}. + */ + Stream> nodes(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/NullReasonerProgressMonitor.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/NullReasonerProgressMonitor.java new file mode 100644 index 0000000000..4584356f95 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/NullReasonerProgressMonitor.java @@ -0,0 +1,26 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +import java.io.Serializable; + +/** + * An implementation of a progress monitor that does nothing when it receives + * notification of progress events. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class NullReasonerProgressMonitor implements ReasonerProgressMonitor, Serializable { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/OWLReasoner.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/OWLReasoner.java new file mode 100644 index 0000000000..b91b8f251b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/OWLReasoner.java @@ -0,0 +1,2923 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.List; +import java.util.Set; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.util.Version; + +/** + * An OWLReasoner reasons over a set of axioms (the set of reasoner axioms) that is based on the + * imports closure of a particular ontology - the "root" ontology. This ontology can be obtained + * using the {@link OWLReasoner#getRootOntology()} method. When the client responsible for creating + * the reasoner has finished with the reasoner instance it must call the {@link #dispose()} method + * to free any resources that are used by the reasoner. In general, reasoners should not be + * instantiated directly, but should be created using the appropriate + * {@link org.semanticweb.owlapi.reasoner.OWLReasonerFactory}.
+ *

Ontology Change Management (Buffering and Non-Buffering Modes)

At creation time, an + * OWLReasoner will load the axioms in the root ontology imports closure. It will attach itself as a + * listener to the {@link org.semanticweb.owlapi.model.OWLOntologyManager} that manages the root + * ontology. The reasoner will listen to any {@link org.semanticweb.owlapi.model.OWLOntologyChange}s + * and respond appropriately to them before answering any queries. If the + * {@link org.semanticweb.owlapi.reasoner.BufferingMode} of the reasoner (the answer to + * {@link #getBufferingMode()} is + * {@link org.semanticweb.owlapi.reasoner.BufferingMode#NON_BUFFERING}) the ontology changes are + * processed by the reasoner immediately so that any queries asked after the changes are answered + * with respect to the changed ontologies. If the + * {@link org.semanticweb.owlapi.reasoner.BufferingMode} of the reasoner is + * {@link org.semanticweb.owlapi.reasoner.BufferingMode#BUFFERING} then ontology changes are stored + * in a buffer and are only taken into consideration when the buffer is flushed with the + * {@link #flush()} method. When reasoning, axioms in the root ontology imports closure, minus the + * axioms returned by the {@link #getPendingAxiomAdditions()} method, plus the axioms returned by + * the {@link #getPendingAxiomRemovals()} are taken into consideration.
+ * Note that there is no guarantee that the reasoner implementation will respond to changes in an + * incremental (and efficient manner) manner.
+ *

Reasoner Axioms

The set of axioms that the reasoner takes into consideration when + * answering queries is known as the set of reasoner axioms. This corresponds the axioms in + * the imports closure of the root ontology plus the axioms returned by the + * {@link #getPendingAxiomRemovals()} minus the axioms returned by + * {@link #getPendingAxiomAdditions()}
+ *

Nodes

The reasoner interface contains methods that return + * {@link org.semanticweb.owlapi.reasoner.NodeSet}s. These are sets of + * {@link org.semanticweb.owlapi.reasoner.Node}s. A {@code Node} contains entities.
+ * For a {@code Node<OWLClass>} of classes, each class in the node is equivalent to the other + * classes in the {@code Node} with respect to the imports closure of the root ontology.
+ * For a {@code Node<OWLObjectProperty>} of object properties, each object property in the + * {@code Node} is equivalent to the other object properties in the node with respect to the imports + * closure of the root ontology.
+ * For a {@code Node<OWLDataProperty>} of data properties, each data property in the + * {@code Node} is equivalent to the other data properties in the node with respect to the imports + * closure of the root ontology.
+ * For a {@code Node<OWLNamedIndividual>} of named individuals, each individual in the node is + * the same as the other individuals in the node with respect to the imports closure of the root + * ontology.
+ * By abuse of notation, we say that a {@code NodeSet} "contains" an entity if that entity is + * contained in one of the {@code Nodes} in the {@code NodeSet}.
+ *

Hierarchies

A hierarchy (class hierarchy, object property hierarchy, data property + * hierarchy) is viewed as a directed acyclic graph (DAG) containing nodes connected via edges. Each + * node in the hierarchy represents a set of entities that are equivalent to each other. Each + * hierarchy has a top node (see org.semanticweb.owlapi.reasoner.Node#isTopNode()) and a bottom node + * (see org.semanticweb.owlapi.reasoner.Node#isBottomNode()).
+ * The figure below shows an example class hierarchy. Each box in the hierarchy represents a + * {@code Node}. In this case the top node contains {@code owl:Thing} and the bottom node contains + * {@code owl:Nothing} because the nodes in the hierarchy are {@code OWLClass} nodes. In this case, + * class {@code G} is equivalent to {@code owl:Thing} so it appears as an entity in the top node + * along with {@code owl:Thing}. Similarly, class {@code K} is unsatisfiable, so it is equivalent to + * {@code owl:Nothing}, and therefore appears in the bottom node containing {@code owl:Nothing}. In + * this example, classes {@code A} and {@code B} are equivalent so they appear in one node, also, + * classes {@code D} and {@code F} are equivalent so they appear in one node.
+ * Asking for the subclasses of a given class (expression) returns the a {@code NodeSet} containing + * the nodes that contain classes that are strict subclasses of the specified class (expression). + * For example, asking for the subclasses of class {@code C} returns the {@code NodeSet} + * {@code {E}} and {@code {owl:Nothing, K}}.
+ * Asking for the direct subclasses of a given class (expression) returns the {@code NodeSet} that + * contains the nodes that contains classes that are direct subclasses of the specified class. For + * example, asking for the direct subclasses of class {@code A} returns the {@code NodeSet} + * containing the nodes {@code {C}} and {@code {D, F}}. Note that there are + * convenience methods on {@link NodeSet} and {@link org.semanticweb.owlapi.reasoner.Node} that can + * be used to directly access the entities in a {@code NodeSet} without having to iterate over the + * nodes and entities in a {@code NodeSet}. For example, a "plain" stream of classes contained + * inside the {@code Nodes} contained inside a {@code NodeSet} can easily be obtained using the + * {@link NodeSet#entities()} method. In this case we could quickly obtain + * {@code {C, D, F}} as the direct subclasses of {@code A} simply by using the + * {@link #getSubClasses(org.semanticweb.owlapi.model.OWLClassExpression, boolean)} (with + * boolean=true) method on {@code OWLReasoner} and then we could use the {@link NodeSet#entities()} + * method on the returned {@code NodeSet} .
+ * Asking for equivalent classes of a class (expression) returns a {@code Node} that contains + * classes that are equivalent to the class (expression) . For example, asking for the equivalent + * classes of {@code owl:Nothing} (i.e. asking for the unsatisfiable classes) returns the + * {@code Node} {@code {owl:Nothing, K}}.
+ * hierarchy
+ *

Definitions

In what follows, an extension of the + * OWL 2 Functional Syntax is given in order to + * capture notions like a class being a "direct" subclass of another class.
+ *

StrictSubClassOf

Given two class expressions {@code CE1} and {@code CE2} and an ontology + * {@code O}, {@code CE1} is a strict subclass of {@code CE2}, written + * {@code StrictSubClassOf(CE1 CE2)} if {@code O} entails {@code SubClassOf(CE1 CE2)} and {@code O} + * does not entail {@code SubClassOf(CE2 CE1)}
+ *

DirectSubClassOf

Given two class expressions {@code CE1} and {@code CE2} and an ontology + * {@code O}, {@code CE1} is a direct subclass of {@code CE2}, written + * {@code DirectSubClassOf(CE1 CE2)}, with respect to {@code O} if {@code O} entails + * {@code StrictSubClassOf(CE1 CE2)} and there is no class name {@code C} in the signature of + * {@code O} such that {@code O} entails {@code StrictSubClassOf(CE1 C)} and {@code O} entails + * {@code StrictSubClassOf(C CE2)}.
+ *

StrictSubObjectPropertyOf

Given two object property expressions {@code OPE1} and + * {@code OPE2} and an ontology {@code O}, {@code OPE1} is a strict subproperty of {@code OPE2}, + * written {@code StrictSubObjectPropertyOf(OPE1 OPE2)} if {@code O} entails + * {@code SubObjectPropertyOf(OPE1 OPE2)} and {@code O} does not entail + * {@code SubObjectPropertyOf(OPE2 OPE1)}
+ *

DirectSubObjectPropertyOf

Given two object property expressions {@code OPE1} and + * {@code OPE2} and an ontology {@code O}, {@code OPE1} is a direct subproperty of + * {@code OPE2}, written {@code DirectSubObjectPropertyOf(OPE1 OPE2)}, with respect to {@code O} if + * {@code O} entails {@code StrictSubObjectPropertyOf(OPE1 OPE2)} and there is no object property + * name {@code P} in the signature of {@code O} such that {@code O} entails + * {@code StrictSubObjectPropertyOf(OPE1 P)} and {@code O} entails + * {@code StrictSubObjectPropertyOf(P OPE2)}.
+ *

StrictSubDataPropertyOf

Given two object property expressions {@code DPE1} and + * {@code DPE2} and an ontology {@code O}, {@code DPE1} is a strict subproperty of {@code DPE2}, + * written {@code StrictSubDataPropertyOf(DPE1 DPE2)} if {@code O} entails + * {@code SubDataPropertyOf(DPE1 DPE2)} and {@code O} does not entail + * {@code SubDataPropertyOf(DPE1 DPE2)}
+ *

DirectSubDataPropertyOf

Given two data property expressions {@code DPE1} and + * {@code DPE2} and an ontology {@code O}, {@code DPE1} is a direct subproperty of + * {@code DPE2}, written {@code DirectSubDataPropertyOf(DPE1 DPE2)}, with respect to {@code O} if + * {@code O} entails {@code StrictSubDataPropertyOf(DPE1 DPE2)} and there is no data property name + * {@code P} in the signature of {@code O} such that {@code O} entails + * {@code StrictSubDataPropertyOf(DPE1 P)} and {@code O} entails + * {@code StrictSubDataPropertyOf(P DPE2)}.
+ *

DirectClassAssertion

Given an individual {@code j} and a class expression {@code CE} and + * an ontology {@code O}, {@code CE} is a direct class assertion (type) for {@code j}, written + * {@code DirectClassAssertion(CE j)}, if {@code O} entails {@code ClassAssertion(CE j)} and there + * is no class name {@code C} in the signature of {@code O} such that {@code O} entails + * {@code ClassAssertion(C j)} and {@code O} entails {@code StrictSubClassOf(C CE)}. + *

ObjectPropertyComplementOf

Given an object property expression {@code pe}, the object + * property complement of {@code pe} is written as {@code ObjectPropertyComplementOf(pe)}. The + * interpretation of {@code ObjectPropertyComplementOf(pe)} is equal to the interpretation of + * {@code owl:topObjectProperty} minus the interpretation of {@code pe}. In other words, + * {@code ObjectPropertyComplementOf(pe)} is the set of pairs of individuals that are not in + * {@code pe}. + *

DataPropertyComplementOf

Given a data property expression {@code pe} , the data property + * complement of {@code pe} is written as {@code DataPropertyComplementOf(pe)}. The interpretation + * of {@code DataPropertyComplementOf(pe)} is equal to the interpretation of + * {@code owl:topDataProperty} minus the interpretation of {@code pe}. In other words, + * {@code DataPropertyComplementOf(pe)} is the set of pairs of individual and literals that are not + * in {@code pe}. + *

Simplified Object Property Expression

A simplified object property expression + * is either a named property {@code P}, or an object inverse property of the form + * {@code ObjectInverseOf(P)} where {@code P} is a named property. In other words, there is no + * nesting of {@code ObjectInverseOf} operators. + *

Error Handling

An {@code OWLReasoner} may throw the following exceptions to indicate + * errors. More documentation for each type of exception can be found on the particular exception + * class. + *
    + *
  • {@link org.semanticweb.owlapi.reasoner.AxiomNotInProfileException}
  • + *
  • {@link org.semanticweb.owlapi.reasoner.ClassExpressionNotInProfileException}
  • + *
  • {@link org.semanticweb.owlapi.reasoner.FreshEntitiesException}
  • + *
  • {@link org.semanticweb.owlapi.reasoner.InconsistentOntologyException}
  • + *
  • {@link org.semanticweb.owlapi.reasoner.TimeOutException}
  • + *
  • {@link org.semanticweb.owlapi.reasoner.ReasonerInterruptedException}
  • + *
  • {@link org.semanticweb.owlapi.reasoner.UnsupportedEntailmentTypeException}
  • + *
  • {@link org.semanticweb.owlapi.reasoner.ReasonerInternalException}
  • + *
+ * Note that {@link org.semanticweb.owlapi.reasoner.ReasonerInternalException} may be throw by any + * of the reasoner methods below. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public interface OWLReasoner { + + /** + * Gets the name of this reasoner. + * + * @return A string that represents the name of this reasoner. + */ + String getReasonerName(); + + /** + * Gets the version of this reasoner. + * + * @return The version of this reasoner. Not {@code null}. + */ + Version getReasonerVersion(); + + /** + * Gets the buffering mode of this reasoner. + * + * @return The buffering mode of this reasoner. + */ + BufferingMode getBufferingMode(); + + /** + * Flushes any changes stored in the buffer, which causes the reasoner to take into + * consideration the changes the current root ontology specified by the changes. If the reasoner + * buffering mode is {@link org.semanticweb.owlapi.reasoner.BufferingMode#NON_BUFFERING} then + * this method will have no effect. + */ + void flush(); + + /** + * Gets the pending changes which need to be taken into consideration by the reasoner so that it + * is up to date with the root ontology imports closure. After the {@link #flush()} method is + * called the set of pending changes will be empty. + * + * @return A set of changes. Note that the changes represent the raw changes as applied to the + * imports closure of the root ontology. + */ + List getPendingChanges(); + + /** + * Gets the pending changes which need to be taken into consideration by the reasoner so that it + * is up to date with the root ontology imports closure. After the {@link #flush()} method is + * called the stream of pending changes will be empty. + * + * @return A stream of changes. Note that the changes represent the raw changes as applied to + * the imports closure of the root ontology. + */ + default Stream pendingChanges() { + return getPendingChanges().stream(); + } + + /** + * Gets the axioms that as a result of ontology changes need to be added to the reasoner to + * synchronise it with the root ontology imports closure. If the buffering mode is + * {@link org.semanticweb.owlapi.reasoner.BufferingMode#NON_BUFFERING} then there will be no + * pending axiom additions. + * + * @return The set of axioms that need to added to the reasoner to the reasoner to synchronise + * it with the root ontology imports closure. + */ + Set getPendingAxiomAdditions(); + + /** + * Gets the axioms that as a result of ontology changes need to be added to the reasoner to + * synchronise it with the root ontology imports closure. If the buffering mode is + * {@link org.semanticweb.owlapi.reasoner.BufferingMode#NON_BUFFERING} then there will be no + * pending axiom additions. + * + * @return The stream of axioms that need to added to the reasoner to the reasoner to + * synchronise it with the root ontology imports closure. + */ + default Stream pendingAxiomAdditions() { + return getPendingAxiomAdditions().stream(); + } + + /** + * Gets the axioms that as a result of ontology changes need to removed to the reasoner to + * synchronise it with the root ontology imports closure. If the buffering mode is + * {@link org.semanticweb.owlapi.reasoner.BufferingMode#NON_BUFFERING} then there will be no + * pending axiom additions. + * + * @return The set of axioms that need to added to the reasoner to the reasoner to synchronise + * it with the root ontology imports closure. + */ + Set getPendingAxiomRemovals(); + + /** + * Gets the axioms that as a result of ontology changes need to removed to the reasoner to + * synchronise it with the root ontology imports closure. If the buffering mode is + * {@link org.semanticweb.owlapi.reasoner.BufferingMode#NON_BUFFERING} then there will be no + * pending axiom additions. + * + * @return The stream of axioms that need to added to the reasoner to the reasoner to + * synchronise it with the root ontology imports closure. + */ + default Stream pendingAxiomRemovals() { + return getPendingAxiomRemovals().stream(); + } + + /** + * Gets the "root" ontology that is loaded into this reasoner. The reasoner takes into account + * the axioms in this ontology and its imports closure, plus the axioms returned by + * {@link #getPendingAxiomRemovals()}, minus the axioms returned by + * {@link #getPendingAxiomAdditions()} when reasoning.
+ * Note that the root ontology is set at reasoner creation time and cannot be changed + * thereafter. Clients that want to add ontologies to and remove ontologies from the reasoner + * after creation time should create a "dummy" ontology that imports the "real" ontologies and + * then specify the dummy ontology as the root ontology at reasoner creation time. + * + * @return The root ontology that is loaded into the reasoner. + */ + OWLOntology getRootOntology(); + + /** + * Asks the reasoner to interrupt what it is currently doing. An ReasonerInterruptedException + * will be thrown in the thread that invoked the last reasoner operation. The OWL API is not + * thread safe in general, but it is likely that this method will be called from another thread + * than the event dispatch thread or the thread in which reasoning takes place.
+ * Note that the reasoner will periodically check for interrupt requests. Asking the reasoner to + * interrupt the current process does not mean that it will be interrupted immediately. However, + * clients can expect to be able to interrupt individual consistency checks, satisfiability + * checks etc. + */ + void interrupt(); + + /** + * Asks the reasoner to precompute certain types of inferences. Note that it is NOT necessary to + * call this method before asking any other queries - the reasoner will answer all queries + * correctly regardless of whether inferences are precomputed or not. For example, if the + * imports closure of the root ontology entails {@code SubClassOf(A B)} then the result of + * {@code getSubClasses(B)} will contain {@code A}, regardless of whether + * {@code precomputeInferences(InferenceType#CLASS_HIERARCHY)} has been called.
+ * If the reasoner does not support the precomputation of a particular type of inference then it + * will silently ignore the request. + * + * @param inferenceTypes Suggests a list of the types of inferences that should be precomputed. + * If the list is empty then the reasoner will determine which types of inferences are + * precomputed. Note that the order of the list is unimportant - the reasoner will + * determine the order in which inferences are computed. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + void precomputeInferences(InferenceType... inferenceTypes); + + /** + * Determines if a specific set of inferences have been precomputed. + * + * @param inferenceType The type of inference to check for. + * @return {@code true} if the specified type of inferences have been precomputed, otherwise + * {@code false}. + */ + boolean isPrecomputed(InferenceType inferenceType); + + /** + * Returns the set of {@link org.semanticweb.owlapi.reasoner.InferenceType}s that are + * precomputable by reasoner. + * + * @return A set of {@link org.semanticweb.owlapi.reasoner.InferenceType}s that can be + * precomputed by this reasoner. + */ + Set getPrecomputableInferenceTypes(); + + /** + * Returns the stream of {@link org.semanticweb.owlapi.reasoner.InferenceType}s that are + * precomputable by reasoner. + * + * @return A stream of {@link org.semanticweb.owlapi.reasoner.InferenceType}s that can be + * precomputed by this reasoner. + */ + default Stream precomputableInferenceTypes() { + return getPrecomputableInferenceTypes().stream(); + } + + /** + * Determines if the set of reasoner axioms is consistent. Note that this method will NOT throw + * an {@link org.semanticweb.owlapi.reasoner.InconsistentOntologyException} even if the root + * ontology imports closure is inconsistent. + * + * @return {@code true} if the imports closure of the root ontology is consistent, or {@code + * false} if the imports closure of the root ontology is inconsistent. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process). + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + boolean isConsistent(); + + /** + * A convenience method that determines if the specified class expression is satisfiable with + * respect to the reasoner axioms. + * + * @param classExpression The class expression + * @return {@code true} if classExpression is satisfiable with respect to the set of axioms, or + * {@code false} if classExpression is unsatisfiable with respect to the axioms. + * @throws InconsistentOntologyException if the set of reasoner axioms is inconsistent + * @throws ClassExpressionNotInProfileException if {@code classExpression} is not within the + * profile that is supported by this reasoner. + * @throws FreshEntitiesException if the signature of the classExpression is not contained + * within the signature of the set of reasoner axioms. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + boolean isSatisfiable(OWLClassExpression classExpression); + + /** + * A convenience method that obtains the classes in the signature of the root ontology that are + * unsatisfiable. + * + * @return A {@code Node} that is the bottom node in the class hierarchy. This node represents + * {@code owl:Nothing} and contains {@code owl:Nothing} itself plus classes that are + * equivalent to {@code owl:Nothing}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + * @throws InconsistentOntologyException if the set of reasoner axioms is inconsistent + */ + Node getUnsatisfiableClasses(); + + /** + * A convenience method that obtains the classes in the signature of the root ontology that are + * unsatisfiable. + * + * @return A {@code Node} that is the bottom node in the class hierarchy. This node represents + * {@code owl:Nothing} and contains {@code owl:Nothing} itself plus classes that are + * equivalent to {@code owl:Nothing}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + * @throws InconsistentOntologyException if the set of reasoner axioms is inconsistent + */ + default Stream unsatisfiableClasses() { + return getUnsatisfiableClasses().entities(); + } + + /** + * A convenience method that determines if the specified axiom is entailed by the set of + * reasoner axioms. + * + * @param axiom The axiom + * @return {@code true} if {@code axiom} is entailed by the reasoner axioms or {@code false} if + * {@code axiom} is not entailed by the reasoner axioms. {@code true} if the set of + * reasoner axioms is inconsistent. + * @throws FreshEntitiesException if the signature of the axiom is not contained within the + * signature of the imports closure of the root ontology. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + * @throws UnsupportedEntailmentTypeException if the reasoner cannot perform a check to see if + * the specified axiom is entailed + * @throws AxiomNotInProfileException if {@code axiom} is not in the profile that is supported + * by this reasoner. + * @throws InconsistentOntologyException if the set of reasoner axioms is inconsistent + * @see #isEntailmentCheckingSupported(org.semanticweb.owlapi.model.AxiomType) + */ + boolean isEntailed(OWLAxiom axiom); + + /** + * Determines if the specified set of axioms is entailed by the reasoner axioms. + * + * @param axioms The set of axioms to be tested + * @return {@code true} if the set of axioms is entailed by the axioms in the imports closure of + * the root ontology, otherwise {@code false} . If the set of reasoner axioms is + * inconsistent then {@code true} . + * @throws FreshEntitiesException if the signature of the set of axioms is not contained within + * the signature of the imports closure of the root ontology and the undeclared entity + * policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + * @throws UnsupportedEntailmentTypeException if the reasoner cannot perform a check to see if + * the specified axiom is entailed + * @throws AxiomNotInProfileException if {@code axiom} is not in the profile that is supported + * by this reasoner. + * @throws InconsistentOntologyException if the set of reasoner axioms is inconsistent + * @see #isEntailmentCheckingSupported(org.semanticweb.owlapi.model.AxiomType) + */ + boolean isEntailed(Set axioms); + + /** + * @param axioms The set of axioms to be tested + * @return true if axioms are entailed + * @see OWLReasoner#isEntailed(Set) + */ + default boolean isEntailed(Stream axioms) { + return isEntailed(asUnorderedSet(axioms)); + } + + /** + * @param axioms The set of axioms to be tested + * @return true if axioms are entailed + * @see OWLReasoner#isEntailed(Set) + */ + default boolean isEntailed(OWLAxiom... axioms) { + return isEntailed(Stream.of(axioms)); + } + + /** + * Determines if entailment checking for the specified axiom type is supported. + * + * @param axiomType The axiom type + * @return {@code true} if entailment checking for the specified axiom type is supported, + * otherwise {@code false}. If {@code true} then asking + * {@link #isEntailed(org.semanticweb.owlapi.model.OWLAxiom)} will not throw an + * exception of + * {@link org.semanticweb.owlapi.reasoner.UnsupportedEntailmentTypeException} . If + * {@code false} then asking {@link #isEntailed(org.semanticweb.owlapi.model.OWLAxiom)} + * will throw an + * {@link org.semanticweb.owlapi.reasoner.UnsupportedEntailmentTypeException} . + */ + boolean isEntailmentCheckingSupported(AxiomType axiomType); + + // Methods for dealing with the class hierarchy + + /** + * Gets the {@code Node} corresponding to the top node (containing {@code owl:Thing}) in the + * class hierarchy. + * + * @return A {@code Node} containing {@code owl:Thing} that is the top node in the class + * hierarchy. This {@code Node} is essentially equal to the {@code Node} returned by + * calling + * {@link #getEquivalentClasses(org.semanticweb.owlapi.model.OWLClassExpression)} with a + * parameter of {@code owl:Thing}. + */ + Node getTopClassNode(); + + /** + * Gets the {@code Node} corresponding to the top node (containing {@code owl:Thing}) in the + * class hierarchy. + * + * @return A {@code Node} containing {@code owl:Thing} that is the top node in the class + * hierarchy. This {@code Node} is essentially equal to the {@code Node} returned by + * calling + * {@link #getEquivalentClasses(org.semanticweb.owlapi.model.OWLClassExpression)} with a + * parameter of {@code owl:Thing}. + */ + default Stream topClassNode() { + return getTopClassNode().entities(); + } + + /** + * Gets the {@code Node} corresponding to the bottom node (containing {@code owl:Nothing}) in + * the class hierarchy. + * + * @return A {@code Node} containing {@code owl:Nothing} that is the bottom node in the class + * hierarchy. This {@code Node} is essentially equal to the {@code Node} that will be + * returned by calling + * {@link #getEquivalentClasses(org.semanticweb.owlapi.model.OWLClassExpression)} with a + * parameter of {@code owl:Nothing}. + */ + Node getBottomClassNode(); + + /** + * Gets the {@code Node} corresponding to the bottom node (containing {@code owl:Nothing}) in + * the class hierarchy. + * + * @return A {@code Node} containing {@code owl:Nothing} that is the bottom node in the class + * hierarchy. This {@code Node} is essentially equal to the {@code Node} that will be + * returned by calling + * {@link #getEquivalentClasses(org.semanticweb.owlapi.model.OWLClassExpression)} with a + * parameter of {@code owl:Nothing}. + */ + default Stream bottomClassNode() { + return getBottomClassNode().entities(); + } + + /** + * Gets the set of named classes that are the strict (potentially direct) subclasses of the + * specified class expression with respect to the reasoner axioms. Note that the classes are + * returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param ce The class expression whose strict (direct) subclasses are to be retrieved. + * @param direct Specifies if the direct subclasses should be retrieved ( {@code true}) or if + * the all subclasses (descendant) classes should be retrieved ({@code false}). + * @return If direct is {@code true}, a {@code NodeSet} such that for each class {@code C} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code DirectSubClassOf(C, ce)}.
+ * If direct is {@code false}, a {@code NodeSet} such that for each class {@code C} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code StrictSubClassOf(C, ce)}.
+ * If {@code ce} is equivalent to {@code owl:Nothing} then the empty {@code NodeSet} + * will be returned. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws ClassExpressionNotInProfileException if {@code classExpression} is not within the + * profile that is supported by this reasoner. + * @throws FreshEntitiesException if the signature of the classExpression is not contained + * within the signature of the imports closure of the root ontology and the undeclared + * entity policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + NodeSet getSubClasses(OWLClassExpression ce, boolean direct); + + /** + * Gets the set of named classes that are the strict (potentially direct) subclasses of the + * specified class expression with respect to the reasoner axioms. Note that the classes are + * returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param ce The class expression whose strict (direct) subclasses are to be retrieved. + * @param direct Specifies if the direct subclasses should be retrieved ( {@code true}) or if + * the all subclasses (descendant) classes should be retrieved ({@code false}). + * @return If direct is {@code true}, a {@code NodeSet} such that for each class {@code C} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code DirectSubClassOf(C, ce)}.
+ * If direct is {@code false}, a {@code NodeSet} such that for each class {@code C} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code StrictSubClassOf(C, ce)}.
+ * If {@code ce} is equivalent to {@code owl:Nothing} then the empty {@code NodeSet} + * will be returned. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws ClassExpressionNotInProfileException if {@code classExpression} is not within the + * profile that is supported by this reasoner. + * @throws FreshEntitiesException if the signature of the classExpression is not contained + * within the signature of the imports closure of the root ontology and the undeclared + * entity policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + default Stream subClasses(OWLClassExpression ce, boolean direct) { + return getSubClasses(ce, direct).entities(); + } + + /** + * @param ce The class expression whose strict (direct) subclasses are to be retrieved. + * @param depth use {@code DIRECT} for direct subclasses only, {@code ALL} for all subclasses + * @return If depth is {@code DIRECT}, a {@code NodeSet} such that for each class {@code C} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code DirectSubClassOf(C, ce)}.
+ * If direct is {@code ALL}, a {@code NodeSet} such that for each class {@code C} in the + * {@code + * NodeSet} the set of reasoner axioms entails {@code StrictSubClassOf(C, ce)}.
+ * If {@code + * ce} is equivalent to {@code owl:Nothing} then the empty {@code NodeSet} will be returned. + * @see OWLReasoner#getSubClasses(OWLClassExpression, boolean) + */ + default NodeSet getSubClasses(OWLClassExpression ce, InferenceDepth depth) { + return getSubClasses(ce, depth.isDirectOnly()); + } + + /** + * @param ce The class expression whose strict (direct) subclasses are to be retrieved. + * @param depth use {@code DIRECT} for direct subclasses only, {@code ALL} for all subclasses + * @return If depth is {@code DIRECT}, a {@code NodeSet} such that for each class {@code C} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code DirectSubClassOf(C, ce)}.
+ * If direct is {@code ALL}, a {@code NodeSet} such that for each class {@code C} in the + * {@code + * NodeSet} the set of reasoner axioms entails {@code StrictSubClassOf(C, ce)}.
+ * If {@code + * ce} is equivalent to {@code owl:Nothing} then the empty {@code NodeSet} will be returned. + * @see OWLReasoner#getSubClasses(OWLClassExpression, boolean) + */ + default Stream subClasses(OWLClassExpression ce, InferenceDepth depth) { + return getSubClasses(ce, depth).entities(); + } + + /** + * Returns all subclasses. + * + * @param ce The class expression whose strict (direct) subclasses are to be retrieved. + * @return a {@code NodeSet} such that for each class {@code C} in the {@code NodeSet} the set + * of reasoner axioms entails {@code StrictSubClassOf(C, ce)}.
+ * If {@code ce} is equivalent to {@code owl:Nothing} then the empty {@code NodeSet} + * will be returned. + * @see OWLReasoner#getSubClasses(OWLClassExpression, boolean) + */ + default NodeSet getSubClasses(OWLClassExpression ce) { + return getSubClasses(ce, false); + } + + /** + * Returns all subclasses. + * + * @param ce The class expression whose strict (direct) subclasses are to be retrieved. + * @return a {@code NodeSet} such that for each class {@code C} in the {@code NodeSet} the set + * of reasoner axioms entails {@code StrictSubClassOf(C, ce)}.
+ * If {@code ce} is equivalent to {@code owl:Nothing} then the empty {@code NodeSet} + * will be returned. + * @see OWLReasoner#getSubClasses(OWLClassExpression, boolean) + */ + default Stream subClasses(OWLClassExpression ce) { + return getSubClasses(ce).entities(); + } + + /** + * Gets the set of named classes that are the strict (potentially direct) super classes of the + * specified class expression with respect to the imports closure of the root ontology. Note + * that the classes are returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param ce The class expression whose strict (direct) super classes are to be retrieved. + * @param direct Specifies if the direct super classes should be retrieved ( {@code true}) or if + * the all super classes (ancestors) classes should be retrieved ({@code false}). + * @return If direct is {@code true}, a {@code NodeSet} such that for each class {@code C} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code DirectSubClassOf(ce, C)}.
+ * If direct is {@code false}, a {@code NodeSet} such that for each class {@code C} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code StrictSubClassOf(ce, C)}.
+ * If {@code ce} is equivalent to {@code owl:Thing} then the empty {@code NodeSet} will + * be returned. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws ClassExpressionNotInProfileException if {@code classExpression} is not within the + * profile that is supported by this reasoner. + * @throws FreshEntitiesException if the signature of the classExpression is not contained + * within the signature of the imports closure of the root ontology and the undeclared + * entity policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + NodeSet getSuperClasses(OWLClassExpression ce, boolean direct); + + /** + * Gets the stream of named classes that are the strict (potentially direct) super classes of + * the specified class expression with respect to the imports closure of the root ontology. Note + * that the classes are returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param ce The class expression whose strict (direct) super classes are to be retrieved. + * @param direct Specifies if the direct super classes should be retrieved ( {@code true}) or if + * the all super classes (ancestors) classes should be retrieved ({@code false}). + * @return If direct is {@code true}, a {@code NodeSet} such that for each class {@code C} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code DirectSubClassOf(ce, C)}.
+ * If direct is {@code false}, a {@code NodeSet} such that for each class {@code C} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code StrictSubClassOf(ce, C)}.
+ * If {@code ce} is equivalent to {@code owl:Thing} then the empty {@code NodeSet} will + * be returned. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws ClassExpressionNotInProfileException if {@code classExpression} is not within the + * profile that is supported by this reasoner. + * @throws FreshEntitiesException if the signature of the classExpression is not contained + * within the signature of the imports closure of the root ontology and the undeclared + * entity policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + default Stream superClasses(OWLClassExpression ce, boolean direct) { + return getSuperClasses(ce, direct).entities(); + } + + /** + * @param ce The class expression whose strict (direct) super classes are to be retrieved. + * @param depth Specifies if the direct super classes should be retrieved ( {@code DIRECT}) or + * if the all super classes (ancestors) classes should be retrieved ({@code ALL}). + * @return If direct is {@code DIRECT}, a {@code NodeSet} such that for each class {@code C} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code DirectSubClassOf(ce, C)}.
+ * If direct is {@code false}, a {@code NodeSet} such that for each class {@code C} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code StrictSubClassOf(ce, C)}.
+ * If {@code ce} is equivalent to {@code owl:Thing} then the empty {@code NodeSet} will + * be returned. + * @see OWLReasoner#getSuperClasses(OWLClassExpression, boolean) + */ + default NodeSet getSuperClasses(OWLClassExpression ce, InferenceDepth depth) { + return getSuperClasses(ce, depth.isDirectOnly()); + } + + /** + * @param ce The class expression whose strict (direct) super classes are to be retrieved. + * @param depth Specifies if the direct super classes should be retrieved ( {@code DIRECT}) or + * if the all super classes (ancestors) classes should be retrieved ({@code ALL}). + * @return If direct is {@code DIRECT}, a {@code NodeSet} such that for each class {@code C} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code DirectSubClassOf(ce, C)}.
+ * If direct is {@code false}, a {@code NodeSet} such that for each class {@code C} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code StrictSubClassOf(ce, C)}.
+ * If {@code ce} is equivalent to {@code owl:Thing} then the empty {@code NodeSet} will + * be returned. + * @see OWLReasoner#getSuperClasses(OWLClassExpression, boolean) + */ + default Stream superClasses(OWLClassExpression ce, InferenceDepth depth) { + return getSuperClasses(ce, depth).entities(); + } + + /** + * @param ce The class expression whose strict (direct) super classes are to be retrieved. + * @return a {@code NodeSet} such that for each class {@code C} in the {@code NodeSet} the set + * of reasoner axioms entails {@code StrictSubClassOf(ce, C)}.
+ * If {@code ce} is equivalent to {@code owl:Thing} then the empty {@code NodeSet} will + * be returned. + * @see OWLReasoner#getSuperClasses(OWLClassExpression, boolean) Return all superclasses. + */ + default NodeSet getSuperClasses(OWLClassExpression ce) { + return getSuperClasses(ce, false); + } + + /** + * @param ce The class expression whose strict (direct) super classes are to be retrieved. + * @return a {@code NodeSet} such that for each class {@code C} in the {@code NodeSet} the set + * of reasoner axioms entails {@code StrictSubClassOf(ce, C)}.
+ * If {@code ce} is equivalent to {@code owl:Thing} then the empty {@code NodeSet} will + * be returned. + * @see OWLReasoner#getSuperClasses(OWLClassExpression, boolean) Return all superclasses. + */ + default Stream superClasses(OWLClassExpression ce) { + return getSuperClasses(ce).entities(); + } + + /** + * Gets the set of named classes that are equivalent to the specified class expression with + * respect to the set of reasoner axioms. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.Node}. + * + * @param ce The class expression whose equivalent classes are to be retrieved. + * @return A node containing the named classes such that for each named class {@code C} in the + * node the root ontology imports closure entails {@code EquivalentClasses(ce C)}. If + * {@code ce} is not a class name (i.e. it is an anonymous class expression) and there + * are no such classes {@code C} then the node will be empty.
+ * If {@code ce} is a named class then {@code ce} will be contained in the node.
+ * If {@code ce} is unsatisfiable with respect to the set of reasoner axioms then the + * node representing and containing {@code owl:Nothing}, i.e. the bottom node, will be + * returned.
+ * If {@code ce} is equivalent to {@code owl:Thing} with respect to the set of reasoner + * axioms then the node representing and containing {@code + * owl:Thing}, i.e. the top node, will be returned. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws ClassExpressionNotInProfileException if {@code classExpression} is not within the + * profile that is supported by this reasoner. + * @throws FreshEntitiesException if the signature of the classExpression is not contained + * within the signature of the imports closure of the root ontology and the undeclared + * entity policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + Node getEquivalentClasses(OWLClassExpression ce); + + /** + * Gets the stream of named classes that are equivalent to the specified class expression with + * respect to the set of reasoner axioms. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.Node}. + * + * @param ce The class expression whose equivalent classes are to be retrieved. + * @return A node containing the named classes such that for each named class {@code C} in the + * node the root ontology imports closure entails {@code EquivalentClasses(ce C)}. If + * {@code ce} is not a class name (i.e. it is an anonymous class expression) and there + * are no such classes {@code C} then the node will be empty.
+ * If {@code ce} is a named class then {@code ce} will be contained in the node.
+ * If {@code ce} is unsatisfiable with respect to the set of reasoner axioms then the + * node representing and containing {@code owl:Nothing}, i.e. the bottom node, will be + * returned.
+ * If {@code ce} is equivalent to {@code owl:Thing} with respect to the set of reasoner + * axioms then the node representing and containing {@code + * owl:Thing}, i.e. the top node, will be returned. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws ClassExpressionNotInProfileException if {@code classExpression} is not within the + * profile that is supported by this reasoner. + * @throws FreshEntitiesException if the signature of the classExpression is not contained + * within the signature of the imports closure of the root ontology and the undeclared + * entity policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + default Stream equivalentClasses(OWLClassExpression ce) { + return getEquivalentClasses(ce).entities(); + } + + /** + * Gets the classes that are disjoint with the specified class expression {@code ce}. The + * classes are returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param ce The class expression whose disjoint classes are to be retrieved. + * @return The return value is a {@code NodeSet} such that for each class {@code D} in the + * {@code NodeSet} the set of reasoner axioms entails {@code EquivalentClasses(D, + * ObjectComplementOf(ce))} or {@code StrictSubClassOf(D, ObjectComplementOf(ce))}. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws ClassExpressionNotInProfileException if {@code classExpression} is not within the + * profile that is supported by this reasoner. + * @throws FreshEntitiesException if the signature of the classExpression is not contained + * within the signature of the imports closure of the root ontology and the undeclared + * entity policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + NodeSet getDisjointClasses(OWLClassExpression ce); + + /** + * Gets the classes that are disjoint with the specified class expression {@code ce}. The + * classes are returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param ce The class expression whose disjoint classes are to be retrieved. + * @return The return value is a {@code NodeSet} such that for each class {@code D} in the + * {@code NodeSet} the set of reasoner axioms entails {@code EquivalentClasses(D, + * ObjectComplementOf(ce))} or {@code StrictSubClassOf(D, ObjectComplementOf(ce))}. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws ClassExpressionNotInProfileException if {@code classExpression} is not within the + * profile that is supported by this reasoner. + * @throws FreshEntitiesException if the signature of the classExpression is not contained + * within the signature of the imports closure of the root ontology and the undeclared + * entity policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + default Stream disjointClasses(OWLClassExpression ce) { + return getDisjointClasses(ce).entities(); + } + + // Methods for dealing with the object property hierarchy + + /** + * Gets the {@code Node} corresponding to the top node (containing + * {@code owl:topObjectProperty}) in the object property hierarchy. + * + * @return A {@code Node} containing {@code owl:topObjectProperty} that is the top node in the + * object property hierarchy. This {@code Node} is essentially equivalent to the + * {@code Node} returned by calling + * {@link #getEquivalentObjectProperties(org.semanticweb.owlapi.model.OWLObjectPropertyExpression)} + * with a parameter of {@code owl:topObjectProperty}. + */ + Node getTopObjectPropertyNode(); + + /** + * Gets the {@code Node} corresponding to the top node (containing + * {@code owl:topObjectProperty}) in the object property hierarchy. + * + * @return A {@code Node} containing {@code owl:topObjectProperty} that is the top node in the + * object property hierarchy. This {@code Node} is essentially equivalent to the + * {@code Node} returned by calling + * {@link #getEquivalentObjectProperties(org.semanticweb.owlapi.model.OWLObjectPropertyExpression)} + * with a parameter of {@code owl:topObjectProperty}. + */ + default Stream topObjectPropertyNode() { + return getTopObjectPropertyNode().entities(); + } + + /** + * Gets the {@code Node} corresponding to the bottom node (containing + * {@code owl:bottomObjectProperty}) in the object property hierarchy. + * + * @return A {@code Node}, containing {@code owl:bottomObjectProperty}, that is the bottom node + * in the object property hierarchy. This {@code Node} is essentially equal to the + * {@code Node} that will be returned by calling + * {@link #getEquivalentObjectProperties(org.semanticweb.owlapi.model.OWLObjectPropertyExpression)} + * with a parameter of {@code owl:bottomObjectProperty}. + */ + Node getBottomObjectPropertyNode(); + + /** + * Gets the {@code Node} corresponding to the bottom node (containing + * {@code owl:bottomObjectProperty}) in the object property hierarchy. + * + * @return A {@code Node}, containing {@code owl:bottomObjectProperty}, that is the bottom node + * in the object property hierarchy. This {@code Node} is essentially equal to the + * {@code Node} that will be returned by calling + * {@link #getEquivalentObjectProperties(org.semanticweb.owlapi.model.OWLObjectPropertyExpression)} + * with a parameter of {@code owl:bottomObjectProperty}. + */ + default Stream bottomObjectPropertyNode() { + return getBottomObjectPropertyNode().entities(); + } + + /** + * Gets the set of simplified object property expressions that are the strict + * (potentially direct) subproperties of the specified object property expression with respect + * to the imports closure of the root ontology. Note that the properties are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param pe The object property expression whose strict (direct) subproperties are to be + * retrieved. + * @param direct Specifies if the direct subproperties should be retrieved ( {@code true}) or if + * the all subproperties (descendants) should be retrieved ({@code false}). + * @return If direct is {@code true}, a {@code NodeSet} of simplified object + * property expressions, such that for each simplified object + * property expression, {@code P}, in the {@code NodeSet} the set of reasoner axioms + * entails {@code + * DirectSubObjectPropertyOf(P, pe)}.
+ * If direct is {@code false}, a {@code NodeSet} of simplified object + * property expressions, such that for each simplified object + * property expression, {@code P}, in the {@code NodeSet} the set of reasoner axioms + * entails {@code StrictSubObjectPropertyOf(P, pe)}.
+ * If {@code pe} is equivalent to {@code owl:bottomObjectProperty} then the empty + * {@code NodeSet} will be returned. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the object property expression is not + * contained within the signature of the imports closure of the root ontology and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + NodeSet getSubObjectProperties(OWLObjectPropertyExpression pe, + boolean direct); + + /** + * Gets the stream of simplified object property expressions that are the + * strict (potentially direct) subproperties of the specified object property expression with + * respect to the imports closure of the root ontology. Note that the properties are returned as + * a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param pe The object property expression whose strict (direct) subproperties are to be + * retrieved. + * @param direct Specifies if the direct subproperties should be retrieved ( {@code true}) or if + * the all subproperties (descendants) should be retrieved ({@code false}). + * @return If direct is {@code true}, a {@code NodeSet} of simplified object + * property expressions, such that for each simplified object + * property expression, {@code P}, in the {@code NodeSet} the set of reasoner axioms + * entails {@code + * DirectSubObjectPropertyOf(P, pe)}.
+ * If direct is {@code false}, a {@code NodeSet} of simplified object + * property expressions, such that for each simplified object + * property expression, {@code P}, in the {@code NodeSet} the set of reasoner axioms + * entails {@code StrictSubObjectPropertyOf(P, pe)}.
+ * If {@code pe} is equivalent to {@code owl:bottomObjectProperty} then the empty + * {@code NodeSet} will be returned. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the object property expression is not + * contained within the signature of the imports closure of the root ontology and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + default Stream subObjectProperties(OWLObjectPropertyExpression pe, + boolean direct) { + return getSubObjectProperties(pe, direct).entities(); + } + + /** + * @param pe The object property expression whose strict (direct) super properties are to be + * retrieved. + * @param depth Specifies if the direct subproperties should be retrieved ( {@code DIRECT}) or + * if the all subproperties (descendants) should be retrieved ({@code ALL}). + * @return If depth is {@code DIRECT}, a {@code NodeSet} of simplified object + * property expressions, such that for each simplified object + * property expression, {@code P}, in the {@code NodeSet} the set of reasoner axioms + * entails {@code + * DirectSubObjectPropertyOf(P, pe)}.
+ * If direct is {@code ALL}, a {@code NodeSet} of simplified object + * property expressions, such that for each simplified object + * property expression, {@code P}, in the {@code NodeSet} the set of reasoner axioms + * entails {@code StrictSubObjectPropertyOf(P, pe)}.
+ * If {@code pe} is equivalent to {@code owl:bottomObjectProperty} then the empty + * {@code NodeSet} will be returned. + * @see OWLReasoner#getSubObjectProperties(OWLObjectPropertyExpression, boolean) Gets the set of + * simplified object property expressions that are the strict + * (potentially direct) subproperties of the specified object property expression with + * respect to the imports closure of the root ontology. Note that the properties are + * returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default NodeSet getSubObjectProperties( + OWLObjectPropertyExpression pe, InferenceDepth depth) { + return getSubObjectProperties(pe, depth.isDirectOnly()); + } + + /** + * @param pe The object property expression whose strict (direct) super properties are to be + * retrieved. + * @param depth Specifies if the direct subproperties should be retrieved ( {@code DIRECT}) or + * if the all subproperties (descendants) should be retrieved ({@code ALL}). + * @return If depth is {@code DIRECT}, a {@code NodeSet} of simplified object + * property expressions, such that for each simplified object + * property expression, {@code P}, in the {@code NodeSet} the set of reasoner axioms + * entails {@code + * DirectSubObjectPropertyOf(P, pe)}.
+ * If direct is {@code ALL}, a {@code NodeSet} of simplified object + * property expressions, such that for each simplified object + * property expression, {@code P}, in the {@code NodeSet} the set of reasoner axioms + * entails {@code StrictSubObjectPropertyOf(P, pe)}.
+ * If {@code pe} is equivalent to {@code owl:bottomObjectProperty} then the empty + * {@code NodeSet} will be returned. + * @see OWLReasoner#getSubObjectProperties(OWLObjectPropertyExpression, boolean) Gets the set of + * simplified object property expressions that are the strict + * (potentially direct) subproperties of the specified object property expression with + * respect to the imports closure of the root ontology. Note that the properties are + * returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default Stream subObjectProperties(OWLObjectPropertyExpression pe, + InferenceDepth depth) { + return getSubObjectProperties(pe, depth).entities(); + } + + /** + * @param pe The object property expression whose strict (direct) super properties are to be + * retrieved. + * @return A {@code NodeSet} of simplified object property expressions, such + * that for each simplified object property expression, {@code P}, in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code StrictSubObjectPropertyOf(P, pe)}.
+ * If {@code pe} is equivalent to {@code owl:bottomObjectProperty} then the empty {@code + * NodeSet} will be returned. + * @see OWLReasoner#getSubObjectProperties(OWLObjectPropertyExpression, boolean) Gets the set of + * all simplified object property expressions that are the strict + * (potentially direct) subproperties of the specified object property expression with + * respect to the imports closure of the root ontology. Note that the properties are + * returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default NodeSet getSubObjectProperties( + OWLObjectPropertyExpression pe) { + return getSubObjectProperties(pe, false); + } + + /** + * @param pe The object property expression whose strict (direct) super properties are to be + * retrieved. + * @return A {@code NodeSet} of simplified object property expressions, such + * that for each simplified object property expression, {@code P}, in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code StrictSubObjectPropertyOf(P, pe)}.
+ * If {@code pe} is equivalent to {@code owl:bottomObjectProperty} then the empty {@code + * NodeSet} will be returned. + * @see OWLReasoner#getSubObjectProperties(OWLObjectPropertyExpression, boolean) Gets the set of + * all simplified object property expressions that are the strict + * (potentially direct) subproperties of the specified object property expression with + * respect to the imports closure of the root ontology. Note that the properties are + * returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default Stream subObjectProperties( + OWLObjectPropertyExpression pe) { + return getSubObjectProperties(pe, false).entities(); + } + + /** + * Gets the set of simplified object property expressions that are the strict + * (potentially direct) super properties of the specified object property expression with + * respect to the imports closure of the root ontology. Note that the properties are returned as + * a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param pe The object property expression whose strict (direct) super properties are to be + * retrieved. + * @param direct Specifies if the direct super properties should be retrieved ( {@code true}) or + * if the all super properties (ancestors) should be retrieved ({@code false}). + * @return If direct is {@code true}, a {@code NodeSet} of simplified object + * property expressions, such that for each simplified object + * property expression, {@code P}, in the {@code NodeSet}, the set of reasoner + * axioms entails {@code + * DirectSubObjectPropertyOf(pe, P)}.
+ * If direct is {@code false}, a {@code NodeSet} of simplified object + * property expressions, such that for each simplified object + * property expression, {@code P}, in the {@code NodeSet}, the set of reasoner + * axioms entails {@code StrictSubObjectPropertyOf(pe, P)}.
+ * If {@code pe} is equivalent to {@code owl:topObjectProperty} then the empty + * {@code NodeSet} will be returned. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the object property expression is not + * contained within the signature of the imports closure of the root ontology and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + NodeSet getSuperObjectProperties(OWLObjectPropertyExpression pe, + boolean direct); + + /** + * Gets the stream of simplified object property expressions that are the + * strict (potentially direct) super properties of the specified object property expression with + * respect to the imports closure of the root ontology. Note that the properties are returned as + * a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param pe The object property expression whose strict (direct) super properties are to be + * retrieved. + * @param direct Specifies if the direct super properties should be retrieved ( {@code true}) or + * if the all super properties (ancestors) should be retrieved ({@code false}). + * @return If direct is {@code true}, a {@code NodeSet} of simplified object + * property expressions, such that for each simplified object + * property expression, {@code P}, in the {@code NodeSet}, the set of reasoner + * axioms entails {@code + * DirectSubObjectPropertyOf(pe, P)}.
+ * If direct is {@code false}, a {@code NodeSet} of simplified object + * property expressions, such that for each simplified object + * property expression, {@code P}, in the {@code NodeSet}, the set of reasoner + * axioms entails {@code StrictSubObjectPropertyOf(pe, P)}.
+ * If {@code pe} is equivalent to {@code owl:topObjectProperty} then the empty + * {@code NodeSet} will be returned. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the object property expression is not + * contained within the signature of the imports closure of the root ontology and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + default Stream superObjectProperties( + OWLObjectPropertyExpression pe, boolean direct) { + return getSuperObjectProperties(pe, direct).entities(); + } + + /** + * @param pe The object property expression whose strict (direct) super properties are to be + * retrieved. + * @param depth Specifies if the direct super properties should be retrieved ( {@code DIRECT}) + * or if the all super properties (ancestors) should be retrieved ({@code ALL}). + * @return If depth is {@code DIRECT}, a {@code NodeSet} of simplified object + * property expressions, such that for each simplified object + * property expression, {@code P}, in the {@code NodeSet}, the set of reasoner + * axioms entails {@code + * DirectSubObjectPropertyOf(pe, P)}.
+ * If depth is {@code ALL}, a {@code NodeSet} of simplified object + * property expressions, such that for each simplified object + * property expression, {@code P}, in the {@code NodeSet}, the set of reasoner + * axioms entails {@code StrictSubObjectPropertyOf(pe, P)}.
+ * If {@code pe} is equivalent to {@code owl:topObjectProperty} then the empty + * {@code NodeSet} will be returned. + * @see OWLReasoner#getSuperObjectProperties(OWLObjectPropertyExpression, boolean) Gets the set + * of simplified object property expressions that are the strict + * (potentially direct) super properties of the specified object property expression with + * respect to the imports closure of the root ontology. Note that the properties are + * returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default NodeSet getSuperObjectProperties( + OWLObjectPropertyExpression pe, InferenceDepth depth) { + return getSuperObjectProperties(pe, depth.isDirectOnly()); + } + + /** + * @param pe The object property expression whose strict (direct) super properties are to be + * retrieved. + * @param depth Specifies if the direct super properties should be retrieved ( {@code DIRECT}) + * or if the all super properties (ancestors) should be retrieved ({@code ALL}). + * @return If depth is {@code DIRECT}, a {@code NodeSet} of simplified object + * property expressions, such that for each simplified object + * property expression, {@code P}, in the {@code NodeSet}, the set of reasoner + * axioms entails {@code + * DirectSubObjectPropertyOf(pe, P)}.
+ * If depth is {@code ALL}, a {@code NodeSet} of simplified object + * property expressions, such that for each simplified object + * property expression, {@code P}, in the {@code NodeSet}, the set of reasoner + * axioms entails {@code StrictSubObjectPropertyOf(pe, P)}.
+ * If {@code pe} is equivalent to {@code owl:topObjectProperty} then the empty + * {@code NodeSet} will be returned. + * @see OWLReasoner#getSuperObjectProperties(OWLObjectPropertyExpression, boolean) Gets the set + * of simplified object property expressions that are the strict + * (potentially direct) super properties of the specified object property expression with + * respect to the imports closure of the root ontology. Note that the properties are + * returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default Stream superObjectProperties( + OWLObjectPropertyExpression pe, InferenceDepth depth) { + return getSuperObjectProperties(pe, depth).entities(); + } + + /** + * @param pe The object property expression whose strict (direct) super properties are to be + * retrieved. + * @return A {@code NodeSet} of simplified object property expressions, such + * that for each simplified object property expression, {@code P}, in + * the {@code NodeSet} , the set of reasoner axioms entails + * {@code StrictSubObjectPropertyOf(pe, + * P)} .
+ * If {@code pe} is equivalent to {@code owl:topObjectProperty} then the empty {@code + * NodeSet} will be returned. + * @see OWLReasoner#getSuperObjectProperties(OWLObjectPropertyExpression, boolean) Gets the set + * of all simplified object property expressions that are the strict + * (potentially direct) super properties of the specified object property expression with + * respect to the imports closure of the root ontology. Note that the properties are + * returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default NodeSet getSuperObjectProperties( + OWLObjectPropertyExpression pe) { + return getSuperObjectProperties(pe, false); + } + + /** + * @param pe The object property expression whose strict (direct) super properties are to be + * retrieved. + * @return A {@code NodeSet} of simplified object property expressions, such + * that for each simplified object property expression, {@code P}, in + * the {@code NodeSet} , the set of reasoner axioms entails + * {@code StrictSubObjectPropertyOf(pe, + * P)} .
+ * If {@code pe} is equivalent to {@code owl:topObjectProperty} then the empty {@code + * NodeSet} will be returned. + * @see OWLReasoner#getSuperObjectProperties(OWLObjectPropertyExpression, boolean) Gets the set + * of all simplified object property expressions that are the strict + * (potentially direct) super properties of the specified object property expression with + * respect to the imports closure of the root ontology. Note that the properties are + * returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default Stream superObjectProperties( + OWLObjectPropertyExpression pe) { + return getSuperObjectProperties(pe, false).entities(); + } + + /** + * Gets the set of simplified object property expressions that are equivalent + * to the specified object property expression with respect to the set of reasoner axioms. The + * properties are returned as a {@link org.semanticweb.owlapi.reasoner.Node}. + * + * @param pe The object property expression whose equivalent properties are to be retrieved. + * @return A node containing the simplified object property expressions such + * that for each simplified object property expression, {@code P}, in + * the node, the set of reasoner axioms entails + * {@code EquivalentObjectProperties(pe P)}.
+ * If {@code pe} is a simplified object property expression If + * {@code pe} is unsatisfiable with respect to the set of reasoner axioms then the node + * representing and containing {@code owl:bottomObjectProperty}, i.e. the bottom node, + * will be returned.
+ * If {@code pe} is equivalent to {@code owl:topObjectProperty} with respect to the set + * of reasoner axioms then the node representing and containing + * {@code owl:topObjectProperty}, i.e. the top node, will be returned. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the object property expression is not + * contained within the signature of the imports closure of the root ontology and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + Node getEquivalentObjectProperties(OWLObjectPropertyExpression pe); + + /** + * Gets the stream of simplified object property expressions that are + * equivalent to the specified object property expression with respect to the set of reasoner + * axioms. The properties are returned as a {@link org.semanticweb.owlapi.reasoner.Node}. + * + * @param pe The object property expression whose equivalent properties are to be retrieved. + * @return A node containing the simplified object property expressions such + * that for each simplified object property expression, {@code P}, in + * the node, the set of reasoner axioms entails + * {@code EquivalentObjectProperties(pe P)}.
+ * If {@code pe} is a simplified object property expression If + * {@code pe} is unsatisfiable with respect to the set of reasoner axioms then the node + * representing and containing {@code owl:bottomObjectProperty}, i.e. the bottom node, + * will be returned.
+ * If {@code pe} is equivalent to {@code owl:topObjectProperty} with respect to the set + * of reasoner axioms then the node representing and containing + * {@code owl:topObjectProperty}, i.e. the top node, will be returned. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the object property expression is not + * contained within the signature of the imports closure of the root ontology and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + default Stream equivalentObjectProperties( + OWLObjectPropertyExpression pe) { + return getEquivalentObjectProperties(pe).entities(); + } + + /** + * Gets the simplified object property expressions that are disjoint with the + * specified object property expression {@code pe}. The object properties are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param pe The object property expression whose disjoint object properties are to be + * retrieved. + * @return The return value is a {@code NodeSet} of simplified object property + * expressions, such that for each simplified object property + * expression, {@code P}, in the {@code NodeSet} the set of reasoner axioms entails + * {@code + * EquivalentObjectProperties(P, ObjectPropertyComplementOf(pe))} or {@code + * StrictSubObjectPropertyOf(P, ObjectPropertyComplementOf(pe))} . + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws ClassExpressionNotInProfileException if {@code object propertyExpression} is not + * within the profile that is supported by this reasoner. + * @throws FreshEntitiesException if the signature of {@code pe} is not contained within the + * signature of the imports closure of the root ontology and the undeclared entity + * policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}.and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW} + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + NodeSet getDisjointObjectProperties( + OWLObjectPropertyExpression pe); + + /** + * Gets the simplified object property expressions that are disjoint with the + * specified object property expression {@code pe}. The object properties are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param pe The object property expression whose disjoint object properties are to be + * retrieved. + * @return The return value is a {@code NodeSet} of simplified object property + * expressions, such that for each simplified object property + * expression, {@code P}, in the {@code NodeSet} the set of reasoner axioms entails + * {@code + * EquivalentObjectProperties(P, ObjectPropertyComplementOf(pe))} or {@code + * StrictSubObjectPropertyOf(P, ObjectPropertyComplementOf(pe))} . + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws ClassExpressionNotInProfileException if {@code object propertyExpression} is not + * within the profile that is supported by this reasoner. + * @throws FreshEntitiesException if the signature of {@code pe} is not contained within the + * signature of the imports closure of the root ontology and the undeclared entity + * policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}.and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW} + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + default Stream disjointObjectProperties( + OWLObjectPropertyExpression pe) { + return getDisjointObjectProperties(pe).entities(); + } + + /** + * Gets the set of simplified object property expressions that are the + * inverses of the specified object property expression with respect to the imports closure of + * the root ontology. The properties are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} + * + * @param pe The property expression whose inverse properties are to be retrieved. + * @return A {@code NodeSet} of simplified object property expressions, such + * that for each simplified object property expression {@code P} in the nodes set, the + * set of reasoner axioms entails {@code InverseObjectProperties(pe, P)}. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the object property expression is not + * contained within the signature of the imports closure of the root ontology and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + Node getInverseObjectProperties(OWLObjectPropertyExpression pe); + + /** + * Gets the set of simplified object property expressions that are the + * inverses of the specified object property expression with respect to the imports closure of + * the root ontology. The properties are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} + * + * @param pe The property expression whose inverse properties are to be retrieved. + * @return A {@code NodeSet} of simplified object property expressions, such + * that for each simplified object property expression {@code P} in the nodes set, the + * set of reasoner axioms entails {@code InverseObjectProperties(pe, P)}. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the object property expression is not + * contained within the signature of the imports closure of the root ontology and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + default Stream inverseObjectProperties( + OWLObjectPropertyExpression pe) { + return getInverseObjectProperties(pe).entities(); + } + + /** + * Gets the named classes that are the direct or indirect domains of this property with respect + * to the imports closure of the root ontology. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} . + * + * @param pe The property expression whose domains are to be retrieved. + * @param direct Specifies if the direct domains should be retrieved ( {@code true} ), or if all + * domains should be retrieved ( {@code false}). + * @return Let {@code N = getEquivalentClasses(ObjectSomeValuesFrom(pe owl:Thing))} .
+ * If {@code direct} is {@code true}: then if {@code N} is not empty then the return + * value is {@code N}, else the return value is the result of + * {@code getSuperClasses(ObjectSomeValuesFrom(pe + * owl:Thing), true)} .
+ * If {@code direct} is {@code false}: then the result of {@code + * getSuperClasses(ObjectSomeValuesFrom(pe owl:Thing), false)} together with {@code N} if {@code + * N} is non-empty. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the object property expression is not + * contained within the signature of the imports closure of the root ontology and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + NodeSet getObjectPropertyDomains(OWLObjectPropertyExpression pe, boolean direct); + + /** + * Gets the named classes that are the direct or indirect domains of this property with respect + * to the imports closure of the root ontology. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} . + * + * @param pe The property expression whose domains are to be retrieved. + * @param direct Specifies if the direct domains should be retrieved ( {@code true} ), or if all + * domains should be retrieved ( {@code false}). + * @return Let {@code N = getEquivalentClasses(ObjectSomeValuesFrom(pe owl:Thing))} .
+ * If {@code direct} is {@code true}: then if {@code N} is not empty then the return + * value is {@code N}, else the return value is the result of + * {@code getSuperClasses(ObjectSomeValuesFrom(pe + * owl:Thing), true)} .
+ * If {@code direct} is {@code false}: then the result of {@code + * getSuperClasses(ObjectSomeValuesFrom(pe owl:Thing), false)} together with {@code N} if {@code + * N} is non-empty. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the object property expression is not + * contained within the signature of the imports closure of the root ontology and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + default Stream objectPropertyDomains(OWLObjectPropertyExpression pe, boolean direct) { + return getObjectPropertyDomains(pe, direct).entities(); + } + + /** + * @param pe The property expression whose domains are to be retrieved. + * @param depth Specifies if the direct domains should be retrieved ( {@code DIRECT} ), or if + * all domains should be retrieved ( {@code ALL}). + * @return Let {@code N = getEquivalentClasses(ObjectSomeValuesFrom(pe owl:Thing))} .
+ * If {@code direct} is {@code DIRECT}: then if {@code N} is not empty then the return + * value is {@code N}, else the return value is the result of + * {@code getSuperClasses(ObjectSomeValuesFrom(pe + * owl:Thing), true)} .
+ * If {@code direct} is {@code ALL}: then the result of {@code + * getSuperClasses(ObjectSomeValuesFrom(pe owl:Thing), false)} together with {@code N} if {@code + * N} is non-empty. + * @see OWLReasoner#getObjectPropertyDomains(OWLObjectPropertyExpression, boolean) Gets the + * named classes that are the direct or indirect domains of this property with respect to + * the imports closure of the root ontology. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} . + */ + default NodeSet getObjectPropertyDomains(OWLObjectPropertyExpression pe, + InferenceDepth depth) { + return getObjectPropertyDomains(pe, depth.isDirectOnly()); + } + + /** + * @param pe The property expression whose domains are to be retrieved. + * @param depth Specifies if the direct domains should be retrieved ( {@code DIRECT} ), or if + * all domains should be retrieved ( {@code ALL}). + * @return Let {@code N = getEquivalentClasses(ObjectSomeValuesFrom(pe owl:Thing))} .
+ * If {@code direct} is {@code DIRECT}: then if {@code N} is not empty then the return + * value is {@code N}, else the return value is the result of + * {@code getSuperClasses(ObjectSomeValuesFrom(pe + * owl:Thing), true)} .
+ * If {@code direct} is {@code ALL}: then the result of {@code + * getSuperClasses(ObjectSomeValuesFrom(pe owl:Thing), false)} together with {@code N} if {@code + * N} is non-empty. + * @see OWLReasoner#getObjectPropertyDomains(OWLObjectPropertyExpression, boolean) Gets the + * named classes that are the direct or indirect domains of this property with respect to + * the imports closure of the root ontology. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} . + */ + default Stream objectPropertyDomains(OWLObjectPropertyExpression pe, + InferenceDepth depth) { + return getObjectPropertyDomains(pe, depth).entities(); + } + + /** + * @param pe The property expression whose domains are to be retrieved. + * @return Let {@code N = getEquivalentClasses(ObjectSomeValuesFrom(pe owl:Thing))} .
+ * Return the result of + * {@code getSuperClasses(ObjectSomeValuesFrom(pe owl:Thing), false)} together with + * {@code N} if {@code N} is non-empty. + * @see OWLReasoner#getObjectPropertyDomains(OWLObjectPropertyExpression, boolean) Gets the + * named classes that are the direct or indirect domains of this property with respect to + * the imports closure of the root ontology. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} . + */ + default NodeSet getObjectPropertyDomains(OWLObjectPropertyExpression pe) { + return getObjectPropertyDomains(pe, false); + } + + /** + * @param pe The property expression whose domains are to be retrieved. + * @return Let {@code N = getEquivalentClasses(ObjectSomeValuesFrom(pe owl:Thing))} .
+ * Return the result of + * {@code getSuperClasses(ObjectSomeValuesFrom(pe owl:Thing), false)} together with + * {@code N} if {@code N} is non-empty. + * @see OWLReasoner#getObjectPropertyDomains(OWLObjectPropertyExpression, boolean) Gets the + * named classes that are the direct or indirect domains of this property with respect to + * the imports closure of the root ontology. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} . + */ + default Stream objectPropertyDomains(OWLObjectPropertyExpression pe) { + return getObjectPropertyDomains(pe).entities(); + } + + /** + * Gets the named classes that are the direct or indirect ranges of this property with respect + * to the imports closure of the root ontology. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} . + * + * @param pe The property expression whose ranges are to be retrieved. + * @param direct Specifies if the direct ranges should be retrieved ( {@code true} ), or if all + * ranges should be retrieved ( {@code false}). + * @return Let {@code N = getEquivalentClasses(ObjectSomeValuesFrom(ObjectInverseOf(pe) + * owl:Thing))} .
+ * If {@code direct} is {@code true}: then if {@code N} is not empty then the return + * value is {@code N}, else the return value is the result of {@code + * getSuperClasses(ObjectSomeValuesFrom(ObjectInverseOf(pe) owl:Thing), true)} .
+ * If {@code + * direct} is {@code false}: then the result of + * {@code getSuperClasses(ObjectSomeValuesFrom(ObjectInverseOf(pe) + * owl:Thing), false)} together with {@code N} if {@code N} is non-empty. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the object property expression is not + * contained within the signature of the imports closure of the root ontology and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + NodeSet getObjectPropertyRanges(OWLObjectPropertyExpression pe, boolean direct); + + /** + * Gets the named classes that are the direct or indirect ranges of this property with respect + * to the imports closure of the root ontology. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} . + * + * @param pe The property expression whose ranges are to be retrieved. + * @param direct Specifies if the direct ranges should be retrieved ( {@code true} ), or if all + * ranges should be retrieved ( {@code false}). + * @return Let {@code N = getEquivalentClasses(ObjectSomeValuesFrom(ObjectInverseOf(pe) + * owl:Thing))} .
+ * If {@code direct} is {@code true}: then if {@code N} is not empty then the return + * value is {@code N}, else the return value is the result of {@code + * getSuperClasses(ObjectSomeValuesFrom(ObjectInverseOf(pe) owl:Thing), true)} .
+ * If {@code + * direct} is {@code false}: then the result of + * {@code getSuperClasses(ObjectSomeValuesFrom(ObjectInverseOf(pe) + * owl:Thing), false)} together with {@code N} if {@code N} is non-empty. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the object property expression is not + * contained within the signature of the imports closure of the root ontology and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + default Stream objectPropertyRanges(OWLObjectPropertyExpression pe, boolean direct) { + return getObjectPropertyRanges(pe, direct).entities(); + } + + /** + * @param pe The property expression whose ranges are to be retrieved. + * @param depth Specifies if the direct ranges should be retrieved ( {@code DIRECT} ), or if all + * ranges should be retrieved ( {@code ALL}). + * @return Let {@code N = getEquivalentClasses(ObjectSomeValuesFrom(ObjectInverseOf(pe) + * owl:Thing))} .
+ * If {@code depth} is {@code DIRECT}: then if {@code N} is not empty then the return + * value is {@code N}, else the return value is the result of {@code + * getSuperClasses(ObjectSomeValuesFrom(ObjectInverseOf(pe) owl:Thing), true)} .
+ * If {@code + * depth} is {@code ALL}: then the result of + * {@code getSuperClasses(ObjectSomeValuesFrom(ObjectInverseOf(pe) + * owl:Thing), false)} together with {@code N} if {@code N} is non-empty. + * @see OWLReasoner#getObjectPropertyRanges(OWLObjectPropertyExpression, boolean) Gets the named + * classes that are the direct or indirect ranges of this property with respect to the + * imports closure of the root ontology. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} . + */ + default NodeSet getObjectPropertyRanges(OWLObjectPropertyExpression pe, + InferenceDepth depth) { + return getObjectPropertyRanges(pe, depth.isDirectOnly()); + } + + /** + * @param pe The property expression whose ranges are to be retrieved. + * @param depth Specifies if the direct ranges should be retrieved ( {@code DIRECT} ), or if all + * ranges should be retrieved ( {@code ALL}). + * @return Let {@code N = getEquivalentClasses(ObjectSomeValuesFrom(ObjectInverseOf(pe) + * owl:Thing))} .
+ * If {@code depth} is {@code DIRECT}: then if {@code N} is not empty then the return + * value is {@code N}, else the return value is the result of {@code + * getSuperClasses(ObjectSomeValuesFrom(ObjectInverseOf(pe) owl:Thing), true)} .
+ * If {@code + * depth} is {@code ALL}: then the result of + * {@code getSuperClasses(ObjectSomeValuesFrom(ObjectInverseOf(pe) + * owl:Thing), false)} together with {@code N} if {@code N} is non-empty. + * @see OWLReasoner#getObjectPropertyRanges(OWLObjectPropertyExpression, boolean) Gets the named + * classes that are the direct or indirect ranges of this property with respect to the + * imports closure of the root ontology. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} . + */ + default Stream objectPropertyRanges(OWLObjectPropertyExpression pe, + InferenceDepth depth) { + return getObjectPropertyRanges(pe, depth).entities(); + } + + /** + * @param pe The property expression whose ranges are to be retrieved. + * @return Let {@code N = getEquivalentClasses(ObjectSomeValuesFrom(ObjectInverseOf(pe) + * owl:Thing))} .
+ * Return the result of {@code getSuperClasses(ObjectSomeValuesFrom(ObjectInverseOf(pe) + * owl:Thing), false)} together with {@code N} if {@code N} is non-empty. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the object property expression is not + * contained within the signature of the imports closure of the root ontology and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + * @see OWLReasoner#getObjectPropertyRanges(OWLObjectPropertyExpression, boolean) Gets the named + * classes that are the direct or indirect ranges of this property with respect to the + * imports closure of the root ontology. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} . + */ + default NodeSet getObjectPropertyRanges(OWLObjectPropertyExpression pe) { + return getObjectPropertyRanges(pe, false); + } + + /** + * @param pe The property expression whose ranges are to be retrieved. + * @return Let {@code N = getEquivalentClasses(ObjectSomeValuesFrom(ObjectInverseOf(pe) + * owl:Thing))} .
+ * Return the result of {@code getSuperClasses(ObjectSomeValuesFrom(ObjectInverseOf(pe) + * owl:Thing), false)} together with {@code N} if {@code N} is non-empty. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the object property expression is not + * contained within the signature of the imports closure of the root ontology and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + * @see OWLReasoner#getObjectPropertyRanges(OWLObjectPropertyExpression, boolean) Gets the named + * classes that are the direct or indirect ranges of this property with respect to the + * imports closure of the root ontology. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} . + */ + default Stream objectPropertyRanges(OWLObjectPropertyExpression pe) { + return getObjectPropertyRanges(pe, false).entities(); + } + + // Methods for dealing with the data property hierarchy + + /** + * Gets the {@code Node} corresponding to the top node (containing {@code owl:topDataProperty}) + * in the data property hierarchy. + * + * @return A {@code Node}, containing {@code owl:topDataProperty}, that is the top node in the + * data property hierarchy. This {@code Node} is essentially equal to the {@code Node} + * returned by calling + * {@link #getEquivalentDataProperties(org.semanticweb.owlapi.model.OWLDataProperty)} + * with a parameter of {@code owl:topDataProperty}. + */ + Node getTopDataPropertyNode(); + + /** + * Gets the {@code Node} corresponding to the top node (containing {@code owl:topDataProperty}) + * in the data property hierarchy. + * + * @return A {@code Node}, containing {@code owl:topDataProperty}, that is the top node in the + * data property hierarchy. This {@code Node} is essentially equal to the {@code Node} + * returned by calling + * {@link #getEquivalentDataProperties(org.semanticweb.owlapi.model.OWLDataProperty)} + * with a parameter of {@code owl:topDataProperty}. + */ + default Stream topDataPropertyNode() { + return getTopDataPropertyNode().entities(); + } + + /** + * Gets the {@code Node} corresponding to the bottom node (containing + * {@code owl:bottomDataProperty}) in the data property hierarchy. + * + * @return A {@code Node}, containing {@code owl:bottomDataProperty}, that is the bottom node in + * the data property hierarchy. This {@code Node} is essentially equal to the + * {@code Node} that will be returned by calling + * {@link #getEquivalentDataProperties(org.semanticweb.owlapi.model.OWLDataProperty)} + * with a parameter of {@code owl:bottomDataProperty}. + */ + Node getBottomDataPropertyNode(); + + /** + * Gets the {@code Node} corresponding to the bottom node (containing + * {@code owl:bottomDataProperty}) in the data property hierarchy. + * + * @return A {@code Node}, containing {@code owl:bottomDataProperty}, that is the bottom node in + * the data property hierarchy. This {@code Node} is essentially equal to the + * {@code Node} that will be returned by calling + * {@link #getEquivalentDataProperties(org.semanticweb.owlapi.model.OWLDataProperty)} + * with a parameter of {@code owl:bottomDataProperty}. + */ + default Stream bottomDataPropertyNode() { + return getBottomDataPropertyNode().entities(); + } + + /** + * Gets the set of named data properties that are the strict (potentially direct) subproperties + * of the specified data property expression with respect to the imports closure of the root + * ontology. Note that the properties are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param pe The data property whose strict (direct) subproperties are to be retrieved. + * @param direct Specifies if the direct subproperties should be retrieved ( {@code true}) or if + * the all subproperties (descendants) should be retrieved ({@code false}). + * @return If direct is {@code true}, a {@code NodeSet} such that for each property {@code P} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code DirectSubDataPropertyOf(P, + * pe)} .
+ * If direct is {@code false}, a {@code NodeSet} such that for each property {@code + * P} in the {@code NodeSet} the set of reasoner axioms entails {@code + * StrictSubDataPropertyOf(P, pe)}.
+ * If {@code pe} is equivalent to {@code + * owl:bottomDataProperty} then the empty {@code NodeSet} will be returned. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the data property is not contained within + * the signature of the imports closure of the root ontology and the undeclared entity + * policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + NodeSet getSubDataProperties(OWLDataProperty pe, boolean direct); + + /** + * Gets the set of named data properties that are the strict (potentially direct) subproperties + * of the specified data property expression with respect to the imports closure of the root + * ontology. Note that the properties are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param pe The data property whose strict (direct) subproperties are to be retrieved. + * @param direct Specifies if the direct subproperties should be retrieved ( {@code true}) or if + * the all subproperties (descendants) should be retrieved ({@code false}). + * @return If direct is {@code true}, a {@code NodeSet} such that for each property {@code P} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code DirectSubDataPropertyOf(P, + * pe)} .
+ * If direct is {@code false}, a {@code NodeSet} such that for each property {@code + * P} in the {@code NodeSet} the set of reasoner axioms entails {@code + * StrictSubDataPropertyOf(P, pe)}.
+ * If {@code pe} is equivalent to {@code + * owl:bottomDataProperty} then the empty {@code NodeSet} will be returned. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the data property is not contained within + * the signature of the imports closure of the root ontology and the undeclared entity + * policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + default Stream subDataProperties(OWLDataProperty pe, boolean direct) { + return getSubDataProperties(pe, direct).entities(); + } + + /** + * @param pe The data property whose strict (direct) subproperties are to be retrieved. + * @param depth Specifies if the direct subproperties should be retrieved ( {@code DIRECT}) or + * if the all subproperties (descendants) should be retrieved ({@code ALL}). + * @return If depth is {@code DIRECT}, a {@code NodeSet} such that for each property {@code P} + * in the {@code NodeSet} the set of reasoner axioms entails + * {@code DirectSubDataPropertyOf(P, + * pe)} .
+ * If depth is {@code ALL}, a {@code NodeSet} such that for each property {@code P} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code StrictSubDataPropertyOf(P, + * pe)} .
+ * If {@code pe} is equivalent to {@code owl:bottomDataProperty} then the empty + * {@code NodeSet} will be returned. + * @see OWLReasoner#getSubDataProperties(OWLDataProperty, boolean) Gets the set of named data + * properties that are the strict (potentially direct) subproperties of the specified data + * property expression with respect to the imports closure of the root ontology. Note that + * the properties are returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default NodeSet getSubDataProperties(OWLDataProperty pe, + InferenceDepth depth) { + return getSubDataProperties(pe, depth.isDirectOnly()); + } + + /** + * @param pe The data property whose strict (direct) subproperties are to be retrieved. + * @param depth Specifies if the direct subproperties should be retrieved ( {@code DIRECT}) or + * if the all subproperties (descendants) should be retrieved ({@code ALL}). + * @return If depth is {@code DIRECT}, a {@code NodeSet} such that for each property {@code P} + * in the {@code NodeSet} the set of reasoner axioms entails + * {@code DirectSubDataPropertyOf(P, + * pe)} .
+ * If depth is {@code ALL}, a {@code NodeSet} such that for each property {@code P} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code StrictSubDataPropertyOf(P, + * pe)} .
+ * If {@code pe} is equivalent to {@code owl:bottomDataProperty} then the empty + * {@code NodeSet} will be returned. + * @see OWLReasoner#getSubDataProperties(OWLDataProperty, boolean) Gets the set of named data + * properties that are the strict (potentially direct) subproperties of the specified data + * property expression with respect to the imports closure of the root ontology. Note that + * the properties are returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default Stream subDataProperties(OWLDataProperty pe, InferenceDepth depth) { + return getSubDataProperties(pe, depth).entities(); + } + + /** + * @param pe The data property whose strict (direct) subproperties are to be retrieved. + * @return a {@code NodeSet} such that for each property {@code P} in the {@code NodeSet} the + * set of reasoner axioms entails {@code StrictSubDataPropertyOf(P, pe)}.
+ * If {@code pe} is equivalent to {@code owl:bottomDataProperty} then the empty + * {@code NodeSet} will be returned. + * @see OWLReasoner#getSubDataProperties(OWLDataProperty, boolean) Gets the set of named data + * properties that are the strict (potentially direct) subproperties of the specified data + * property expression with respect to the imports closure of the root ontology. Note that + * the properties are returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default NodeSet getSubDataProperties(OWLDataProperty pe) { + return getSubDataProperties(pe, false); + } + + /** + * @param pe The data property whose strict (direct) subproperties are to be retrieved. + * @return a {@code NodeSet} such that for each property {@code P} in the {@code NodeSet} the + * set of reasoner axioms entails {@code StrictSubDataPropertyOf(P, pe)}.
+ * If {@code pe} is equivalent to {@code owl:bottomDataProperty} then the empty + * {@code NodeSet} will be returned. + * @see OWLReasoner#getSubDataProperties(OWLDataProperty, boolean) Gets the set of named data + * properties that are the strict (potentially direct) subproperties of the specified data + * property expression with respect to the imports closure of the root ontology. Note that + * the properties are returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default Stream subDataProperties(OWLDataProperty pe) { + return getSubDataProperties(pe).entities(); + } + + /** + * Gets the set of named data properties that are the strict (potentially direct) super + * properties of the specified data property with respect to the imports closure of the root + * ontology. Note that the properties are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param pe The data property whose strict (direct) super properties are to be retrieved. + * @param direct Specifies if the direct super properties should be retrieved ( {@code true}) or + * if the all super properties (ancestors) should be retrieved ({@code false}). + * @return If direct is {@code true}, a {@code NodeSet} such that for each property {@code P} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code DirectSubDataPropertyOf(pe, + * P)} .
+ * If direct is {@code false}, a {@code NodeSet} such that for each property {@code P} + * in the {@code NodeSet} the set of reasoner axioms entails + * {@code StrictSubDataPropertyOf(pe, + * P)} .
+ * If {@code pe} is equivalent to {@code owl:topDataProperty} then the empty {@code + * NodeSet} will be returned. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the data property is not contained within + * the signature of the imports closure of the root ontology and the undeclared entity + * policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + NodeSet getSuperDataProperties(OWLDataProperty pe, boolean direct); + + /** + * Gets the stream of named data properties that are the strict (potentially direct) super + * properties of the specified data property with respect to the imports closure of the root + * ontology. Note that the properties are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param pe The data property whose strict (direct) super properties are to be retrieved. + * @param direct Specifies if the direct super properties should be retrieved ( {@code true}) or + * if the all super properties (ancestors) should be retrieved ({@code false}). + * @return If direct is {@code true}, a {@code NodeSet} such that for each property {@code P} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code DirectSubDataPropertyOf(pe, + * P)} .
+ * If direct is {@code false}, a {@code NodeSet} such that for each property {@code P} + * in the {@code NodeSet} the set of reasoner axioms entails + * {@code StrictSubDataPropertyOf(pe, + * P)} .
+ * If {@code pe} is equivalent to {@code owl:topDataProperty} then the empty {@code + * NodeSet} will be returned. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the data property is not contained within + * the signature of the imports closure of the root ontology and the undeclared entity + * policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + default Stream superDataProperties(OWLDataProperty pe, boolean direct) { + return getSuperDataProperties(pe, direct).entities(); + } + + /** + * @param pe The data property whose strict (direct) super properties are to be retrieved. + * @param depth Specifies if the direct super properties should be retrieved ( {@code DIRECT}) + * or if the all super properties (ancestors) should be retrieved ({@code ALL}). + * @return If depth is {@code DIRECT}, a {@code NodeSet} such that for each property {@code P} + * in the {@code NodeSet} the set of reasoner axioms entails + * {@code DirectSubDataPropertyOf(pe, + * P)} .
+ * If depth is {@code ALL}, a {@code NodeSet} such that for each property {@code P} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code StrictSubDataPropertyOf(pe, + * P)} .
+ * If {@code pe} is equivalent to {@code owl:topDataProperty} then the empty {@code + * NodeSet} will be returned. + * @see OWLReasoner#getSuperDataProperties(OWLDataProperty, boolean) Gets the set of named data + * properties that are the strict (potentially direct) super properties of the specified + * data property with respect to the imports closure of the root ontology. Note that the + * properties are returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default NodeSet getSuperDataProperties(OWLDataProperty pe, + InferenceDepth depth) { + return getSuperDataProperties(pe, depth.isDirectOnly()); + } + + /** + * @param pe The data property whose strict (direct) super properties are to be retrieved. + * @param depth Specifies if the direct super properties should be retrieved ( {@code DIRECT}) + * or if the all super properties (ancestors) should be retrieved ({@code ALL}). + * @return If depth is {@code DIRECT}, a {@code NodeSet} such that for each property {@code P} + * in the {@code NodeSet} the set of reasoner axioms entails + * {@code DirectSubDataPropertyOf(pe, + * P)} .
+ * If depth is {@code ALL}, a {@code NodeSet} such that for each property {@code P} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code StrictSubDataPropertyOf(pe, + * P)} .
+ * If {@code pe} is equivalent to {@code owl:topDataProperty} then the empty {@code + * NodeSet} will be returned. + * @see OWLReasoner#getSuperDataProperties(OWLDataProperty, boolean) Gets the set of named data + * properties that are the strict (potentially direct) super properties of the specified + * data property with respect to the imports closure of the root ontology. Note that the + * properties are returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default Stream superDataProperties(OWLDataProperty pe, InferenceDepth depth) { + return getSuperDataProperties(pe, depth).entities(); + } + + /** + * @param pe The data property whose strict (direct) super properties are to be retrieved. + * @return a {@code NodeSet} such that for each property {@code P} in the {@code NodeSet} the + * set of reasoner axioms entails {@code StrictSubDataPropertyOf(pe, P)}.
+ * If {@code pe} is equivalent to {@code owl:topDataProperty} then the empty + * {@code NodeSet} will be returned. + * @see OWLReasoner#getSuperDataProperties(OWLDataProperty, boolean) Gets the set of named data + * properties that are the strict (potentially direct) super properties of the specified + * data property with respect to the imports closure of the root ontology. Note that the + * properties are returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default NodeSet getSuperDataProperties(OWLDataProperty pe) { + return getSuperDataProperties(pe, false); + } + + /** + * @param pe The data property whose strict (direct) super properties are to be retrieved. + * @return a {@code NodeSet} such that for each property {@code P} in the {@code NodeSet} the + * set of reasoner axioms entails {@code StrictSubDataPropertyOf(pe, P)}.
+ * If {@code pe} is equivalent to {@code owl:topDataProperty} then the empty + * {@code NodeSet} will be returned. + * @see OWLReasoner#getSuperDataProperties(OWLDataProperty, boolean) Gets the set of named data + * properties that are the strict (potentially direct) super properties of the specified + * data property with respect to the imports closure of the root ontology. Note that the + * properties are returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default Stream superDataProperties(OWLDataProperty pe) { + return getSuperDataProperties(pe, false).entities(); + } + + /** + * Gets the set of named data properties that are equivalent to the specified data property + * expression with respect to the imports closure of the root ontology. The properties are + * returned as a {@link org.semanticweb.owlapi.reasoner.Node}. + * + * @param pe The data property expression whose equivalent properties are to be retrieved. + * @return A node containing the named data properties such that for each named data property + * {@code P} in the node, the set of reasoner axioms entails + * {@code EquivalentDataProperties(pe + * P)} .
+ * If {@code pe} is a named data property then {@code pe} will be contained in the node. + *
+ * If {@code pe} is unsatisfiable with respect to the set of reasoner axioms then the + * node representing and containing {@code owl:bottomDataProperty}, i.e. the bottom + * node, will be returned.
+ * If {@code ce} is equivalent to {@code owl:topDataProperty} with respect to the set of + * reasoner axioms then the node representing and containing {@code + * owl:topDataProperty}, i.e. the top node, will be returned
+ * . + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the data property expression is not + * contained within the signature of the imports closure of the root ontology and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + Node getEquivalentDataProperties(OWLDataProperty pe); + + /** + * Gets the stream of named data properties that are equivalent to the specified data property + * expression with respect to the imports closure of the root ontology. The properties are + * returned as a {@link org.semanticweb.owlapi.reasoner.Node}. + * + * @param pe The data property expression whose equivalent properties are to be retrieved. + * @return A node containing the named data properties such that for each named data property + * {@code P} in the node, the set of reasoner axioms entails + * {@code EquivalentDataProperties(pe + * P)} .
+ * If {@code pe} is a named data property then {@code pe} will be contained in the node. + *
+ * If {@code pe} is unsatisfiable with respect to the set of reasoner axioms then the + * node representing and containing {@code owl:bottomDataProperty}, i.e. the bottom + * node, will be returned.
+ * If {@code ce} is equivalent to {@code owl:topDataProperty} with respect to the set of + * reasoner axioms then the node representing and containing {@code + * owl:topDataProperty}, i.e. the top node, will be returned
+ * . + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the data property expression is not + * contained within the signature of the imports closure of the root ontology and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + default Stream equivalentDataProperties(OWLDataProperty pe) { + return getEquivalentDataProperties(pe).entities(); + } + + /** + * Gets the data properties that are disjoint with the specified data property expression + * {@code pe}. The data properties are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param pe The data property expression whose disjoint data properties are to be retrieved. + * @return The return value is a {@code NodeSet} such that for each data property {@code P} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code EquivalentDataProperties(P, + * DataPropertyComplementOf(pe))} or {@code StrictSubDataPropertyOf(P, + * DataPropertyComplementOf(pe))} . + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws ClassExpressionNotInProfileException if {@code data propertyExpression} is not within + * the profile that is supported by this reasoner. + * @throws FreshEntitiesException if the signature of {@code pe} is not contained within the + * signature of the imports closure of the root ontology and the undeclared entity + * policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + NodeSet getDisjointDataProperties(OWLDataPropertyExpression pe); + + /** + * Gets the data properties that are disjoint with the specified data property expression + * {@code pe}. The data properties are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param pe The data property expression whose disjoint data properties are to be retrieved. + * @return The return value is a {@code NodeSet} such that for each data property {@code P} in + * the {@code NodeSet} the set of reasoner axioms entails + * {@code EquivalentDataProperties(P, + * DataPropertyComplementOf(pe))} or {@code StrictSubDataPropertyOf(P, + * DataPropertyComplementOf(pe))} . + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws ClassExpressionNotInProfileException if {@code data propertyExpression} is not within + * the profile that is supported by this reasoner. + * @throws FreshEntitiesException if the signature of {@code pe} is not contained within the + * signature of the imports closure of the root ontology and the undeclared entity + * policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + default Stream disjointDataProperties(OWLDataProperty pe) { + return getDisjointDataProperties(pe).entities(); + } + + /** + * Gets the named classes that are the direct or indirect domains of this property with respect + * to the imports closure of the root ontology. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} . + * + * @param pe The property expression whose domains are to be retrieved. + * @param direct Specifies if the direct domains should be retrieved ( {@code true} ), or if all + * domains should be retrieved ( {@code false}). + * @return Let {@code N = getEquivalentClasses(DataSomeValuesFrom(pe rdfs:Literal))} .
+ * If {@code direct} is {@code true}: then if {@code N} is not empty then the return + * value is {@code N}, else the return value is the result of + * {@code getSuperClasses(DataSomeValuesFrom(pe + * rdfs:Literal), true)} .
+ * If {@code direct} is {@code false}: then the result of {@code + * getSuperClasses(DataSomeValuesFrom(pe rdfs:Literal), false)} together with {@code N} if + * {@code N} is non-empty.
+ * (Note, {@code rdfs:Literal} is the top datatype). + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the object property expression is not + * contained within the signature of the imports closure of the root ontology and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + NodeSet getDataPropertyDomains(OWLDataProperty pe, boolean direct); + + /** + * Gets the named classes that are the direct or indirect domains of this property with respect + * to the imports closure of the root ontology. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} . + * + * @param pe The property expression whose domains are to be retrieved. + * @param direct Specifies if the direct domains should be retrieved ( {@code true} ), or if all + * domains should be retrieved ( {@code false}). + * @return Let {@code N = getEquivalentClasses(DataSomeValuesFrom(pe rdfs:Literal))} .
+ * If {@code direct} is {@code true}: then if {@code N} is not empty then the return + * value is {@code N}, else the return value is the result of + * {@code getSuperClasses(DataSomeValuesFrom(pe + * rdfs:Literal), true)} .
+ * If {@code direct} is {@code false}: then the result of {@code + * getSuperClasses(DataSomeValuesFrom(pe rdfs:Literal), false)} together with {@code N} if + * {@code N} is non-empty.
+ * (Note, {@code rdfs:Literal} is the top datatype). + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the object property expression is not + * contained within the signature of the imports closure of the root ontology and the + * undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + default Stream dataPropertyDomains(OWLDataProperty pe, boolean direct) { + return getDataPropertyDomains(pe, direct).entities(); + } + + /** + * @param pe The property expression whose domains are to be retrieved. + * @param depth Specifies if the direct domains should be retrieved ( {@code DIRECT} ), or if + * all domains should be retrieved ( {@code ALL}). + * @return Let {@code N = getEquivalentClasses(DataSomeValuesFrom(pe rdfs:Literal))} .
+ * If {@code depth} is {@code DIRECT}: then if {@code N} is not empty then the return + * value is {@code N}, else the return value is the result of + * {@code getSuperClasses(DataSomeValuesFrom(pe + * rdfs:Literal), true)} .
+ * If {@code direct} is {@code ALL}: then the result of {@code + * getSuperClasses(DataSomeValuesFrom(pe rdfs:Literal), false)} together with {@code N} if + * {@code N} is non-empty.
+ * (Note, {@code rdfs:Literal} is the top datatype). + * @see OWLReasoner#getDataPropertyDomains(OWLDataProperty, boolean) Gets the named classes that + * are the direct or indirect domains of this property with respect to the imports closure + * of the root ontology. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} . + */ + default NodeSet getDataPropertyDomains(OWLDataProperty pe, InferenceDepth depth) { + return getDataPropertyDomains(pe, depth.isDirectOnly()); + } + + /** + * @param pe The property expression whose domains are to be retrieved. + * @param depth Specifies if the direct domains should be retrieved ( {@code DIRECT} ), or if + * all domains should be retrieved ( {@code ALL}). + * @return Let {@code N = getEquivalentClasses(DataSomeValuesFrom(pe rdfs:Literal))} .
+ * If {@code depth} is {@code DIRECT}: then if {@code N} is not empty then the return + * value is {@code N}, else the return value is the result of + * {@code getSuperClasses(DataSomeValuesFrom(pe + * rdfs:Literal), true)} .
+ * If {@code direct} is {@code ALL}: then the result of {@code + * getSuperClasses(DataSomeValuesFrom(pe rdfs:Literal), false)} together with {@code N} if + * {@code N} is non-empty.
+ * (Note, {@code rdfs:Literal} is the top datatype). + * @see OWLReasoner#getDataPropertyDomains(OWLDataProperty, boolean) Gets the named classes that + * are the direct or indirect domains of this property with respect to the imports closure + * of the root ontology. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} . + */ + default Stream dataPropertyDomains(OWLDataProperty pe, InferenceDepth depth) { + return getDataPropertyDomains(pe, depth.isDirectOnly()).entities(); + } + + /** + * @param pe The property expression whose domains are to be retrieved. + * @return Let {@code N = getEquivalentClasses(DataSomeValuesFrom(pe rdfs:Literal))} .
+ * Return the result of + * {@code getSuperClasses(DataSomeValuesFrom(pe rdfs:Literal), false)} together with + * {@code N} if {@code N} is non-empty.
+ * (Note, {@code rdfs:Literal} is the top datatype). + * @see OWLReasoner#getDataPropertyDomains(OWLDataProperty, boolean) Gets the named classes that + * are the direct or indirect domains of this property with respect to the imports closure + * of the root ontology. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} . + */ + default NodeSet getDataPropertyDomains(OWLDataProperty pe) { + return getDataPropertyDomains(pe, false); + } + + /** + * @param pe The property expression whose domains are to be retrieved. + * @return Let {@code N = getEquivalentClasses(DataSomeValuesFrom(pe rdfs:Literal))} .
+ * Return the result of + * {@code getSuperClasses(DataSomeValuesFrom(pe rdfs:Literal), false)} together with + * {@code N} if {@code N} is non-empty.
+ * (Note, {@code rdfs:Literal} is the top datatype). + * @see OWLReasoner#getDataPropertyDomains(OWLDataProperty, boolean) Gets the named classes that + * are the direct or indirect domains of this property with respect to the imports closure + * of the root ontology. The classes are returned as a + * {@link org.semanticweb.owlapi.reasoner.NodeSet} . + */ + default Stream dataPropertyDomains(OWLDataProperty pe) { + return getDataPropertyDomains(pe, false).entities(); + } + + // Methods for dealing with individuals and their types + + /** + * Gets the named classes which are (potentially direct) types of the specified named + * individual. The classes are returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param ind The individual whose types are to be retrieved. + * @param direct Specifies if the direct types should be retrieved ( {@code true}), or if all + * types should be retrieved ( {@code false}). + * @return If {@code direct} is {@code true}, a {@code NodeSet} containing named classes such + * that for each named class {@code C} in the node set, the set of reasoner axioms + * entails {@code DirectClassAssertion(C, ind)}.
+ * If {@code direct} is {@code false}, a {@code + * NodeSet} containing named classes such that for each named class {@code C} in the node set, + * the set of reasoner axioms entails {@code ClassAssertion(C, ind)}.
+ * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the individual is not contained within the + * signature of the imports closure of the root ontology and the undeclared entity + * policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + NodeSet getTypes(OWLNamedIndividual ind, boolean direct); + + /** + * Gets the named classes which are (potentially direct) types of the specified named + * individual. The classes are returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param ind The individual whose types are to be retrieved. + * @param direct Specifies if the direct types should be retrieved ( {@code true}), or if all + * types should be retrieved ( {@code false}). + * @return If {@code direct} is {@code true}, a {@code NodeSet} containing named classes such + * that for each named class {@code C} in the node set, the set of reasoner axioms + * entails {@code DirectClassAssertion(C, ind)}.
+ * If {@code direct} is {@code false}, a {@code + * NodeSet} containing named classes such that for each named class {@code C} in the node set, + * the set of reasoner axioms entails {@code ClassAssertion(C, ind)}.
+ * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the individual is not contained within the + * signature of the imports closure of the root ontology and the undeclared entity + * policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + default Stream types(OWLNamedIndividual ind, boolean direct) { + return getTypes(ind, direct).entities(); + } + + /** + * @param ind The individual whose types are to be retrieved. + * @param depth Specifies if the direct types should be retrieved ( {@code DIRECT} ), or if all + * types should be retrieved ( {@code ALL}). + * @return If {@code depth} is {@code DIRECT}, a {@code NodeSet} containing named classes such + * that for each named class {@code C} in the node set, the set of reasoner axioms + * entails {@code DirectClassAssertion(C, ind)}.
+ * If {@code depth} is {@code ALL}, a {@code NodeSet} containing named classes such that + * for each named class {@code C} in the node set, the set of reasoner axioms entails + * {@code ClassAssertion(C, ind)}.
+ * @see OWLReasoner#getTypes(OWLNamedIndividual, boolean) Gets the named classes which are + * (potentially direct) types of the specified named individual. The classes are returned + * as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default NodeSet getTypes(OWLNamedIndividual ind, InferenceDepth depth) { + return getTypes(ind, depth.isDirectOnly()); + } + + /** + * @param ind The individual whose types are to be retrieved. + * @param depth Specifies if the direct types should be retrieved ( {@code DIRECT} ), or if all + * types should be retrieved ( {@code ALL}). + * @return If {@code depth} is {@code DIRECT}, a {@code NodeSet} containing named classes such + * that for each named class {@code C} in the node set, the set of reasoner axioms + * entails {@code DirectClassAssertion(C, ind)}.
+ * If {@code depth} is {@code ALL}, a {@code NodeSet} containing named classes such that + * for each named class {@code C} in the node set, the set of reasoner axioms entails + * {@code ClassAssertion(C, ind)}.
+ * @see OWLReasoner#getTypes(OWLNamedIndividual, boolean) Gets the named classes which are + * (potentially direct) types of the specified named individual. The classes are returned + * as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default Stream types(OWLNamedIndividual ind, InferenceDepth depth) { + return getTypes(ind, depth).entities(); + } + + /** + * @param ind The individual whose types are to be retrieved. + * @return a {@code NodeSet} containing named classes such that for each named class {@code C} + * in the node set, the set of reasoner axioms entails {@code ClassAssertion(C, ind)}. + *
+ * @see OWLReasoner#getTypes(OWLNamedIndividual, boolean) Gets the named classes which are + * (potentially direct) types of the specified named individual. The classes are returned + * as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default NodeSet getTypes(OWLNamedIndividual ind) { + return getTypes(ind, false); + } + + /** + * @param ind The individual whose types are to be retrieved. + * @return a {@code NodeSet} containing named classes such that for each named class {@code C} + * in the node set, the set of reasoner axioms entails {@code ClassAssertion(C, ind)}. + *
+ * @see OWLReasoner#getTypes(OWLNamedIndividual, boolean) Gets the named classes which are + * (potentially direct) types of the specified named individual. The classes are returned + * as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default Stream types(OWLNamedIndividual ind) { + return getTypes(ind, false).entities(); + } + + /** + * Gets the individuals which are instances of the specified class expression. The individuals + * are returned a a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param ce The class expression whose instances are to be retrieved. + * @param direct Specifies if the direct instances should be retrieved ( {@code true}), or if + * all instances should be retrieved ( {@code false}). + * @return If {@code direct} is {@code true}, a {@code NodeSet} containing named individuals + * such that for each named individual {@code j} in the node set, the set of reasoner + * axioms entails {@code DirectClassAssertion(ce, j)}.
+ * If {@code direct} is {@code false}, a {@code NodeSet} containing named individuals + * such that for each named individual {@code j} in the node set, the set of reasoner + * axioms entails {@code ClassAssertion(ce, j)}.
+ * If ce is unsatisfiable with respect to the set of reasoner axioms then the empty + * {@code NodeSet} is returned. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws ClassExpressionNotInProfileException if the class expression {@code ce} is not in the + * profile that is supported by this reasoner. + * @throws FreshEntitiesException if the signature of the class expression is not contained + * within the signature of the imports closure of the root ontology and the undeclared + * entity policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + * @see org.semanticweb.owlapi.reasoner.IndividualNodeSetPolicy + */ + NodeSet getInstances(OWLClassExpression ce, boolean direct); + + /** + * Gets the individuals which are instances of the specified class expression. The individuals + * are returned a a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param ce The class expression whose instances are to be retrieved. + * @param direct Specifies if the direct instances should be retrieved ( {@code true}), or if + * all instances should be retrieved ( {@code false}). + * @return If {@code direct} is {@code true}, a {@code NodeSet} containing named individuals + * such that for each named individual {@code j} in the node set, the set of reasoner + * axioms entails {@code DirectClassAssertion(ce, j)}.
+ * If {@code direct} is {@code false}, a {@code Stream} containing named individuals + * such that for each named individual {@code j} in the node set, the set of reasoner + * axioms entails {@code ClassAssertion(ce, j)}.
+ * If ce is unsatisfiable with respect to the set of reasoner axioms then the empty + * {@code NodeSet} is returned. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws ClassExpressionNotInProfileException if the class expression {@code ce} is not in the + * profile that is supported by this reasoner. + * @throws FreshEntitiesException if the signature of the class expression is not contained + * within the signature of the imports closure of the root ontology and the undeclared + * entity policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + * @see org.semanticweb.owlapi.reasoner.IndividualNodeSetPolicy + */ + default Stream instances(OWLClassExpression ce, boolean direct) { + return getInstances(ce, direct).entities(); + } + + /** + * Gets the individuals which are instances of the specified class expression. The individuals + * are returned a a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param ce The class expression whose instances are to be retrieved. + * @param direct Specifies if the direct instances should be retrieved ( {@code true}), or if + * all instances should be retrieved ( {@code false}). + * @return If {@code direct} is {@code true}, a {@code Stream} containing named individuals (if + * the reasoner uses {@code IndividualNodeSetPolicy#BY_SAME_AS}, only the representative + * individuals will be listed) such that for each named individual {@code j} in the node + * set, the set of reasoner axioms entails {@code DirectClassAssertion(ce, j)}.
+ * If {@code direct} is {@code false}, a {@code NodeSet} containing named individuals + * such that for each named individual {@code j} in the node set, the set of reasoner + * axioms entails {@code ClassAssertion(ce, j)}.
+ * If ce is unsatisfiable with respect to the set of reasoner axioms then the empty + * {@code NodeSet} is returned. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws ClassExpressionNotInProfileException if the class expression {@code ce} is not in the + * profile that is supported by this reasoner. + * @throws FreshEntitiesException if the signature of the class expression is not contained + * within the signature of the imports closure of the root ontology and the undeclared + * entity policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + * @see org.semanticweb.owlapi.reasoner.IndividualNodeSetPolicy + */ + default Stream representativeInstances(OWLClassExpression ce, + boolean direct) { + return getIndividualNodeSetPolicy().filter(getInstances(ce, direct)); + } + + /** + * @param ce The class expression whose instances are to be retrieved. + * @param depth Specifies if the direct instances should be retrieved ( {@code DIRECT}), or if + * all instances should be retrieved ( {@code ALL}). + * @return If {@code depth} is {@code DIRECT}, a {@code NodeSet} containing named individuals + * such that for each named individual {@code j} in the node set, the set of reasoner + * axioms entails {@code DirectClassAssertion(ce, j)}.
+ * If {@code depth} is {@code ALL}, a {@code + * NodeSet} containing named individuals such that for each named individual {@code j} in the + * node set, the set of reasoner axioms entails {@code ClassAssertion(ce, j)}.
+ * If ce is unsatisfiable with respect to the set of reasoner axioms then the empty + * {@code NodeSet} is returned. + * @see OWLReasoner#getInstances(OWLClassExpression, boolean) Gets the individuals which are + * instances of the specified class expression. The individuals are returned a a + * {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default NodeSet getInstances(OWLClassExpression ce, InferenceDepth depth) { + return getInstances(ce, depth.isDirectOnly()); + } + + /** + * @param ce The class expression whose instances are to be retrieved. + * @param depth Specifies if the direct instances should be retrieved ( {@code DIRECT}), or if + * all instances should be retrieved ( {@code ALL}). + * @return If {@code depth} is {@code DIRECT}, a {@code NodeSet} containing named individuals + * such that for each named individual {@code j} in the node set, the set of reasoner + * axioms entails {@code DirectClassAssertion(ce, j)}.
+ * If {@code depth} is {@code ALL}, a {@code + * NodeSet} containing named individuals such that for each named individual {@code j} in the + * node set, the set of reasoner axioms entails {@code ClassAssertion(ce, j)}.
+ * If ce is unsatisfiable with respect to the set of reasoner axioms then the empty + * {@code NodeSet} is returned. + * @see OWLReasoner#getInstances(OWLClassExpression, boolean) Gets the individuals which are + * instances of the specified class expression. The individuals are returned a a + * {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default Stream instances(OWLClassExpression ce, InferenceDepth depth) { + return getInstances(ce, depth).entities(); + } + + /** + * @param ce The class expression whose instances are to be retrieved. + * @param depth Specifies if the direct instances should be retrieved ( {@code DIRECT}), or if + * all instances should be retrieved ( {@code ALL}). + * @return If {@code depth} is {@code DIRECT}, a {@code Stream} containing named individuals (if + * the reasoner uses {@code IndividualNodeSetPolicy#BY_SAME_AS}, only the representative + * individuals will be listed) such that for each named individual {@code j} in the node + * set, the set of reasoner axioms entails {@code DirectClassAssertion(ce, j)}.
+ * If {@code depth} is {@code ALL}, a {@code + * NodeSet} containing named individuals such that for each named individual {@code j} in the + * node set, the set of reasoner axioms entails {@code ClassAssertion(ce, j)}.
+ * If ce is unsatisfiable with respect to the set of reasoner axioms then the empty + * {@code NodeSet} is returned. + * @see OWLReasoner#getInstances(OWLClassExpression, boolean) Gets the individuals which are + * instances of the specified class expression. The individuals are returned a a + * {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default Stream representativeInstances(OWLClassExpression ce, + InferenceDepth depth) { + return getIndividualNodeSetPolicy().filter(getInstances(ce, depth)); + } + + /** + * @param ce The class expression whose instances are to be retrieved. + * @return a {@code NodeSet} containing named individuals such that for each named individual + * {@code j} in the node set, the set of reasoner axioms entails + * {@code ClassAssertion(ce, j)}.
+ * If ce is unsatisfiable with respect to the set of reasoner axioms then the empty + * {@code + * NodeSet} is returned. + * @see OWLReasoner#getInstances(OWLClassExpression, boolean) Gets the individuals which are + * instances of the specified class expression. The individuals are returned a a + * {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default NodeSet getInstances(OWLClassExpression ce) { + return getInstances(ce, false); + } + + /** + * @param ce The class expression whose instances are to be retrieved. + * @return a {@code Stream} containing named individuals such that for each named individual + * {@code j} in the node set, the set of reasoner axioms entails + * {@code ClassAssertion(ce, j)}.
+ * If ce is unsatisfiable with respect to the set of reasoner axioms then the empty + * {@code + * NodeSet} is returned. + * @see OWLReasoner#getInstances(OWLClassExpression, boolean) Gets the individuals which are + * instances of the specified class expression. The individuals are returned a a + * {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default Stream instances(OWLClassExpression ce) { + return getInstances(ce, false).entities(); + } + + /** + * @param ce The class expression whose instances are to be retrieved. + * @return a {@code Stream} containing named individuals (if the reasoner uses + * {@code IndividualNodeSetPolicy#BY_SAME_AS}, only the representative individuals will + * be listed) such that for each named individual {@code j} in the node set, the set of + * reasoner axioms entails {@code ClassAssertion(ce, j)}.
+ * If ce is unsatisfiable with respect to the set of reasoner axioms then the empty + * {@code + * NodeSet} is returned. + * @see OWLReasoner#getInstances(OWLClassExpression, boolean) Gets the individuals which are + * instances of the specified class expression. The individuals are returned a a + * {@link org.semanticweb.owlapi.reasoner.NodeSet}. + */ + default Stream representativeInstances(OWLClassExpression ce) { + return getIndividualNodeSetPolicy().filter(getInstances(ce, false)); + } + + /** + * Gets the object property values for the specified individual and object property expression. + * The individuals are returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param ind The individual that is the subject of the object property values + * @param pe The object property expression whose values are to be retrieved for the specified + * individual + * @return A {@code NodeSet} containing named individuals such that for each individual {@code + * j} in the node set, the set of reasoner axioms entails + * {@code ObjectPropertyAssertion(pe ind + * j)} . + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the individual and property expression is + * not contained within the signature of the imports closure of the root ontology and + * the undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + * @see org.semanticweb.owlapi.reasoner.IndividualNodeSetPolicy + */ + NodeSet getObjectPropertyValues(OWLNamedIndividual ind, + OWLObjectPropertyExpression pe); + + /** + * Gets the object property values for the specified individual and object property expression. + * The individuals are returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param ind The individual that is the subject of the object property values + * @param pe The object property expression whose values are to be retrieved for the specified + * individual + * @return A {@code NodeSet} containing named individuals such that for each individual {@code + * j} in the node set, the set of reasoner axioms entails + * {@code ObjectPropertyAssertion(pe ind + * j)} . + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the individual and property expression is + * not contained within the signature of the imports closure of the root ontology and + * the undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + * @see org.semanticweb.owlapi.reasoner.IndividualNodeSetPolicy + */ + default Stream objectPropertyValues(OWLNamedIndividual ind, + OWLObjectPropertyExpression pe) { + return getObjectPropertyValues(ind, pe).entities(); + } + + /** + * Gets the data property values for the specified individual and data property expression. The + * values are a set of literals. Note that the results are not guaranteed to be complete for + * this method. The reasoner may also return canonical literals or they may be in a form that + * bears a resemblance to the syntax of the literals in the root ontology imports closure. + * + * @param ind The individual that is the subject of the data property values + * @param pe The data property expression whose values are to be retrieved for the specified + * individual + * @return A set of {@code OWLLiteral}s containing literals such that for each literal {@code l} + * in the set, the set of reasoner axioms entails + * {@code DataPropertyAssertion(pe ind l)}. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the individual and property expression is + * not contained within the signature of the imports closure of the root ontology and + * the undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + * @see org.semanticweb.owlapi.reasoner.IndividualNodeSetPolicy + */ + Set getDataPropertyValues(OWLNamedIndividual ind, OWLDataProperty pe); + + /** + * Gets the data property values for the specified individual and data property expression. The + * values are a set of literals. Note that the results are not guaranteed to be complete for + * this method. The reasoner may also return canonical literals or they may be in a form that + * bears a resemblance to the syntax of the literals in the root ontology imports closure. + * + * @param ind The individual that is the subject of the data property values + * @param pe The data property expression whose values are to be retrieved for the specified + * individual + * @return A set of {@code OWLLiteral}s containing literals such that for each literal {@code l} + * in the set, the set of reasoner axioms entails + * {@code DataPropertyAssertion(pe ind l)}. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the individual and property expression is + * not contained within the signature of the imports closure of the root ontology and + * the undeclared entity policy of this reasoner is set to + * {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + * @see org.semanticweb.owlapi.reasoner.IndividualNodeSetPolicy + */ + default Stream dataPropertyValues(OWLNamedIndividual ind, OWLDataProperty pe) { + return getDataPropertyValues(ind, pe).stream(); + } + + /** + * Gets the individuals that are the same as the specified individual. + * + * @param ind The individual whose same individuals are to be retrieved. + * @return A node containing individuals such that for each individual {@code j} in the node, + * the root ontology imports closure entails {@code SameIndividual(j, ind)}. Note that + * the node will contain {@code j}. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the individual is not contained within the + * signature of the imports closure of the root ontology and the undeclared entity + * policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + Node getSameIndividuals(OWLNamedIndividual ind); + + /** + * Gets the individuals that are the same as the specified individual. + * + * @param ind The individual whose same individuals are to be retrieved. + * @return A node containing individuals such that for each individual {@code j} in the node, + * the root ontology imports closure entails {@code SameIndividual(j, ind)}. Note that + * the node will contain {@code j}. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the individual is not contained within the + * signature of the imports closure of the root ontology and the undeclared entity + * policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + default Stream sameIndividuals(OWLNamedIndividual ind) { + return getSameIndividuals(ind).entities(); + } + + /** + * Gets the individuals which are entailed to be different from the specified individual. The + * individuals are returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param ind The individual whose different individuals are to be returned. + * @return A {@code NodeSet} containing {@code OWLNamedIndividual} s such that for each + * individual {@code i} in the {@code NodeSet} the set of reasoner axioms entails {@code + * DifferentIndividuals(ind, i)}. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the individual is not contained within the + * signature of the imports closure of the root ontology and the undeclared entity + * policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + NodeSet getDifferentIndividuals(OWLNamedIndividual ind); + + /** + * Gets the individuals which are entailed to be different from the specified individual. The + * individuals are returned as a {@link org.semanticweb.owlapi.reasoner.NodeSet}. + * + * @param ind The individual whose different individuals are to be returned. + * @return A {@code NodeSet} containing {@code OWLNamedIndividual} s such that for each + * individual {@code i} in the {@code NodeSet} the set of reasoner axioms entails {@code + * DifferentIndividuals(ind, i)}. + * @throws InconsistentOntologyException if the imports closure of the root ontology is + * inconsistent + * @throws FreshEntitiesException if the signature of the individual is not contained within the + * signature of the imports closure of the root ontology and the undeclared entity + * policy of this reasoner is set to {@link FreshEntityPolicy#DISALLOW}. + * @throws ReasonerInterruptedException if the reasoning process was interrupted for any + * particular reason (for example if reasoning was cancelled by a client process) + * @throws TimeOutException if the reasoner timed out during a basic reasoning operation. See + * {@link #getTimeOut()}. + */ + default Stream differentIndividuals(OWLNamedIndividual ind) { + return getDifferentIndividuals(ind).entities(); + } + + /** + * Gets the time out (in milliseconds) for the most basic reasoning operations. That is the + * maximum time for a satisfiability test, subsumption test etc. The time out should be set at + * reasoner creation time. During satisfiability (subsumption) checking the reasoner will check + * to see if the time it has spent doing the single check is longer than the value returned by + * this method. If this is the case, the reasoner will throw a + * {@link org.semanticweb.owlapi.reasoner.TimeOutException} in the thread that is executing the + * reasoning process.
+ * Note that clients that want a higher level timeout, at the level of classification for + * example, should start their own timers and request that the reasoner interrupts the current + * process using the {@link #interrupt()} method. + * + * @return The time out in milliseconds for basic reasoner operation. By default this is the + * value of {@link Long#MAX_VALUE}. + */ + long getTimeOut(); + + /** + * Gets the Fresh Entity Policy in use by this reasoner. The policy is set at reasoner creation + * time. + * + * @return The policy. + */ + FreshEntityPolicy getFreshEntityPolicy(); + + /** + * Gets the IndividualNodeSetPolicy in use by this reasoner. The policy is set at reasoner + * creation time. + * + * @return The policy. + */ + IndividualNodeSetPolicy getIndividualNodeSetPolicy(); + + /** + * Disposes of this reasoner. This frees up any resources used by the reasoner and detaches the + * reasoner as an {@link org.semanticweb.owlapi.model.OWLOntologyChangeListener} from the + * {@link org.semanticweb.owlapi.model.OWLOntologyManager} that manages the ontologies contained + * within the reasoner. + */ + void dispose(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/OWLReasonerConfiguration.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/OWLReasonerConfiguration.java new file mode 100644 index 0000000000..3b3af9fe34 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/OWLReasonerConfiguration.java @@ -0,0 +1,81 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +import java.io.Serializable; + +/** + * An OWLReasonerConfiguration can be used to customise the setup of a reasoner + * at reasoner creation time via an + * {@link org.semanticweb.owlapi.reasoner.OWLReasonerFactory}. Specific + * reasoners may define their own configuration objects with configuration + * options particular to the reasoner. There are also a set of general options + * defined by this configuration object.
+ * Note that once a reasoner has been created, changing fields (via setter + * methods or directly) on the configuration object will have no effect. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @see org.semanticweb.owlapi.reasoner.OWLReasonerFactory + * @see org.semanticweb.owlapi.reasoner.SimpleConfiguration + * @since 3.0.0 + */ +public interface OWLReasonerConfiguration extends Serializable { + + /** + * Gets a progress monitor that the reasoner may update with information + * about the progress of its reasoning process. + * + * @return A progress monitor. By default this returns {@link NullReasonerProgressMonitor} + */ + ReasonerProgressMonitor getProgressMonitor(); + + /** + * Gets the timeout in milliseconds for basic single reasoner operations + * (satisfiability check time out). If the value is equal to + * {@link Long#MAX_VALUE} then this means that the reasoner should never + * time out.
+ * The reasoner will monitor the elapsed time during a satisfiability check + * (attempt to build a model for example) and if the elapsed time exceeds + * the timeout then it will abort the test as soon as possible and terminate + * all reasoning. A {@link org.semanticweb.owlapi.reasoner.TimeOutException} + * will be thrown in the thread that invoked the last reasoner operation. + *
+ * Note that this is not a timeout for method calls such as "getSubClasses", + * which may involve many satisfiability (or other basic reasoning task) + * checks, the sum of which may well exceed the timeout. + * + * @return The time out in milliseconds. By default this is set to the value of {@link + * Long#MAX_VALUE}, which means the reasoner SHOULD NOT timeout. + */ + long getTimeOut(); + + /** + * Gets the fresh entity policy that should be used. By default this is set + * to {@link FreshEntityPolicy#ALLOW}. + * + * @return The fresh entity policy. + */ + FreshEntityPolicy getFreshEntityPolicy(); + + /** + * Gets the {@link org.semanticweb.owlapi.reasoner.IndividualNodeSetPolicy} + * which determines how {@code NodeSet}s of named individuals are returned + * from the reasoner. + * + * @return The {@code IndividualNodeSetPolicy} that should be used. By default the policy is + * {@link org.semanticweb.owlapi.reasoner.IndividualNodeSetPolicy#BY_NAME} i.e. by default + * individuals that are the same as each other are not grouped into the same node within a node + * set. + */ + IndividualNodeSetPolicy getIndividualNodeSetPolicy(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/OWLReasonerFactory.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/OWLReasonerFactory.java new file mode 100644 index 0000000000..5b0e0b3653 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/OWLReasonerFactory.java @@ -0,0 +1,117 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * An OWLReasonerFactory is a point for creating instances of + * {@link org.semanticweb.owlapi.reasoner.OWLReasoner} objects. A reasoner + * reasons over a set of ontologies that is defined by an ontology and its + * imports closure. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @see org.semanticweb.owlapi.reasoner.OWLReasoner + * @since 3.0.0 + */ +public interface OWLReasonerFactory { + + /** + * Gets the name of the reasoner created by this factory. + * + * @return A string that represents the name of the reasoner created by this factory. + */ + String getReasonerName(); + + /** + * Creates an OWLReasoner that reasons over the imports closure of the + * specified ontology. The reasoner will obtain the imports closure from the + * ontology manager associated with {@code ontology}. The reasoner will + * listen for ontology changes to the ontologies that it is reasoning over + * and will always answer queries with respect to the changed ontologies + * (see {@link org.semanticweb.owlapi.reasoner.OWLReasoner} for further + * details). + * + * @param ontology The ontology whose imports closure will be reasoned over by the reasoner that + * is created. + * @return The reasoner that reasons over the imports closure of the specified ontology. Note + * that calling this method multiple times with the same manager and ontology will return + * fresh instances of OWLReasoner. + * @throws NullPointerException if the {@code manager} or {@code ontology} are {@code null}. + */ + OWLReasoner createNonBufferingReasoner(OWLOntology ontology); + + /** + * Creates a buffering reasoner that reasons over the imports closure of the + * specified ontology. The reasoner will obtain the imports closure from the + * ontology manager associated with {@code ontology}. The reasoner will + * listen for ontology changes to the ontologies it is reasoning over but + * will only answer queries with respect to the changed ontologies when the + * {@link OWLReasoner#flush()} method is called (see + * {@link org.semanticweb.owlapi.reasoner.OWLReasoner} for further details). + * + * @param ontology The ontology whose imports closure will be reasoned over by the reasoner that + * is created. + * @return The reasoner that reasons over the imports closure of the specified ontology. Note + * that calling this method multiple times with the same manager and ontology will return + * fresh instances of OWLReasoner. + * @throws NullPointerException if the {@code manager} or {@code ontology} are {@code null}. + */ + OWLReasoner createReasoner(OWLOntology ontology); + + /** + * Creates an OWLReasoner that reasons over the imports closure of the + * specified ontology. The reasoner will obtain the imports closure from the + * ontology manager associated with {@code ontology}. The reasoner will + * listen for ontology changes to the ontologies that it is reasoning over + * and will always answer queries with respect to the changed ontologies + * (see {@link org.semanticweb.owlapi.reasoner.OWLReasoner} for further + * details). + * + * @param ontology The ontology whose imports closure will be reasoned over by the reasoner that + * is created. + * @param config A configuration object that can be used to customise the setup of the reasoner + * that will be created by calling this method. + * @return The reasoner that reasons over the imports closure of the specified ontology. Note + * that calling this method multiple times with the same manager and ontology will return + * fresh instances of OWLReasoner. + * @throws IllegalConfigurationException if the configuration object is inappropriate for + * reasoners created by this factory, or if there is an illegal setting on the configuration. + * @throws NullPointerException if any of {@code manager}, {@code ontology} or {@code config} + * are {@code null}. + */ + OWLReasoner createNonBufferingReasoner(OWLOntology ontology, OWLReasonerConfiguration config); + + /** + * Creates a buffering reasoner that reasons over the imports closure of the + * specified ontology. The reasoner will obtain the imports closure from the + * ontology manager associated with {@code ontology}. The reasoner will + * listen for ontology changes to the ontologies it is reasoning over but + * will only answer queries with respect to the changed ontologies when the + * {@link OWLReasoner#flush()} method is called (see + * {@link org.semanticweb.owlapi.reasoner.OWLReasoner} for further details). + * + * @param ontology The ontology whose imports closure will be reasoned over by the reasoner that + * is created. + * @param config A configuration object that can be used to customise the setup of the reasoner + * that will be created by calling this method. + * @return The reasoner that reasons over the imports closure of the specified ontology. Note + * that calling this method multiple times with the same manager and ontology will return + * fresh instances of OWLReasoner. + * @throws IllegalConfigurationException if the configuration object is inappropriate for + * reasoners created by this factory, or if there is an illegal setting on the configuration. + * @throws NullPointerException if any of {@code manager}, {@code ontology} or {@code config} + * are {@code null}. + */ + OWLReasoner createReasoner(OWLOntology ontology, OWLReasonerConfiguration config); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/OWLReasonerRuntimeException.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/OWLReasonerRuntimeException.java new file mode 100644 index 0000000000..27a1a81659 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/OWLReasonerRuntimeException.java @@ -0,0 +1,52 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLRuntimeException; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class OWLReasonerRuntimeException extends OWLRuntimeException { + + /** + * Default constructor. + */ + public OWLReasonerRuntimeException() { + super(); + } + + /** + * @param cause error cause + */ + public OWLReasonerRuntimeException(@Nullable Throwable cause) { + super(cause); + } + + /** + * @param message error message + */ + public OWLReasonerRuntimeException(String message) { + super(message); + } + + /** + * @param message error message + * @param cause error cause + */ + public OWLReasonerRuntimeException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/ReasonerInternalException.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/ReasonerInternalException.java new file mode 100644 index 0000000000..6c375d8788 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/ReasonerInternalException.java @@ -0,0 +1,52 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +/** + * Specifies that a some internal error occurred during reasoning. Each reasoner + * implementation will specify the cause of the error in the message.
+ * This exception is only thrown when an internal error (due to errors in the + * reasoner code) has occurred and the reasoner cannot recover silently from the + * error. If the reasoner can recover silently this exception will not be + * thrown.
+ * Clients should dispose of the reasoner when an internal reasoner exception is + * thrown because the error is unrecoverable and the internal state of the + * reasoner may be corrupt. + * + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +public class ReasonerInternalException extends OWLReasonerRuntimeException { + + /** + * @param cause error cause + */ + public ReasonerInternalException(Throwable cause) { + super(cause); + } + + /** + * @param message error message + */ + public ReasonerInternalException(String message) { + super(message); + } + + /** + * @param message error message + * @param cause error cause + */ + public ReasonerInternalException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/ReasonerInterruptedException.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/ReasonerInterruptedException.java new file mode 100644 index 0000000000..3cb1b0cfaf --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/ReasonerInterruptedException.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +import org.semanticweb.owlapi.model.OWLRuntimeException; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class ReasonerInterruptedException extends OWLRuntimeException { + + /** + * Default constructor. + */ + public ReasonerInterruptedException() { + super(); + } + + /** + * @param message error message + */ + public ReasonerInterruptedException(String message) { + super(message); + } + + /** + * @param message error message + * @param cause error cause + */ + public ReasonerInterruptedException(String message, Throwable cause) { + super(message, cause); + } + + /** + * @param cause error cause + */ + public ReasonerInterruptedException(Throwable cause) { + super(cause); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/ReasonerProgressMonitor.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/ReasonerProgressMonitor.java new file mode 100644 index 0000000000..0ab2c85c33 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/ReasonerProgressMonitor.java @@ -0,0 +1,95 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +import java.io.Serializable; + +/** + * The ReasonerProgressMonitor interface should be implemented by objects that wish to monitor the + * progress of a reasoner. The reasoner whose progress is being monitored will call the methods on + * this interface. The progress monitor is designed to monitor long running reasoner tasks such as + * loading, preprocessing, consistency checking, classification and realisation.
+ * Tasks are executed sequentially. Nested tasks are not supported.
+ * The general contract is that the reasoner will call {@link #reasonerTaskStarted(String)}, then + * call either {@link #reasonerTaskBusy()} or {@link #reasonerTaskProgressChanged(int, int)} any + * number of times and finally call {@link #reasonerTaskStopped()} when the task ends or has been + * interrupted. This cycle may then be repeated. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +@SuppressWarnings("unused") +public interface ReasonerProgressMonitor extends Serializable { + + /** + * A standard name for the task of loading a reasoner with axioms. Note that there is no + * guarantee that the reasoner will use this name for loading. + */ + String LOADING = "Loading"; + /** + * A standard name for the task of computing the class hierarchy. Note that there is no + * guarantee that the reasoner will use this name for the task of computing the class hierarchy. + */ + String CLASSIFYING = "Classifying"; + /** + * A standard name for the task of computing the types of individual. Note that there is no + * guarantee that the reasoner will use this name for the task of realising. + */ + String REALIZING = "Realizing"; + /** + * A standard name for the task of classifying and realising at the same time. Note that there + * is no guarantee that the reasoner will use this name for the task of classifying. + */ + String CLASSIFYING_AND_REALIZING = "Classifying and Realizing"; + + /** + * Indicates that some reasoner task, for example, loading, consistency checking, + * classification, realisation etc. has started. When the task has finished the + * {@link #reasonerTaskStopped()} method will be called. Once this method has been called it + * will not be called again unless the {@link #reasonerTaskStopped()} method has been called. + * The notion of subtasks is not supported.
+ * Note that this method may be called from a thread that is not the event dispatch thread. + * + * @param taskName The name of the task + */ + default void reasonerTaskStarted(String taskName) {} + + /** + * Indicates that a previously started task has now stopped. This method will only be called + * after the {@link #reasonerTaskStarted(String)} method has been called. The notion of subtasks + * is not supported.
+ * Note that this method may be called from a thread that is not the event dispatch thread. + */ + default void reasonerTaskStopped() {} + + /** + * Indicates that the reasoner is part way through a particular task, for example consistency + * checking, classification or realisation. This method will only be called after the + * {@link #reasonerTaskStarted(String)} method has been called. It will not be called after the + * {@link #reasonerTaskStopped()} method has been called.
+ * Note that this method may be called from a thread that is not the event dispatch thread. + * + * @param value The value or portion of the task completed + * @param max The total size of the task + */ + default void reasonerTaskProgressChanged(int value, int max) {} + + /** + * Indicates that the reasoner is busy performing a task whose size cannot be determined. This + * method will only be called after the {@link #reasonerTaskStarted(String)} method has been + * called. It will not be called after the {@link #reasonerTaskStopped()} method has been + * called.
+ * Note that this method may be called from a thread that is not the event dispatch thread. + */ + default void reasonerTaskBusy() {} +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/SimpleConfiguration.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/SimpleConfiguration.java new file mode 100644 index 0000000000..e4cb6dee91 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/SimpleConfiguration.java @@ -0,0 +1,101 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +/** + * A simple configuration with the general options. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class SimpleConfiguration implements OWLReasonerConfiguration { + + private ReasonerProgressMonitor progressMonitor = new NullReasonerProgressMonitor(); + private FreshEntityPolicy freshEntityPolicy = FreshEntityPolicy.ALLOW; + private IndividualNodeSetPolicy individualNodeSetPolicy = IndividualNodeSetPolicy.BY_NAME; + private long timeOut = Long.MAX_VALUE; + + /** + * Default constructor. + */ + public SimpleConfiguration() { + super(); + } + + /** + * @param progressMonitor the progress monitor to use + */ + public SimpleConfiguration(ReasonerProgressMonitor progressMonitor) { + this.progressMonitor = progressMonitor; + } + + /** + * @param progressMonitor the progress monitor to use + * @param timeOut the timeout in milliseconds + */ + public SimpleConfiguration(ReasonerProgressMonitor progressMonitor, long timeOut) { + this.progressMonitor = progressMonitor; + this.timeOut = timeOut; + } + + /** + * @param progressMonitor the progress monitor to use + * @param freshEntityPolicy the policy for fresh entities + * @param timeOut the timeout in milliseconds + * @param individualNodeSetPolicy the policy for individual nodes + */ + public SimpleConfiguration(ReasonerProgressMonitor progressMonitor, + FreshEntityPolicy freshEntityPolicy, + long timeOut, IndividualNodeSetPolicy individualNodeSetPolicy) { + this.progressMonitor = progressMonitor; + this.freshEntityPolicy = freshEntityPolicy; + this.timeOut = timeOut; + this.individualNodeSetPolicy = individualNodeSetPolicy; + } + + /** + * @param freshEntityPolicy the policy for fresh entities + * @param timeOut the timeout in milliseconds + */ + public SimpleConfiguration(FreshEntityPolicy freshEntityPolicy, long timeOut) { + this.freshEntityPolicy = freshEntityPolicy; + this.timeOut = timeOut; + } + + /** + * @param timeOut the timeout in milliseconds + */ + public SimpleConfiguration(long timeOut) { + this.timeOut = timeOut; + } + + @Override + public ReasonerProgressMonitor getProgressMonitor() { + return progressMonitor; + } + + @Override + public long getTimeOut() { + return timeOut; + } + + @Override + public FreshEntityPolicy getFreshEntityPolicy() { + return freshEntityPolicy; + } + + @Override + public IndividualNodeSetPolicy getIndividualNodeSetPolicy() { + return individualNodeSetPolicy; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/TimeOutException.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/TimeOutException.java new file mode 100644 index 0000000000..17fb8fd46a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/TimeOutException.java @@ -0,0 +1,45 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +/** + * Thrown when the current reasoner operation has been interrupted due to a + * satisfiability check timeout. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class TimeOutException extends OWLReasonerRuntimeException { + + /** + * Default constructor. + */ + public TimeOutException() { + this("Timeout occurred while reasoning!"); + } + + /** + * @param message error message + */ + public TimeOutException(String message) { + super(message); + } + + /** + * @param message error message + * @param cause error cause + */ + public TimeOutException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/TimedConsoleProgressMonitor.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/TimedConsoleProgressMonitor.java new file mode 100644 index 0000000000..ee612ebde5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/TimedConsoleProgressMonitor.java @@ -0,0 +1,61 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +import java.io.Serializable; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class TimedConsoleProgressMonitor implements ReasonerProgressMonitor, + Serializable { + + private int lastPercentage; + private long lastTime; + private long beginTime; + + @Override + public void reasonerTaskStarted(String taskName) { + System.out.print(taskName); + System.out.println(" ..."); + lastTime = System.nanoTime(); + beginTime = lastTime; + } + + @Override + public void reasonerTaskStopped() { + System.out.println(" ... finished in " + + (System.nanoTime() - beginTime) / 1000000.0D); + lastPercentage = 0; + } + + @Override + public void reasonerTaskProgressChanged(int value, int max) { + long time = System.nanoTime(); + if (max > 0) { + int percent = value * 100 / max; + if (lastPercentage != percent) { + System.out.println(" " + percent + "%\t" + (time - lastTime) + / 1000000); + lastTime = time; + lastPercentage = percent; + } + } + } + + @Override + public void reasonerTaskBusy() { + System.out.println(" busy ..."); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/UnsupportedEntailmentTypeException.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/UnsupportedEntailmentTypeException.java new file mode 100644 index 0000000000..c724556cc4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/UnsupportedEntailmentTypeException.java @@ -0,0 +1,40 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLRuntimeException; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class UnsupportedEntailmentTypeException extends OWLRuntimeException { + + private final OWLAxiom axiom; + + /** + * @param axiom unsupported entailment + */ + public UnsupportedEntailmentTypeException(OWLAxiom axiom) { + super("Cannot check entailment: " + axiom); + this.axiom = axiom; + } + + /** + * @return unsupported axiom + */ + public OWLAxiom getAxiom() { + return axiom; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/knowledgeexploration/OWLKnowledgeExplorerReasoner.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/knowledgeexploration/OWLKnowledgeExplorerReasoner.java new file mode 100644 index 0000000000..51a853f68a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/knowledgeexploration/OWLKnowledgeExplorerReasoner.java @@ -0,0 +1,103 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.reasoner.knowledgeexploration; + +import java.util.Collection; + +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.reasoner.Node; +import org.semanticweb.owlapi.reasoner.OWLReasoner; + +/** + * Extension of OWLReasoner to allow access to reasoner completion graph. + */ +public interface OWLKnowledgeExplorerReasoner extends OWLReasoner { + + /** + * @param expression the expression of which the completion tree is to be computed + * @return compute and return the root node of the completion tree for the expression + */ + RootNode getRoot(OWLClassExpression expression); + + /** + * @param node a node, as returned by either {@link #getRoot(OWLClassExpression)} or + * {@link #getObjectNeighbours(RootNode, OWLObjectProperty)} + * @param deterministicOnly true if only deterministic results should be returned + * @return neighbors by object property + */ + Node getObjectNeighbours(RootNode node, + boolean deterministicOnly); + + /** + * @param node a node, as returned by either {@link #getRoot(OWLClassExpression)} or + * {@link #getObjectNeighbours(RootNode, OWLObjectProperty)} + * @param deterministicOnly true if only deterministic results should be returned + * @return neighbors by data property + */ + Node getDataNeighbours(RootNode node, boolean deterministicOnly); + + /** + * @param node a node, as returned by either {@link #getRoot(OWLClassExpression)} or + * {@link #getObjectNeighbours(RootNode, boolean)} + * @param property the property being followed + * @return neighbors by object property + */ + Collection getObjectNeighbours(RootNode node, OWLObjectProperty property); + + /** + * @param node a node, as returned by either {@link #getRoot(OWLClassExpression)} or + * {@link #getObjectNeighbours(RootNode, boolean)} + * @param property the property being followed + * @return neighbors by data property + */ + Collection getDataNeighbours(RootNode node, OWLDataProperty property); + + /** + * @param node a node, as returned by either {@link #getRoot(OWLClassExpression)} or + * {@link #getObjectNeighbours(RootNode, OWLObjectProperty)} + * @param deterministicOnly true if only deterministic results should be returned + * @return neighbors label by object property + */ + Node getObjectLabel(RootNode node, boolean deterministicOnly); + + /** + * @param node a node, as returned by {@link #getDataNeighbours(RootNode, boolean)} + * @param deterministicOnly true if only deterministic results should be returned + * @return neighbors label by data property + */ + Node getDataLabel(RootNode node, boolean deterministicOnly); + + /** + * @param node a node, as return by either {@link #getRoot(OWLClassExpression)} or + * {@link #getObjectNeighbours(RootNode, OWLObjectProperty)} + * @return a node that blocks given node, or null if there is no such blocker + */ + RootNode getBlocker(RootNode node); + + /** + * Interface for a tableaux node. + */ + @FunctionalInterface + interface RootNode { + + /** + * @param actual node type + * @return inner node representation + */ + T getNode(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/knowledgeexploration/package-info.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/knowledgeexploration/package-info.java new file mode 100644 index 0000000000..1f492482e5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/knowledgeexploration/package-info.java @@ -0,0 +1,18 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Knowledge exploration package. OWLKnowledgeExplorerReasoner provides access + * to the tableaux tree + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.reasoner.knowledgeexploration; diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/knowledgeexploration/packageinfo b/api/src/main/java/org/semanticweb/owlapi/reasoner/knowledgeexploration/packageinfo new file mode 100644 index 0000000000..8ce0371286 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/knowledgeexploration/packageinfo @@ -0,0 +1 @@ +version 5.0.0 diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/package-info.java b/api/src/main/java/org/semanticweb/owlapi/reasoner/package-info.java new file mode 100644 index 0000000000..0f5b8a9588 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * OWLReasoner package. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.reasoner; diff --git a/api/src/main/java/org/semanticweb/owlapi/reasoner/packageinfo b/api/src/main/java/org/semanticweb/owlapi/reasoner/packageinfo new file mode 100644 index 0000000000..0ca47308f9 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/reasoner/packageinfo @@ -0,0 +1 @@ +version 5.1.1 diff --git a/api/src/main/java/org/semanticweb/owlapi/search/AnnotationVisitor.java b/api/src/main/java/org/semanticweb/owlapi/search/AnnotationVisitor.java new file mode 100644 index 0000000000..30d604fdd1 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/search/AnnotationVisitor.java @@ -0,0 +1,40 @@ +package org.semanticweb.owlapi.search; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.Set; +import org.semanticweb.owlapi.model.HasAnnotations; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAxiomVisitorEx; +import org.semanticweb.owlapi.util.CollectionFactory; + +@SuppressWarnings("unchecked") +class AnnotationVisitor implements OWLAxiomVisitorEx> { + + private final boolean value; + + AnnotationVisitor(boolean value) { + this.value = value; + } + + @Override + public Set doDefault(Object object) { + return asUnorderedSet(((HasAnnotations) object).annotations().map(this::get)); + } + + private C get(OWLAnnotation a) { + if (value) { + return (C) a.getValue(); + } + return (C) a; + } + + @Override + public Set visit(OWLAnnotationAssertionAxiom axiom) { + if (value) { + return CollectionFactory.createSet((C) axiom.getValue()); + } + return CollectionFactory.createSet((C) axiom.getAnnotation()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/search/DomainVisitor.java b/api/src/main/java/org/semanticweb/owlapi/search/DomainVisitor.java new file mode 100644 index 0000000000..7b39b10ca5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/search/DomainVisitor.java @@ -0,0 +1,26 @@ +package org.semanticweb.owlapi.search; + +import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLAxiomVisitorEx; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; + +@SuppressWarnings("unchecked") +class DomainVisitor implements OWLAxiomVisitorEx { + + @Override + public C visit(OWLAnnotationPropertyDomainAxiom axiom) { + return (C) axiom.getDomain(); + } + + @Override + public C visit(OWLDataPropertyDomainAxiom axiom) { + return (C) axiom.getDomain(); + } + + @Override + public C visit(OWLObjectPropertyDomainAxiom axiom) { + return (C) axiom.getDomain(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/search/EntitySearcher.java b/api/src/main/java/org/semanticweb/owlapi/search/EntitySearcher.java new file mode 100644 index 0000000000..f4d282f39b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/search/EntitySearcher.java @@ -0,0 +1,1648 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.search; + +import static org.semanticweb.owlapi.model.parameters.AxiomAnnotations.CONSIDER_AXIOM_ANNOTATIONS; +import static org.semanticweb.owlapi.model.parameters.AxiomAnnotations.IGNORE_AXIOM_ANNOTATIONS; +import static org.semanticweb.owlapi.model.parameters.Imports.EXCLUDED; +import static org.semanticweb.owlapi.model.parameters.Imports.fromBoolean; +import static org.semanticweb.owlapi.search.Filters.subAnnotationWithSub; +import static org.semanticweb.owlapi.search.Filters.subAnnotationWithSuper; +import static org.semanticweb.owlapi.search.Filters.subDataPropertyWithSub; +import static org.semanticweb.owlapi.search.Filters.subDataPropertyWithSuper; +import static org.semanticweb.owlapi.search.Filters.subObjectPropertyWithSub; +import static org.semanticweb.owlapi.search.Filters.subObjectPropertyWithSuper; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.contains; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.empty; + +import java.util.Collection; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationSubject; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.parameters.Imports; + +import com.google.common.collect.LinkedListMultimap; +import com.google.common.collect.Multimap; + +/** + * Convenience methods moved from OWLEntity and its subinterfaces. + * + * @author ignazio + */ +public class EntitySearcher { + + private EntitySearcher() {} + + /** + * Gets the annotations for e. These are deemed to be annotations in annotation assertion axioms + * that have a subject that is an IRI that is equal to the IRI of e, and it also includes + * annotations on the annotation assertion axioms whose annotation property matches + * + * @param e entity + * @param ontology The ontology to be examined for annotation assertion axioms + * @return The annotations that participate directly in an annotation assertion whose subject is + * an IRI corresponding to the IRI of e. + */ + public static Stream getAnnotations(OWLEntity e, OWLOntology ontology) { + return getAnnotations(e.getIRI(), ontology); + } + + /** + * Gets the annotations for e. These are deemed to be annotations in annotation assertion axioms + * that have a subject that is an IRI that is equal to the IRI of e, and it also includes + * annotations on the annotation assertion axioms whose annotation property matches. + * + * @param e entity + * @param ontology The ontology to be examined for annotation assertion axioms + * @return The annotations that participate directly in an annotation assertion whose subject is + * an IRI corresponding to the IRI of e. + */ + public static Stream getAnnotations(OWLAnnotationSubject e, + OWLOntology ontology) { + return Searcher.annotations(ontology.annotationAssertionAxioms(e)); + } + + /** + * Obtains the annotations on e where the annotation has the specified annotation property. This + * includes the annotations on annotation assertion axioms with matching annotation property. + * + * @param e entity + * @param ontology The ontology to examine for annotation axioms + * @param annotationProperty The annotation property + * @return A {@code Stream} of {@code OWLAnnotation} objects that have the specified URI. + */ + public static Stream getAnnotations(OWLEntity e, OWLOntology ontology, + OWLAnnotationProperty annotationProperty) { + return getAnnotations(e.getIRI(), ontology, annotationProperty); + } + + /** + * Obtains the annotations on e where the annotation has the specified annotation property; this + * is restricted to the object of annotation assertion axioms. + * + * @param e entity + * @param ontology The ontology to examine for annotation axioms + * @param annotationProperty The annotation property. If null, any annotation property will + * match. + * @return A {@code Stream} of {@code OWLAnnotation} objects that have the specified URI. + */ + public static Stream getAnnotationObjects(OWLEntity e, OWLOntology ontology, + @Nullable OWLAnnotationProperty annotationProperty) { + return getAnnotationObjects(e.getIRI(), ontology, annotationProperty); + } + + /** + * Obtains the annotations on e; this is restricted to the object of annotation assertion + * axioms. + * + * @param e entity + * @param ontology The ontology to examine for annotation axioms + * @return A {@code Stream} of {@code OWLAnnotation} objects that have the specified URI. + */ + public static Stream getAnnotationObjects(OWLEntity e, OWLOntology ontology) { + return getAnnotationObjects(e.getIRI(), ontology, null); + } + + /** + * Obtains the annotations on e where the annotation has the specified annotation property; this + * is restricted to the object of annotation assertion axioms. + * + * @param e entity + * @param ontology The ontology to examine for annotation axioms + * @param annotationProperty The annotation property. If null, any annotation property will + * match. + * @return A {@code Stream} of {@code OWLAnnotation} objects that have the specified URI. + */ + public static Stream getAnnotationObjects(OWLAnnotationSubject e, + OWLOntology ontology, @Nullable OWLAnnotationProperty annotationProperty) { + return Searcher.annotationObjects(ontology.annotationAssertionAxioms(e), + annotationProperty); + } + + /** + * Obtains the annotations on e where the annotation has the specified annotation property; this + * is restricted to the object of annotation assertion axioms. + * + * @param e entity + * @param ontologies The ontologies to examine for annotation axioms + * @param annotationProperty The annotation property. If null, any annotation property will + * match. + * @return A {@code Stream} of {@code OWLAnnotation} objects that have the specified URI. + */ + public static Stream getAnnotationObjects(OWLAnnotationSubject e, + Stream ontologies, @Nullable OWLAnnotationProperty annotationProperty) { + return ontologies.flatMap(o -> getAnnotationObjects(e, o, annotationProperty)); + } + + /** + * Obtains the annotations on e where the annotation has the specified annotation property; this + * is restricted to the object of annotation assertion axioms. + * + * @param e entity + * @param ontologies The ontologies to examine for annotation axioms + * @param annotationProperty The annotation property. If null, any annotation property will + * match. + * @return A {@code Stream} of {@code OWLAnnotation} objects that have the specified URI. + */ + public static Stream getAnnotationObjects(OWLEntity e, + Stream ontologies, @Nullable OWLAnnotationProperty annotationProperty) { + return ontologies.flatMap(o -> getAnnotationObjects(e, o, annotationProperty)); + } + + /** + * Obtains the annotations on e where the annotation has the specified annotation property. This + * includes the annotations on annotation assertion axioms with matching annotation property. + * + * @param e entity + * @param ontology The ontology to examine for annotation axioms + * @param annotationProperty The annotation property + * @return A {@code Stream} of {@code OWLAnnotation} objects that have the specified URI. + */ + public static Stream getAnnotations(OWLAnnotationSubject e, OWLOntology ontology, + OWLAnnotationProperty annotationProperty) { + return Searcher.annotations(ontology.annotationAssertionAxioms(e), annotationProperty); + } + + /** + * Obtains the annotations on e where the annotation has the specified annotation property. This + * includes the annotations on annotation assertion axioms with matching annotation property. + * + * @param e entity + * @param ontologies The ontologies to examine for annotation axioms + * @param annotationProperty The annotation property + * @return A {@code Stream} of {@code OWLAnnotation} objects that have the specified URI. + */ + public static Stream getAnnotations(OWLAnnotationSubject e, + Stream ontologies, OWLAnnotationProperty annotationProperty) { + return ontologies.flatMap(o -> getAnnotations(e, o, annotationProperty)); + } + + /** + * Obtains the annotations on e where the annotation has the specified annotation property. This + * includes the annotations on annotation assertion axioms with matching annotation property. + * + * @param e entity + * @param ontologies The ontologies to examine for annotation axioms + * @param annotationProperty The annotation property + * @return A {@code Stream} of {@code OWLAnnotation} objects that have the specified URI. + */ + public static Stream getAnnotations(OWLEntity e, Stream ontologies, + OWLAnnotationProperty annotationProperty) { + return ontologies.flatMap(o -> getAnnotations(e, o, annotationProperty)); + } + + /** + * @param e entity + * @param ontology the ontology to use + * @return the annotation assertion axioms about e in the provided ontology + */ + public static Stream getAnnotationAssertionAxioms(OWLEntity e, + OWLOntology ontology) { + return getAnnotationAssertionAxioms(e.getIRI(), ontology); + } + + /** + * @param e entity + * @param ontology the ontology to use + * @return the annotation assertion axioms about e in the provided ontology + */ + public static Stream getAnnotationAssertionAxioms( + OWLAnnotationSubject e, OWLOntology ontology) { + return ontology.annotationAssertionAxioms(e); + } + + /** + * Gets the properties which are asserted to be sub-properties of e in the specified ontology. + * + * @param e entity + * @param ontology The ontology to be examined for SubProperty axioms. + * @return A {@code Stream} of properties such that for each property {@code p} the {@code ontology} + * contains an {@code SubPropertyOf(p, e)} axiom. + */ + public static Stream getSubProperties( + OWLObjectPropertyExpression e, OWLOntology ontology) { + return Searcher.sub(ontology.axioms(subObjectPropertyWithSuper, e, EXCLUDED)); + } + + /** + * Gets the properties which are asserted to be sub-properties of e in the specified ontology. + * + * @param e entity + * @param ontology The ontology to be examined for SubProperty axioms. + * @return A {@code Stream} of properties such that for each property {@code p} the {@code ontology} + * contains an {@code SubPropertyOf(p, e)} axiom. + */ + public static Stream getSubProperties(OWLDataProperty e, + OWLOntology ontology) { + return Searcher.sub(ontology.axioms(subDataPropertyWithSuper, e, EXCLUDED)); + } + + /** + * Gets the properties which are asserted to be sub-properties of e in the specified ontology. + * + * @param e entity + * @param ontology The ontology to be examined for SubProperty axioms. + * @return A {@code Stream} of properties such that for each property {@code p} the {@code ontology} + * contains an {@code SubPropertyOf(p, e)} axiom. + */ + public static Stream getSubProperties(OWLAnnotationProperty e, + OWLOntology ontology) { + return Searcher.sub(ontology.axioms(subAnnotationWithSuper, e, EXCLUDED)); + } + + /** + * Gets the properties which are asserted to be sub-properties of e in the specified ontologies. + * + * @param e entity + * @param ontologies The ontologies to be examined for SubProperty axioms. + * @return A {@code Stream} of properties such that for each property {@code p} one of the ontologies in + * {@code ontologies} contains an {@code SubPropertyOf(p, e)} axiom. + */ + public static Stream getSubProperties( + OWLObjectPropertyExpression e, Stream ontologies) { + return ontologies.flatMap(o -> getSubProperties(e, o)); + } + + /** + * Gets the properties which are asserted to be sub-properties of e in the specified ontologies. + * + * @param e entity + * @param ontologies The ontologies to be examined for SubProperty axioms. + * @return A {@code Stream} of properties such that for each property {@code p} one of the ontologies in + * {@code ontologies} contains an {@code SubPropertyOf(p, e)} axiom. + */ + public static Stream getSubProperties(OWLDataProperty e, + Stream ontologies) { + return ontologies.flatMap(o -> getSubProperties(e, o)); + } + + /** + * Gets the properties which are asserted to be sub-properties of e in the specified ontologies. + * + * @param e entity + * @param ontologies The ontologies to be examined for SubProperty axioms. + * @return A {@code Stream} of properties such that for each property {@code p} one of the ontologies in + * {@code ontologies} contains an {@code SubPropertyOf(p, e)} axiom. + */ + public static Stream getSubProperties(OWLAnnotationProperty e, + Stream ontologies) { + return ontologies.flatMap(o -> getSubProperties(e, o)); + } + + /** + * Gets the object property expressions (entities or inverses) which are asserted to be + * super-properties of e in the specified ontology. + * + * @param e object property expression + * @param ontology The ontology to be examined for SubProperty axioms. + * @return A {@code Stream} of properties such that for each property {@code p} {@code ontology} + * contains an {@code SubPropertyOf(p, e)} axiom. + */ + public static Stream getSuperProperties( + OWLObjectPropertyExpression e, OWLOntology ontology) { + return Searcher.sup(ontology.axioms(subObjectPropertyWithSub, e, EXCLUDED)); + } + + /** + * Gets the data properties which are asserted to be super-properties of e in the specified + * ontology. + * + * @param e data property + * @param ontology The ontology to be examined for SubProperty axioms. + * @return A {@code Stream} of properties such that for each property {@code p} {@code ontology} + * contains an {@code SubPropertyOf(p, e)} axiom. + */ + public static Stream getSuperProperties(OWLDataProperty e, + OWLOntology ontology) { + return Searcher.sup(ontology.axioms(subDataPropertyWithSub, e, EXCLUDED)); + } + + /** + * Gets the annotation properties which are asserted to be super-properties of e in the + * specified ontology. + * + * @param e annotation property + * @param ontology The ontology to be examined for SubProperty axioms. + * @return A {@code Stream} of properties such that for each property {@code p} {@code ontology} + * contains an {@code SubPropertyOf(p, e)} axiom. + */ + public static Stream getSuperProperties(OWLAnnotationProperty e, + OWLOntology ontology) { + return Searcher.sup(ontology.axioms(subAnnotationWithSub, e, EXCLUDED)); + } + + /** + * Gets the properties which are asserted to be super-properties of e in the specified ontologies. + * + * @param e entity + * @param ontologies The ontologies to be examined for SubPropertyOf axioms. + * @return A {@code Stream} of properties such that for each property {@code p} one of the ontologies in + * {@code ontologies} contains an {@code SubPropertyOf(p, e)} axiom. + */ + public static Stream getSuperProperties( + OWLObjectPropertyExpression e, Stream ontologies) { + return ontologies.flatMap(o -> getSuperProperties(e, o)); + } + + /** + * Gets the properties which are asserted to be super-properties of e in the specified ontologies. + * + * @param e entity + * @param ontologies The ontologies to be examined for SubPropertyOf axioms. + * @return A {@code Stream} of properties such that for each property {@code p} one of the ontologies in + * {@code ontologies} contains an {@code SubPropertyOf(p, e)} axiom. + */ + public static Stream getSuperProperties(OWLDataProperty e, + Stream ontologies) { + return ontologies.flatMap(o -> getSuperProperties(e, o)); + } + + /** + * Gets the properties which are asserted to be super-properties of e in the specified ontologies. + * + * @param e entity + * @param ontologies The ontologies to be examined for SubPropertyOf axioms. + * @return A {@code Stream} of properties such that for each property {@code p} one of the ontologies in + * {@code ontologies} contains an {@code SubPropertyOf(p, e)} axiom. + */ + public static Stream getSuperProperties(OWLAnnotationProperty e, + Stream ontologies) { + return ontologies.flatMap(o -> getSuperProperties(e, o)); + } + + /** + * Gets the classes which have been asserted to be superclasses of e in the specified + * ontology. + * + * @param e entity + * @param ontology The ontology to be examined + * @return A {@code Stream} of {@code OWLClassExpression}s that represent the superclasses of e, which + * have been asserted in the specified ontology. + */ + public static Stream getSuperClasses(OWLClass e, OWLOntology ontology) { + return Searcher.sup(ontology.subClassAxiomsForSubClass(e)); + } + + /** + * Gets the classes which have been asserted to be superclasses of e in the specified + * ontologies. + * + * @param e entity + * @param ontologies The ontologies to be examined. + * @return A {@code Stream} of {@code OWLClassExpressions}s that represent the super classes of e + */ + public static Stream getSuperClasses(OWLClass e, + Stream ontologies) { + return ontologies.flatMap(o -> getSuperClasses(e, o)); + } + + /** + * Gets the classes which have been asserted to be subclasses of e in the specified + * ontology. + * + * @param e entity + * @param ontology The ontology which should be examined for subclass axioms. + * @return A {@code Stream} of {@code OWLClassExpression}s that represent the asserted subclasses of e. + */ + public static Stream getSubClasses(OWLClass e, OWLOntology ontology) { + return Searcher.sub(ontology.subClassAxiomsForSuperClass(e)); + } + + /** + * Gets the classes which have been asserted to be subclasses of e in the specified + * ontologies. + * + * @param e entity + * @param ontologies The ontologies which should be examined for subclass axioms. + * @return A {@code Stream} of {@code OWLClassExpression}s that represent the asserted subclasses of e. + */ + public static Stream getSubClasses(OWLClass e, + Stream ontologies) { + return ontologies.flatMap(o -> getSubClasses(e, o)); + } + + /** + * Gets the classes which have been asserted to be equivalent with e by axioms in the specified + * ontology. + * + * @param e entity + * @param ontology The ontology to be examined for axioms + * @return A {@code Stream} of {@code OWLClassExpression}s that represent the equivalent classes of e, + * that have been asserted in the specified ontology. + */ + public static Stream getEquivalentClasses(OWLClass e, + OWLOntology ontology) { + return Searcher.equivalent(ontology.equivalentClassesAxioms(e)).filter(c -> !c.equals(e)) + .map(c -> (OWLClassExpression) c); + } + + /** + * Gets the classes which have been asserted to be equivalent with e by axioms in the specified + * ontologies. + * + * @param e entity + * @param ontologies The ontologies to be examined for axioms + * @return A {@code Stream} of {@code OWLClassExpression}s that represent the equivalent classes of e, + * that have been asserted in the specified ontologies. + */ + public static Stream getEquivalentClasses(OWLClass e, + Stream ontologies) { + return ontologies.flatMap(o -> getEquivalentClasses(e, o)); + } + + /** + * Gets the classes which have been asserted to be disjoint with e by axioms in the specified + * ontology. + * + * @param e entity + * @param ontology The ontology to search for disjoint class axioms + * @return A {@code Stream} of {@code OWLClassExpression}s that represent the disjoint classes of e. + */ + public static Stream getDisjointClasses(OWLClass e, OWLOntology ontology) { + return Searcher.different(ontology.disjointClassesAxioms(e)); + } + + /** + * Gets the classes which have been asserted to be disjoint with e by axioms in the specified + * ontologies. + * + * @param e entity + * @param ontologies The ontologies to search for disjoint class axioms + * @return A {@code Stream} of {@code OWLClassExpression}s that represent the disjoint classes of e. + */ + public static Stream getDisjointClasses(OWLClass e, + Stream ontologies) { + return ontologies.flatMap(o -> getDisjointClasses(e, o)); + } + + /** + * Gets the individuals asserted to be different to e in the specified ontology. + * + * @param e individual + * @param ontology The ontology to search for different individuals + * @return A {@code Stream} of different {@code OWLIndividual}s. + */ + public static Stream getDifferentIndividuals(OWLIndividual e, + OWLOntology ontology) { + return Searcher.different(ontology.differentIndividualAxioms(e)); + } + + /** + * Gets the individuals asserted to be different to e in the specified ontologies. + * + * @param e individual + * @param ontologies The ontologies to search for different individuals + * @return A {@code Stream} of different {@code OWLIndividual}s. + */ + public static Stream getDifferentIndividuals(OWLIndividual e, + Stream ontologies) { + return ontologies.flatMap(o -> getDifferentIndividuals(e, o)); + } + + /** + * Gets the individuals asserted to be same as e in the specified ontology. + * + * @param e individual + * @param ontology The ontology to search for same individuals + * @return A {@code Stream} of same {@code OWLIndividual}s. + */ + public static Stream getSameIndividuals(OWLIndividual e, OWLOntology ontology) { + return Searcher.equivalent(ontology.sameIndividualAxioms(e)).filter(c -> !c.equals(e)) + .map(c -> (OWLIndividual) c); + } + + /** + * Gets the individuals asserted to be same as e in the specified ontologies. + * + * @param e individual + * @param ontologies The ontologies to search for same individuals + * @return A {@code Stream} of same {@code OWLIndividual}s. + */ + public static Stream getSameIndividuals(OWLIndividual e, + Stream ontologies) { + return ontologies.flatMap(o -> getSameIndividuals(e, o)); + } + + /** + * Gets the data properties which have been asserted to be equivalent with e by axioms in the + * specified ontology. + * + * @param e entity + * @param ontology The ontology to be examined for axioms + * @return A {@code Stream} of {@code OWLDataPropertyExpression}s that represent the data properties + * equivalent to e, that have been asserted in the specified ontology. + */ + public static Stream getEquivalentProperties(OWLDataProperty e, + OWLOntology ontology) { + return Searcher.equivalent(ontology.equivalentDataPropertiesAxioms(e)) + .filter(c -> !c.equals(e)).map(c -> (OWLDataProperty) c); + } + + /** + * Gets the data properties which have been asserted to be equivalent with e by axioms in the + * specified ontologies. + * + * @param e entity + * @param ontologies The ontologies to be examined for axioms + * @return A {@code Stream} of {@code OWLDataPropertyExpression}s that represent the data properties + * equivalent to e, that have been asserted in the specified ontologies. + */ + public static Stream getEquivalentProperties(OWLDataProperty e, + Stream ontologies) { + return ontologies.flatMap(o -> getEquivalentProperties(e, o)); + } + + /** + * Gets the annotation properties which have been asserted to be equivalent with e by axioms in + * the specified ontology. Note: this method is here to avoid special casing annotation + * properties. They cannot be asserted to be equivalent, so result is always empty. + * + * @param e entity + * @param ontology The ontology to be examined for axioms + * @return A {@code Stream} of {@code OWLAnnotationProperty}s that represent the annotation properties + * equivalent to e, that have been asserted in the specified ontology. + */ + @SuppressWarnings("unused") + public static Stream getEquivalentProperties(OWLAnnotationProperty e, + OWLOntology ontology) { + return Stream.empty(); + } + + /** + * Gets the annotation properties which have been asserted to be equivalent with e by axioms in + * the specified ontologies. Note: this method is here to avoid special casing annotation + * properties. They cannot be asserted to be equivalent, so result is always empty. + * + * @param e entity + * @param ontologies The ontologies to be examined for axioms + * @return A {@code Stream} of {@code OWLAnnotationProperty}s that represent the annotation properties + * equivalent to e, that have been asserted in the specified ontologies. + */ + @SuppressWarnings("unused") + public static Stream getEquivalentProperties(OWLAnnotationProperty e, + Stream ontologies) { + return Stream.empty(); + } + + /** + * Gets the object properties which have been asserted to be equivalent with e by axioms in the + * specified ontology. + * + * @param e entity + * @param ontology The ontology to be examined for axioms + * @return A {@code Stream} of {@code OWLObjectPropertyExpression}s that represent the object properties + * equivalent to e, that have been asserted in the specified ontology. + */ + public static Stream getEquivalentProperties( + OWLObjectPropertyExpression e, OWLOntology ontology) { + return Searcher.equivalent(ontology.equivalentObjectPropertiesAxioms(e)) + .filter(c -> !c.equals(e)).map(c -> (OWLObjectPropertyExpression) c); + } + + /** + * Gets the object properties which have been asserted to be equivalent with e by axioms in the + * specified ontologies. + * + * @param e entity + * @param ontologies The ontologies to be examined for axioms + * @return A {@code Stream} of {@code OWLObjectPropertyExpression}s that represent the object properties + * equivalent to e, that have been asserted in the specified ontologies. + */ + public static Stream getEquivalentProperties( + OWLObjectPropertyExpression e, Stream ontologies) { + return ontologies.flatMap(o -> getEquivalentProperties(e, o)); + } + + /** + * Gets the object properties which have been asserted to be disjoint with e in the specified + * ontology. + * + * @param e entity + * @param ontology The ontology to search for disjoint axioms + * @return A {@code Stream} of {@code OWLObjectPropertyExpression}s that represent the object properties + * disjoint with e. + */ + public static Stream getDisjointProperties( + OWLObjectPropertyExpression e, OWLOntology ontology) { + return Searcher.different(ontology.disjointObjectPropertiesAxioms(e)); + } + + /** + * Gets the object properties which have been asserted to be disjoint with e in the specified + * ontologies. + * + * @param e entity + * @param ontologies The ontologies to search for disjoint axioms + * @return A {@code Stream} of {@code OWLObjectPropertyExpression}s that represent the object properties + * disjoint with e. + */ + public static Stream getDisjointProperties( + OWLObjectPropertyExpression e, Stream ontologies) { + return ontologies.flatMap(o -> getDisjointProperties(e, o)); + } + + /** + * Gets the data properties which have been asserted to be disjoint with e in the specified + * ontology. + * + * @param e entity + * @param ontology The ontology to search for disjoint axioms + * @return A {@code Stream} of {@code OWLDataProperty}s that represent the data properties disjoint with + * e. + */ + public static Stream getDisjointProperties(OWLDataProperty e, + OWLOntology ontology) { + return Searcher.different(ontology.disjointDataPropertiesAxioms(e)); + } + + /** + * Gets the data properties which have been asserted to be disjoint with e in the specified + * ontologies. + * + * @param e entity + * @param ontologies The ontologies to search for disjoint axioms + * @return A {@code Stream} of {@code OWLDataProperty}s that represent the data properties disjoint with + * e. + */ + public static Stream getDisjointProperties(OWLDataProperty e, + Stream ontologies) { + return ontologies.flatMap(o -> getDisjointProperties(e, o)); + } + + /** + * Gets the annotation properties which have been asserted to be disjoint with e in the + * specified ontology. Note: This method is here for backwards compatibility. No disjoint axioms + * for annotation properties. + * + * @param e entity + * @param ontology The ontology to search for disjoint axioms + * @return A {@code Stream} of {@code OWLAnnotationProperty}s that represent the properties disjoint + * with e. + */ + @SuppressWarnings("unused") + public static Stream getDisjointProperties(OWLAnnotationProperty e, + OWLOntology ontology) { + // no annotation property disjoints + return empty(); + } + + /** + * Gets the annotation properties which have been asserted to be disjoint with e in the + * specified ontologies. Note: This method is here for backwards compatibility. No disjoint + * axioms for annotation properties. + * + * @param e entity + * @param ontologies The ontologies to search for disjoint axioms + * @return A {@code Stream} of {@code OWLAnnotationProperty}s that represent the properties disjoint + * with e. + */ + @SuppressWarnings("unused") + public static Stream getDisjointProperties(OWLAnnotationProperty e, + Stream ontologies) { + // no annotation property disjoints + return empty(); + } + + /** + * Gets the individuals that have been asserted to be an instance of e by axioms in the + * specified ontology. + * + * @param e entity + * @param ontology The ontology to be examined for class assertion axioms that assert an + * individual to be an instance of e. + * @return A {@code Stream} of {@code OWLIndividual}s that represent the individual that have been + * asserted to be an instance of e. + */ + public static Stream getIndividuals(OWLClass e, OWLOntology ontology) { + return Searcher.instances(ontology.classAssertionAxioms(e)); + } + + /** + * Gets the individuals that have been asserted to be an instance of e by axioms in the + * specified ontologies. + * + * @param e entity + * @param ontologies The ontologies to be examined for class assertion axioms that assert an + * individual to be an instance of e. + * @return A {@code Stream} of {@code OWLIndividual}s that represent the individual that have been + * asserted to be an instance of e. + */ + public static Stream getIndividuals(OWLClass e, Stream ontologies) { + return ontologies.flatMap(o -> getIndividuals(e, o)); + } + + /** + * Gets the axioms in the specified ontology that contain e in their signature. + * + * @param e entity + * @param ontology The ontology that will be searched for axioms + * @return The axioms in the specified ontology whose signature contains e. + */ + public static Stream getReferencingAxioms(OWLEntity e, OWLOntology ontology) { + return ontology.referencingAxioms(e, EXCLUDED); + } + + /** + * Gets the axioms in the specified ontology and possibly its imports closure that contain e in + * their signature. + * + * @param e entity + * @param ontology The ontology that will be searched for axioms + * @param includeImports If {@code true} then axioms in the imports closure will also be + * returned, if {@code false} then only the axioms in the specified ontology will be + * returned. + * @return The axioms in the specified ontology whose signature contains e. + */ + public static Stream getReferencingAxioms(OWLEntity e, OWLOntology ontology, + Imports includeImports) { + return ontology.referencingAxioms(e, includeImports); + } + + /** + * Gets the asserted domains of e. + * + * @param e entity + * @param ontology The ontology that should be examined for axioms which assert a domain of e + * @return A {@code Stream} of {@code OWLClassExpression}s corresponding to the domains of e (the domain + * of e is essentially the intersection of these class expressions). + */ + public static Stream getDomains(OWLDataProperty e, OWLOntology ontology) { + return Searcher.domain(ontology.dataPropertyDomainAxioms(e)); + } + + /** + * Gets the asserted domains of e by examining the axioms in the specified ontologies. + * + * @param e entity + * @param ontologies The ontologies to be examined. + * @return A {@code Stream} of {@code OWLClassExpression}s that represent the asserted domains of e. + */ + public static Stream getDomains(OWLDataProperty e, + Stream ontologies) { + return ontologies.flatMap(o -> getDomains(e, o)); + } + + /** + * Gets the asserted domains of e. + * + * @param e entity + * @param ontology The ontology that should be examined for axioms which assert a domain of e + * @return A {@code Stream} of {@code OWLClassExpression}s corresponding to the domains of e (the domain + * of e is essentially the intersection of these class expressions). + */ + public static Stream getDomains(OWLObjectPropertyExpression e, + OWLOntology ontology) { + return Searcher.domain(ontology.objectPropertyDomainAxioms(e)); + } + + /** + * Gets the ranges of e that have been asserted in the specified ontology. + * + * @param e entity + * @param ontology The ontology to be searched for axioms which assert a range for e. + * @return A {@code Stream} of ranges for e. + */ + public static Stream getRanges(OWLDataProperty e, OWLOntology ontology) { + return Searcher.range(ontology.dataPropertyRangeAxioms(e)); + } + + /** + * Gets the asserted ranges of e by examining the axioms in the specified ontologies. + * + * @param e entity + * @param ontologies The ontologies to be examined for range axioms. + * @return A {@code Stream} of ranges for e, which have been asserted by axioms in the specified + * ontologies. + */ + public static Stream getRanges(OWLDataProperty e, + Stream ontologies) { + return ontologies.flatMap(o -> getRanges(e, o)); + } + + /** + * Gets the asserted domains of e by examining the axioms in the specified ontologies. + * + * @param e entity + * @param ontologies The ontologies to be examined. + * @return A {@code Stream} of {@code OWLClassExpression}s that represent the asserted domains of e. + */ + public static Stream getDomains(OWLObjectPropertyExpression e, + Stream ontologies) { + return ontologies.flatMap(o -> getDomains(e, o)); + } + + /** + * Gets the ranges of e that have been asserted in the specified ontology. + * + * @param e entity + * @param ontology The ontology to be searched for axioms which assert a range for e. + * @return A {@code Stream} of ranges for e. + */ + public static Stream getRanges(OWLObjectPropertyExpression e, + OWLOntology ontology) { + return Searcher.range(ontology.objectPropertyRangeAxioms(e)); + } + + /** + * Gets the asserted ranges of e by examining the axioms in the specified ontologies. + * + * @param e entity + * @param ontologies The ontologies to be examined for range axioms. + * @return A {@code Stream} of ranges for e, which have been asserted by axioms in the specified + * ontologies. + */ + public static Stream getRanges(OWLObjectPropertyExpression e, + Stream ontologies) { + return ontologies.flatMap(o -> getRanges(e, o)); + } + + /** + * Gets the asserted domains of e. + * + * @param e entity + * @param ontology The ontology that should be examined for axioms which assert a domain of e + * @return A {@code Stream} of {@code IRI}s corresponding to the domains of e (the domain of e is + * essentially the intersection of these IRIs). + */ + public static Stream getDomains(OWLAnnotationProperty e, OWLOntology ontology) { + return Searcher.domain(ontology.annotationPropertyDomainAxioms(e)); + } + + /** + * Gets the asserted domains of e by examining the axioms in the specified ontologies. + * + * @param e entity + * @param ontologies The ontologies to be examined. + * @return A {@code Stream} of {@code IRI}s that represent the asserted domains of e. + */ + public static Stream getDomains(OWLAnnotationProperty e, Stream ontologies) { + return ontologies.flatMap(o -> getDomains(e, o)); + } + + /** + * Gets the ranges of e that have been asserted in the specified ontology. + * + * @param e entity + * @param ontology The ontology to be searched for axioms which assert a range for e. + * @return A {@code Stream} of ranges for e. + */ + public static Stream getRanges(OWLAnnotationProperty e, OWLOntology ontology) { + return Searcher.range(ontology.annotationPropertyRangeAxioms(e)); + } + + /** + * Gets the asserted ranges of e by examining the axioms in the specified ontologies. + * + * @param e entity + * @param ontologies The ontologies to be examined for range axioms. + * @return A {@code Stream} of ranges for e, which have been asserted by axioms in the specified + * ontologies. + */ + public static Stream getRanges(OWLAnnotationProperty e, Stream ontologies) { + return ontologies.flatMap(o -> getRanges(e, o)); + } + + /** + * Checks if e is declared transitive in the ontology. + * + * @param ontology ontology + * @param e property + * @return true for transitive properties + */ + public static boolean isTransitive(OWLObjectPropertyExpression e, OWLOntology ontology) { + return ontology.transitiveObjectPropertyAxioms(e).findAny().isPresent(); + } + + /** + * Checks if e is declared transitive in a collection of ontologies. + * + * @param ontologies ontologies + * @param e property + * @return true for transitive properties + */ + public static boolean isTransitive(OWLObjectPropertyExpression e, + Stream ontologies) { + return ontologies.anyMatch(o -> isTransitive(e, o)); + } + + /** + * Checks if e is declared symmetric in the ontology. + * + * @param ontology ontology + * @param e property + * @return true for symmetric properties + */ + public static boolean isSymmetric(OWLObjectPropertyExpression e, OWLOntology ontology) { + return ontology.symmetricObjectPropertyAxioms(e).findAny().isPresent(); + } + + /** + * Checks if e is declared symmetric in a collection of ontologies. + * + * @param ontologies ontologies + * @param e property + * @return true for symmetric properties + */ + public static boolean isSymmetric(OWLObjectPropertyExpression e, + Stream ontologies) { + return ontologies.anyMatch(o -> isSymmetric(e, o)); + } + + /** + * Checks if e is declared asymmetric in the ontology. + * + * @param ontology ontology + * @param e property + * @return true for asymmetric properties + */ + public static boolean isAsymmetric(OWLObjectPropertyExpression e, OWLOntology ontology) { + return ontology.asymmetricObjectPropertyAxioms(e).findAny().isPresent(); + } + + /** + * Checks if e is declared asymmetric in a collection of ontologies. + * + * @param ontologies ontologies + * @param e property + * @return true for asymmetric properties + */ + public static boolean isAsymmetric(OWLObjectPropertyExpression e, + Stream ontologies) { + return ontologies.anyMatch(o -> isAsymmetric(e, o)); + } + + /** + * Checks if e is declared reflexive in the ontology. + * + * @param ontology ontology + * @param e property + * @return true for reflexive properties + */ + public static boolean isReflexive(OWLObjectPropertyExpression e, OWLOntology ontology) { + return ontology.reflexiveObjectPropertyAxioms(e).findAny().isPresent(); + } + + /** + * Checks if e is declared reflexive in a collection of ontologies. + * + * @param ontologies ontologies + * @param e property + * @return true for reflexive properties + */ + public static boolean isReflexive(OWLObjectPropertyExpression e, + Stream ontologies) { + return ontologies.anyMatch(o -> isReflexive(e, o)); + } + + /** + * Checks if e is declared irreflexive in the ontology. + * + * @param ontology ontology + * @param e property + * @return true for irreflexive properties + */ + public static boolean isIrreflexive(OWLObjectPropertyExpression e, OWLOntology ontology) { + return ontology.irreflexiveObjectPropertyAxioms(e).findAny().isPresent(); + } + + /** + * Checks if e is declared irreflexive in a collection of ontologies. + * + * @param ontologies ontologies + * @param e property + * @return true for irreflexive properties + */ + public static boolean isIrreflexive(OWLObjectPropertyExpression e, + Stream ontologies) { + return ontologies.anyMatch(o -> isIrreflexive(e, o)); + } + + /** + * Checks if e is declared inverse functional in the ontology. + * + * @param ontology ontology + * @param e property + * @return true for inverse functional properties + */ + public static boolean isInverseFunctional(OWLObjectPropertyExpression e, OWLOntology ontology) { + return ontology.inverseFunctionalObjectPropertyAxioms(e).findAny().isPresent(); + } + + /** + * Checks if e is declared inverse functional in a collection of ontologies. + * + * @param ontologies ontologies + * @param e property + * @return true for inverse functional properties + */ + public static boolean isInverseFunctional(OWLObjectPropertyExpression e, + Stream ontologies) { + return ontologies.anyMatch(o -> isInverseFunctional(e, o)); + } + + /** + * Checks if e is declared functional in the ontology. + * + * @param ontology ontology + * @param e property + * @return true for functional object properties + */ + public static boolean isFunctional(OWLObjectPropertyExpression e, OWLOntology ontology) { + return ontology.functionalObjectPropertyAxioms(e).findAny().isPresent(); + } + + /** + * Checks if e is declared functional in a collection of ontologies. + * + * @param ontologies ontologies + * @param e property + * @return true for functional object properties + */ + public static boolean isFunctional(OWLObjectPropertyExpression e, + Stream ontologies) { + return ontologies.anyMatch(o -> isFunctional(e, o)); + } + + /** + * Checks if e is declared functional in the ontology. + * + * @param ontology ontology + * @param e property + * @return true for functional data properties + */ + public static boolean isFunctional(OWLDataProperty e, OWLOntology ontology) { + return ontology.functionalDataPropertyAxioms(e).findAny().isPresent(); + } + + /** + * Checks if e is declared functional in a collection of ontologies. + * + * @param ontologies ontologies + * @param e property + * @return true for functional data properties + */ + public static boolean isFunctional(OWLDataProperty e, Stream ontologies) { + return ontologies.anyMatch(o -> isFunctional(e, o)); + } + + /** + * Checks if c is defined (is included in equivalent axioms) in the ontology. + * + * @param ontology ontology + * @param c class + * @return true for defined classes + */ + public static boolean isDefined(OWLClass c, OWLOntology ontology) { + return ontology.equivalentClassesAxioms(c).findAny().isPresent(); + } + + /** + * Checks if c is defined (is included in equivalent axioms) in a collection of ontologies. + * + * @param ontologies ontologies + * @param c class + * @return true for defined classes + */ + public static boolean isDefined(OWLClass c, Stream ontologies) { + return ontologies.anyMatch(o -> isDefined(c, o)); + } + + /** + * Checks if the ontology contains axiom a, with or without imports closure. + * + * @param ontology ontology + * @param a axiom + * @param imports true if imports closure is included + * @return true if a is contained + */ + public static boolean containsAxiom(OWLAxiom a, OWLOntology ontology, Imports imports) { + return ontology.containsAxiom(a, imports, CONSIDER_AXIOM_ANNOTATIONS); + } + + /** + * Checks if any of the ontologies contains axiom a, with or without imports closure. + * + * @param ontologies ontologies + * @param a axiom + * @param imports true if imports closure is included + * @return true if a is contained + */ + public static boolean containsAxiom(OWLAxiom a, Stream ontologies, + Imports imports) { + return ontologies.anyMatch(o -> containsAxiom(a, o, imports)); + } + + /** + * Checks if the ontology contains axiom a, with or without imports closure, ignoring annotations. + * + * @param ontology ontology + * @param a axiom + * @param imports true if imports closure is included + * @return true if a is contained + */ + public static boolean containsAxiomIgnoreAnnotations(OWLAxiom a, OWLOntology ontology, + boolean imports) { + return ontology.containsAxiom(a, fromBoolean(imports), IGNORE_AXIOM_ANNOTATIONS); + } + + /** + * Checks if any of the ontologies contains axiom a, with or without imports closure. + * + * @param ontologies ontologies + * @param a axiom + * @param imports true if imports closure is included + * @return true if a is contained + */ + public static boolean containsAxiomIgnoreAnnotations(OWLAxiom a, Stream ontologies, + boolean imports) { + return ontologies.anyMatch(o -> containsAxiomIgnoreAnnotations(a, o, imports)); + } + + /** + * Get matching axioms for a, ignoring annotations. + * + * @param ontology ontology + * @param a axiom + * @param imports true if imports closure is included + * @return matching axioms + */ + public static Collection getAxiomsIgnoreAnnotations(OWLAxiom a, OWLOntology ontology, + Imports imports) { + return asList(ontology.axiomsIgnoreAnnotations(a, imports)); + } + + /** + * Get matching axioms for a, ignoring annotations. + * + * @param ontology ontology + * @param a axiom + * @param imports true if imports closure is included + * @return matching axioms + */ + public static Stream axiomsIgnoreAnnotations(OWLAxiom a, OWLOntology ontology, + Imports imports) { + return ontology.axiomsIgnoreAnnotations(a, imports); + } + + /** + * @param i individual + * @param p property to search + * @param ontology ontology to search + * @return literal values + */ + public static Stream getDataPropertyValues(OWLIndividual i, + OWLDataPropertyExpression p, OWLOntology ontology) { + return Searcher.values(ontology.dataPropertyAssertionAxioms(i), p); + } + + /** + * @param i individual + * @param p property to search + * @param ontologies ontologies to search + * @return literal values + */ + public static Stream getDataPropertyValues(OWLIndividual i, + OWLDataPropertyExpression p, Stream ontologies) { + return ontologies.flatMap(o -> getDataPropertyValues(i, p, o)); + } + + /** + * @param i individual + * @param p property to search + * @param ontology ontology to search + * @return property values + */ + public static Stream getObjectPropertyValues(OWLIndividual i, + OWLObjectPropertyExpression p, OWLOntology ontology) { + return Searcher.values(ontology.objectPropertyAssertionAxioms(i), p); + } + + /** + * @param i individual + * @param p property to search + * @param ontologies ontologies to search + * @return property values + */ + public static Stream getObjectPropertyValues(OWLIndividual i, + OWLObjectPropertyExpression p, Stream ontologies) { + return ontologies.flatMap(o -> getObjectPropertyValues(i, p, o)); + } + + /** + * @param i individual + * @param p property to search + * @param ontology ontology to search + * @return property values + */ + public static Stream getNegativeDataPropertyValues(OWLIndividual i, + OWLDataPropertyExpression p, OWLOntology ontology) { + return Searcher.negValues(ontology.negativeDataPropertyAssertionAxioms(i), p); + } + + /** + * @param i individual + * @param p property to search + * @param ontologies ontologies to search + * @return property values + */ + public static Stream getNegativeDataPropertyValues(OWLIndividual i, + OWLDataPropertyExpression p, Stream ontologies) { + return ontologies.flatMap(o -> getNegativeDataPropertyValues(i, p, o)); + } + + /** + * @param i individual + * @param p property to search + * @param ontology ontology to search + * @return property values + */ + public static Stream getNegativeObjectPropertyValues(OWLIndividual i, + OWLObjectPropertyExpression p, OWLOntology ontology) { + return Searcher.negValues(ontology.negativeObjectPropertyAssertionAxioms(i), p); + } + + /** + * @param i individual + * @param p property to search + * @param ontologies ontologies to search + * @return property values + */ + public static Stream getNegativeObjectPropertyValues(OWLIndividual i, + OWLObjectPropertyExpression p, Stream ontologies) { + return ontologies.flatMap(o -> getNegativeObjectPropertyValues(i, p, o)); + } + + /** + * @param i individual + * @param p property to search + * @param ontology ontology to search + * @return true if values are present + */ + public static boolean hasDataPropertyValues(OWLIndividual i, OWLDataPropertyExpression p, + OWLOntology ontology) { + return Searcher.values(ontology.dataPropertyAssertionAxioms(i), p).findAny().isPresent(); + } + + /** + * @param i individual + * @param p property to search + * @param ontologies ontologies to search + * @return true if value present + */ + public static boolean hasDataPropertyValues(OWLIndividual i, OWLDataPropertyExpression p, + Stream ontologies) { + return ontologies.anyMatch(o -> hasDataPropertyValues(i, p, o)); + } + + /** + * @param i individual + * @param p property to search + * @param ontology ontology to search + * @return true if value present + */ + public static boolean hasObjectPropertyValues(OWLIndividual i, OWLObjectPropertyExpression p, + OWLOntology ontology) { + return Searcher.values(ontology.objectPropertyAssertionAxioms(i), p).findAny().isPresent(); + } + + /** + * @param i individual + * @param p property to search + * @param ontologies ontologies to search + * @return true if value present + */ + public static boolean hasObjectPropertyValues(OWLIndividual i, OWLObjectPropertyExpression p, + Stream ontologies) { + return ontologies.anyMatch(o -> hasObjectPropertyValues(i, p, o)); + } + + /** + * @param i individual + * @param p property to search + * @param ontology ontology to search + * @return true if value present + */ + public static boolean hasNegativeDataPropertyValues(OWLIndividual i, + OWLDataPropertyExpression p, OWLOntology ontology) { + return Searcher.negValues(ontology.negativeDataPropertyAssertionAxioms(i), p).findAny() + .isPresent(); + } + + /** + * @param i individual + * @param p property to search + * @param ontologies ontologies to search + * @return true if value present + */ + public static boolean hasNegativeDataPropertyValues(OWLIndividual i, + OWLDataPropertyExpression p, Stream ontologies) { + return ontologies.anyMatch(o -> hasNegativeDataPropertyValues(i, p, o)); + } + + /** + * @param i individual + * @param p property to search + * @param ontology ontology to search + * @return true if value present + */ + public static boolean hasNegativeObjectPropertyValues(OWLIndividual i, + OWLObjectPropertyExpression p, OWLOntology ontology) { + return Searcher.negValues(ontology.negativeObjectPropertyAssertionAxioms(i), p).findAny() + .isPresent(); + } + + /** + * @param i individual + * @param p property to search + * @param ontologies ontologies to search + * @return true if value present + */ + public static boolean hasNegativeObjectPropertyValues(OWLIndividual i, + OWLObjectPropertyExpression p, Stream ontologies) { + return ontologies.anyMatch(o -> hasNegativeObjectPropertyValues(i, p, o)); + } + + /** + * @param i individual + * @param p property to search + * @param lit literal to search + * @param ontology ontology to search + * @return true if value present + */ + public static boolean hasDataPropertyValue(OWLIndividual i, OWLDataPropertyExpression p, + OWLLiteral lit, OWLOntology ontology) { + return contains(Searcher.values(ontology.dataPropertyAssertionAxioms(i), p), lit); + } + + /** + * @param i individual + * @param p property to search + * @param lit literal to search + * @param ontologies ontologies to search + * @return true if value present + */ + public static boolean hasDataPropertyValue(OWLIndividual i, OWLDataPropertyExpression p, + OWLLiteral lit, Stream ontologies) { + return ontologies.anyMatch(o -> hasDataPropertyValue(i, p, lit, o)); + } + + /** + * @param i individual + * @param p property to search + * @param j individual to search + * @param ontology ontology to search + * @return true if value present + */ + public static boolean hasObjectPropertyValue(OWLIndividual i, OWLObjectPropertyExpression p, + OWLIndividual j, OWLOntology ontology) { + return contains(Searcher.values(ontology.objectPropertyAssertionAxioms(i), p), j); + } + + /** + * @param i individual + * @param p property to search + * @param j individual to search + * @param ontologies ontologies to search + * @return true if value present + */ + public static boolean hasObjectPropertyValue(OWLIndividual i, OWLObjectPropertyExpression p, + OWLIndividual j, Stream ontologies) { + return ontologies.anyMatch(o -> hasObjectPropertyValue(i, p, j, o)); + } + + /** + * @param i individual + * @param p property to search + * @param lit literal to search + * @param ontology ontology to search + * @return true if value present + */ + public static boolean hasNegativeDataPropertyValue(OWLIndividual i, OWLDataPropertyExpression p, + OWLLiteral lit, OWLOntology ontology) { + return contains(Searcher.negValues(ontology.negativeDataPropertyAssertionAxioms(i), p), + lit); + } + + /** + * @param i individual + * @param p property to search + * @param lit literal to search + * @param ontologies ontologies to search + * @return true if value present + */ + public static boolean hasNegativeDataPropertyValue(OWLIndividual i, OWLDataPropertyExpression p, + OWLLiteral lit, Stream ontologies) { + return ontologies.anyMatch(o -> hasNegativeDataPropertyValue(i, p, lit, o)); + } + + /** + * @param i individual + * @param p property to search + * @param j individual to search + * @param ontology ontology to search + * @return true if value present + */ + public static boolean hasNegativeObjectPropertyValue(OWLIndividual i, + OWLObjectPropertyExpression p, OWLIndividual j, OWLOntology ontology) { + return contains(Searcher.negValues(ontology.negativeObjectPropertyAssertionAxioms(i), p), + j); + } + + /** + * @param i individual + * @param p property to search + * @param j individual to search + * @param ontologies ontologies to search + * @return true if value present + */ + public static boolean hasNegativeObjectPropertyValue(OWLIndividual i, + OWLObjectPropertyExpression p, OWLIndividual j, Stream ontologies) { + return ontologies.anyMatch(o -> hasNegativeObjectPropertyValue(i, p, j, o)); + } + + /** + * @param i individual + * @param ontology ontology to search + * @return property values + */ + public static Multimap getDataPropertyValues( + OWLIndividual i, OWLOntology ontology) { + Multimap map = LinkedListMultimap.create(); + ontology.dataPropertyAssertionAxioms(i) + .forEach(ax -> map.put(ax.getProperty(), ax.getObject())); + return map; + } + + /** + * @param i individual + * @param ontologies ontologies to search + * @return literal values + */ + public static Multimap getDataPropertyValues( + OWLIndividual i, Stream ontologies) { + Multimap map = LinkedListMultimap.create(); + ontologies.forEach(o -> map.putAll(getDataPropertyValues(i, o))); + return map; + } + + /** + * @param i individual + * @param ontology ontology to search + * @return property values + */ + public static Multimap getObjectPropertyValues( + OWLIndividual i, OWLOntology ontology) { + Multimap map = LinkedListMultimap.create(); + ontology.objectPropertyAssertionAxioms(i) + .forEach(ax -> map.put(ax.getProperty(), ax.getObject())); + return map; + } + + /** + * @param i individual + * @param ontologies ontologies to search + * @return property values + */ + public static Multimap getObjectPropertyValues( + OWLIndividual i, Stream ontologies) { + Multimap map = LinkedListMultimap.create(); + ontologies.forEach(o -> map.putAll(getObjectPropertyValues(i, o))); + return map; + } + + /** + * @param i individual + * @param ontology ontology to search + * @return property values + */ + public static Multimap getNegativeObjectPropertyValues( + OWLIndividual i, OWLOntology ontology) { + Multimap map = LinkedListMultimap.create(); + ontology.negativeObjectPropertyAssertionAxioms(i) + .forEach(ax -> map.put(ax.getProperty(), ax.getObject())); + return map; + } + + /** + * @param i individual + * @param ontology ontology to search + * @return property values + */ + public static Multimap getNegativeDataPropertyValues( + OWLIndividual i, OWLOntology ontology) { + Multimap map = LinkedListMultimap.create(); + ontology.negativeDataPropertyAssertionAxioms(i) + .forEach(ax -> map.put(ax.getProperty(), ax.getObject())); + return map; + } + + /** + * @param i individual + * @param ontologies ontologies to search + * @return property values + */ + public static Multimap getNegativeObjectPropertyValues( + OWLIndividual i, Stream ontologies) { + Multimap map = LinkedListMultimap.create(); + ontologies.forEach(o -> map.putAll(getNegativeObjectPropertyValues(i, o))); + return map; + } + + /** + * @param i individual + * @param ontologies ontologies to search + * @return property values + */ + public static Multimap getNegativeDataPropertyValues( + OWLIndividual i, Stream ontologies) { + Multimap map = LinkedListMultimap.create(); + ontologies.forEach(o -> map.putAll(getNegativeDataPropertyValues(i, o))); + return map; + } + + /** + * @param e object property + * @param ontology ontology to search + * @return property inverses + */ + public static Stream getInverses(OWLObjectPropertyExpression e, + OWLOntology ontology) { + return Searcher.inverse(ontology.inverseObjectPropertyAxioms(e), e); + } + + /** + * @param e object property + * @param ontologies ontologies to search + * @return property inverses + */ + public static Stream getInverses(OWLObjectPropertyExpression e, + Stream ontologies) { + return ontologies.flatMap(o -> getInverses(e, o)); + } + + /** + * @param e class + * @param ontology ontology to search + * @return instances of class + */ + public static Stream getInstances(OWLClassExpression e, OWLOntology ontology) { + return Searcher.instances(ontology.classAssertionAxioms(e)); + } + + /** + * @param e class + * @param ontologies ontologies to search + * @return instances of class + */ + public static Stream getInstances(OWLClassExpression e, + Stream ontologies) { + return ontologies.flatMap(o -> getInstances(e, o)); + } + + /** + * @param e individual + * @param ontology ontology to search + * @return types for individual + */ + public static Stream getTypes(OWLIndividual e, OWLOntology ontology) { + return Searcher.types(ontology.classAssertionAxioms(e)); + } + + /** + * @param e individual + * @param ontologies ontologies to search + * @return types for individual + */ + public static Stream getTypes(OWLIndividual e, + Stream ontologies) { + return ontologies.flatMap(o -> getTypes(e, o)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/search/EquivalentVisitor.java b/api/src/main/java/org/semanticweb/owlapi/search/EquivalentVisitor.java new file mode 100644 index 0000000000..ab05199314 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/search/EquivalentVisitor.java @@ -0,0 +1,94 @@ +package org.semanticweb.owlapi.search; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.empty; + +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.OWLAxiomVisitorEx; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; + +@SuppressWarnings("unchecked") +class EquivalentVisitor implements OWLAxiomVisitorEx> { + + private final boolean equiv; + + EquivalentVisitor(boolean equiv) { + this.equiv = equiv; + } + + @Override + public Stream doDefault(Object o) { + return empty(); + } + + @Override + public Stream visit(OWLEquivalentClassesAxiom axiom) { + if (equiv) { + return (Stream) axiom.classExpressions(); + } + return doDefault(axiom); + } + + @Override + public Stream visit(OWLEquivalentDataPropertiesAxiom axiom) { + if (equiv) { + return (Stream) axiom.properties(); + } + return doDefault(axiom); + } + + @Override + public Stream visit(OWLEquivalentObjectPropertiesAxiom axiom) { + if (equiv) { + return (Stream) axiom.properties(); + } + return doDefault(axiom); + } + + @Override + public Stream visit(OWLDifferentIndividualsAxiom axiom) { + if (!equiv) { + return (Stream) axiom.individuals(); + } + return doDefault(axiom); + } + + @Override + public Stream visit(OWLSameIndividualAxiom axiom) { + if (equiv) { + return (Stream) axiom.individuals(); + } + return doDefault(axiom); + } + + @Override + public Stream visit(OWLDisjointClassesAxiom axiom) { + if (!equiv) { + return (Stream) axiom.classExpressions(); + } + return doDefault(axiom); + } + + @Override + public Stream visit(OWLDisjointDataPropertiesAxiom axiom) { + if (!equiv) { + return (Stream) axiom.properties(); + } + return doDefault(axiom); + } + + @Override + public Stream visit(OWLDisjointObjectPropertiesAxiom axiom) { + if (!equiv) { + return (Stream) axiom.properties(); + } + return doDefault(axiom); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/search/Filters.java b/api/src/main/java/org/semanticweb/owlapi/search/Filters.java new file mode 100644 index 0000000000..02fa471d11 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/search/Filters.java @@ -0,0 +1,199 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.search; + +import java.util.Collection; + +import javax.annotation.Nonnull; + +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; +import org.semanticweb.owlapi.util.CollectionFactory; +import org.semanticweb.owlapi.util.OWLAxiomSearchFilter; + +/** + * Collection of filters for use in searching through ontology axioms. + * + * @author ignazio + * @since 4.0.0 + */ +public class Filters { + + /** + * filter returning subannotation axioms where the super property matches the input key. + */ + public static final OWLAxiomSearchFilter subAnnotationWithSuper = new AxiomFilter<>( + AxiomType.SUB_ANNOTATION_PROPERTY_OF, OWLSubAnnotationPropertyOfAxiom::getSuperProperty); + /** + * filter returning subannotation axioms where the sub property matches the input key. + */ + public static final OWLAxiomSearchFilter subAnnotationWithSub = new AxiomFilter<>( + AxiomType.SUB_ANNOTATION_PROPERTY_OF, OWLSubAnnotationPropertyOfAxiom::getSubProperty); + /** + * filter returning subclass axioms where the super class matches the input key. + */ + public static final OWLAxiomSearchFilter subClassWithSuper = + new AxiomFilter<>(AxiomType.SUBCLASS_OF, OWLSubClassOfAxiom::getSuperClass); + /** + * filter returning subclass axioms where the sub class matches the input key. + */ + public static final OWLAxiomSearchFilter subClassWithSub = + new AxiomFilter<>(AxiomType.SUBCLASS_OF, OWLSubClassOfAxiom::getSubClass); + /** + * filter returning sub object property axioms where the super property matches the input key. + */ + public static final OWLAxiomSearchFilter subObjectPropertyWithSuper = new AxiomFilter<>( + AxiomType.SUB_OBJECT_PROPERTY, OWLSubObjectPropertyOfAxiom::getSuperProperty); + /** + * filter returning sub object property axioms where the sub property matches the input key. + */ + public static final OWLAxiomSearchFilter subObjectPropertyWithSub = new AxiomFilter<>( + AxiomType.SUB_OBJECT_PROPERTY, OWLSubObjectPropertyOfAxiom::getSubProperty); + /** + * filter returning sub data property axioms where the super property matches the input key. + */ + public static final OWLAxiomSearchFilter subDataPropertyWithSuper = + new AxiomFilter<>(AxiomType.SUB_DATA_PROPERTY, OWLSubDataPropertyOfAxiom::getSuperProperty); + /** + * filter returning sub data property axioms where the sub property matches the input key. + */ + public static final OWLAxiomSearchFilter subDataPropertyWithSub = + new AxiomFilter<>(AxiomType.SUB_DATA_PROPERTY, OWLSubDataPropertyOfAxiom::getSubProperty); + /** + * filter returning datatype definition axioms where the datatype matches the input key. + */ + public static final OWLAxiomSearchFilter datatypeDefFilter = + new AxiomFilter<>(AxiomType.DATATYPE_DEFINITION, OWLDatatypeDefinitionAxiom::getDatatype); + /** + * filter returning annotation property range axioms where the property matches the input key. + */ + public static final OWLAxiomSearchFilter apRangeFilter = new AxiomFilter<>( + AxiomType.ANNOTATION_PROPERTY_RANGE, OWLAnnotationPropertyRangeAxiom::getProperty); + /** + * filter returning annotation property domain axioms where the property matches the input key. + */ + public static final OWLAxiomSearchFilter apDomainFilter = new AxiomFilter<>( + AxiomType.ANNOTATION_PROPERTY_DOMAIN, OWLAnnotationPropertyDomainAxiom::getProperty); + /** + * filter returning annotation assertions where the subject matches the input key. + * + * @deprecated use + * {@link org.semanticweb.owlapi.model.OWLOntology#annotationAssertionAxioms(org.semanticweb.owlapi.model.OWLAnnotationSubject)} + * in place of this filter as it is much faster, thanks to indexing. + */ + @Deprecated + public static final OWLAxiomSearchFilter annotations = + new AxiomFilter<>(AxiomType.ANNOTATION_ASSERTION, OWLAnnotationAssertionAxiom::getSubject); + /** + * filter returning all axioms included in TBox or RBox. No assertions, non logical axioms or + * SWRL rules. + */ + public static final OWLAxiomSearchFilter axiomsFromTBoxAndRBox = + new AxiomFilter(AxiomType.TBoxAndRBoxAxiomTypes, a -> a) { + + @Override + public boolean pass(OWLAxiom axiom, Object key) { + // for this filter, accept all axioms + return true; + } + }; + /** + * filter returning all axioms not in TBox or RBox; therefore, ABox axioms, nonlogical axioms + * and SWRL rules. + */ + public static final OWLAxiomSearchFilter axiomsNotInTBoxOrRBox = + new AxiomFilter(AxiomType.AXIOM_TYPES, a -> a) { + + @Override + public boolean pass(@Nonnull OWLAxiom axiom, Object key) { + // for this filter, only accept the axioms whose types are not in + // tbox or rbox + return !AxiomType.TBoxAndRBoxAxiomTypes.contains(axiom.getAxiomType()); + } + }; + + private Filters() {} + + @FunctionalInterface + private interface Filter { + + Object filter(A axiom); + } + + /** + * @param axiom type + * @author ignazio + */ + public static class AxiomFilter implements OWLAxiomSearchFilter { + + private final Collection> types; + private final Filter filter; + + /** + * @param type axiom type to filter on + * @param f filter lambda + */ + public AxiomFilter(AxiomType type, Filter f) { + types = CollectionFactory.>list(type); + filter = f; + } + + /** + * @param types axiom types to filter on + * @param f filter lambda + */ + public AxiomFilter(Collection> types, Filter f) { + this.types = types; + filter = f; + } + + /** + * @param f filter lambda + * @param types axiom types to filter on + */ + public AxiomFilter(Filter f, AxiomType... types) { + this.types = CollectionFactory.list(types); + filter = f; + } + + @Override + public Iterable> getAxiomTypes() { + return types; + } + + @SuppressWarnings("unchecked") + @Override + public boolean pass(OWLAxiom axiom, Object key) { + return axiomValue((A) axiom).equals(key); + } + + /** + * Override this method to select what part of the axiom should be compared with the input + * key. + * + * @param axiom axiom to check + * @return Object to compare to the input key + */ + protected Object axiomValue(A axiom) { + return filter.filter(axiom); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/search/RangeVisitor.java b/api/src/main/java/org/semanticweb/owlapi/search/RangeVisitor.java new file mode 100644 index 0000000000..f4e5bb9163 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/search/RangeVisitor.java @@ -0,0 +1,26 @@ +package org.semanticweb.owlapi.search; + +import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLAxiomVisitorEx; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; + +@SuppressWarnings("unchecked") +class RangeVisitor implements OWLAxiomVisitorEx { + + @Override + public C visit(OWLAnnotationPropertyRangeAxiom axiom) { + return (C) axiom.getRange(); + } + + @Override + public C visit(OWLDataPropertyRangeAxiom axiom) { + return (C) axiom.getRange(); + } + + @Override + public C visit(OWLObjectPropertyRangeAxiom axiom) { + return (C) axiom.getRange(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/search/Searcher.java b/api/src/main/java/org/semanticweb/owlapi/search/Searcher.java new file mode 100644 index 0000000000..489bd669de --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/search/Searcher.java @@ -0,0 +1,601 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.search; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.empty; + +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.HasObject; +import org.semanticweb.owlapi.model.HasProperty; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationValue; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLPropertyAssertionObject; +import org.semanticweb.owlapi.model.OWLPropertyExpression; + +/** + * A collection of static search utilities. + * + * @author ignazio + */ +public final class Searcher { + + private Searcher() {} + + private static boolean filter(@Nullable OWLPropertyExpression p, HasProperty ax) { + return p == null || ax.getProperty().equals(p); + } + + private static Stream filterValues( + Stream> stream, + @Nullable OWLPropertyExpression p) { + return stream.filter(ax -> filter(p, ax)).map(HasObject::getObject).distinct(); + } + + /** + * Retrieve literals from a collection of assertions. + * + * @param axioms axioms + * @param p optional property to match. Null means all. + * @return literals + */ + public static Stream values(Stream axioms, + @Nullable OWLDataPropertyExpression p) { + return filterValues(axioms, p); + } + + /** + * Retrieve objects from a collection of assertions. + * + * @param axioms axioms + * @param p optional property to match. Null means all. + * @return objects + */ + public static Stream values(Stream axioms, + @Nullable OWLObjectPropertyExpression p) { + return filterValues(axioms, p); + } + + /** + * Retrieve literals from a collection of negative assertions. + * + * @param axioms axioms + * @param p optional property to match. Null means all. + * @return literals + */ + public static Stream negValues(Stream axioms, + @Nullable OWLDataPropertyExpression p) { + return filterValues(axioms, p); + } + + /** + * Retrieve objects from a collection of negative assertions. + * + * @param axioms axioms + * @param p optional property to match. Null means all. + * @return objects + */ + public static Stream negValues( + Stream axioms, + @Nullable OWLObjectPropertyExpression p) { + return filterValues(axioms, p); + } + + /** + * Retrieve classes from class assertions. + * + * @param axioms axioms + * @return classes + */ + public static Stream types(Stream axioms) { + return axioms.map(OWLClassAssertionAxiom::getClassExpression); + } + + /** + * Retrieve individuals from class assertions. + * + * @param axioms axioms + * @return individuals + */ + public static Stream instances(Stream axioms) { + return axioms.map(OWLClassAssertionAxiom::getIndividual); + } + + /** + * Retrieve inverses from a collection of inverse axioms. + * + * @param axioms axioms to check + * @param p property to match; not returned in the set + * @return inverses of p + */ + public static Stream inverse( + Stream axioms, OWLObjectPropertyExpression p) { + return axioms.map(ax -> getInverse(p, ax)); + } + + protected static OWLObjectPropertyExpression getInverse(OWLObjectPropertyExpression p, + OWLInverseObjectPropertiesAxiom ax) { + if (ax.getFirstProperty().equals(p)) { + return ax.getSecondProperty(); + } else { + return ax.getFirstProperty(); + } + } + + /** + * Retrieve annotation values from annotations. + * + * @param annotations annotations + * @return annotation values + */ + public static Stream values(Stream annotations) { + return values(annotations, null); + } + + /** + * Retrieve annotation values from annotations. + * + * @param annotations annotations + * @param p optional annotation property to filter. Null means all. + * @return annotation values + */ + public static Stream values(Stream annotations, + @Nullable OWLAnnotationProperty p) { + return annotations.filter(ax -> filter(p, ax)).map(ax -> ax.getValue()); + } + + /** + * Retrieve annotations from a collection of axioms. For regular axioms, their annotations are + * retrieved; for annotation assertion axioms, their asserted annotation is retrieved as well. + * + * @param axioms axioms + * @return annotations + */ + public static Stream annotations(Stream axioms) { + return annotations(axioms, null); + } + + /** + * Retrieve annotations from a collection of annotation assertion axioms. + * + * @param axioms axioms + * @param p optional annotation property to filter. Null means all. + * @return annotations + */ + public static Stream annotationObjects( + Stream axioms, @Nullable OWLAnnotationProperty p) { + return axioms.flatMap(ax -> annotationObject(ax, p)).distinct(); + } + + /** + * Retrieve the annotation from an annotation assertion axiom. + * + * @param axiom axiom + * @param p optional annotation property to filter. Null means all. + * @return annotations + */ + public static Stream annotationObject(OWLAnnotationAssertionAxiom axiom, + @Nullable OWLAnnotationProperty p) { + if (p == null || axiom.getProperty().equals(p)) { + return Stream.of(axiom.getAnnotation()); + } + return Stream.empty(); + } + + /** + * Retrieve annotations from a collection of annotation assertion axioms. This is limited to the + * annotation object and excludes annotations on the axiom itself. + * + * @param axioms axioms + * @return annotations + */ + public static Stream annotationObjects( + Stream axioms) { + return axioms.map(OWLAnnotationAssertionAxiom::getAnnotation).distinct(); + } + + /** + * Retrieve annotations from a collection of axioms. For regular axioms, their annotations are + * retrieved; for annotation assertion axioms, their asserted annotation is retrieved as well. + * + * @param axioms axioms + * @param p optional annotation property to filter. Null means all. + * @return annotations + */ + public static Stream annotations(Stream axioms, + @Nullable OWLAnnotationProperty p) { + return axioms.flatMap(ax -> annotations(ax, p)).distinct(); + } + + /** + * Retrieve annotations from an axiom. For regular axioms, their annotations are retrieved; for + * annotation assertion axioms, their asserted annotation is retrieved as well. + * + * @param axiom axiom + * @param p optional annotation property to filter. Null means all. + * @return annotations + */ + public static Stream annotations(OWLAxiom axiom, + @Nullable OWLAnnotationProperty p) { + Stream stream = empty(); + if (axiom instanceof OWLAnnotationAssertionAxiom) { + stream = Stream.of(((OWLAnnotationAssertionAxiom) axiom).getAnnotation()); + } + stream = Stream.concat(stream, axiom.annotations()).distinct().sorted(); + if (p != null) { + stream = stream.filter(a -> a.getProperty().equals(p)); + } + return stream.distinct(); + } + + /** + * Retrieve equivalent entities from axioms, including individuals from sameAs axioms. A mixture + * of axiom types can be passed in, as long as the entity type they contain is compatible with + * the return type for the collection. + * + * @param returned type + * @param axioms axioms + * @return equivalent entities + */ + @SuppressWarnings("unchecked") + public static Stream equivalent(Stream axioms) { + return (Stream) equivalent(axioms, OWLObject.class); + } + + /** + * Retrieve equivalent entities from axioms, including individuals from sameAs axioms. A mixture + * of axiom types can be passed in, as long as the entity type they contain is compatible with + * the return type for the collection. + * + * @param returned type + * @param axioms axioms + * @param type type contained in the returned collection + * @return equivalent entities + */ + public static Stream equivalent(Stream axioms, + Class type) { + return axioms.flatMap(ax -> equivalent(ax, type)); + } + + /** + * Retrieve equivalent entities from an axiom, including individuals from sameAs axioms. + * + * @param axiom axiom + * @param type contained in the returned collection + * @return equivalent entities + */ + public static Stream equivalent(OWLAxiom axiom) { + return axiom.accept(new EquivalentVisitor(true)); + } + + /** + * Retrieve equivalent entities from an axiom, including individuals from sameAs axioms. + * + * @param axiom axiom + * @param type type returned + * @param type contained in the returned collection + * @return equivalent entities + */ + public static Stream equivalent(OWLAxiom axiom, + @SuppressWarnings("unused") Class type) { + return axiom.accept(new EquivalentVisitor(true)); + } + + /** + * Retrieve disjoint entities from axioms, including individuals from differentFrom axioms. A + * mixture of axiom types can be passed in, as long as the entity type they contain is + * compatible with the return type for the collection. + * + * @param returned type + * @param axioms axioms + * @return disjoint entities + */ + @SuppressWarnings("unchecked") + public static Stream different(Stream axioms) { + return (Stream) different(axioms, OWLObject.class); + } + + /** + * Retrieve disjoint entities from axioms, including individuals from differentFrom axioms. A + * mixture of axiom types can be passed in, as long as the entity type they contain is + * compatible with the return type for the collection. + * + * @param returned type + * @param axioms axioms + * @param type type contained in the returned collection + * @return disjoint entities + */ + public static Stream different(Stream axioms, + Class type) { + return axioms.flatMap(ax -> different(ax, type)); + } + + /** + * Retrieve disjoint entities from an axiom, including individuals from differentFrom axioms. + * + * @param returned type + * @param axiom axiom + * @return disjoint entities + */ + public static Stream different(OWLAxiom axiom) { + return axiom.accept(new EquivalentVisitor(false)); + } + + /** + * Retrieve disjoint entities from an axiom, including individuals from differentFrom axioms. + * + * @param returned type + * @param axiom axiom + * @param type witness for returned type + * @return disjoint entities + */ + public static Stream different(OWLAxiom axiom, + @SuppressWarnings("unused") Class type) { + return axiom.accept(new EquivalentVisitor(false)); + } + + /** + * Retrieve the sub part of axioms, i.e., subclass or subproperty. A mixture of axiom types can + * be passed in, as long as the entity type they contain is compatible with the return type for + * the collection. + * + * @param returned type + * @param axioms axioms + * @return sub expressions + */ + @SuppressWarnings("unchecked") + public static Stream sub(Stream axioms) { + return (Stream) sub(axioms, OWLObject.class); + } + + /** + * Retrieve the sub part of axioms, i.e., subclass or subproperty. A mixture of axiom types can + * be passed in, as long as the entity type they contain is compatible with the return type for + * the collection. + * + * @param returned type + * @param axioms axioms + * @param type type contained in the returned collection + * @return sub expressions + */ + public static Stream sub(Stream axioms, + Class type) { + return axioms.map(ax -> sub(ax, type)); + } + + /** + * Retrieve the sub part of an axiom, i.e., subclass or subproperty. A mixture of axiom types + * can be passed in, as long as the entity type they contain is compatible with the return type + * for the collection. + * + * @param returned type + * @param axiom axiom + * @return sub expressions + */ + public static C sub(OWLAxiom axiom) { + return axiom.accept(new SupSubVisitor(false)); + } + + /** + * Retrieve the sub part of an axiom, i.e., subclass or subproperty. A mixture of axiom types + * can be passed in, as long as the entity type they contain is compatible with the return type + * for the collection. + * + * @param returned type + * @param axiom axiom + * @param type witness for returned type + * @return sub expressions + */ + public static C sub(OWLAxiom axiom, + @SuppressWarnings("unused") Class type) { + return axiom.accept(new SupSubVisitor(false)); + } + + /** + * Retrieve the super part of axioms, i.e., superclass or super property. A mixture of axiom + * types can be passed in, as long as the entity type they contain is compatible with the return + * type for the collection. + * + * @param returned type + * @param axioms axioms + * @param type type contained in the returned collection + * @return sub expressions + */ + public static Stream sup(Stream axioms, + Class type) { + return axioms.map(ax -> sup(ax, type)); + } + + /** + * Retrieve the super part of axioms, i.e., superclass or super property. A mixture of axiom + * types can be passed in, as long as the entity type they contain is compatible with the return + * type for the collection. + * + * @param returned type + * @param axioms axioms + * @return sub expressions + */ + @SuppressWarnings("unchecked") + public static Stream sup(Stream axioms) { + return (Stream) sup(axioms, OWLObject.class); + } + + /** + * Retrieve the super part of an axiom, i.e., superclass or super property. A mixture of axiom + * types can be passed in, as long as the entity type they contain is compatible with the return + * type for the collection. + * + * @param returned type + * @param axiom axiom + * @return sub expressions + */ + public static C sup(OWLAxiom axiom) { + return axiom.accept(new SupSubVisitor(true)); + } + + /** + * Retrieve the super part of an axiom, i.e., superclass or super property. A mixture of axiom + * types can be passed in, as long as the entity type they contain is compatible with the return + * type for the collection. + * + * @param returned type + * @param axiom axiom + * @param type witness for returned type + * @return sub expressions + */ + public static C sup(OWLAxiom axiom, + @SuppressWarnings("unused") Class type) { + return axiom.accept(new SupSubVisitor(true)); + } + + /** + * Retrieve the domains from domain axioms. A mixture of axiom types can be passed in. + * + * @param returned type + * @param axioms axioms + * @return sub expressions + */ + @SuppressWarnings("unchecked") + public static Stream domain(Stream axioms) { + return (Stream) domain(axioms, OWLObject.class); + } + + /** + * Retrieve the domains from domain axioms. A mixture of axiom types can be passed in. + * + * @param returned type + * @param axioms axioms + * @param type type contained in the returned collection + * @return sub expressions + */ + public static Stream domain(Stream axioms, + Class type) { + return axioms.map(ax -> domain(ax, type)); + } + + /** + * Retrieve the domains from domain axioms. A mixture of axiom types can be passed in. + * + * @param returned type + * @param axiom axiom + * @return sub expressions + */ + public static C domain(OWLAxiom axiom) { + return axiom.accept(new DomainVisitor()); + } + + /** + * Retrieve the domains from domain axioms. A mixture of axiom types can be passed in. + * + * @param returned type + * @param axiom axiom + * @param type witness for returned type + * @return sub expressions + */ + public static C domain(OWLAxiom axiom, + @SuppressWarnings("unused") Class type) { + return axiom.accept(new DomainVisitor()); + } + + /** + * Retrieve the ranges from range axioms. A mixture of axiom types can be passed in. + * + * @param returned type + * @param axioms axioms + * @return sub expressions + */ + @SuppressWarnings("unchecked") + public static Stream range(Stream axioms) { + return (Stream) range(axioms, OWLObject.class); + } + + /** + * Retrieve the ranges from range axioms. A mixture of axiom types can be passed in. + * + * @param returned type + * @param axioms axioms + * @param type type contained in the returned collection + * @return sub expressions + */ + public static Stream range(Stream axioms, + Class type) { + return axioms.map(ax -> range(ax, type)); + } + + /** + * Retrieve the ranges from a range axiom. A mixture of axiom types can be passed in. + * + * @param returned type + * @param axiom axiom + * @return sub expressions + */ + public static C range(OWLAxiom axiom) { + return axiom.accept(new RangeVisitor()); + } + + /** + * Retrieve the ranges from a range axiom. A mixture of axiom types can be passed in. + * + * @param returned type + * @param axiom axiom + * @param type witness for returned type + * @return sub expressions + */ + public static C range(OWLAxiom axiom, + @SuppressWarnings("unused") Class type) { + return axiom.accept(new RangeVisitor()); + } + + /** + * Transform a collection of ontologies to a collection of IRIs of those ontologies. Anonymous + * ontologies are skipped. + * + * @param ontologies ontologies to transform + * @return collection of IRIs for the ontologies. + */ + public static Stream ontologiesIRIs(Stream ontologies) { + return ontologyIRIs(ontologies.map(OWLOntology::getOntologyID)); + } + + /** + * Transform a collection of ontology ids to a collection of IRIs of those ontology ids. + * Anonymous ontology ids are skipped. + * + * @param ids ontology ids to transform + * @return collection of IRIs for the ontology ids. + */ + public static Stream ontologyIRIs(Stream ids) { + return ids.filter(i -> i.getOntologyIRI().isPresent()).map(i -> i.getOntologyIRI().get()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/search/SupSubVisitor.java b/api/src/main/java/org/semanticweb/owlapi/search/SupSubVisitor.java new file mode 100644 index 0000000000..6414fd9f22 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/search/SupSubVisitor.java @@ -0,0 +1,38 @@ +package org.semanticweb.owlapi.search; + +import org.semanticweb.owlapi.model.OWLAxiomVisitorEx; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; + +@SuppressWarnings("unchecked") +class SupSubVisitor implements OWLAxiomVisitorEx { + + private final boolean sup; + + SupSubVisitor(boolean sup) { + this.sup = sup; + } + + @Override + public C visit(OWLSubAnnotationPropertyOfAxiom axiom) { + return (C) (sup ? axiom.getSuperProperty() : axiom.getSubProperty()); + } + + @Override + public C visit(OWLSubClassOfAxiom axiom) { + return (C) (sup ? axiom.getSuperClass() : axiom.getSubClass()); + } + + @Override + public C visit(OWLSubDataPropertyOfAxiom axiom) { + return (C) (sup ? axiom.getSuperProperty() : axiom.getSubProperty()); + } + + @Override + public C visit(OWLSubObjectPropertyOfAxiom axiom) { + return (C) (sup ? axiom.getSuperProperty() : axiom.getSubProperty()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/search/package-info.java b/api/src/main/java/org/semanticweb/owlapi/search/package-info.java new file mode 100644 index 0000000000..edbfdd31cb --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/search/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Search utilities package. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.search; diff --git a/api/src/main/java/org/semanticweb/owlapi/search/packageinfo b/api/src/main/java/org/semanticweb/owlapi/search/packageinfo new file mode 100644 index 0000000000..5274cfaacc --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/search/packageinfo @@ -0,0 +1 @@ +version 5.0.4 diff --git a/api/src/main/java/org/semanticweb/owlapi/util/AbstractCollector.java b/api/src/main/java/org/semanticweb/owlapi/util/AbstractCollector.java new file mode 100644 index 0000000000..c45e63ecc6 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/AbstractCollector.java @@ -0,0 +1,48 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.Collection; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.HasComponents; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectVisitor; + +/** + * A utility class that visits all components of classes and axioms; this base class allows + * subclasses to choose elements of interest and override handling of such elements. + * + * @since 5.0.0 + */ +public abstract class AbstractCollector implements OWLObjectVisitor { + + @Override + public void doDefault(Object object) { + if (object instanceof HasComponents) { + processStream(((HasComponents) object).components()); + } + } + + protected void processStream(Stream s) { + s.forEach(o -> { + if (o instanceof OWLObject) { + ((OWLObject) o).accept(this); + } else if (o instanceof Stream) { + processStream((Stream) o); + } else if (o instanceof Collection) { + processStream(((Collection) o).stream()); + } + }); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/AbstractCollectorEx.java b/api/src/main/java/org/semanticweb/owlapi/util/AbstractCollectorEx.java new file mode 100644 index 0000000000..a283b87a79 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/AbstractCollectorEx.java @@ -0,0 +1,68 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.Collection; +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.HasComponents; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectVisitorEx; + +/** + * A utility class that visits all components of classes and axioms; this base + * class allows subclasses to choose elements of interest and override handling + * of such elements. + * + * @param type returned + * @since 5.0.0 + */ +public abstract class AbstractCollectorEx implements OWLObjectVisitorEx> { + + protected Collection objects; + + /** + * @param c collection to accumulate objects + */ + public AbstractCollectorEx(Collection c) { + objects = checkNotNull(c, "c cannot be null"); + } + + @Override + public Collection doDefault(Object object) { + if (object instanceof HasComponents) { + processStream(((HasComponents) object).components()); + } + return objects; + } + + protected void processStream(Stream s) { + s.forEach(o -> { + if (o instanceof OWLObject) { + ((OWLObject) o).accept(this); + } else if (o instanceof Stream) { + processStream((Stream) o); + } else if (o instanceof Collection) { + processStream(((Collection) o).stream()); + } + }); + } + + /** + * @return collected objects + */ + public Collection getObjects() { + return objects; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/AbstractOWLStorer.java b/api/src/main/java/org/semanticweb/owlapi/util/AbstractOWLStorer.java new file mode 100644 index 0000000000..d610ee739b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/AbstractOWLStorer.java @@ -0,0 +1,148 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.Writer; +import java.net.URL; +import java.net.URLConnection; +import java.nio.charset.StandardCharsets; +import java.util.Optional; +import org.semanticweb.owlapi.io.OWLOntologyDocumentTarget; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.model.OWLStorer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Base class for ontology storers. Note that all current implementations are + * stateless. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public abstract class AbstractOWLStorer implements OWLStorer { + + protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractOWLStorer.class); + + private static OutputStream prepareActualOutput(IRI documentIRI) throws IOException { + // files opened with FileOutputStream + if ("file".equals(documentIRI.getScheme())) { + File file = new File(documentIRI.toURI()); + // Ensure that the necessary directories exist. + file.getParentFile().mkdirs(); + return new FileOutputStream(file); + } + // URLs + URL url = documentIRI.toURI().toURL(); + URLConnection conn = url.openConnection(); + return conn.getOutputStream(); + } + + @Override + public void storeOntology(OWLOntology ontology, IRI documentIRI, + OWLDocumentFormat ontologyFormat) + throws OWLOntologyStorageException { + if (!documentIRI.isAbsolute()) { + throw new OWLOntologyStorageException("Document IRI must be absolute: " + documentIRI); + } + try ( + // prepare actual output + OutputStream os = prepareActualOutput(documentIRI)) { + store(ontology, ontologyFormat, os); + } catch (IOException e) { + throw new OWLOntologyStorageException(e); + } + } + + private void store(OWLOntology ontology, OWLDocumentFormat ontologyFormat, + OutputStream tempOutputStream) + throws OWLOntologyStorageException, IOException { + try (OutputStreamWriter osw = new OutputStreamWriter(tempOutputStream, + StandardCharsets.UTF_8); + BufferedWriter bw = new BufferedWriter(osw); + PrintWriter tempWriter = new PrintWriter(bw);) { + storeOntology(ontology, tempWriter, ontologyFormat); + tempWriter.flush(); + } + } + + @Override + public void storeOntology(OWLOntology ontology, OWLOntologyDocumentTarget target, + OWLDocumentFormat format) + throws OWLOntologyStorageException { + Optional writer = target.getWriter(); + if (format.isTextual() && writer.isPresent()) { + try (Writer w = writer.get(); PrintWriter pw = new PrintWriter(w);) { + storeOntology(ontology, pw, format); + pw.flush(); + return; + } catch (IOException e) { + throw new OWLOntologyStorageException(e); + } + } + Optional outputStream = target.getOutputStream(); + if (outputStream.isPresent()) { + storeOntology(ontology, outputStream.get(), format); + return; + } + Optional documentIRI = target.getDocumentIRI(); + if (documentIRI.isPresent()) { + storeOntology(ontology, documentIRI.get(), format); + return; + } + throw new OWLOntologyStorageException( + "Neither a Writer, OutputStream or Document IRI could be obtained to store the ontology in this format: " + + format.getKey()); + } + + /* + * Override this to support textual serialisation. + */ + protected abstract void storeOntology(OWLOntology ontology, PrintWriter writer, + OWLDocumentFormat format) + throws OWLOntologyStorageException; + + /* + * Override this to support direct binary serialisation without the UTF-8 + * encoding being applied. + */ + protected void storeOntology(OWLOntology ontology, OutputStream outputStream, + OWLDocumentFormat format) + throws OWLOntologyStorageException { + if (!format.isTextual()) { + throw new OWLOntologyStorageException( + "This method must be overridden to support this binary format: " + + format.getKey()); + } + try { + PrintWriter writer = new PrintWriter( + new BufferedWriter(new OutputStreamWriter(outputStream, + StandardCharsets.UTF_8))); + storeOntology(ontology, writer, format); + writer.flush(); + } catch (OWLRuntimeException e) { + throw new OWLOntologyStorageException(e); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/AnnotationValueShortFormProvider.java b/api/src/main/java/org/semanticweb/owlapi/util/AnnotationValueShortFormProvider.java new file mode 100644 index 0000000000..7583bd292e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/AnnotationValueShortFormProvider.java @@ -0,0 +1,244 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectVisitor; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologySetProvider; + +/** + * A short form provider that generates short forms based on entity annotation values. A list of + * preferred annotation URIs and preferred annotation languages is used to determine which + * annotation value to select if there are multiple annotations for the entity whose short form is + * being generated. If there are multiple annotations the these annotations are ranked by preferred + * IRI and then by preferred language. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class AnnotationValueShortFormProvider implements ShortFormProvider { + + private final OWLOntologySetProvider ontologySetProvider; + private final ShortFormProvider alternateShortFormProvider; + private final IRIShortFormProvider alternateIRIShortFormProvider; + private final List annotationProperties; + private final Map> preferredLanguageMap; + private StringAnnotationVisitor literalRenderer = new StringAnnotationVisitor(); + + /** + * Constructs an annotation value short form provider. Using {@code SimpleShortFormProvider} as + * the alternate short form provider + * + * @param annotationProperties A {@code List} of preferred annotation properties. The list is + * searched from start to end, so that annotations that have a + * property at the start of the list have a higher priority and are + * selected over annotations with properties that appear towards or + * at the end of the list. + * @param preferredLanguageMap A map which maps annotation properties to preferred languages. + * For any given annotation property there may be a list of + * preferred languages. Languages at the start of the list have a + * higher priority over languages at the end of the list. This + * parameter may be empty but it must not be {@code null}. + * @param ontologySetProvider An {@code OWLOntologySetProvider} which provides a set of + * ontology from which candidate annotation axioms should be taken. + * For a given entity, all ontologies are examined. + */ + public AnnotationValueShortFormProvider(List annotationProperties, + Map> preferredLanguageMap, + OWLOntologySetProvider ontologySetProvider) { + this(annotationProperties, preferredLanguageMap, ontologySetProvider, + new SimpleShortFormProvider()); + } + + /** + * Constructs an annotation short form provider. + * + * @param annotationProperties A {@code List} of preferred annotation properties. The list + * is searched from start to end, so that annotations that + * have a property at the start of the list have a higher + * priority and are selected over annotations with properties + * that appear towards or at the end of the list. + * @param preferredLanguageMap A map which maps annotation properties to preferred + * languages. For any given annotation property there may be a + * list of preferred languages. Languages at the start of the + * list have a higher priority over languages at the end of + * the list. This parameter may be empty but it must not be + * {@code null}. + * @param ontologySetProvider An {@code OWLOntologySetProvider} which provides a set of + * ontology from which candidate annotation axioms should be + * taken. For a given entity, all ontologies are examined. + * @param alternateShortFormProvider A short form provider which will be used to generate the + * short form for an entity that does not have any + * annotations. This provider will also be used in the case + * where the value of an annotation is an + * {@code OWLIndividual} for providing the short form of the + * individual. + */ + public AnnotationValueShortFormProvider(List annotationProperties, + Map> preferredLanguageMap, + OWLOntologySetProvider ontologySetProvider, ShortFormProvider alternateShortFormProvider) { + this(ontologySetProvider, alternateShortFormProvider, new SimpleIRIShortFormProvider(), + annotationProperties, preferredLanguageMap); + } + + /** + * @param ontologySetProvider ontologies + * @param alternateShortFormProvider short form provider + * @param alternateIRIShortFormProvider iri short form provider + * @param annotationProperties annotation properties + * @param preferredLanguageMap preferred language map + */ + public AnnotationValueShortFormProvider(OWLOntologySetProvider ontologySetProvider, + ShortFormProvider alternateShortFormProvider, + IRIShortFormProvider alternateIRIShortFormProvider, + List annotationProperties, + Map> preferredLanguageMap) { + this.ontologySetProvider = + checkNotNull(ontologySetProvider, "ontologySetProvider cannot be null"); + this.alternateShortFormProvider = + checkNotNull(alternateShortFormProvider, "alternateShortFormProvider cannot be null"); + this.alternateIRIShortFormProvider = checkNotNull(alternateIRIShortFormProvider, + "alternateIRIShortFormProvider cannot be null"); + this.annotationProperties = + checkNotNull(annotationProperties, "annotationProperties cannot be null"); + this.preferredLanguageMap = + checkNotNull(preferredLanguageMap, "preferredLanguageMap cannot be null"); + } + + @Override + public String getShortForm(OWLEntity entity) { + Stream onts = ontologySetProvider.ontologies(); + List flatMap = asList( + onts.flatMap(o -> o.annotationAssertionAxioms(entity.getIRI(), INCLUDED).sorted())); + for (OWLAnnotationProperty prop : annotationProperties) { + // visit the properties in order of preference + AnnotationLanguageFilter checker = + new AnnotationLanguageFilter(prop, preferredLanguageMap.get(prop)); + flatMap.forEach(ax -> ax.accept(checker)); + OWLObject match = checker.getMatch(); + if (match != null) { + return getRendering(match); + } + } + return alternateShortFormProvider.getShortForm(entity); + } + + /** + * Obtains the rendering of the specified object. If the object is a constant then the rendering + * is equal to the literal value, if the object is an individual then the rendering is equal to + * the rendering of the individual as provided by the alternate short form provider + * + * @param object The object to the rendered + * @return The rendering of the object. + */ + private String getRendering(OWLObject object) { + // We return the literal value of constants or use the alternate + // short form provider to render individuals. + if (object instanceof OWLLiteral) { + // TODO refactor this method to use the annotation value visitor + return literalRenderer.visit((OWLLiteral) object); + } else if (object.isIRI()) { + return alternateIRIShortFormProvider.getShortForm((IRI) object); + } else { + return alternateShortFormProvider.getShortForm((OWLEntity) object); + } + } + + /** + * @return the annotation URIs that this short form provider uses. + */ + public List getAnnotationProperties() { + return annotationProperties; + } + + /** + * @return the preferred language map + */ + public Map> getPreferredLanguageMap() { + return preferredLanguageMap; + } + + /** + * @param literalRenderer the literal renderer to set + */ + public void setLiteralRenderer(StringAnnotationVisitor literalRenderer) { + this.literalRenderer = checkNotNull(literalRenderer); + } + + private static class AnnotationLanguageFilter implements OWLObjectVisitor { + + private final OWLAnnotationProperty prop; + private final List preferredLanguages; + @Nullable + protected OWLObject candidateValue = null; + int lastLangMatchIndex = Integer.MAX_VALUE; + + AnnotationLanguageFilter(OWLAnnotationProperty prop, + @Nullable List preferredLanguages) { + this.prop = prop; + this.preferredLanguages = + preferredLanguages == null ? Collections.emptyList() : preferredLanguages; + } + + @Nullable + public OWLObject getMatch() { + return candidateValue; + } + + @Override + public void visit(OWLAnnotationAssertionAxiom axiom) { + if (lastLangMatchIndex > 0 && axiom.getProperty().equals(prop)) { + // a perfect match - no need to carry on search + axiom.getValue().accept(this); + } + } + + @Override + public void visit(OWLLiteral node) { + if (preferredLanguages.isEmpty()) { + // if there are no languages just match the first thing + lastLangMatchIndex = 0; + candidateValue = node; + } else { + int index = preferredLanguages.indexOf(node.getLang()); + if (index >= 0 && index < lastLangMatchIndex) { + lastLangMatchIndex = index; + candidateValue = node; + } + } + } + + @Override + public void visit(IRI iri) { + // No language + candidateValue = iri; + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/AnnotationWalkingControl.java b/api/src/main/java/org/semanticweb/owlapi/util/AnnotationWalkingControl.java new file mode 100644 index 0000000000..1025934f24 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/AnnotationWalkingControl.java @@ -0,0 +1,50 @@ +package org.semanticweb.owlapi.util; + +import org.semanticweb.owlapi.model.HasAnnotations; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * Control flag for whether to walk annotations + */ +public enum AnnotationWalkingControl { + /** + * Do not walk any annotations + */ + DONT_WALK_ANNOTATIONS, + /** + * Only walk ontology annotations (previous behaviour) + */ + WALK_ONTOLOGY_ANNOTATIONS_ONLY { + @Override + public void walk(StructureWalker walker, OWLObject o) { + if (o instanceof OWLOntology) { + ((OWLOntology) o).annotations().forEach(a -> a.accept(walker)); + } + } + }, + /** + * Walk all annotations + */ + WALK_ANNOTATIONS { + @Override + public void walk(StructureWalker walker, OWLObject o) { + if (o instanceof HasAnnotations) { + ((HasAnnotations) o).annotations().forEach(a -> a.accept(walker)); + } + } + }; + + /** + * Visit annotations on the object, if the setting allows for the annotations to be visited. + * + * @param type + * + * @param walker walker to use to visit annotations + * @param o object containing annotations + */ + @SuppressWarnings("unused") + public void walk(StructureWalker walker, OWLObject o) { + // default implementation + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/AnonymousNodeChecker.java b/api/src/main/java/org/semanticweb/owlapi/util/AnonymousNodeChecker.java new file mode 100644 index 0000000000..dbb23f288b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/AnonymousNodeChecker.java @@ -0,0 +1,40 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import org.semanticweb.owlapi.model.IRI; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface AnonymousNodeChecker { + + /** + * @param iri iri to check + * @return true if iri is a blank node iri + */ + boolean isAnonymousNode(IRI iri); + + /** + * @param iri iri to check + * @return true if iri is a blank node iri + */ + boolean isAnonymousNode(String iri); + + /** + * @param iri iri to check + * @return true if iri is a blank node iri for shared nodes + */ + boolean isAnonymousSharedNode(String iri); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/AnonymousNodeCheckerImpl.java b/api/src/main/java/org/semanticweb/owlapi/util/AnonymousNodeCheckerImpl.java new file mode 100644 index 0000000000..a0b3688dc5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/AnonymousNodeCheckerImpl.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.NodeID; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * default implementation for an anonymous node checker. This implementation + * delegates to NodeID + * + * @author ignazio + * @since 4.0.0 + */ +public class AnonymousNodeCheckerImpl implements AnonymousNodeChecker { + + private static final Logger LOGGER = LoggerFactory + .getLogger(AnonymousNodeCheckerImpl.class); + + @Override + public boolean isAnonymousNode(IRI iri) { + boolean value = NodeID.isAnonymousNodeIRI(iri); + if (value) { + LOGGER.trace("anonymous iri {}", iri); + } + return value; + } + + @Override + public boolean isAnonymousNode(String iri) { + boolean value = NodeID.isAnonymousNodeIRI(iri); + if (value) { + LOGGER.trace("anonymous string {}", iri); + } + return value; + } + + @Override + public boolean isAnonymousSharedNode(String iri) { + boolean value = NodeID.isAnonymousNodeID(iri); + if (value) { + LOGGER.trace("anonymous shared id {}", iri); + } + return value; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/AutoIRIMapper.java b/api/src/main/java/org/semanticweb/owlapi/util/AutoIRIMapper.java new file mode 100644 index 0000000000..ae88b49561 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/AutoIRIMapper.java @@ -0,0 +1,387 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.CollectionFactory.createMap; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.Serializable; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.annotations.HasPriority; +import org.semanticweb.owlapi.io.DocumentSources; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntologyIRIMapper; +import org.semanticweb.owlapi.vocab.Namespaces; +import org.semanticweb.owlapi.vocab.OWLXMLVocabulary; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +/** + * A mapper which given a root folder attempts to automatically discover and map files to + * ontologies. The mapper is capable of mapping ontologies in RDF/XML, OWL/XML, Manchester OWL + * Syntax, Functional Syntax and OBO (other serialisations are not supported). Zip and jar files + * containing ontologies are supported, either as main argument to the constructor or as content of + * the root folder. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +@HasPriority(1) +public class AutoIRIMapper extends DefaultHandler implements OWLOntologyIRIMapper, Serializable { + + private static final String ONTOLOGY_ELEMENT_FOUND_PARSING_COMPLETE = + "Ontology element found, parsing complete."; + static final Pattern pattern = Pattern.compile("Ontology\\(<([^>]+)>"); + static final Pattern manPattern = Pattern.compile("Ontology:[\r\n ]*<([^>]+)>"); + private static final Logger LOGGER = LoggerFactory.getLogger(AutoIRIMapper.class); + private final Set fileExtensions = + new HashSet<>(Arrays.asList(".owl", ".xml", ".rdf", ".omn", ".ofn")); + private final boolean recursive; + private final Map handlerMap = createMap(); + private final Map ontologyIRI2PhysicalURIMap = createMap(); + private final Map oboFileMap = createMap(); + private final String directoryPath; + private boolean mapped; + @Nullable + private transient File currentFile; + + /** + * Creates an auto-mapper which examines ontologies that reside in the specified root folder + * (and possibly sub-folders). + * + * @param rootDirectory The root directory which should be searched for ontologies; this can + * also be a zip/jar file containing ontologies. If root is actually a + * folder, zip/jar files included in the folder are parsed for ontologies. + * The zip parsing is delegated to ZipIRIMapper. + * @param recursive Sub directories will be searched recursively if {@code true}. + */ + public AutoIRIMapper(File rootDirectory, boolean recursive) { + directoryPath = + checkNotNull(rootDirectory, "rootDirectory cannot be null").getAbsolutePath(); + this.recursive = recursive; + mapped = false; + /** + * A handler to handle RDF/XML files. The xml:base (if present) is taken to be the ontology + * URI of the ontology document being parsed. + */ + handlerMap.put(Namespaces.RDF + "RDF", this::baseIRI); + /** + * A handler that can handle OWL/XML files as well as RDF/XML with an owl:Ontology element + * is defined with a non empty rdf:about. + */ + handlerMap.put(OWLXMLVocabulary.ONTOLOGY.toString(), this::ontologyIRI); + } + + @Nullable + protected IRI ontologyIRI(Attributes attributes) { + String ontURI = attributes.getValue(Namespaces.OWL.toString(), "ontologyIRI"); + if (ontURI == null) { + ontURI = attributes.getValue("ontologyIRI"); + } + if (ontURI == null) { + ontURI = attributes.getValue(Namespaces.RDF.toString(), "about"); + } + if (ontURI == null) { + return null; + } + return IRI.create(ontURI); + } + + @Nullable + protected IRI baseIRI(Attributes attributes) { + String baseValue = attributes.getValue(Namespaces.XML.toString(), "base"); + if (baseValue == null) { + return null; + } + return IRI.create(baseValue); + } + + /** + * @param tok token + * @return IRI without quotes (< and >) + */ + static IRI unquote(String tok) { + String substring = tok.substring(1, tok.length() - 1); + assert substring != null; + return IRI.create(substring); + } + + protected File getDirectory() { + return new File(directoryPath); + } + + /** + * The mapper only examines files that have specified file extensions. This method returns the + * file extensions that cause a file to be examined. + * + * @return A {@code Set} of file extensions. + */ + public Set getFileExtensions() { + return new HashSet<>(fileExtensions); + } + + /** + * Sets the extensions of files that are to be examined for ontological content. (By default the + * extensions are {@code owl}, {@code xml} and {@code rdf}). Only files that have the specified + * extensions will be examined to see if they contain ontologies. + * + * @param extensions the set of extensions + */ + public void setFileExtensions(Collection extensions) { + fileExtensions.clear(); + fileExtensions.addAll(extensions); + } + + /** + * Gets the set of ontology IRIs that this mapper has found. + * + * @return A {@code Set} of ontology (logical) IRIs + */ + public Set getOntologyIRIs() { + if (!mapped) { + mapFiles(); + } + return new HashSet<>(ontologyIRI2PhysicalURIMap.keySet()); + } + + /** + * update the map. + */ + public void update() { + mapFiles(); + } + + @Override + @Nullable + public IRI getDocumentIRI(IRI ontologyIRI) { + if (!mapped) { + mapFiles(); + } + if (ontologyIRI.toString().endsWith(".obo")) { + String path = ontologyIRI.toURI().getPath(); + if (path != null) { + int lastSepIndex = path.lastIndexOf('/'); + String name = path.substring(lastSepIndex + 1, path.length()); + IRI documentIRI = oboFileMap.get(name); + if (documentIRI != null) { + return documentIRI; + } + } + } + return ontologyIRI2PhysicalURIMap.get(ontologyIRI); + } + + private void mapFiles() { + mapped = true; + ontologyIRI2PhysicalURIMap.clear(); + processFile(getDirectory()); + } + + private void processFile(File f) { + if (f.isHidden()) { + return; + } + // if pointed directly at a zip file, map it + parseIfExtensionSupported(f); + File[] files = f.listFiles(); + if (files == null) { + return; + } + for (File file : files) { + if (file.isDirectory() && recursive) { + processFile(file); + } else { + parseIfExtensionSupported(file); + } + } + } + + protected void parseIfExtensionSupported(File file) { + String name = file.getName(); + int lastIndexOf = name.lastIndexOf('.'); + if (lastIndexOf < 0) { + // no extension for the file, nothing to do + return; + } + String extension = name.substring(lastIndexOf); + if (".zip".equalsIgnoreCase(extension) || ".jar".equalsIgnoreCase(extension)) { + try { + ZipIRIMapper mapper = new ZipIRIMapper(file, "jar:" + file.toURI() + "!/"); + mapper.oboMappings().forEach(e -> oboFileMap.put(e.getKey(), e.getValue())); + mapper.iriMappings() + .forEach(e -> ontologyIRI2PhysicalURIMap.put(e.getKey(), e.getValue())); + } catch (IOException e) { + // if we can't parse a file, then we can't map it + LOGGER.debug("Exception reading file", e); + } + + } else if (".obo".equalsIgnoreCase(extension)) { + oboFileMap.put(name, IRI.create(file)); + } else if (".ofn".equalsIgnoreCase(extension)) { + parseFSSFile(file); + } else if (".omn".equalsIgnoreCase(extension)) { + parseManchesterSyntaxFile(file); + } else if (fileExtensions.contains(extension.toLowerCase())) { + parseFile(file); + } + } + + /** + * Search first 100 lines for FSS style Ontology(<IRI> ... + * + * @param file the file to parse + */ + private void parseFSSFile(File file) { + try (InputStream input = new FileInputStream(file); + Reader reader = new InputStreamReader(input, "UTF-8"); + BufferedReader br = new BufferedReader(reader)) { + String line = ""; + Matcher m = pattern.matcher(line); + int n = 0; + while ((line = br.readLine()) != null && n++ < 100) { + m.reset(line); + if (m.matches()) { + String group = m.group(1); + assert group != null; + addMapping(IRI.create(group), file); + break; + } + } + } catch (IOException e) { + // if we can't parse a file, then we can't map it + LOGGER.debug("Exception reading file", e); + } + } + + private void parseFile(File file) { + try (FileInputStream in = new FileInputStream(file); + BufferedInputStream delegate = new BufferedInputStream(in); + InputStream is = DocumentSources.wrap(delegate);) { + currentFile = file; + // Using the default expansion limit. If the ontology IRI cannot be + // found before 64000 entities are expanded, the file is too + // expensive to parse. + SAXParsers.initParserWithOWLAPIStandards(null, "64000").parse(is, this); + } catch (SAXException e) { + // Exceptions thrown to halt parsing early when the ontology IRI is found + // should not be logged because they are not actual errors, only a performance hack. + if (!Objects.equals(ONTOLOGY_ELEMENT_FOUND_PARSING_COMPLETE, e.getMessage())) { + LOGGER.debug("SAX Exception reading file", e); + } + } catch (IOException e) { + // if we can't parse a file, then we can't map it + LOGGER.debug("IO Exception reading file", e); + } + } + + private void parseManchesterSyntaxFile(File file) { + try (FileInputStream input = new FileInputStream(file); + InputStreamReader reader = new InputStreamReader(input, StandardCharsets.UTF_8); + BufferedReader br = new BufferedReader(reader)) { + // Ontology: + String line = br.readLine(); + while (line != null) { + if (parseManLine(file, line) != null) { + return; + } + line = br.readLine(); + } + } catch (IOException e) { + // if we can't parse a file, then we can't map it + LOGGER.debug("Exception reading file", e); + } + } + + @Nullable + private IRI parseManLine(File file, String line) { + Matcher matcher = manPattern.matcher(line); + if (matcher.matches()) { + IRI iri = IRI.create(matcher.group(1)); + addMapping(iri, file); + return iri; + } + return null; + } + + @Override + public void startElement(@Nullable String uri, @Nullable String localName, + @Nullable String qName, @Nullable Attributes attributes) throws SAXException { + String tag = uri + localName; + OntologyRootElementHandler handler = handlerMap.get(tag); + if (handler != null) { + IRI ontologyIRI = handler.handle(checkNotNull(attributes)); + if (ontologyIRI != null && currentFile != null) { + addMapping(ontologyIRI, verifyNotNull(currentFile)); + } + } + if (tag.equals("http://www.w3.org/2002/07/owl#Ontology")) { + throw new SAXException(ONTOLOGY_ELEMENT_FOUND_PARSING_COMPLETE); + } + } + + /** + * @param ontologyIRI ontology + * @param file file + */ + protected void addMapping(IRI ontologyIRI, File file) { + ontologyIRI2PhysicalURIMap.put(ontologyIRI, IRI.create(file)); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("AutoIRIMapper: ("); + sb.append(ontologyIRI2PhysicalURIMap.size()).append(" ontologies)\n"); + ontologyIRI2PhysicalURIMap.forEach((k, v) -> sb.append(" ").append(k.toQuotedString()) + .append(" -> ").append(v).append('\n')); + return sb.toString(); + } + + /** + * A simple interface which extracts an ontology IRI from a set of element attributes. + */ + @FunctionalInterface + private interface OntologyRootElementHandler extends Serializable { + + /** + * Gets the ontology IRI. + * + * @param attributes The attributes which will be examined for the ontology IRI. + * @return The ontology IRI or {@code null} if no ontology IRI could be found. + */ + @Nullable + IRI handle(Attributes attributes); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/AxiomAppearance.java b/api/src/main/java/org/semanticweb/owlapi/util/AxiomAppearance.java new file mode 100644 index 0000000000..ee51ddd757 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/AxiomAppearance.java @@ -0,0 +1,17 @@ +package org.semanticweb.owlapi.util; + +import org.semanticweb.owlapi.model.OWLAxiom; + +/** + * An interface for checking if an axiom appears as annotated source multiple + * times. This requires an id to be emitted. + */ +@FunctionalInterface +public interface AxiomAppearance { + + /** + * @param ax an axiom + * @return true if ax appears more than once as annotated source. + */ + boolean appearsMultipleTimes(OWLAxiom ax); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/AxiomSubjectProviderEx.java b/api/src/main/java/org/semanticweb/owlapi/util/AxiomSubjectProviderEx.java new file mode 100644 index 0000000000..8a6488d585 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/AxiomSubjectProviderEx.java @@ -0,0 +1,272 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLAxiomVisitorEx; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLHasKeyAxiom; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; +import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.SWRLRule; + +/** + * Provides the object that is the subject of an axiom. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 5.0.0 + */ +public class AxiomSubjectProviderEx implements OWLAxiomVisitorEx { + + private static final AxiomSubjectProviderEx visitor = new AxiomSubjectProviderEx(); + + /** + * @param axiom the axiom to visit + * @return the subject + */ + public static OWLObject getSubject(OWLAxiom axiom) { + return checkNotNull(axiom, "axiom cannot be null").accept(visitor); + } + + @Override + public OWLObject visit(OWLSubClassOfAxiom axiom) { + return axiom.getSubClass(); + } + + @Override + public OWLObject visit(OWLNegativeObjectPropertyAssertionAxiom axiom) { + return axiom.getSubject(); + } + + @Override + public OWLObject visit(OWLAsymmetricObjectPropertyAxiom axiom) { + return axiom.getProperty(); + } + + @Override + public OWLObject visit(OWLReflexiveObjectPropertyAxiom axiom) { + return axiom.getProperty(); + } + + @Override + public OWLObject visit(OWLDisjointClassesAxiom axiom) { + return axiom.classExpressions().findFirst().orElse(null); + } + + @Override + public OWLObject visit(OWLDataPropertyDomainAxiom axiom) { + return axiom.getProperty(); + } + + @Override + public OWLObject visit(OWLObjectPropertyDomainAxiom axiom) { + return axiom.getProperty(); + } + + @Override + public OWLObject visit(OWLEquivalentObjectPropertiesAxiom axiom) { + return axiom.properties().iterator().next(); + } + + @Override + public OWLObject visit(OWLNegativeDataPropertyAssertionAxiom axiom) { + return axiom.getSubject(); + } + + @Override + public OWLObject visit(OWLDifferentIndividualsAxiom axiom) { + return axiom.individuals().iterator().next(); + } + + @Override + public OWLObject visit(OWLDisjointDataPropertiesAxiom axiom) { + return axiom.properties().iterator().next(); + } + + @Override + public OWLObject visit(OWLDisjointObjectPropertiesAxiom axiom) { + return axiom.properties().iterator().next(); + } + + @Override + public OWLObject visit(OWLObjectPropertyRangeAxiom axiom) { + return axiom.getProperty(); + } + + @Override + public OWLObject visit(OWLObjectPropertyAssertionAxiom axiom) { + return axiom.getSubject(); + } + + @Override + public OWLObject visit(OWLFunctionalObjectPropertyAxiom axiom) { + return axiom.getProperty(); + } + + @Override + public OWLObject visit(OWLSubObjectPropertyOfAxiom axiom) { + return axiom.getSubProperty(); + } + + @Override + public OWLObject visit(OWLDisjointUnionAxiom axiom) { + return axiom.getOWLClass(); + } + + @Override + public OWLObject visit(OWLDeclarationAxiom axiom) { + return axiom.getEntity(); + } + + @Override + public OWLObject visit(OWLAnnotationAssertionAxiom axiom) { + return axiom.getSubject(); + } + + @Override + public OWLObject visit(OWLSymmetricObjectPropertyAxiom axiom) { + return axiom.getProperty(); + } + + @Override + public OWLObject visit(OWLDataPropertyRangeAxiom axiom) { + return axiom.getProperty(); + } + + @Override + public OWLObject visit(OWLFunctionalDataPropertyAxiom axiom) { + return axiom.getProperty(); + } + + @Override + public OWLObject visit(OWLEquivalentDataPropertiesAxiom axiom) { + return axiom.properties().iterator().next(); + } + + @Override + public OWLObject visit(OWLClassAssertionAxiom axiom) { + return axiom.getIndividual(); + } + + @Override + public OWLObject visit(OWLEquivalentClassesAxiom axiom) { + return axiom.classExpressions().findFirst().orElse(null); + } + + @Override + public OWLObject visit(OWLDataPropertyAssertionAxiom axiom) { + return axiom.getSubject(); + } + + @Override + public OWLObject visit(OWLTransitiveObjectPropertyAxiom axiom) { + return axiom.getProperty(); + } + + @Override + public OWLObject visit(OWLIrreflexiveObjectPropertyAxiom axiom) { + return axiom.getProperty(); + } + + @Override + public OWLObject visit(OWLSubDataPropertyOfAxiom axiom) { + return axiom.getSubProperty(); + } + + @Override + public OWLObject visit(OWLInverseFunctionalObjectPropertyAxiom axiom) { + return axiom.getProperty(); + } + + @Override + public OWLObject visit(OWLSameIndividualAxiom axiom) { + return axiom.individuals().iterator().next(); + } + + @Override + public OWLObject visit(OWLSubPropertyChainOfAxiom axiom) { + return axiom.getSuperProperty(); + } + + @Override + public OWLObject visit(OWLInverseObjectPropertiesAxiom axiom) { + return axiom.getFirstProperty(); + } + + @Override + public OWLObject visit(SWRLRule rule) { + return rule.head().iterator().next(); + } + + @Override + public OWLObject visit(OWLHasKeyAxiom axiom) { + return axiom.getClassExpression(); + } + + @Override + public OWLObject visit(OWLAnnotationPropertyDomainAxiom axiom) { + return axiom.getProperty(); + } + + @Override + public OWLObject visit(OWLAnnotationPropertyRangeAxiom axiom) { + return axiom.getProperty(); + } + + @Override + public OWLObject visit(OWLSubAnnotationPropertyOfAxiom axiom) { + return axiom.getSubProperty(); + } + + @Override + public OWLObject visit(OWLDatatypeDefinitionAxiom axiom) { + return axiom.getDataRange(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/BidirectionalShortFormProvider.java b/api/src/main/java/org/semanticweb/owlapi/util/BidirectionalShortFormProvider.java new file mode 100644 index 0000000000..ea271f52a9 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/BidirectionalShortFormProvider.java @@ -0,0 +1,81 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.OWLEntity; + +/** + * A short form provider which is capable of translating back and forth between entities and their + * short forms. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface BidirectionalShortFormProvider extends ShortFormProvider { + + /** + * For a given short form this method obtains the entities which have this short form. + * + * @param shortForm The short form of the entities that will be retrieved. + * @return The set of entities that have the specified short form. The set that is returned is a + * copy; modifications to the returned set will not be reflected in this object. + */ + default Set getEntities(String shortForm) { + return asSet(entities(shortForm)); + } + + /** + * For a given short form this method obtains the entities which have this short form. + * + * @param shortForm The short form of the entities that will be retrieved. + * @return stream of entities that have the specified short form. + */ + Stream entities(String shortForm); + + /** + * A convenience method which gets an entity from its short form. + * + * @param shortForm The short form of the entity. + * @return The actual entity or {@code null} if there is no entity which has the specified short + * form. If the specified short form corresponds to more than one entity then an entity + * will be chosen by the implementation of the short form provider. + */ + @Nullable + OWLEntity getEntity(String shortForm); + + /** + * Gets all of the short forms that are mapped to entities. + * + * @return A set which contains the strings representing the short forms of entities for which + * there is a mapping. The set that is returned is a copy; modifications to the returned + * set will not be reflected in this object. + */ + default Set getShortForms() { + return asSet(shortForms()); + } + + /** + * Gets all of the short forms that are mapped to entities. + * + * @return stream of the strings representing the short forms of entities for which there is a + * mapping. + */ + Stream shortForms(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/BidirectionalShortFormProviderAdapter.java b/api/src/main/java/org/semanticweb/owlapi/util/BidirectionalShortFormProviderAdapter.java new file mode 100644 index 0000000000..43bdc6a8f3 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/BidirectionalShortFormProviderAdapter.java @@ -0,0 +1,140 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyChangeVisitor; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.RemoveAxiom; + +/** + * A bidirectional short form provider which uses a specified short form provider to generate the + * bidirectional entity--short form mappings. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class BidirectionalShortFormProviderAdapter extends CachingBidirectionalShortFormProvider { + + @Nullable + protected final Collection ontologies; + private final ShortFormProvider shortFormProvider; + @Nullable + private OWLOntologyManager man; + + /** + * @param shortFormProvider the short form provider to use + */ + public BidirectionalShortFormProviderAdapter(ShortFormProvider shortFormProvider) { + this.shortFormProvider = + checkNotNull(shortFormProvider, "shortFormProvider cannot be null"); + ontologies = null; + } + + /** + * Creates a BidirectionalShortFormProvider that maps between the entities that are referenced + * in the specified ontologies and the short forms of these entities. + * + * @param ontologies The ontologies that contain references to the entities to be mapped. + * @param shortFormProvider The short form provider that should be used to generate the short + * forms of the referenced entities. + */ + public BidirectionalShortFormProviderAdapter(Collection ontologies, + ShortFormProvider shortFormProvider) { + this.shortFormProvider = + checkNotNull(shortFormProvider, "shortFormProvider cannot be null"); + this.ontologies = checkNotNull(ontologies, "ontologies cannot be null"); + rebuild(ontologies.stream().flatMap(OWLOntology::unsortedSignature)); + } + + /** + * Creates a BidirectionalShortFormProvider that maps between the entities that are referenced + * in the specified ontologies and the short forms of these entities. Note that the + * {@code dispose} method must be called when the provider has been finished with so that the + * provider may remove itself as a listener from the manager. + * + * @param ontologies The ontologies that contain references to the entities to be mapped. + * @param shortFormProvider The short form provider that should be used to generate the short + * forms of the referenced entities. + * @param man This short form provider will track changes to ontologies. The provider will + * listen for ontology changes and update the cache of entity--short form mappings based + * on whether the specified ontologies contain references to entities or not. + */ + public BidirectionalShortFormProviderAdapter(OWLOntologyManager man, + Collection ontologies, ShortFormProvider shortFormProvider) { + this(ontologies, shortFormProvider); + this.man = checkNotNull(man, "man cannot be null"); + verifyNotNull(this.man).addOntologyChangeListener(this::handleChanges); + } + + @Override + protected String generateShortForm(OWLEntity entity) { + return shortFormProvider.getShortForm(entity); + } + + @Override + public void dispose() { + if (man != null) { + man.removeOntologyChangeListener(this::handleChanges); + } + } + + void handleChanges(List changes) { + if (ontologies == null) { + return; + } + Set processed = new HashSet<>(); + for (OWLOntologyChange chg : changes) { + assert ontologies != null; + if (ontologies.contains(chg.getOntology())) { + OWLOntologyChangeVisitor v = new OWLOntologyChangeVisitor() { + + @Override + public void visit(AddAxiom change) { + change.signature().filter(processed::add) + .forEach(BidirectionalShortFormProviderAdapter.this::add); + } + + @Override + public void visit(RemoveAxiom change) { + change.signature().filter(processed::add) + .filter(BidirectionalShortFormProviderAdapter.this::noLongerReferenced) + .forEach(BidirectionalShortFormProviderAdapter.this::remove); + } + }; + chg.accept(v); + } + } + } + + protected boolean noLongerReferenced(OWLEntity ent) { + if (ontologies == null) { + return true; + } + assert ontologies != null; + return ontologies.stream().noneMatch(ont -> ont.containsEntityInSignature(ent)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/CachingBidirectionalShortFormProvider.java b/api/src/main/java/org/semanticweb/owlapi/util/CachingBidirectionalShortFormProvider.java new file mode 100644 index 0000000000..aa9a02cb08 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/CachingBidirectionalShortFormProvider.java @@ -0,0 +1,126 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.CollectionFactory.createSyncMap; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.empty; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.OWLEntity; + +/** + * A bidirectional short form provider that caches entity short forms. The provider has various + * methods to add, remove, update entities in the cache and also to rebuild the cache from scratch. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public abstract class CachingBidirectionalShortFormProvider + implements BidirectionalShortFormProvider { + + private final Map> shortForm2EntityMap = createSyncMap(); + private final Map entity2ShortFormMap = createSyncMap(); + + protected CachingBidirectionalShortFormProvider() {} + + /** + * Generates the short form for the specified entity. This short form will be cached so that it + * can be retrieved efficiently and so that the entity can be obtained from the short form. If + * the short form for the entity changes then the cache must explicitly be updated using the + * {@code update} method. + * + * @param entity The entity whose short form should be generated. + * @return short form + */ + protected abstract String generateShortForm(OWLEntity entity); + + @Override + public Stream shortForms() { + return shortForm2EntityMap.keySet().stream(); + } + + /** + * Rebuilds the cache using entities obtained from the specified entity set provider. + * + * @param entities The entities whose short forms will be cached. + */ + protected void rebuild(Stream entities) { + shortForm2EntityMap.clear(); + entity2ShortFormMap.clear(); + entities.forEach(this::add); + } + + /** + * Adds an entity to the cache. + * + * @param entity The entity to be added to the cache - the short form will automatically be + * generated and added to the cache. + */ + public void add(OWLEntity entity) { + String shortForm = generateShortForm(entity); + entity2ShortFormMap.put(entity, shortForm); + shortForm2EntityMap.computeIfAbsent(shortForm, s -> new HashSet<>(1)).add(entity); + } + + /** + * Removes an entity and its short form from the cache. + * + * @param entity The entity to be removed. + */ + protected void remove(OWLEntity entity) { + String shortForm = entity2ShortFormMap.remove(entity); + if (shortForm != null) { + shortForm2EntityMap.remove(shortForm); + } + } + + @Override + public Stream entities(String shortForm) { + Set entities = shortForm2EntityMap.get(shortForm); + if (entities != null && !entities.isEmpty()) { + return entities.stream(); + } + return empty(); + } + + @Override + @Nullable + public OWLEntity getEntity(String shortForm) { + Set entities = shortForm2EntityMap.get(shortForm); + if (entities != null && !entities.isEmpty()) { + return entities.iterator().next(); + } + return null; + } + + @Override + public String getShortForm(OWLEntity entity) { + String sf = entity2ShortFormMap.get(entity); + if (sf != null) { + return sf; + } + return generateShortForm(entity); + } + + @Override + public void dispose() { + shortForm2EntityMap.clear(); + entity2ShortFormMap.clear(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/CollectionFactory.java b/api/src/main/java/org/semanticweb/owlapi/util/CollectionFactory.java new file mode 100644 index 0000000000..b6feac0231 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/CollectionFactory.java @@ -0,0 +1,439 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.WeakHashMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.atomic.AtomicInteger; + +import javax.annotation.Nullable; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class CollectionFactory { + + private static final AtomicInteger EXPECTEDTHREADS = new AtomicInteger(1); + + private CollectionFactory() {} + + /** + * @return The current number of expected updating threads. + */ + public static int getExpectedThreads() { + return EXPECTEDTHREADS.get(); + } + + /** + * @param value the number of expected threads that will update threadsafe collections; useful + * for increasing the concurrency in ConcurrentHashMap instances created by this factory + */ + public static void setExpectedThreads(int value) { + EXPECTEDTHREADS.set(value); + } + + /** + * @param axiom type + * @return fresh non threadsafe set + */ + public static Set createSet() { + return new HashSet<>(0); + } + + /** + * @param axiom type + * @return fresh non threadsafe set + */ + public static Set createLinkedSet() { + return new LinkedHashSet<>(0); + } + + /** + * @param axiom type + * @return fresh non threadsafe list + */ + public static List createList() { + return new ArrayList<>(); + } + + /** + * @param elements values to add to the list + * @param axiom type + * @return fresh non threadsafe list + */ + @SafeVarargs + public static List createList(T... elements) { + List l = new ArrayList<>(); + for (T t : elements) { + l.add(t); + } + return l; + } + + /** + * @param content type + * @return fresh threadsafe list + */ + public static List createSyncList() { + return new CopyOnWriteArrayList<>(); + } + + /** + * @param i iterable + * @param type + * @return list from iterable + */ + public static List list(Iterable i) { + List l = new ArrayList<>(); + for (T t : i) { + l.add(t); + } + return l; + } + + /** + * @param i iterable + * @param type + * @return list from iterable + */ + @SafeVarargs + public static List list(T... i) { + return createList(i); + } + + /** + * @param i iterable + * @param type + * @return list from iterable + */ + public static List list(T i) { + return Collections.singletonList(i); + } + + /** + * @param c values to add to the set + * @param axiom type + * @return fresh non threadsafe set + */ + public static Set createSet(Collection c) { + return new HashSet<>(c); + } + + /** + * @param initialCapacity initial capacity for the new set + * @param axiom type + * @return fresh non threadsafe set + */ + public static Set createSet(int initialCapacity) { + return new HashSet<>(initialCapacity); + } + + /** + * @param key type + * @param value type + * @return fresh map + */ + public static Map createMap() { + return new HashMap<>(); + } + + /** + * @param key type + * @param value type + * @return a new weak HashMap wrapped as a synchronized map + */ + public static Map> createSyncWeakMap() { + return Collections.synchronizedMap(new WeakHashMap>()); + } + + /** + * @param elements values to add to the set + * @param axiom type + * @return fresh non threadsafe set + */ + @SafeVarargs + public static Set createSet(T... elements) { + return new HashSet<>(list(elements)); + } + + /** + * @param element value to add to the set + * @param axiom type + * @return fresh non threadsafe set + */ + public static Set createSet(T element) { + Set result = createSet(); + result.add(element); + return result; + } + + /** + * @param set type + * @return fresh threadsafe set + */ + public static Set createSyncSet() { + ConcurrentHashMap internalMap = createSyncMap(); + return Collections.newSetFromMap(internalMap); + } + + /** + * @param key type + * @param value type + * @return fresh threadsafe HashMap + */ + public static ConcurrentHashMap createSyncMap() { + return new ConcurrentHashMap<>(16, 0.75F, EXPECTEDTHREADS.get()); + } + + /** + * @param source the collection to lazily copy + * @param axiom type + * @return a lazy defensive copy for source; the source collection will not be copied until a + * method that modifies the collection gets called, e.g., add(), addAll() + */ + public static Set getCopyOnRequestSet(Collection source) { + return getCopyOnRequestSetFromMutableCollection(source); + } + + /** + * @param source source collection + * @param axiom type + * @return copy on request that builds a list from the input set + */ + public static Set getCopyOnRequestSetFromMutableCollection( + @Nullable Collection source) { + if (source == null || source.isEmpty()) { + return Collections.emptySet(); + } + return new ConditionalCopySet<>(source, true); + } + + /** + * @param source the source collection, expected to be immutable + * @param axiom type + * @return copy on request that does not build a list immediately + */ + public static Set copy(@Nullable Collection source) { + return getCopyOnRequestSetFromImmutableCollection(source); + } + + /** + * @param source the source collection, expected to be mutable; the backing list is created + * immediately + * @param axiom type + * @return copy on request that builds a list immediately + */ + public static Set copyMutable(@Nullable Collection source) { + return getCopyOnRequestSetFromMutableCollection(source); + } + + /** + * @param source the source collection, expected to be immutable + * @param axiom type + * @return copy on request that does not build a list immediately + */ + public static Set getCopyOnRequestSetFromImmutableCollection( + @Nullable Collection source) { + if (source == null || source.isEmpty()) { + return Collections.emptySet(); + } + return new ConditionalCopySet<>(source, false); + } + + /** + * a set implementation that uses a delegate collection for all read-only operations and makes a + * copy if changes are attempted. Useful for cheap defensive copies: no costly rehashing on the + * original collection is made unless changes are attempted. Changes are not mirrored back to + * the original collection, although changes to the original set BEFORE changes to the copy are + * reflected in the copy. If the source collection is not supposed to change, then this + * collection behaves just like a regular defensive copy; if the source collection can change, + * then this collection should be built from a cheap copy of the original collection. For + * example, if the source collection is a set, it can be copied into a list; the cost of the + * copy operation from set to list is approximately 1/3 of the cost of copying into a new + * HashSet. This is not efficient if the most common operations performed on the copy are + * contains() or containsAll(), since they are more expensive for lists wrt sets; a counter for + * these calls is maintained by the collection, so if a large number of contains/containsAll + * calls takes place, the delegate is turned into a regular set. This implementation is not + * threadsafe even if the source set is: there is no lock during the copy, and the new set is + * not threadsafe. + * + * @param the type contained + */ + public static class ConditionalCopySet implements Set { + + private static final int MAXCONTAINS = 10; + protected Collection delegate; + private boolean copyDone = false; + private int containsCounter = 0; + + /** + * @param source initial elements + * @param listCopy true if a copy must be made + */ + public ConditionalCopySet(Collection source, boolean listCopy) { + if (listCopy) { + delegate = new ArrayList<>(source); + } else { + delegate = source; + } + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == null) { + return false; + } + if (this == obj) { + return true; + } + if (obj instanceof ConditionalCopySet) { + return delegate.containsAll(((ConditionalCopySet) obj).delegate) + && ((ConditionalCopySet) obj).delegate.containsAll(delegate); + } + if (obj instanceof Collection) { + return delegate.containsAll((Collection) obj) + && ((Collection) obj).containsAll(delegate); + } + return false; + } + + @Override + public int hashCode() { + return delegate.hashCode(); + } + + @Override + public String toString() { + return delegate.toString(); + } + + @Override + public boolean add(@Nullable T e) { + if (!copyDone) { + copyDone = true; + delegate = new LinkedHashSet<>(delegate); + } + return delegate.add(e); + } + + @Override + public boolean addAll(@Nullable Collection c) { + if (!copyDone) { + copyDone = true; + delegate = new LinkedHashSet<>(delegate); + } + return delegate.addAll(c); + } + + @Override + public void clear() { + if (!copyDone) { + copyDone = true; + delegate = new LinkedHashSet<>(); + } + delegate.clear(); + } + + @Override + public boolean contains(@Nullable Object o) { + containsCounter++; + if (containsCounter >= MAXCONTAINS && !copyDone) { + checkDelegate(); + } + return delegate.contains(o); + } + + private void checkDelegate() { + // many calls to contains, inefficient if the delegate is not a + // set + if (!(delegate instanceof Set)) { + copyDone = true; + delegate = new LinkedHashSet<>(delegate); + } + } + + @Override + public boolean containsAll(@Nullable Collection c) { + containsCounter++; + if (containsCounter >= MAXCONTAINS && !copyDone) { + checkDelegate(); + } + return delegate.containsAll(c); + } + + @Override + public boolean isEmpty() { + return delegate.isEmpty(); + } + + @Override + public Iterator iterator() { + return delegate.iterator(); + } + + @Override + public boolean remove(@Nullable Object o) { + if (!copyDone) { + copyDone = true; + delegate = new LinkedHashSet<>(delegate); + } + return delegate.remove(o); + } + + @Override + public boolean removeAll(@Nullable Collection c) { + if (!copyDone) { + copyDone = true; + delegate = new LinkedHashSet<>(delegate); + } + return delegate.removeAll(c); + } + + @Override + public boolean retainAll(@Nullable Collection c) { + if (!copyDone) { + copyDone = true; + delegate = new LinkedHashSet<>(delegate); + } + return delegate.retainAll(c); + } + + @Override + public int size() { + return delegate.size(); + } + + @Override + public Object[] toArray() { + return delegate.toArray(); + } + + @Override + public Q[] toArray(@Nullable Q[] a) { + return delegate.toArray(a); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/CommonBaseIRIMapper.java b/api/src/main/java/org/semanticweb/owlapi/util/CommonBaseIRIMapper.java new file mode 100644 index 0000000000..fae6158daf --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/CommonBaseIRIMapper.java @@ -0,0 +1,67 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntologyIRIMapper; + +/** + * An ontology IRI mapper that can be used to map ontology IRIs to ontology + * document IRIs which share the same base. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class CommonBaseIRIMapper implements OWLOntologyIRIMapper { + + private final IRI base; + private final Map iriMap = new HashMap<>(); + + /** + * Creates a mapper, which maps ontology URIs to URIs which share the + * specified base. + * + * @param base the base IRI + */ + public CommonBaseIRIMapper(IRI base) { + this.base = checkNotNull(base, "base cannot be null"); + } + + /** + * Adds a mapping from an ontology IRI to an ontology document IRI which has + * a base of this mapper and a specified local name - in other words the + * document IRI will be determined by resolving the local name against the + * URI base of this mapper. + * + * @param ontologyIRI the ontology IRI + * @param localName the document IRI + */ + public void addMapping(IRI ontologyIRI, String localName) { + checkNotNull(localName, "localName cannot be null"); + checkNotNull(ontologyIRI, "ontologyIRI cannot be null"); + IRI documentIRI = base.resolve(localName); + iriMap.put(ontologyIRI, documentIRI); + } + + @Override + @Nullable + public IRI getDocumentIRI(IRI ontologyIRI) { + checkNotNull(ontologyIRI, "ontologyIRI cannot be null"); + return iriMap.get(ontologyIRI); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/Construct.java b/api/src/main/java/org/semanticweb/owlapi/util/Construct.java new file mode 100644 index 0000000000..51ce41312c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/Construct.java @@ -0,0 +1,135 @@ +package org.semanticweb.owlapi.util; + +import java.util.Arrays; +import java.util.Collections; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; + +/** + * Construct enum. + */ +public enum Construct { + //@formatter:off + /** Role restrictions (domain + * and range on data and + * object properties). */ + ROLE_DOMAIN_RANGE ("RRESTR"), + /** Atomic negations. */ + ATOMIC_NEGATION ("NEG"), + /** Complex concept negation. */ + CONCEPT_COMPLEX_NEGATION ("C"), + /** Concept union. */ + CONCEPT_UNION ("U"), + /** Concept + * intersections. */ + CONCEPT_INTERSECTION ("CINT"), + /** Universal + * restrictions. */ + UNIVERSAL_RESTRICTION ("UNIVRESTR"), + /** Limited existential + * quantifications (Top + * only). */ + LIMITED_EXISTENTIAL ("LIMEXIST"), + /** Full existential + * qualification (existential + * restrictions that have + * fillers other than top. */ + FULL_EXISTENTIAL ("E", LIMITED_EXISTENTIAL), + /** Role hierarchy + * (rdfs:subPropertyOf). */ + ROLE_HIERARCHY ("H"), + /** Transitive roles. */ + ROLE_TRANSITIVE ("+"), + /** Reflexivity and property + * chains. */ + ROLE_REFLEXIVITY_CHAINS ("Rr", ROLE_HIERARCHY, ROLE_TRANSITIVE), + /** Complex role inclusion + * axioms; irreflexivity; + * role disjointness. */ + ROLE_COMPLEX ("R", ROLE_REFLEXIVITY_CHAINS, ROLE_HIERARCHY, ROLE_TRANSITIVE), + /** Nominals. (Enumerated + * classes of object value + * restrictions: owl:oneOf, + * owl:hasValue). */ + NOMINALS ("O"), + /** Inverse properties. */ + ROLE_INVERSE ("I"), + /** Functional properties, a + * special case of uniqueness + * quantification. */ + F ("F"), + /** Cardinality restrictions + * (owl:cardinality, + * owl:maxCardinality), a + * special case of counting + * quantification. Filler + * can only be top. */ + N ("N", F), + /** Qualified cardinality + * restrictions (available + * in OWL 2, cardinality + * restrictions that have + * fillers other than top). */ + Q ("Q", N, F), + /** Use of data properties, + * data values or data types. */ + D ("(D)"), + ; + //@formatter:on + + /** + * Constructs incompatible with each other - if one is found in an ontology, the other cannot be + * found. E.g., if Rr and I are found, then Rr is upgraded to R. + */ + public static EnumSet incompatibleRoleFetures = + EnumSet.of(ROLE_REFLEXIVITY_CHAINS, ROLE_INVERSE); + + private final String s; + Set includedConstructs = Collections.emptySet(); + + Construct(String s, Construct... components) { + this.s = s; + if (components.length > 0) { + includedConstructs = new HashSet<>(Arrays.asList(components)); + } + } + + /** + * @return constructs occurring within this name. Plain constructs have no components. + */ + public Set includedConstructs() { + return includedConstructs; + } + + /** + * If this construct subsumes another construct (e.g., R subsumes role hierarchy and role + * transitivity), then the subsumed construct is removed from the set. + * + * @param constructs constructs to trim + */ + public void removeSubsumedConstructs(Set constructs) { + if (includedConstructs.isEmpty()) { + return; + } + if (constructs.contains(this)) { + constructs.removeAll(includedConstructs); + } + } + + /** + * Remove all redundant constructs from the input. + * + * @param constructs constructs to trim + */ + public static void trim(Set constructs) { + for (Construct c : values()) { + c.removeSubsumedConstructs(constructs); + } + } + + @Override + public String toString() { + return s; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/DLExpressivityChecker.java b/api/src/main/java/org/semanticweb/owlapi/util/DLExpressivityChecker.java new file mode 100644 index 0000000000..b8cb4ad139 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/DLExpressivityChecker.java @@ -0,0 +1,570 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.model.parameters.Imports.EXCLUDED; +import static org.semanticweb.owlapi.util.Construct.ATOMIC_NEGATION; +import static org.semanticweb.owlapi.util.Construct.CONCEPT_COMPLEX_NEGATION; +import static org.semanticweb.owlapi.util.Construct.CONCEPT_INTERSECTION; +import static org.semanticweb.owlapi.util.Construct.CONCEPT_UNION; +import static org.semanticweb.owlapi.util.Construct.D; +import static org.semanticweb.owlapi.util.Construct.F; +import static org.semanticweb.owlapi.util.Construct.FULL_EXISTENTIAL; +import static org.semanticweb.owlapi.util.Construct.LIMITED_EXISTENTIAL; +import static org.semanticweb.owlapi.util.Construct.N; +import static org.semanticweb.owlapi.util.Construct.NOMINALS; +import static org.semanticweb.owlapi.util.Construct.Q; +import static org.semanticweb.owlapi.util.Construct.ROLE_COMPLEX; +import static org.semanticweb.owlapi.util.Construct.ROLE_DOMAIN_RANGE; +import static org.semanticweb.owlapi.util.Construct.ROLE_HIERARCHY; +import static org.semanticweb.owlapi.util.Construct.ROLE_INVERSE; +import static org.semanticweb.owlapi.util.Construct.ROLE_REFLEXIVITY_CHAINS; +import static org.semanticweb.owlapi.util.Construct.ROLE_TRANSITIVE; +import static org.semanticweb.owlapi.util.Construct.UNIVERSAL_RESTRICTION; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; + +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataCardinalityRestriction; +import org.semanticweb.owlapi.model.OWLDataComplementOf; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectCardinalityRestriction; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectInverseOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLObjectVisitor; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class DLExpressivityChecker implements OWLObjectVisitor { + + /** + * @return Collection of Languages that include all constructs used in the ontology. Each + * language returned allows for all constructs found and has no sublanguages that also + * allow for all constructs found. E.g., if FL is returned, FL0 and FLMNUS cannot be + * returned. + */ + public Collection expressibleInLanguages() { + return Arrays.stream(Languages.values()).filter(this::minimal).collect(Collectors.toList()); + } + + /** + * @param l language to check + * @return true if l is minimal, i.e., all sublanguages of l cannot represent all the constructs + * found, but l can. + */ + public boolean minimal(Languages l) { + if (!l.components.containsAll(getOrderedConstructs())) { + // not minimal because it does not cover the constructs found + return false; + } + return Arrays.stream(Languages.values()).filter(p -> p.isSubLanguageOf(l)) + .noneMatch(this::minimal); + } + + /** + * @param l language to check + * @return true if l is sufficient to express the ontology, i.e., if all constructs found in the + * ontology are included in the language + */ + public boolean isWithin(Languages l) { + return l.components.containsAll(getOrderedConstructs()); + } + + /** + * @param c construct to check + * @return true if the matched constructs contain c. + */ + public boolean has(Construct c) { + return getOrderedConstructs().contains(c); + } + + private Set constructs; + private final List ontologies; + + /** + * @param ontologies ontologies + */ + public DLExpressivityChecker(Collection ontologies) { + this.ontologies = new ArrayList<>(ontologies); + } + + private static boolean isTop(OWLClassExpression classExpression) { + return classExpression.isOWLThing(); + } + + /** + * @return ordered constructs + */ + public List getConstructs() { + return new ArrayList<>(getOrderedConstructs()); + } + + /** + * @return DL name + */ + public String getDescriptionLogicName() { + return getOrderedConstructs().stream().map(Object::toString).collect(Collectors.joining()); + } + + private Set getOrderedConstructs() { + if (constructs == null) { + constructs = new TreeSet<>(); + ontologies.stream().flatMap(OWLOntology::logicalAxioms).forEach(ax -> ax.accept(this)); + } + Construct.trim(constructs); + return constructs; + } + + private void addConstruct(Construct c) { + if (constructs == null) { + constructs = new TreeSet<>(); + } + // Rr+I = R + I + if (c == ROLE_INVERSE && constructs.contains(ROLE_REFLEXIVITY_CHAINS)) { + constructs.add(c); + constructs.remove(ROLE_REFLEXIVITY_CHAINS); + constructs.add(ROLE_COMPLEX); + } else if (c == ROLE_REFLEXIVITY_CHAINS && constructs.contains(ROLE_INVERSE)) { + constructs.add(ROLE_COMPLEX); + } else { + constructs.add(c); + } + } + + private boolean isAtomic(OWLClassExpression classExpression) { + if (classExpression.isAnonymous()) { + return false; + } + return ontologies.stream() + .noneMatch(ont -> ont.axioms((OWLClass) classExpression, EXCLUDED).count() > 0); + } + + private void checkCardinality(OWLDataCardinalityRestriction restriction) { + if (restriction.isQualified()) { + addConstruct(Q); + } else { + addConstruct(N); + } + restriction.getFiller().accept(this); + restriction.getProperty().accept(this); + } + + private void checkCardinality(OWLObjectCardinalityRestriction restriction) { + if (restriction.isQualified()) { + addConstruct(Q); + } else { + addConstruct(N); + } + restriction.getFiller().accept(this); + restriction.getProperty().accept(this); + } + + // Property expression + @Override + public void visit(OWLObjectInverseOf property) { + addConstruct(ROLE_INVERSE); + } + + @Override + public void visit(OWLDataProperty property) { + addConstruct(D); + } + + // Data stuff + @Override + public void visit(OWLDataComplementOf node) { + addConstruct(D); + } + + @Override + public void visit(OWLDataOneOf node) { + addConstruct(D); + } + + @Override + public void visit(OWLDatatypeRestriction node) { + addConstruct(D); + } + + @Override + public void visit(OWLLiteral node) { + addConstruct(D); + } + + @Override + public void visit(OWLFacetRestriction node) { + addConstruct(D); + } + + // class expressions + @Override + public void visit(OWLObjectIntersectionOf ce) { + addConstruct(CONCEPT_INTERSECTION); + ce.operands().forEach(o -> o.accept(this)); + } + + @Override + public void visit(OWLObjectUnionOf ce) { + addConstruct(CONCEPT_UNION); + ce.operands().forEach(o -> o.accept(this)); + } + + @Override + public void visit(OWLObjectComplementOf ce) { + if (isAtomic(ce)) { + addConstruct(ATOMIC_NEGATION); + } else { + addConstruct(CONCEPT_COMPLEX_NEGATION); + } + ce.getOperand().accept(this); + } + + @Override + public void visit(OWLObjectSomeValuesFrom ce) { + if (isTop(ce.getFiller())) { + addConstruct(LIMITED_EXISTENTIAL); + } else { + addConstruct(FULL_EXISTENTIAL); + } + ce.getProperty().accept(this); + ce.getFiller().accept(this); + } + + @Override + public void visit(OWLObjectAllValuesFrom ce) { + addConstruct(UNIVERSAL_RESTRICTION); + ce.getProperty().accept(this); + ce.getFiller().accept(this); + } + + @Override + public void visit(OWLObjectHasValue ce) { + addConstruct(NOMINALS); + addConstruct(FULL_EXISTENTIAL); + ce.getProperty().accept(this); + } + + @Override + public void visit(OWLObjectMinCardinality ce) { + checkCardinality(ce); + } + + @Override + public void visit(OWLObjectExactCardinality ce) { + checkCardinality(ce); + } + + @Override + public void visit(OWLObjectMaxCardinality ce) { + checkCardinality(ce); + } + + @Override + public void visit(OWLObjectHasSelf ce) { + ce.getProperty().accept(this); + addConstruct(ROLE_COMPLEX); + } + + @Override + public void visit(OWLObjectOneOf ce) { + addConstruct(CONCEPT_UNION); + addConstruct(NOMINALS); + } + + @Override + public void visit(OWLDataSomeValuesFrom ce) { + addConstruct(FULL_EXISTENTIAL); + ce.getFiller().accept(this); + ce.getProperty().accept(this); + } + + @Override + public void visit(OWLDataAllValuesFrom ce) { + ce.getFiller().accept(this); + ce.getProperty().accept(this); + } + + @Override + public void visit(OWLDataHasValue ce) { + addConstruct(D); + ce.getProperty().accept(this); + } + + @Override + public void visit(OWLDataMinCardinality ce) { + checkCardinality(ce); + } + + @Override + public void visit(OWLDataExactCardinality ce) { + checkCardinality(ce); + } + + @Override + public void visit(OWLDataMaxCardinality ce) { + checkCardinality(ce); + } + + // Axioms + @Override + public void visit(OWLSubClassOfAxiom axiom) { + axiom.getSubClass().accept(this); + axiom.getSuperClass().accept(this); + } + + @Override + public void visit(OWLNegativeObjectPropertyAssertionAxiom axiom) { + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLAsymmetricObjectPropertyAxiom axiom) { + addConstruct(ROLE_COMPLEX); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLReflexiveObjectPropertyAxiom axiom) { + addConstruct(ROLE_REFLEXIVITY_CHAINS); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLDisjointClassesAxiom axiom) { + addConstruct(CONCEPT_COMPLEX_NEGATION); + axiom.classExpressions().forEach(o -> o.accept(this)); + } + + @Override + public void visit(OWLDataPropertyDomainAxiom axiom) { + addConstruct(ROLE_DOMAIN_RANGE); + addConstruct(D); + axiom.getDomain().accept(this); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLObjectPropertyDomainAxiom axiom) { + addConstruct(ROLE_DOMAIN_RANGE); + axiom.getDomain().accept(this); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLEquivalentObjectPropertiesAxiom axiom) { + addConstruct(ROLE_HIERARCHY); + axiom.properties().forEach(o -> o.accept(this)); + } + + @Override + public void visit(OWLNegativeDataPropertyAssertionAxiom axiom) { + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLDifferentIndividualsAxiom axiom) { + addConstruct(CONCEPT_UNION); + addConstruct(NOMINALS); + addConstruct(CONCEPT_COMPLEX_NEGATION); + } + + @Override + public void visit(OWLDisjointDataPropertiesAxiom axiom) { + addConstruct(D); + axiom.properties().forEach(prop -> prop.accept(this)); + } + + @Override + public void visit(OWLDisjointObjectPropertiesAxiom axiom) { + addConstruct(ROLE_COMPLEX); + axiom.properties().forEach(o -> o.accept(this)); + } + + @Override + public void visit(OWLObjectPropertyRangeAxiom axiom) { + addConstruct(ROLE_DOMAIN_RANGE); + axiom.getRange().accept(this); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLObjectPropertyAssertionAxiom axiom) { + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLFunctionalObjectPropertyAxiom axiom) { + addConstruct(F); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLSubObjectPropertyOfAxiom axiom) { + addConstruct(ROLE_HIERARCHY); + axiom.getSubProperty().accept(this); + axiom.getSuperProperty().accept(this); + } + + @Override + public void visit(OWLDisjointUnionAxiom axiom) { + addConstruct(CONCEPT_UNION); + addConstruct(CONCEPT_COMPLEX_NEGATION); + axiom.classExpressions().forEach(o -> o.accept(this)); + } + + @Override + public void visit(OWLSymmetricObjectPropertyAxiom axiom) { + addConstruct(ROLE_INVERSE); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLDataPropertyRangeAxiom axiom) { + addConstruct(ROLE_DOMAIN_RANGE); + addConstruct(D); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLFunctionalDataPropertyAxiom axiom) { + addConstruct(F); + addConstruct(D); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLEquivalentDataPropertiesAxiom axiom) { + addConstruct(ROLE_HIERARCHY); + addConstruct(D); + axiom.properties().forEach(o -> o.accept(this)); + } + + @Override + public void visit(OWLClassAssertionAxiom axiom) { + axiom.getClassExpression().accept(this); + } + + @Override + public void visit(OWLEquivalentClassesAxiom axiom) { + axiom.classExpressions().forEach(o -> o.accept(this)); + } + + @Override + public void visit(OWLDataPropertyAssertionAxiom axiom) { + addConstruct(D); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLTransitiveObjectPropertyAxiom axiom) { + addConstruct(ROLE_TRANSITIVE); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLIrreflexiveObjectPropertyAxiom axiom) { + addConstruct(ROLE_COMPLEX); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLSubDataPropertyOfAxiom axiom) { + addConstruct(ROLE_HIERARCHY); + addConstruct(D); + } + + @Override + public void visit(OWLInverseFunctionalObjectPropertyAxiom axiom) { + addConstruct(ROLE_INVERSE); + addConstruct(F); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLSameIndividualAxiom axiom) { + addConstruct(NOMINALS); + } + + @Override + public void visit(OWLSubPropertyChainOfAxiom axiom) { + addConstruct(ROLE_REFLEXIVITY_CHAINS); + axiom.getPropertyChain().forEach(o -> o.accept(this)); + axiom.getSuperProperty().accept(this); + } + + @Override + public void visit(OWLInverseObjectPropertiesAxiom axiom) { + addConstruct(ROLE_INVERSE); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/DefaultPrefixManager.java b/api/src/main/java/org/semanticweb/owlapi/util/DefaultPrefixManager.java new file mode 100644 index 0000000000..a2e18c8bf8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/DefaultPrefixManager.java @@ -0,0 +1,265 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.io.XMLUtils; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.model.PrefixManager; +import org.semanticweb.owlapi.vocab.Namespaces; + +/** + * @author Matthew Horridge, The University Of Manchester, Information Management Group + * @since 2.2.0 + */ +public class DefaultPrefixManager + implements PrefixManager, ShortFormProvider, IRIShortFormProvider { + + private final Map reverseprefix2NamespaceMap; + // XXX config + private Map prefix2NamespaceMap; + private StringComparator comparator; + + /** + * @param defaultPrefix default prefix + */ + public DefaultPrefixManager(@Nullable String defaultPrefix) { + this(null, null, defaultPrefix); + } + + /** + * @param pm the prefix manager to copy + * @param c comparator to sort prefixes + * @param defaultPrefix default prefix + */ + public DefaultPrefixManager(@Nullable PrefixManager pm, @Nullable StringComparator c, + @Nullable String defaultPrefix) { + comparator = c == null ? new StringLengthComparator() : c; + prefix2NamespaceMap = new TreeMap<>(comparator); + reverseprefix2NamespaceMap = new TreeMap<>(comparator); + setupDefaultPrefixes(); + if (pm != null) { + copyPrefixesFrom(pm); + } + if (defaultPrefix != null) { + setDefaultPrefix(defaultPrefix); + } + } + + /** + * Default constructor setting the comparator to string length comparator. + */ + public DefaultPrefixManager() { + this(null, null, null); + } + + @Override + public StringComparator getPrefixComparator() { + return comparator; + } + + @Override + public void setPrefixComparator(StringComparator comparator) { + checkNotNull(comparator, "comparator cannot be null"); + this.comparator = comparator; + Map p = prefix2NamespaceMap; + prefix2NamespaceMap = new TreeMap<>(comparator); + prefix2NamespaceMap.putAll(p); + } + + @Override + public void clear() { + prefix2NamespaceMap.clear(); + reverseprefix2NamespaceMap.clear(); + } + + @Override + public Stream prefixNames() { + return prefix2NamespaceMap.keySet().stream(); + } + + private void setupDefaultPrefixes() { + setPrefix("owl:", Namespaces.OWL.toString()); + setPrefix("rdfs:", Namespaces.RDFS.toString()); + setPrefix("rdf:", Namespaces.RDF.toString()); + setPrefix("xsd:", Namespaces.XSD.toString()); + setPrefix("xml:", Namespaces.XML.toString()); + } + + @Override + @Nullable + public String getPrefixIRI(IRI iri) { + String prefix = reverseprefix2NamespaceMap.get(iri.getNamespace()); + if (prefix == null) { + String iriString = iri.toString(); + String prefixed = null; + for (String s : reverseprefix2NamespaceMap.keySet()) { + if (iriString.startsWith(s) && XMLUtils.isQName(iriString, s.length())) { + prefix = reverseprefix2NamespaceMap.get(s); + prefixed = iriString.replace(s, prefix); + } + } + if (prefixed != null && XMLUtils.isQName(prefixed)) { + return prefixed; + } + } + if (prefix == null) { + return null; + } + return iri.prefixedBy(prefix); + } + + @Override + public String getPrefixIRIIgnoreQName(IRI iri) { + String prefix = reverseprefix2NamespaceMap.get(iri.getNamespace()); + if (prefix == null) { + String iriString = iri.toString(); + String prefixed = null; + for (String s : reverseprefix2NamespaceMap.keySet()) { + if (iriString.startsWith(s) && XMLUtils.isQName(iriString, s.length())) { + prefix = reverseprefix2NamespaceMap.get(s); + prefixed = iriString.replace(s, prefix); + } + } + if (prefixed != null) { + return prefixed; + } + } + if (prefix == null) { + return null; + } + return iri.prefixedBy(prefix); + } + + @Override + @Nullable + public String getDefaultPrefix() { + return prefix2NamespaceMap.get(":"); + } + + @Override + public void setDefaultPrefix(@Nullable String defaultPrefix) { + String prefixToUnregister = prefix2NamespaceMap.get(":"); + if (prefixToUnregister != null) { + prefix2NamespaceMap.remove(":"); + reverseprefix2NamespaceMap.remove(prefixToUnregister, ":"); + } + if (defaultPrefix == null) { + return; + } + prefix2NamespaceMap.put(":", defaultPrefix); + if (!reverseprefix2NamespaceMap.containsKey(defaultPrefix)) { + reverseprefix2NamespaceMap.put(defaultPrefix, ":"); + } + } + + @Override + public boolean containsPrefixMapping(String prefixName) { + return prefix2NamespaceMap.get(prefixName) != null; + } + + @Override + public void copyPrefixesFrom(PrefixManager from) { + copyPrefixesFrom(from.getPrefixName2PrefixMap()); + } + + @Override + public void copyPrefixesFrom(Map from) { + from.forEach(this::setPrefix); + } + + @Override + public IRI getIRI(String prefixIRI) { + if (prefixIRI.startsWith("<")) { + return IRI.create(prefixIRI.substring(1, prefixIRI.length() - 1)); + } + int sep = prefixIRI.indexOf(':'); + if (sep == -1) { + if (getDefaultPrefix() == null) { + return IRI.create(prefixIRI); + } + return IRI.create(getDefaultPrefix() + prefixIRI); + } else { + String prefixName = prefixIRI.substring(0, sep + 1); + if (!containsPrefixMapping(prefixName)) { + throw new OWLRuntimeException( + "Prefix not registered for prefix name: " + prefixName); + } + String prefix = getPrefix(prefixName); + String localName = prefixIRI.substring(sep + 1); + return IRI.create(prefix, localName); + } + } + + @Override + public Map getPrefixName2PrefixMap() { + return Collections.unmodifiableMap(prefix2NamespaceMap); + } + + @Override + @Nullable + public String getPrefix(String prefixName) { + return prefix2NamespaceMap.get(prefixName); + } + + @Override + public void setPrefix(String inputPrefixName, String prefix) { + checkNotNull(inputPrefixName, "prefixName cannot be null"); + checkNotNull(prefix, "prefix cannot be null"); + String _prefixName = inputPrefixName; + if (!_prefixName.endsWith(":")) { + _prefixName += ":"; + } + prefix2NamespaceMap.put(_prefixName, prefix); + reverseprefix2NamespaceMap.put(prefix, _prefixName); + } + + @Override + public void unregisterNamespace(String namespace) { + List toRemove = new ArrayList<>(); + prefix2NamespaceMap.forEach((k, v) -> { + if (v.equals(namespace)) { + toRemove.add(k); + } + }); + reverseprefix2NamespaceMap.remove(namespace); + prefix2NamespaceMap.keySet().removeAll(toRemove); + } + + @Override + public String getShortForm(IRI iri) { + String sf = getPrefixIRI(iri); + if (sf == null) { + return iri.toQuotedString(); + } else { + return sf; + } + } + + @Override + public String getShortForm(OWLEntity entity) { + return getShortForm(entity.getIRI()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/DelegatingObjectVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/util/DelegatingObjectVisitorEx.java new file mode 100644 index 0000000000..6306496a48 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/DelegatingObjectVisitorEx.java @@ -0,0 +1,542 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataComplementOf; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataIntersectionOf; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDataUnionOf; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLHasKeyAxiom; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectInverseOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLObjectVisitorEx; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; +import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.SWRLBuiltInAtom; +import org.semanticweb.owlapi.model.SWRLClassAtom; +import org.semanticweb.owlapi.model.SWRLDataPropertyAtom; +import org.semanticweb.owlapi.model.SWRLDataRangeAtom; +import org.semanticweb.owlapi.model.SWRLDifferentIndividualsAtom; +import org.semanticweb.owlapi.model.SWRLIndividualArgument; +import org.semanticweb.owlapi.model.SWRLLiteralArgument; +import org.semanticweb.owlapi.model.SWRLObjectPropertyAtom; +import org.semanticweb.owlapi.model.SWRLRule; +import org.semanticweb.owlapi.model.SWRLSameIndividualAtom; +import org.semanticweb.owlapi.model.SWRLVariable; + +/** + * A delegating visitor. This utility class can be used to override visiting a particular type of + * object. + * + * @param the returned type + * @author Matthew Horridge, The University Of Manchester, Information Management Group + * @since 2.2.0 + */ +public class DelegatingObjectVisitorEx implements OWLObjectVisitorEx { + + private final OWLObjectVisitorEx delegate; + + /** + * Constructs a visitor where the specified delegate will be used to visit all objects unless + * one of the visit methods in this visitor is overridden. + * + * @param delegate The delegate. + */ + public DelegatingObjectVisitorEx(OWLObjectVisitorEx delegate) { + this.delegate = delegate; + } + + @Override + public O visit(OWLAsymmetricObjectPropertyAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLClassAssertionAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLDataPropertyAssertionAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLDataPropertyDomainAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLDataPropertyRangeAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLSubDataPropertyOfAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLDeclarationAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLDifferentIndividualsAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLDisjointClassesAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLDisjointDataPropertiesAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLDisjointObjectPropertiesAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLDisjointUnionAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLAnnotationAssertionAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLEquivalentClassesAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLEquivalentDataPropertiesAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLEquivalentObjectPropertiesAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLFunctionalDataPropertyAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLFunctionalObjectPropertyAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLInverseFunctionalObjectPropertyAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLInverseObjectPropertiesAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLIrreflexiveObjectPropertyAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLNegativeDataPropertyAssertionAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLNegativeObjectPropertyAssertionAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLObjectPropertyAssertionAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLSubPropertyChainOfAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLObjectPropertyDomainAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLObjectPropertyRangeAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLSubObjectPropertyOfAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLReflexiveObjectPropertyAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLSameIndividualAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLSubClassOfAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLSymmetricObjectPropertyAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLTransitiveObjectPropertyAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(SWRLRule rule) { + return delegate.visit(rule); + } + + @Override + public O visit(OWLClass ce) { + return delegate.visit(ce); + } + + @Override + public O visit(OWLDataAllValuesFrom ce) { + return delegate.visit(ce); + } + + @Override + public O visit(OWLDataExactCardinality ce) { + return delegate.visit(ce); + } + + @Override + public O visit(OWLDataMaxCardinality ce) { + return delegate.visit(ce); + } + + @Override + public O visit(OWLDataMinCardinality ce) { + return delegate.visit(ce); + } + + @Override + public O visit(OWLDataSomeValuesFrom ce) { + return delegate.visit(ce); + } + + @Override + public O visit(OWLDataHasValue ce) { + return delegate.visit(ce); + } + + @Override + public O visit(OWLObjectAllValuesFrom ce) { + return delegate.visit(ce); + } + + @Override + public O visit(OWLObjectComplementOf ce) { + return delegate.visit(ce); + } + + @Override + public O visit(OWLObjectExactCardinality ce) { + return delegate.visit(ce); + } + + @Override + public O visit(OWLObjectIntersectionOf ce) { + return delegate.visit(ce); + } + + @Override + public O visit(OWLObjectMaxCardinality ce) { + return delegate.visit(ce); + } + + @Override + public O visit(OWLObjectMinCardinality ce) { + return delegate.visit(ce); + } + + @Override + public O visit(OWLObjectOneOf ce) { + return delegate.visit(ce); + } + + @Override + public O visit(OWLObjectHasSelf ce) { + return delegate.visit(ce); + } + + @Override + public O visit(OWLObjectSomeValuesFrom ce) { + return delegate.visit(ce); + } + + @Override + public O visit(OWLObjectUnionOf ce) { + return delegate.visit(ce); + } + + @Override + public O visit(OWLObjectHasValue ce) { + return delegate.visit(ce); + } + + @Override + public O visit(OWLDataComplementOf node) { + return delegate.visit(node); + } + + @Override + public O visit(OWLDataOneOf node) { + return delegate.visit(node); + } + + @Override + public O visit(OWLFacetRestriction node) { + return delegate.visit(node); + } + + @Override + public O visit(OWLDatatypeRestriction node) { + return delegate.visit(node); + } + + @Override + public O visit(OWLDatatype node) { + return delegate.visit(node); + } + + @Override + public O visit(OWLLiteral node) { + return delegate.visit(node); + } + + @Override + public O visit(OWLDataProperty property) { + return delegate.visit(property); + } + + @Override + public O visit(OWLObjectProperty property) { + return delegate.visit(property); + } + + @Override + public O visit(OWLObjectInverseOf property) { + return delegate.visit(property); + } + + @Override + public O visit(SWRLLiteralArgument node) { + return delegate.visit(node); + } + + @Override + public O visit(SWRLVariable node) { + return delegate.visit(node); + } + + @Override + public O visit(SWRLIndividualArgument node) { + return delegate.visit(node); + } + + @Override + public O visit(SWRLBuiltInAtom node) { + return delegate.visit(node); + } + + @Override + public O visit(SWRLClassAtom node) { + return delegate.visit(node); + } + + @Override + public O visit(SWRLDataRangeAtom node) { + return delegate.visit(node); + } + + @Override + public O visit(SWRLDataPropertyAtom node) { + return delegate.visit(node); + } + + @Override + public O visit(SWRLDifferentIndividualsAtom node) { + return delegate.visit(node); + } + + @Override + public O visit(SWRLObjectPropertyAtom node) { + return delegate.visit(node); + } + + @Override + public O visit(SWRLSameIndividualAtom node) { + return delegate.visit(node); + } + + @Override + public O visit(OWLOntology ontology) { + return delegate.visit(ontology); + } + + @Override + public O visit(OWLAnnotation node) { + return delegate.visit(node); + } + + @Override + public O visit(OWLAnnotationPropertyDomainAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLAnnotationPropertyRangeAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLSubAnnotationPropertyOfAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLAnnotationProperty property) { + return delegate.visit(property); + } + + @Override + public O visit(OWLHasKeyAxiom axiom) { + return delegate.visit(axiom); + } + + @Override + public O visit(OWLDataIntersectionOf node) { + return delegate.visit(node); + } + + @Override + public O visit(OWLDataUnionOf node) { + return delegate.visit(node); + } + + @Override + public O visit(OWLNamedIndividual individual) { + return delegate.visit(individual); + } + + @Override + public O visit(OWLAnonymousIndividual individual) { + return delegate.visit(individual); + } + + @Override + public O visit(IRI iri) { + return delegate.visit(iri); + } + + @Override + public O visit(OWLDatatypeDefinitionAxiom axiom) { + return delegate.visit(axiom); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/EscapeUtils.java b/api/src/main/java/org/semanticweb/owlapi/util/EscapeUtils.java new file mode 100644 index 0000000000..eebd0e2ab6 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/EscapeUtils.java @@ -0,0 +1,83 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public final class EscapeUtils { + + private EscapeUtils() { + } + + /** + * Escapes quotes and backslashes in a string. Double quotes are replaced + * with a backslash followed by a double quote, and backslashes are replaced + * with a double backslash. + * + * @param s The string to be escaped + * @return The escaped string. + */ + public static String escapeString(String s) { + // We replace double quotes with a back slash followed + // by a double quote. We replace backslashes with a double + // backslash + if (s.indexOf('\"') == -1 && s.indexOf('\\') == -1) { + return s; + } + StringBuilder sb = new StringBuilder(s.length() + 20); + for (int i = 0; i < s.length(); i++) { + char ch = s.charAt(i); + if (ch == '\\') { + sb.append("\\\\"); + } else if (ch == '\"') { + sb.append("\\\""); + } else { + sb.append(ch); + } + } + return verifyNotNull(sb.toString()); + } + + /** + * @param s string to unescape + * @return the unescaped string + */ + public static String unescapeString(String s) { + if (s.indexOf('\\') == -1) { + return s; + } + StringBuilder sb = new StringBuilder(s.length()); + for (int i = 0; i < s.length(); i++) { + char ch = s.charAt(i); + if (ch == '\\') { + int j = i + 1; + if (j < s.length()) { + char escCh = s.charAt(j); + if (escCh == '\\' || escCh == '\"') { + i++; + sb.append(escCh); + } + } else { + sb.append('\\'); + } + } else { + sb.append(ch); + } + } + return sb.toString(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/FilteringOWLOntologyChangeListener.java b/api/src/main/java/org/semanticweb/owlapi/util/FilteringOWLOntologyChangeListener.java new file mode 100644 index 0000000000..212f617308 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/FilteringOWLOntologyChangeListener.java @@ -0,0 +1,35 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.List; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyChangeListener; + +/** + * Incorporates a listener into an {@code OWLOntologyChangeFilter}. This + * listener listens to and processes axiom added and axiom removed changes. To + * filter out axioms of interest, override the appropriate {@code visit} method + * - see {@code OWLOntologyChangeFilter} for more details. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class FilteringOWLOntologyChangeListener extends OWLOntologyChangeFilter implements + OWLOntologyChangeListener { + + @Override + public void ontologiesChanged(List changes) { + processChanges(changes); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/HasPriorityComparator.java b/api/src/main/java/org/semanticweb/owlapi/util/HasPriorityComparator.java new file mode 100644 index 0000000000..3125034284 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/HasPriorityComparator.java @@ -0,0 +1,45 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.io.Serializable; +import java.util.Comparator; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.annotations.HasPriority; + +/** + * Comparator for objects with HasPriority annotations. Objects without + * HasPriority are considered to have lowest priority (Double.MAX_VALUE). + * + * @param comparator type + * @author ignazio + */ +public class HasPriorityComparator implements Comparator, Serializable { + + private static double getPriority(@Nullable Object p) { + HasPriority priority = checkNotNull(p).getClass().getAnnotation(HasPriority.class); + if (priority != null) { + return priority.value(); + } + // if the object does not have a priority annotation, only use + // it last + return Double.MAX_VALUE; + } + + @Override + public int compare(@Nullable T o1, @Nullable T o2) { + return Double.compare(getPriority(o1), getPriority(o2)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/HornAxiomVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/util/HornAxiomVisitorEx.java new file mode 100644 index 0000000000..6d3af3d12b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/HornAxiomVisitorEx.java @@ -0,0 +1,257 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import javax.annotation.Nonnull; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLAxiomVisitorEx; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; + +/** + * Returns true if the visited axioms are an ontology in Horn-SHIQ form. + */ +public class HornAxiomVisitorEx implements OWLAxiomVisitorEx { + + private final PositiveAppearanceVisitorEx positive = new PositiveAppearanceVisitorEx(); + private final NegativeAppearanceVisitorEx negative = new NegativeAppearanceVisitorEx(); + + protected boolean checkNegative(OWLClassExpression c) { + return c.accept(negative).booleanValue(); + } + + protected boolean checkPositive(OWLClassExpression c) { + return c.accept(positive).booleanValue(); + } + + @Override + public Boolean doDefault(Object object) { + return Boolean.FALSE; + } + + @Override + public Boolean visit(OWLSubAnnotationPropertyOfAxiom axiom) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLAnnotationPropertyDomainAxiom axiom) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLAnnotationPropertyRangeAxiom axiom) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(@Nonnull OWLSubClassOfAxiom axiom) { + return Boolean + .valueOf(checkNegative(axiom.getSubClass()) && checkNegative(axiom.getSuperClass())); + } + + @Override + public Boolean visit(OWLDisjointClassesAxiom axiom) { + return Boolean.valueOf(!axiom.classExpressions().anyMatch(c -> !checkNegative(c))); + } + + @Override + public Boolean visit(OWLObjectPropertyDomainAxiom axiom) { + return Boolean.valueOf(checkPositive(axiom.getDomain())); + } + + @Override + public Boolean visit(OWLEquivalentObjectPropertiesAxiom axiom) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLObjectPropertyRangeAxiom axiom) { + return Boolean.valueOf(checkPositive(axiom.getRange())); + } + + @Override + public Boolean visit(OWLFunctionalObjectPropertyAxiom axiom) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLSubObjectPropertyOfAxiom axiom) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLDisjointUnionAxiom axiom) { + if (neitherPositiveNorNegative(axiom.getOWLClass()).booleanValue()) { + return Boolean.FALSE; + } + return Boolean + .valueOf(!axiom.classExpressions().anyMatch(this::neitherPositiveNorNegative)); + } + + protected Boolean neitherPositiveNorNegative(OWLClassExpression c1) { + return Boolean.valueOf(!checkPositive(c1) || !checkNegative(c1)); + } + + @Override + public Boolean visit(OWLDeclarationAxiom axiom) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLAnnotationAssertionAxiom axiom) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLSymmetricObjectPropertyAxiom axiom) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLEquivalentClassesAxiom axiom) { + return Boolean + .valueOf(!axiom.classExpressions().anyMatch(this::neitherPositiveNorNegative)); + } + + @Override + public Boolean visit(OWLTransitiveObjectPropertyAxiom axiom) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLInverseFunctionalObjectPropertyAxiom axiom) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLInverseObjectPropertiesAxiom axiom) { + return Boolean.TRUE; + } + + private class PositiveAppearanceVisitorEx implements OWLClassExpressionVisitorEx { + + PositiveAppearanceVisitorEx() { + } + + @Override + public Boolean doDefault(Object object) { + return Boolean.FALSE; + } + + @Override + public Boolean visit(OWLClass ce) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLObjectIntersectionOf ce) { + return Boolean.valueOf(!ce.operands().anyMatch(c -> c.accept(this) == Boolean.FALSE)); + } + + @Override + public Boolean visit(OWLObjectComplementOf ce) { + return Boolean.valueOf(checkNegative(ce.getOperand())); + } + + @Override + public Boolean visit(OWLObjectSomeValuesFrom ce) { + return ce.getFiller().accept(this); + } + + @Override + public Boolean visit(OWLObjectAllValuesFrom ce) { + return ce.getFiller().accept(this); + } + + @Override + public Boolean visit(OWLObjectMinCardinality ce) { + return ce.getFiller().accept(this); + } + + @Override + public Boolean visit(OWLObjectExactCardinality ce) { + return Boolean + .valueOf(ce.getCardinality() <= 1 && ce.getFiller().accept(this).booleanValue() + && checkNegative(ce.getFiller())); + } + + @Override + public Boolean visit(OWLObjectMaxCardinality ce) { + return Boolean.valueOf(ce.getCardinality() <= 1 && checkNegative(ce.getFiller())); + } + } + + private class NegativeAppearanceVisitorEx implements OWLClassExpressionVisitorEx { + + NegativeAppearanceVisitorEx() { + } + + @Override + public Boolean doDefault(Object object) { + return Boolean.FALSE; + } + + @Override + public Boolean visit(OWLClass ce) { + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLObjectIntersectionOf ce) { + return Boolean.valueOf(!ce.operands().anyMatch(c -> c.accept(this) == Boolean.FALSE)); + } + + @Override + public Boolean visit(OWLObjectUnionOf ce) { + return Boolean.valueOf(!ce.operands().anyMatch(c -> c.accept(this) == Boolean.FALSE)); + } + + @Override + public Boolean visit(OWLObjectSomeValuesFrom ce) { + return ce.getFiller().accept(this); + } + + @Override + public Boolean visit(OWLObjectMinCardinality ce) { + return Boolean + .valueOf(ce.getCardinality() <= 1 && ce.getFiller().accept(this).booleanValue()); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/IRIComparator.java b/api/src/main/java/org/semanticweb/owlapi/util/IRIComparator.java new file mode 100644 index 0000000000..82e8bcf974 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/IRIComparator.java @@ -0,0 +1,45 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import java.io.Serializable; +import java.util.Comparator; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.IRI; + +/** + * A ShortFormProvider based comparator for IRIs. IRIs are sorted according to + * their short forms. + * + * @author ignazio + * @since 4.0.0 + */ +public class IRIComparator implements Comparator, Serializable { + + private final IRIShortFormProvider iriShortFormProvider; + + /** + * @param iriShortFormProvider IRI short form provider + */ + public IRIComparator(IRIShortFormProvider iriShortFormProvider) { + this.iriShortFormProvider = iriShortFormProvider; + } + + @Override + public int compare(@Nullable IRI o1, @Nullable IRI o2) { + return iriShortFormProvider.getShortForm(verifyNotNull(o1)) + .compareTo(iriShortFormProvider.getShortForm(verifyNotNull(o2))); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/IRIShortFormProvider.java b/api/src/main/java/org/semanticweb/owlapi/util/IRIShortFormProvider.java new file mode 100644 index 0000000000..ca80b34736 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/IRIShortFormProvider.java @@ -0,0 +1,32 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.io.Serializable; +import org.semanticweb.owlapi.model.IRI; + +/** + * A short form provider that produces short forms for URIs. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +@FunctionalInterface +public interface IRIShortFormProvider extends Serializable { + + /** + * @param iri the IRI to shorten + * @return the short form + */ + String getShortForm(IRI iri); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/ImportsStructureEntitySorter.java b/api/src/main/java/org/semanticweb/owlapi/util/ImportsStructureEntitySorter.java new file mode 100644 index 0000000000..7038b71474 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/ImportsStructureEntitySorter.java @@ -0,0 +1,30 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class ImportsStructureEntitySorter extends ImportsStructureObjectSorter { + + /** + * @param ontology the ontology + */ + public ImportsStructureEntitySorter(OWLOntology ontology) { + super(ontology, OWLOntology::signature); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/ImportsStructureObjectSorter.java b/api/src/main/java/org/semanticweb/owlapi/util/ImportsStructureObjectSorter.java new file mode 100644 index 0000000000..e6ed489ec2 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/ImportsStructureObjectSorter.java @@ -0,0 +1,92 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * Sorts objects into sets based on where they appear in the imports closure of + * an ontology. Consider ontology B that imports ontology A. A map will be + * generated that maps each ontology, A, B, to a set of objects that are + * associated with the ontology. If an object is associated with ontology A and + * associated with ontology B then it will only appear in the set of objects + * that are associated with ontology A since A appears higher up the imports + * closure. An example of the use of this class is to obtain a map of ontologies + * to sets of entities where each set of entities contains entities that are + * first mentioned in the ontology that maps to them. + * + * @param the type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @see org.semanticweb.owlapi.util.ImportsStructureEntitySorter + * @since 2.2.0 + */ +public class ImportsStructureObjectSorter { + + private final OWLOntology ontology; + private final ObjectSelector objectSelector; + + /** + * Creates a sorter for the specified ontology, whose imports closure is + * obtained with the specified manager, and for each ontology whose objects + * are selected using the specified object selector. + * + * @param ontology The ontology + * @param objectSelector The selector that will be used to select objects that are associated + * with each ontology. + */ + public ImportsStructureObjectSorter(OWLOntology ontology, ObjectSelector objectSelector) { + this.ontology = checkNotNull(ontology, "ontology cannot be null"); + this.objectSelector = checkNotNull(objectSelector, "objectSelector cannot be null"); + } + + /** + * Gets a map that maps ontologies to sets of associated objects. The + * ontologies will be the ontologies that are contained in the imports + * closure of the original specified ontology. + * + * @return The map. + */ + public Map> getObjects() { + List imports = asList(ontology.importsClosure()); + Collections.reverse(imports); + Map> ontology2EntityMap = new HashMap<>(); + Set processed = new HashSet<>(); + imports.forEach(ont -> ontology2EntityMap + .put(ont, asSet(objectSelector.objects(ont).filter(processed::add)))); + return ontology2EntityMap; + } + + /** + * @param type of selected objects + */ + @FunctionalInterface + public interface ObjectSelector { + + /** + * @param ontology the ontology to explore + * @return set of objects selected + */ + Stream objects(OWLOntology ontology); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/IndividualAppearance.java b/api/src/main/java/org/semanticweb/owlapi/util/IndividualAppearance.java new file mode 100644 index 0000000000..ccee6073c2 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/IndividualAppearance.java @@ -0,0 +1,17 @@ +package org.semanticweb.owlapi.util; + +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; + +/** + * An interface for checking if an anonymous individual is references multiple + * times as object of a statement. This requires an id to be emitted. + */ +@FunctionalInterface +public interface IndividualAppearance { + + /** + * @param i an anonymous individual + * @return true if i appears more than once as object. + */ + boolean appearsMultipleTimes(OWLAnonymousIndividual i); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/InferredAxiomGenerator.java b/api/src/main/java/org/semanticweb/owlapi/util/InferredAxiomGenerator.java new file mode 100644 index 0000000000..e8fd85070b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/InferredAxiomGenerator.java @@ -0,0 +1,44 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.Set; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.reasoner.OWLReasoner; + +/** + * Given a reasoner, implementations of this interface generate axioms that + * represent inferred information. For example, an implementation might generate + * the necessary subclass axioms that represent the inferred class subsumption + * hierarchy within the reasoner. It is assumed that axioms generated reflect + * the inferences drawn from the ontologies which were loaded into the reasoner. + * + * @param the axiom type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public interface InferredAxiomGenerator { + + /** + * @param df data factory + * @param reasoner the reasoner to use + * @return the set of axioms generated + */ + Set createAxioms(OWLDataFactory df, OWLReasoner reasoner); + + /** + * @return the label + */ + String getLabel(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/InferredClassAssertionAxiomGenerator.java b/api/src/main/java/org/semanticweb/owlapi/util/InferredClassAssertionAxiomGenerator.java new file mode 100644 index 0000000000..1c16911fca --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/InferredClassAssertionAxiomGenerator.java @@ -0,0 +1,41 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.Set; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.reasoner.OWLReasoner; + +/** + * Generates {@code OWLClassAssertionsAxiom}s for inferred individual types. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class InferredClassAssertionAxiomGenerator extends + InferredIndividualAxiomGenerator { + + @Override + protected void addAxioms(OWLNamedIndividual entity, OWLReasoner reasoner, + OWLDataFactory dataFactory, Set result) { + reasoner.getTypes(entity, false).entities() + .forEach(t -> result.add(dataFactory.getOWLClassAssertionAxiom(t, entity))); + } + + @Override + public String getLabel() { + return "Class assertions (individual types)"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/InferredClassAxiomGenerator.java b/api/src/main/java/org/semanticweb/owlapi/util/InferredClassAxiomGenerator.java new file mode 100644 index 0000000000..6dd9ad1d34 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/InferredClassAxiomGenerator.java @@ -0,0 +1,32 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAxiom; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @param the axiom type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public abstract class InferredClassAxiomGenerator + extends InferredEntityAxiomGenerator { + + @Override + protected Stream getEntities(OWLOntology ont) { + return ont.classesInSignature(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/InferredDataPropertyAxiomGenerator.java b/api/src/main/java/org/semanticweb/owlapi/util/InferredDataPropertyAxiomGenerator.java new file mode 100644 index 0000000000..460c7fa75a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/InferredDataPropertyAxiomGenerator.java @@ -0,0 +1,32 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @param the axiom type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public abstract class InferredDataPropertyAxiomGenerator + extends InferredEntityAxiomGenerator { + + @Override + protected Stream getEntities(OWLOntology ont) { + return ont.dataPropertiesInSignature(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/InferredDataPropertyCharacteristicAxiomGenerator.java b/api/src/main/java/org/semanticweb/owlapi/util/InferredDataPropertyCharacteristicAxiomGenerator.java new file mode 100644 index 0000000000..0d781e72c4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/InferredDataPropertyCharacteristicAxiomGenerator.java @@ -0,0 +1,46 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.Set; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyCharacteristicAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.reasoner.OWLReasoner; + +/** + * Generates inferred data property characteristics. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class InferredDataPropertyCharacteristicAxiomGenerator + extends InferredDataPropertyAxiomGenerator { + + @Override + protected void addAxioms(OWLDataProperty entity, OWLReasoner reasoner, + OWLDataFactory dataFactory, + Set result) { + OWLFunctionalDataPropertyAxiom axiom = dataFactory + .getOWLFunctionalDataPropertyAxiom(entity); + if (reasoner.isEntailed(axiom)) { + result.add(axiom); + } + } + + @Override + public String getLabel() { + return "Data property characteristics"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/InferredDisjointClassesAxiomGenerator.java b/api/src/main/java/org/semanticweb/owlapi/util/InferredDisjointClassesAxiomGenerator.java new file mode 100644 index 0000000000..9b1c46830f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/InferredDisjointClassesAxiomGenerator.java @@ -0,0 +1,44 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.Set; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.reasoner.InferenceType; +import org.semanticweb.owlapi.reasoner.OWLReasoner; + +/** + * Generates inferred disjoint axioms - note that this currently uses a very + * simple inefficient algorithm. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class InferredDisjointClassesAxiomGenerator extends + InferredClassAxiomGenerator { + + @Override + protected void addAxioms(OWLClass entity, OWLReasoner reasoner, OWLDataFactory dataFactory, + Set result) { + reasoner.precomputeInferences(InferenceType.DISJOINT_CLASSES); + reasoner.getDisjointClasses(entity).forEach(cls -> cls.entities() + .forEach(c -> result.add(dataFactory.getOWLDisjointClassesAxiom(entity, c)))); + } + + @Override + public String getLabel() { + return "Disjoint classes"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/InferredEntityAxiomGenerator.java b/api/src/main/java/org/semanticweb/owlapi/util/InferredEntityAxiomGenerator.java new file mode 100644 index 0000000000..aca97018b1 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/InferredEntityAxiomGenerator.java @@ -0,0 +1,72 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.reasoner.OWLReasoner; + +/** + * Generates axioms which relate to inferred information for a specific entity. + * + * @param the entity type + * @param the axiom type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public abstract class InferredEntityAxiomGenerator + implements InferredAxiomGenerator { + + @Override + public Set createAxioms(OWLDataFactory df, OWLReasoner reasoner) { + Set result = new HashSet<>(); + reasoner.getRootOntology().importsClosure().flatMap(this::getEntities).distinct() + .forEach(e -> addAxioms(e, reasoner, df, result)); + return result; + } + + /** + * Adds inferred axioms to a results set. The inferred axioms are generated + * for the specific entity. + * + * @param entity The entity + * @param reasoner The reasoner that has inferred the new axioms + * @param dataFactory A data factory which should be used to create the new axioms + * @param result The results set, which the new axioms should be added to. + */ + protected abstract void addAxioms(E entity, OWLReasoner reasoner, OWLDataFactory dataFactory, + Set result); + + /** + * Gets the entities from the specified ontology that this generator + * processes. + * + * @param ont The ontology from which entities are to be retrieved. + * @return A set of entities. + */ + protected abstract Stream getEntities(OWLOntology ont); + + protected Stream getAllEntities(OWLReasoner reasoner) { + return reasoner.getRootOntology().importsClosure().flatMap(this::getEntities).distinct(); + } + + @Override + public String toString() { + return getLabel(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/InferredEquivalentClassAxiomGenerator.java b/api/src/main/java/org/semanticweb/owlapi/util/InferredEquivalentClassAxiomGenerator.java new file mode 100644 index 0000000000..de45e592d1 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/InferredEquivalentClassAxiomGenerator.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.Set; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.reasoner.OWLReasoner; + +/** + * Generates inferred equivalent classes axioms. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class InferredEquivalentClassAxiomGenerator extends + InferredClassAxiomGenerator { + + @Override + protected void addAxioms(OWLClass entity, OWLReasoner reasoner, OWLDataFactory dataFactory, + Set result) { + Set equivalentClasses = asUnorderedSet( + reasoner.getEquivalentClasses(entity).entities(), + OWLClassExpression.class); + equivalentClasses.add(entity); + if (equivalentClasses.size() > 1) { + result.add(dataFactory.getOWLEquivalentClassesAxiom(equivalentClasses)); + } + } + + @Override + public String getLabel() { + return "Equivalent classes"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/InferredEquivalentDataPropertiesAxiomGenerator.java b/api/src/main/java/org/semanticweb/owlapi/util/InferredEquivalentDataPropertiesAxiomGenerator.java new file mode 100644 index 0000000000..e53b796298 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/InferredEquivalentDataPropertiesAxiomGenerator.java @@ -0,0 +1,46 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.Set; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.reasoner.OWLReasoner; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class InferredEquivalentDataPropertiesAxiomGenerator extends + InferredDataPropertyAxiomGenerator { + + @Override + protected void addAxioms(OWLDataProperty entity, OWLReasoner reasoner, + OWLDataFactory dataFactory, + Set result) { + Set props = asUnorderedSet( + reasoner.getEquivalentDataProperties(entity).entities()); + props.add(entity); + if (props.size() > 1) { + result.add(dataFactory.getOWLEquivalentDataPropertiesAxiom(props)); + } + } + + @Override + public String getLabel() { + return "Equivalent data properties"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/InferredEquivalentObjectPropertyAxiomGenerator.java b/api/src/main/java/org/semanticweb/owlapi/util/InferredEquivalentObjectPropertyAxiomGenerator.java new file mode 100644 index 0000000000..894ee9238b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/InferredEquivalentObjectPropertyAxiomGenerator.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.Set; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.reasoner.OWLReasoner; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class InferredEquivalentObjectPropertyAxiomGenerator extends + InferredObjectPropertyAxiomGenerator { + + @Override + protected void addAxioms(OWLObjectProperty entity, OWLReasoner reasoner, + OWLDataFactory dataFactory, + Set result, + Set nonSimpleProperties) { + Set equivProps = asUnorderedSet( + reasoner.getEquivalentObjectProperties(entity) + .entities()); + equivProps.add(entity); + if (equivProps.size() > 1) { + result.add(dataFactory.getOWLEquivalentObjectPropertiesAxiom(equivProps)); + } + } + + @Override + public String getLabel() { + return "Equivalent object properties"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/InferredIndividualAxiomGenerator.java b/api/src/main/java/org/semanticweb/owlapi/util/InferredIndividualAxiomGenerator.java new file mode 100644 index 0000000000..34b8186f48 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/InferredIndividualAxiomGenerator.java @@ -0,0 +1,32 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.OWLIndividualAxiom; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @param the axiom type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public abstract class InferredIndividualAxiomGenerator + extends InferredEntityAxiomGenerator { + + @Override + protected Stream getEntities(OWLOntology ont) { + return ont.individualsInSignature(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/InferredInverseObjectPropertiesAxiomGenerator.java b/api/src/main/java/org/semanticweb/owlapi/util/InferredInverseObjectPropertiesAxiomGenerator.java new file mode 100644 index 0000000000..1670e167b8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/InferredInverseObjectPropertiesAxiomGenerator.java @@ -0,0 +1,45 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.Set; + +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.reasoner.OWLReasoner; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class InferredInverseObjectPropertiesAxiomGenerator + extends InferredObjectPropertyAxiomGenerator { + + @Override + protected void addAxioms(OWLObjectProperty entity, OWLReasoner reasoner, + OWLDataFactory dataFactory, Set result, + Set nonSimpleProperties) { + for (OWLObjectPropertyExpression prop : reasoner.getInverseObjectProperties(entity)) { + if (!prop.isAnonymous()) { + result.add(dataFactory.getOWLInverseObjectPropertiesAxiom(entity, prop)); + } + } + } + + @Override + public String getLabel() { + return "Inverse object properties"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/InferredObjectPropertyAxiomGenerator.java b/api/src/main/java/org/semanticweb/owlapi/util/InferredObjectPropertyAxiomGenerator.java new file mode 100644 index 0000000000..de4412dc64 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/InferredObjectPropertyAxiomGenerator.java @@ -0,0 +1,56 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.Set; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.reasoner.OWLReasoner; + +/** + * @param the axiom type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public abstract class InferredObjectPropertyAxiomGenerator + extends InferredEntityAxiomGenerator { + + @Override + protected Stream getEntities(OWLOntology ont) { + return ont.objectPropertiesInSignature(); + } + + @Override + protected final void addAxioms(OWLObjectProperty entity, OWLReasoner reasoner, + OWLDataFactory dataFactory, Set result) { + OWLOntology current = reasoner.getRootOntology(); + OWLObjectPropertyManager objectPropertyManager = new OWLObjectPropertyManager(current); + addAxioms(entity, reasoner, dataFactory, result, + objectPropertyManager.getNonSimpleProperties()); + } + + protected abstract void addAxioms(OWLObjectProperty entity, OWLReasoner reasoner, + OWLDataFactory dataFactory, Set result, + Set nonSimpleProperties); + + protected boolean simple(Set nonSimpleProperties, OWLObject e) { + return nonSimpleProperties.contains(e); + } + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/InferredObjectPropertyCharacteristicAxiomGenerator.java b/api/src/main/java/org/semanticweb/owlapi/util/InferredObjectPropertyCharacteristicAxiomGenerator.java new file mode 100644 index 0000000000..3993fef380 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/InferredObjectPropertyCharacteristicAxiomGenerator.java @@ -0,0 +1,94 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.Set; + +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyCharacteristicAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.reasoner.OWLReasoner; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class InferredObjectPropertyCharacteristicAxiomGenerator + extends InferredObjectPropertyAxiomGenerator { + + /** + * Test to see if a property is only vacuously transitive; i.e. if there cannot be any three + * individuals a,b,c such that foo(a,b) and foo(b,c) - e.g. if the domain and range of foo are + * disjoint. . + * + * @param property property to test + * @param reasoner reasoner to use for testing + * @param df data factory + * @return true if property is trivially transitive, or if entailment checking for + * OWLObjectPropertyAssertionAxioms is not supported. + */ + private static boolean triviallyTransitiveCheck(OWLObjectProperty property, + OWLReasoner reasoner, OWLDataFactory df) { + // create R some (R some owl:Thing) class + OWLObjectSomeValuesFrom chain = df.getOWLObjectSomeValuesFrom(property, + df.getOWLObjectSomeValuesFrom(property, df.getOWLThing())); + // if chain is unsatisfiable, then the property is trivially transitive + return !reasoner.isSatisfiable(chain); + } + + protected static void addIfEntailed(OWLObjectPropertyCharacteristicAxiom axiom, + OWLReasoner reasoner, Set result) { + if (reasoner.isEntailmentCheckingSupported(axiom.getAxiomType()) + && reasoner.isEntailed(axiom)) { + result.add(axiom); + } + } + + @Override + protected void addAxioms(OWLObjectProperty entity, OWLReasoner reasoner, OWLDataFactory df, + Set result, + Set nonSimpleProperties) { + addIfEntailed(df.getOWLSymmetricObjectPropertyAxiom(entity), reasoner, result); + addIfEntailed(df.getOWLReflexiveObjectPropertyAxiom(entity), reasoner, result); + if (simple(entity, reasoner)) { + addIfEntailed(df.getOWLFunctionalObjectPropertyAxiom(entity), reasoner, result); + addIfEntailed(df.getOWLInverseFunctionalObjectPropertyAxiom(entity), reasoner, result); + addIfEntailed(df.getOWLAsymmetricObjectPropertyAxiom(entity), reasoner, result); + addTransitiveAxiomIfEntailed(entity, reasoner, df, result); + addIfEntailed(df.getOWLIrreflexiveObjectPropertyAxiom(entity), reasoner, result); + } + } + + protected boolean simple(OWLObjectProperty entity, OWLReasoner reasoner) { + OWLOntology current = reasoner.getRootOntology(); + OWLObjectPropertyManager objectPropertyManager = new OWLObjectPropertyManager(current); + return !objectPropertyManager.isNonSimple(entity); + } + + protected static void addTransitiveAxiomIfEntailed(OWLObjectProperty p, OWLReasoner r, + OWLDataFactory df, Set result) { + OWLObjectPropertyCharacteristicAxiom axiom = df.getOWLTransitiveObjectPropertyAxiom(p); + if (r.isEntailmentCheckingSupported(axiom.getAxiomType()) && r.isEntailed(axiom) + && !triviallyTransitiveCheck(p, r, df)) { + result.add(axiom); + } + } + + @Override + public String getLabel() { + return "Object property characteristics"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/InferredOntologyGenerator.java b/api/src/main/java/org/semanticweb/owlapi/util/InferredOntologyGenerator.java new file mode 100644 index 0000000000..222624e599 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/InferredOntologyGenerator.java @@ -0,0 +1,135 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.model.parameters.AxiomAnnotations.IGNORE_AXIOM_ANNOTATIONS; +import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.empty; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChangeException; +import org.semanticweb.owlapi.reasoner.OWLReasoner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Generates an ontology based on inferred axioms which are essentially supplied by a reasoner. The + * generator can be configured with {@code InferredAxiomGenerator}s which generate specific kinds of + * axioms e.g. subclass axioms. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class InferredOntologyGenerator { + + private static Logger logger = LoggerFactory.getLogger(InferredOntologyGenerator.class); + // The reasoner which is used to compute the inferred axioms + private final OWLReasoner reasoner; + private final List> axiomGenerators; + + /** + * @param reasoner the reasoner to use + * @param axiomGenerators the axiom generators to use + */ + public InferredOntologyGenerator(OWLReasoner reasoner, + List> axiomGenerators) { + this.reasoner = checkNotNull(reasoner, "reasoner cannot be null"); + checkNotNull(axiomGenerators, "axiomGenerators cannot be null"); + this.axiomGenerators = new ArrayList<>(axiomGenerators); + } + + /** + * @param reasoner the reasoner to use + */ + public InferredOntologyGenerator(OWLReasoner reasoner) { + this(reasoner, generators()); + } + + private static List> generators() { + return CollectionFactory.>list( + new InferredClassAssertionAxiomGenerator(), + new InferredDataPropertyCharacteristicAxiomGenerator(), + new InferredEquivalentClassAxiomGenerator(), + new InferredEquivalentDataPropertiesAxiomGenerator(), + new InferredEquivalentObjectPropertyAxiomGenerator(), + new InferredInverseObjectPropertiesAxiomGenerator(), + new InferredObjectPropertyCharacteristicAxiomGenerator(), + new InferredPropertyAssertionGenerator(), new InferredSubClassAxiomGenerator(), + new InferredSubDataPropertyAxiomGenerator(), + new InferredSubObjectPropertyAxiomGenerator()); + } + + /** + * @return the axiom generators + */ + public List> getAxiomGenerators() { + return new ArrayList<>(axiomGenerators); + } + + /** + * Adds a generator if it isn't already in the list of generators. + * + * @param generator The generator to be added. + */ + public void addGenerator(InferredAxiomGenerator generator) { + checkNotNull(generator, "generator cannot be null"); + if (!axiomGenerators.contains(generator)) { + axiomGenerators.add(generator); + } + } + + /** + * Removes a generator. + * + * @param generator the generator to be removed + */ + public void removeGenerator(InferredAxiomGenerator generator) { + checkNotNull(generator, "generator cannot be null"); + axiomGenerators.remove(generator); + } + + /** + * Adds 'inferred axioms' to an ontology using the generators that have been registered with + * this {@code InferredAxiomGenerator}. + * + * @param df data factory. + * @param ontology The ontology which the inferred axioms will be added to + * @throws OWLOntologyChangeException If there was a problem adding the inferred axioms to the + * specified ontology. + */ + public void fillOntology(OWLDataFactory df, OWLOntology ontology) { + checkNotNull(df, "df cannot be null"); + checkNotNull(ontology, "ontology cannot be null"); + axiomGenerators.stream().flatMap(g -> generate(df, g)) + .filter(ax -> !ontology.containsAxiom(ax, INCLUDED, IGNORE_AXIOM_ANNOTATIONS)) + .forEach(ontology::add); + } + + protected Stream generate(OWLDataFactory df, + InferredAxiomGenerator g) { + try { + return g.createAxioms(df, reasoner).stream().map(x -> x); + } catch (Exception e) { + logger.warn("Error generating {} axioms using {}, version {}", g.getLabel(), + reasoner.getReasonerName(), reasoner.getReasonerVersion(), e); + return empty(); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/InferredPropertyAssertionGenerator.java b/api/src/main/java/org/semanticweb/owlapi/util/InferredPropertyAssertionGenerator.java new file mode 100644 index 0000000000..fb54b49da5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/InferredPropertyAssertionGenerator.java @@ -0,0 +1,53 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.Set; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLPropertyAssertionAxiom; +import org.semanticweb.owlapi.reasoner.OWLReasoner; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class InferredPropertyAssertionGenerator + extends InferredIndividualAxiomGenerator> { + + @Override + protected void addAxioms(OWLNamedIndividual entity, OWLReasoner reasoner, + OWLDataFactory dataFactory, + Set> result) { + checkNotNull(dataFactory, "dataFactory cannot be null"); + checkNotNull(reasoner, "reasoner cannot be null"); + checkNotNull(result, "result cannot be null"); + checkNotNull(entity, "entity cannot be null"); + reasoner.getRootOntology().objectPropertiesInSignature(INCLUDED) + .forEach(p -> reasoner.getObjectPropertyValues(entity, p).entities() + .forEach( + i -> result.add(dataFactory.getOWLObjectPropertyAssertionAxiom(p, entity, i)))); + reasoner.getRootOntology().dataPropertiesInSignature(INCLUDED) + .forEach(p -> reasoner.getDataPropertyValues(entity, p) + .forEach( + v -> result.add(dataFactory.getOWLDataPropertyAssertionAxiom(p, entity, v)))); + } + + @Override + public String getLabel() { + return "Property assertions (property values)"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/InferredSubClassAxiomGenerator.java b/api/src/main/java/org/semanticweb/owlapi/util/InferredSubClassAxiomGenerator.java new file mode 100644 index 0000000000..6af3f22f6c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/InferredSubClassAxiomGenerator.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.Set; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.reasoner.OWLReasoner; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class InferredSubClassAxiomGenerator extends + InferredClassAxiomGenerator { + + @Override + protected void addAxioms(OWLClass entity, OWLReasoner reasoner, OWLDataFactory dataFactory, + Set result) { + checkNotNull(dataFactory, "dataFactory cannot be null"); + checkNotNull(reasoner, "reasoner cannot be null"); + checkNotNull(result, "result cannot be null"); + checkNotNull(entity, "entity cannot be null"); + if (reasoner.isSatisfiable(entity)) { + reasoner.getSuperClasses(entity, true).entities() + .forEach(sup -> result.add(dataFactory.getOWLSubClassOfAxiom(entity, sup))); + } else { + result.add(dataFactory.getOWLSubClassOfAxiom(entity, dataFactory.getOWLNothing())); + } + } + + @Override + public String getLabel() { + return "Subclasses"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/InferredSubDataPropertyAxiomGenerator.java b/api/src/main/java/org/semanticweb/owlapi/util/InferredSubDataPropertyAxiomGenerator.java new file mode 100644 index 0000000000..d7ee5f9581 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/InferredSubDataPropertyAxiomGenerator.java @@ -0,0 +1,46 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.Set; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.reasoner.OWLReasoner; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class InferredSubDataPropertyAxiomGenerator + extends InferredDataPropertyAxiomGenerator { + + @Override + protected void addAxioms(OWLDataProperty entity, OWLReasoner reasoner, + OWLDataFactory dataFactory, + Set result) { + checkNotNull(dataFactory, "dataFactory cannot be null"); + checkNotNull(reasoner, "reasoner cannot be null"); + checkNotNull(result, "result cannot be null"); + checkNotNull(entity, "entity cannot be null"); + reasoner.getSuperDataProperties(entity, true).entities() + .forEach(sup -> result.add(dataFactory.getOWLSubDataPropertyOfAxiom(entity, sup))); + } + + @Override + public String getLabel() { + return "Sub data properties"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/InferredSubObjectPropertyAxiomGenerator.java b/api/src/main/java/org/semanticweb/owlapi/util/InferredSubObjectPropertyAxiomGenerator.java new file mode 100644 index 0000000000..667bf6acc7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/InferredSubObjectPropertyAxiomGenerator.java @@ -0,0 +1,68 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.Set; + +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; +import org.semanticweb.owlapi.reasoner.OWLReasoner; +import org.semanticweb.owlapi.search.EntitySearcher; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class InferredSubObjectPropertyAxiomGenerator + extends InferredObjectPropertyAxiomGenerator { + + @Override + protected void addAxioms(OWLObjectProperty entity, OWLReasoner reasoner, + OWLDataFactory dataFactory, Set result, + Set nonSimpleProperties) { + checkNotNull(dataFactory, "dataFactory cannot be null"); + checkNotNull(reasoner, "reasoner cannot be null"); + checkNotNull(result, "result cannot be null"); + checkNotNull(entity, "entity cannot be null"); + reasoner.getSuperObjectProperties(entity, true).entities().forEach( + p -> addIfSimple(p, entity, dataFactory, result, nonSimpleProperties, reasoner)); + } + + protected void addIfSimple(OWLObjectPropertyExpression p, OWLObjectProperty entity, + OWLDataFactory dataFactory, Set result, + Set nonSimpleProperties, OWLReasoner reasoner) { + boolean nonSimple = false; + boolean inverse = false; + if (!simple(nonSimpleProperties, entity)) { + nonSimple = true; + } + if (p.isAnonymous() + && EntitySearcher.isTransitive(p.getInverseProperty(), reasoner.getRootOntology())) { + inverse = true; + } + if (!(nonSimple && inverse)) { + // having both non simple properties and inverses in an subproperty axiom may cause + // exceptions later on + result.add(dataFactory.getOWLSubObjectPropertyOfAxiom(entity, p)); + } + } + + @Override + public String getLabel() { + return "Sub object properties"; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/Languages.java b/api/src/main/java/org/semanticweb/owlapi/util/Languages.java new file mode 100644 index 0000000000..f4db3999da --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/Languages.java @@ -0,0 +1,354 @@ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.Construct.ATOMIC_NEGATION; +import static org.semanticweb.owlapi.util.Construct.CONCEPT_COMPLEX_NEGATION; +import static org.semanticweb.owlapi.util.Construct.CONCEPT_INTERSECTION; +import static org.semanticweb.owlapi.util.Construct.CONCEPT_UNION; +import static org.semanticweb.owlapi.util.Construct.D; +import static org.semanticweb.owlapi.util.Construct.F; +import static org.semanticweb.owlapi.util.Construct.FULL_EXISTENTIAL; +import static org.semanticweb.owlapi.util.Construct.LIMITED_EXISTENTIAL; +import static org.semanticweb.owlapi.util.Construct.N; +import static org.semanticweb.owlapi.util.Construct.NOMINALS; +import static org.semanticweb.owlapi.util.Construct.Q; +import static org.semanticweb.owlapi.util.Construct.ROLE_COMPLEX; +import static org.semanticweb.owlapi.util.Construct.ROLE_DOMAIN_RANGE; +import static org.semanticweb.owlapi.util.Construct.ROLE_HIERARCHY; +import static org.semanticweb.owlapi.util.Construct.ROLE_INVERSE; +import static org.semanticweb.owlapi.util.Construct.ROLE_REFLEXIVITY_CHAINS; +import static org.semanticweb.owlapi.util.Construct.ROLE_TRANSITIVE; +import static org.semanticweb.owlapi.util.Construct.UNIVERSAL_RESTRICTION; + +import java.util.Arrays; +import java.util.Collection; +import java.util.EnumSet; + +/** Enumeration of known DL languages */ +public enum Languages { + //@formatter:off + /** + * FL0 - A sub-language of FL-, which is obtained by disallowing limited existential + * quantification. + */ + FL0("FL0", CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION), + /** + * FL- - A sub-language of FL, which is obtained by disallowing role restriction. This is + * equivalent to AL without atomic negation. + */ + FLMINUS("FL-", FL0, LIMITED_EXISTENTIAL), + /** + * FL - Frame based description language, allows: + *
    + *
  • Concept intersection
  • + *
  • Universal restrictions
  • + *
  • Limited existential quantification
  • + *
  • Role restriction
  • + *
+ */ + FL("FL", FLMINUS, ROLE_DOMAIN_RANGE), + /** + * AL - Attributive language. This is the base language which allows: + *
    + *
  • Atomic negation (negation of concept names that do not appear on the left-hand side of + * axioms)
  • + *
  • Concept intersection
  • + *
  • Universal restrictions
  • + *
  • Limited existential quantification
  • + *
+ */ + AL("AL", FLMINUS, ATOMIC_NEGATION), + /** + * EL - Existential language, allows: + *
    + *
  • Concept intersection
  • + *
  • Existential restrictions (of full existential quantification)
  • + *
+ */ + EL("EL", CONCEPT_INTERSECTION, FULL_EXISTENTIAL, ROLE_DOMAIN_RANGE), + /** ALE language */ ALE("ALE", AL, FULL_EXISTENTIAL), + /** ALC language */ ALC("ALC", ALE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, ROLE_DOMAIN_RANGE), + /** S language. */ S("S", ALC, ROLE_TRANSITIVE), + /** ALCD language. */ ALCD("ALCD",ALC, D), + /** ALCF language. */ ALCF("ALCF",ALC, F), + /** ALCFD language. */ ALCFD("ALCFD",ALC, F, D), + /** ALCN language. */ ALCN("ALCN",ALC, N), + /** ALCND language. */ ALCND("ALCND",ALC, N, D), + /** ALCQ language. */ ALCQ("ALCQ",ALC, Q), + /** ALCQD language. */ ALCQD("ALCQD",ALC, Q, D), + /** ALCI language. */ ALCI("ALCI",ALC, ROLE_INVERSE), + /** ALCID language. */ ALCID("ALCID",ALC, ROLE_INVERSE, D), + /** ALCIF language. */ ALCIF("ALCIF",ALC, ROLE_INVERSE, F), + /** ALCIFD language. */ ALCIFD("ALCIFD",ALC, ROLE_INVERSE, F, D), + /** ALCIN language. */ ALCIN("ALCIN",ALC, ROLE_INVERSE, N), + /** ALCIND language. */ ALCIND("ALCIND",ALC, ROLE_INVERSE, N, D), + /** ALCIQ language. */ ALCIQ("ALCIQ",ALC, ROLE_INVERSE, Q), + /** ALCIQD language. */ ALCIQD("ALCIQD",ALC, ROLE_INVERSE, Q, D), + /** ALCO language. */ ALCO("ALCO",ALC, NOMINALS), + /** ALCOD language. */ ALCOD("ALCOD",ALC, NOMINALS, D), + /** ALCOF language. */ ALCOF("ALCOF",ALC, NOMINALS, F), + /** ALCOFD language. */ ALCOFD("ALCOFD",ALC, NOMINALS, F, D), + /** ALCON language. */ ALCON("ALCON",ALC, NOMINALS, N), + /** ALCOND language. */ ALCOND("ALCOND",ALC, NOMINALS, N, D), + /** ALCOQ language. */ ALCOQ("ALCOQ",ALC, NOMINALS, Q), + /** ALCOQD language. */ ALCOQD("ALCOQD",ALC, NOMINALS, Q, D), + /** ALCOI language. */ ALCOI("ALCOI",ALC, NOMINALS, ROLE_INVERSE), + /** ALCOID language. */ ALCOID("ALCOID",ALC, NOMINALS, ROLE_INVERSE, D), + /** ALCOIF language. */ ALCOIF("ALCOIF",ALC, NOMINALS, ROLE_INVERSE, F), + /** ALCOIFD language. */ ALCOIFD("ALCOIFD",ALC, NOMINALS, ROLE_INVERSE, F, D), + /** ALCOIN language. */ ALCOIN("ALCOIN",ALC, NOMINALS, ROLE_INVERSE, N), + /** ALCOIND language. */ ALCOIND("ALCOIND",ALC, NOMINALS, ROLE_INVERSE, N, D), + /** ALCOIQ language. */ ALCOIQ("ALCOIQ",ALC, NOMINALS, ROLE_INVERSE, Q), + /** ALCOIQD language. */ ALCOIQD("ALCOIQD",ALC, NOMINALS, ROLE_INVERSE, Q, D), + /** ALCH language. */ ALCH("ALCH",ALC, ROLE_HIERARCHY), + /** ALCHD language. */ ALCHD("ALCHD",ALC, ROLE_HIERARCHY, D), + /** ALCHF language. */ ALCHF("ALCHF",ALC, ROLE_HIERARCHY, F), + /** ALCHFD language. */ ALCHFD("ALCHFD",ALC, ROLE_HIERARCHY, F, D), + /** ALCHN language. */ ALCHN("ALCHN",ALC, ROLE_HIERARCHY, N), + /** ALCHND language. */ ALCHND("ALCHND",ALC, ROLE_HIERARCHY, N, D), + /** ALCHQ language. */ ALCHQ("ALCHQ",ALC, ROLE_HIERARCHY, Q), + /** ALCHQD language. */ ALCHQD("ALCHQD",ALC, ROLE_HIERARCHY, Q, D), + /** ALCHI language. */ ALCHI("ALCHI",ALC, ROLE_HIERARCHY, ROLE_INVERSE), + /** ALCHID language. */ ALCHID("ALCHID",ALC, ROLE_HIERARCHY, ROLE_INVERSE, D), + /** ALCHIF language. */ ALCHIF("ALCHIF",ALC, ROLE_HIERARCHY, ROLE_INVERSE, F), + /** ALCHIFD language. */ ALCHIFD("ALCHIFD",ALC, ROLE_HIERARCHY, ROLE_INVERSE, F, D), + /** ALCHIN language. */ ALCHIN("ALCHIN",ALC, ROLE_HIERARCHY, ROLE_INVERSE, N), + /** ALCHIND language. */ ALCHIND("ALCHIND",ALC, ROLE_HIERARCHY, ROLE_INVERSE, N, D), + /** ALCHIQ language. */ ALCHIQ("ALCHIQ",ALC, ROLE_HIERARCHY, ROLE_INVERSE, Q), + /** ALCHIQD language. */ ALCHIQD("ALCHIQD",ALC, ROLE_HIERARCHY, ROLE_INVERSE, Q, D), + /** ALCHO language. */ ALCHO("ALCHO",ALC, ROLE_HIERARCHY, NOMINALS), + /** ALCHOD language. */ ALCHOD("ALCHOD",ALC, ROLE_HIERARCHY, NOMINALS, D), + /** ALCHOF language. */ ALCHOF("ALCHOF",ALC, ROLE_HIERARCHY, NOMINALS, F), + /** ALCHOFD language. */ ALCHOFD("ALCHOFD",ALC, ROLE_HIERARCHY, NOMINALS, F, D), + /** ALCHON language. */ ALCHON("ALCHON",ALC, ROLE_HIERARCHY, NOMINALS, N), + /** ALCHOND language. */ ALCHOND("ALCHOND",ALC, ROLE_HIERARCHY, NOMINALS, N, D), + /** ALCHOQ language. */ ALCHOQ("ALCHOQ",ALC, ROLE_HIERARCHY, NOMINALS, Q), + /** ALCHOQD language. */ ALCHOQD("ALCHOQD",ALC, ROLE_HIERARCHY, NOMINALS, Q, D), + /** ALCHOI language. */ ALCHOI("ALCHOI",ALC, ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE), + /** ALCHOID language. */ ALCHOID("ALCHOID",ALC, ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, D), + /** ALCHOIF language. */ ALCHOIF("ALCHOIF",ALC, ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, F), + /** ALCHOIFD language. */ ALCHOIFD("ALCHOIFD",ALC, ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, F, D), + /** ALCHOIN language. */ ALCHOIN("ALCHOIN",ALC, ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, N), + /** ALCHOIND language. */ ALCHOIND("ALCHOIND",ALC, ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, N, D), + /** ALCHOIQ language. */ ALCHOIQ("ALCHOIQ",ALC, ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, Q), + /** ALCHOIQD language. */ ALCHOIQD("ALCHOIQD",ALC, ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, Q, D), + /** ALCRr language. */ ALCRr("ALCRr",ALC, ROLE_REFLEXIVITY_CHAINS), + /** ALCRrD language. */ ALCRrD("ALCRrD",ALC, ROLE_REFLEXIVITY_CHAINS, D), + /** ALCRrF language. */ ALCRrF("ALCRrF",ALC, ROLE_REFLEXIVITY_CHAINS, F), + /** ALCRrFD language. */ ALCRrFD("ALCRrFD",ALC, ROLE_REFLEXIVITY_CHAINS, F, D), + /** ALCRrN language. */ ALCRrN("ALCRrN",ALC, ROLE_REFLEXIVITY_CHAINS, N), + /** ALCRrND language. */ ALCRrND("ALCRrND",ALC, ROLE_REFLEXIVITY_CHAINS, N, D), + /** ALCRrQ language. */ ALCRrQ("ALCRrQ",ALC, ROLE_REFLEXIVITY_CHAINS, Q), + /** ALCRrQD language. */ ALCRrQD("ALCRrQD",ALC, ROLE_REFLEXIVITY_CHAINS, Q, D), + /** ALCRrO language. */ ALCRrO("ALCRrO",ALC, ROLE_REFLEXIVITY_CHAINS, NOMINALS), + /** ALCRrOD language. */ ALCRrOD("ALCRrOD",ALC, ROLE_REFLEXIVITY_CHAINS, NOMINALS, D), + /** ALCRrOF language. */ ALCRrOF("ALCRrOF",ALC, ROLE_REFLEXIVITY_CHAINS, NOMINALS, F), + /** ALCRrOFD language. */ ALCRrOFD("ALCRrOFD",ALC, ROLE_REFLEXIVITY_CHAINS, NOMINALS, F, D), + /** ALCRrON language. */ ALCRrON("ALCRrON",ALC, ROLE_REFLEXIVITY_CHAINS, NOMINALS, N), + /** ALCRrOND language. */ ALCRrOND("ALCRrOND",ALC, ROLE_REFLEXIVITY_CHAINS, NOMINALS, N, D), + /** ALCRrOQ language. */ ALCRrOQ("ALCRrOQ",ALC, ROLE_REFLEXIVITY_CHAINS, NOMINALS, Q), + /** ALCRrOQD language. */ ALCRrOQD("ALCRrOQD",ALC, ROLE_REFLEXIVITY_CHAINS, NOMINALS, Q, D), + /** ALCR language. */ ALCR("ALCR",ALC, ROLE_COMPLEX), + /** ALCRD language. */ ALCRD("ALCRD",ALC, ROLE_COMPLEX, D), + /** ALCRF language. */ ALCRF("ALCRF",ALC, ROLE_COMPLEX, F), + /** ALCRFD language. */ ALCRFD("ALCRFD",ALC, ROLE_COMPLEX, F, D), + /** ALCRN language. */ ALCRN("ALCRN",ALC, ROLE_COMPLEX, N), + /** ALCRND language. */ ALCRND("ALCRND",ALC, ROLE_COMPLEX, N, D), + /** ALCRQ language. */ ALCRQ("ALCRQ",ALC, ROLE_COMPLEX, Q), + /** ALCRQD language. */ ALCRQD("ALCRQD",ALC, ROLE_COMPLEX, Q, D), + /** ALCRI language. */ ALCRI("ALCRI",ALC, ROLE_COMPLEX, ROLE_INVERSE), + /** ALCRID language. */ ALCRID("ALCRID",ALC, ROLE_COMPLEX, ROLE_INVERSE, D), + /** ALCRIF language. */ ALCRIF("ALCRIF",ALC, ROLE_COMPLEX, ROLE_INVERSE, F), + /** ALCRIFD language. */ ALCRIFD("ALCRIFD",ALC, ROLE_COMPLEX, ROLE_INVERSE, F, D), + /** ALCRIN language. */ ALCRIN("ALCRIN",ALC, ROLE_COMPLEX, ROLE_INVERSE, N), + /** ALCRIND language. */ ALCRIND("ALCRIND",ALC, ROLE_COMPLEX, ROLE_INVERSE, N, D), + /** ALCRIQ language. */ ALCRIQ("ALCRIQ",ALC, ROLE_COMPLEX, ROLE_INVERSE, Q), + /** ALCRIQD language. */ ALCRIQD("ALCRIQD",ALC, ROLE_COMPLEX, ROLE_INVERSE, Q, D), + /** ALCRO language. */ ALCRO("ALCRO",ALC, ROLE_COMPLEX, NOMINALS), + /** ALCROD language. */ ALCROD("ALCROD",ALC, ROLE_COMPLEX, NOMINALS, D), + /** ALCROF language. */ ALCROF("ALCROF",ALC, ROLE_COMPLEX, NOMINALS, F), + /** ALCROFD language. */ ALCROFD("ALCROFD",ALC, ROLE_COMPLEX, NOMINALS, F, D), + /** ALCRON language. */ ALCRON("ALCRON",ALC, ROLE_COMPLEX, NOMINALS, N), + /** ALCROND language. */ ALCROND("ALCROND",ALC, ROLE_COMPLEX, NOMINALS, N, D), + /** ALCROQ language. */ ALCROQ("ALCROQ",ALC, ROLE_COMPLEX, NOMINALS, Q), + /** ALCROQD language. */ ALCROQD("ALCROQD",ALC, ROLE_COMPLEX, NOMINALS, Q, D), + /** ALCROI language. */ ALCROI("ALCROI",ALC, ROLE_COMPLEX, NOMINALS, ROLE_INVERSE), + /** ALCROID language. */ ALCROID("ALCROID",ALC, ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, D), + /** ALCROIF language. */ ALCROIF("ALCROIF",ALC, ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, F), + /** ALCROIFD language. */ ALCROIFD("ALCROIFD",ALC, ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, F, D), + /** ALCROIN language. */ ALCROIN("ALCROIN",ALC, ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, N), + /** ALCROIND language. */ ALCROIND("ALCROIND",ALC, ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, N, D), + /** ALCROIQ language. */ ALCROIQ("ALCROIQ",ALC, ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, Q), + /** ALCROIQD language. */ ALCROIQD("ALCROIQD",ALC, ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, Q, D), + /** SD language. */ SD("SD",S, D), + /** SF language. */ SF("SF",S, F), + /** SFD language. */ SFD("SFD",S, F, D), + /** SN language. */ SN("SN",S, N), + /** SND language. */ SND("SND",S, N, D), + /** SQ language. */ SQ("SQ",S, Q), + /** SQD language. */ SQD("SQD",S, Q, D), + /** SI language. */ SI("SI",S, ROLE_INVERSE), + /** SID language. */ SID("SID",S, ROLE_INVERSE, D), + /** SIF language. */ SIF("SIF",S, ROLE_INVERSE, F), + /** SIFD language. */ SIFD("SIFD",S, ROLE_INVERSE, F, D), + /** SIN language. */ SIN("SIN",S, ROLE_INVERSE, N), + /** SIND language. */ SIND("SIND",S, ROLE_INVERSE, N, D), + /** SIQ language. */ SIQ("SIQ",S, ROLE_INVERSE, Q), + /** SIQD language. */ SIQD("SIQD",S, ROLE_INVERSE, Q, D), + /** SO language. */ SO("SO",S, NOMINALS), + /** SOD language. */ SOD("SOD",S, NOMINALS, D), + /** SOF language. */ SOF("SOF",S, NOMINALS, F), + /** SOFD language. */ SOFD("SOFD",S, NOMINALS, F, D), + /** SON language. */ SON("SON",S, NOMINALS, N), + /** SOND language. */ SOND("SOND",S, NOMINALS, N, D), + /** SOQ language. */ SOQ("SOQ",S, NOMINALS, Q), + /** SOQD language. */ SOQD("SOQD",S, NOMINALS, Q, D), + /** SOI language. */ SOI("SOI",S, NOMINALS, ROLE_INVERSE), + /** SOID language. */ SOID("SOID",S, NOMINALS, ROLE_INVERSE, D), + /** SOIF language. */ SOIF("SOIF",S, NOMINALS, ROLE_INVERSE, F), + /** SOIFD language. */ SOIFD("SOIFD",S, NOMINALS, ROLE_INVERSE, F, D), + /** SOIN language. */ SOIN("SOIN",S, NOMINALS, ROLE_INVERSE, N), + /** SOIND language. */ SOIND("SOIND",S, NOMINALS, ROLE_INVERSE, N, D), + /** SOIQ language. */ SOIQ("SOIQ",S, NOMINALS, ROLE_INVERSE, Q), + /** SOIQD language. */ SOIQD("SOIQD",S, NOMINALS, ROLE_INVERSE, Q, D), + /** SH language. */ SH("SH",S, ROLE_HIERARCHY), + /** SHD language. */ SHD("SHD",S, ROLE_HIERARCHY, D), + /** SHF language. */ SHF("SHF",S, ROLE_HIERARCHY, F), + /** SHFD language. */ SHFD("SHFD",S, ROLE_HIERARCHY, F, D), + /** SHN language. */ SHN("SHN",S, ROLE_HIERARCHY, N), + /** SHND language. */ SHND("SHND",S, ROLE_HIERARCHY, N, D), + /** SHQ language. */ SHQ("SHQ",S, ROLE_HIERARCHY, Q), + /** SHQD language. */ SHQD("SHQD",S, ROLE_HIERARCHY, Q, D), + /** SHI language. */ SHI("SHI",S, ROLE_HIERARCHY, ROLE_INVERSE), + /** SHID language. */ SHID("SHID",S, ROLE_HIERARCHY, ROLE_INVERSE, D), + /** SHIF language. */ SHIF("SHIF",S, ROLE_HIERARCHY, ROLE_INVERSE, F), + /** SHIFD language. */ SHIFD("SHIFD",S, ROLE_HIERARCHY, ROLE_INVERSE, F, D), + /** SHIN language. */ SHIN("SHIN",S, ROLE_HIERARCHY, ROLE_INVERSE, N), + /** SHIND language. */ SHIND("SHIND",S, ROLE_HIERARCHY, ROLE_INVERSE, N, D), + /** SHIQ language. */ SHIQ("SHIQ",S, ROLE_HIERARCHY, ROLE_INVERSE, Q), + /** SHIQD language. */ SHIQD("SHIQD",S, ROLE_HIERARCHY, ROLE_INVERSE, Q, D), + /** SHO language. */ SHO("SHO",S, ROLE_HIERARCHY, NOMINALS), + /** SHOD language. */ SHOD("SHOD",S, ROLE_HIERARCHY, NOMINALS, D), + /** SHOF language. */ SHOF("SHOF",S, ROLE_HIERARCHY, NOMINALS, F), + /** SHOFD language. */ SHOFD("SHOFD",S, ROLE_HIERARCHY, NOMINALS, F, D), + /** SHON language. */ SHON("SHON",S, ROLE_HIERARCHY, NOMINALS, N), + /** SHOND language. */ SHOND("SHOND",S, ROLE_HIERARCHY, NOMINALS, N, D), + /** SHOQ language. */ SHOQ("SHOQ",S, ROLE_HIERARCHY, NOMINALS, Q), + /** SHOQD language. */ SHOQD("SHOQD",S, ROLE_HIERARCHY, NOMINALS, Q, D), + /** SHOI language. */ SHOI("SHOI",S, ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE), + /** SHOID language. */ SHOID("SHOID",S, ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, D), + /** SHOIF language. */ SHOIF("SHOIF",S, ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, F), + /** SHOIFD language. */ SHOIFD("SHOIFD",S, ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, F, D), + /** SHOIN language. */ SHOIN("SHOIN",S, ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, N), + /** SHOIND language. */ SHOIND("SHOIND",S, ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, N, D), + /** SHOIQ language. */ SHOIQ("SHOIQ",S, ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, Q), + /** SHOIQD language. */ SHOIQD("SHOIQD",S, ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, Q, D), + /** SRr language. */ SRr("SRr",S, ROLE_REFLEXIVITY_CHAINS), + /** SRrD language. */ SRrD("SRrD",S, ROLE_REFLEXIVITY_CHAINS, D), + /** SRrF language. */ SRrF("SRrF",S, ROLE_REFLEXIVITY_CHAINS, F), + /** SRrFD language. */ SRrFD("SRrFD",S, ROLE_REFLEXIVITY_CHAINS, F, D), + /** SRrN language. */ SRrN("SRrN",S, ROLE_REFLEXIVITY_CHAINS, N), + /** SRrND language. */ SRrND("SRrND",S, ROLE_REFLEXIVITY_CHAINS, N, D), + /** SRrQ language. */ SRrQ("SRrQ",S, ROLE_REFLEXIVITY_CHAINS, Q), + /** SRrQD language. */ SRrQD("SRrQD",S, ROLE_REFLEXIVITY_CHAINS, Q, D), + /** SRrO language. */ SRrO("SRrO",S, ROLE_REFLEXIVITY_CHAINS, NOMINALS), + /** SRrOD language. */ SRrOD("SRrOD",S, ROLE_REFLEXIVITY_CHAINS, NOMINALS, D), + /** SRrOF language. */ SRrOF("SRrOF",S, ROLE_REFLEXIVITY_CHAINS, NOMINALS, F), + /** SRrOFD language. */ SRrOFD("SRrOFD",S, ROLE_REFLEXIVITY_CHAINS, NOMINALS, F, D), + /** SRrON language. */ SRrON("SRrON",S, ROLE_REFLEXIVITY_CHAINS, NOMINALS, N), + /** SRrOND language. */ SRrOND("SRrOND",S, ROLE_REFLEXIVITY_CHAINS, NOMINALS, N, D), + /** SRrOQ language. */ SRrOQ("SRrOQ",S, ROLE_REFLEXIVITY_CHAINS, NOMINALS, Q), + /** SRrOQD language. */ SRrOQD("SRrOQD",S, ROLE_REFLEXIVITY_CHAINS, NOMINALS, Q, D), + /** SR language. */ SR("SR",S, ROLE_COMPLEX), + /** SRD language. */ SRD("SRD",S, ROLE_COMPLEX, D), + /** SRF language. */ SRF("SRF",S, ROLE_COMPLEX, F), + /** SRFD language. */ SRFD("SRFD",S, ROLE_COMPLEX, F, D), + /** SRN language. */ SRN("SRN",S, ROLE_COMPLEX, N), + /** SRND language. */ SRND("SRND",S, ROLE_COMPLEX, N, D), + /** SRQ language. */ SRQ("SRQ",S, ROLE_COMPLEX, Q), + /** SRQD language. */ SRQD("SRQD",S, ROLE_COMPLEX, Q, D), + /** SRI language. */ SRI("SRI",S, ROLE_COMPLEX, ROLE_INVERSE), + /** SRID language. */ SRID("SRID",S, ROLE_COMPLEX, ROLE_INVERSE, D), + /** SRIF language. */ SRIF("SRIF",S, ROLE_COMPLEX, ROLE_INVERSE, F), + /** SRIFD language. */ SRIFD("SRIFD",S, ROLE_COMPLEX, ROLE_INVERSE, F, D), + /** SRIN language. */ SRIN("SRIN",S, ROLE_COMPLEX, ROLE_INVERSE, N), + /** SRIND language. */ SRIND("SRIND",S, ROLE_COMPLEX, ROLE_INVERSE, N, D), + /** SRIQ language. */ SRIQ("SRIQ",S, ROLE_COMPLEX, ROLE_INVERSE, Q), + /** SRIQD language. */ SRIQD("SRIQD",S, ROLE_COMPLEX, ROLE_INVERSE, Q, D), + /** SRO language. */ SRO("SRO",S, ROLE_COMPLEX, NOMINALS), + /** SROD language. */ SROD("SROD",S, ROLE_COMPLEX, NOMINALS, D), + /** SROF language. */ SROF("SROF",S, ROLE_COMPLEX, NOMINALS, F), + /** SROFD language. */ SROFD("SROFD",S, ROLE_COMPLEX, NOMINALS, F, D), + /** SRON language. */ SRON("SRON",S, ROLE_COMPLEX, NOMINALS, N), + /** SROND language. */ SROND("SROND",S, ROLE_COMPLEX, NOMINALS, N, D), + /** SROQ language. */ SROQ("SROQ",S, ROLE_COMPLEX, NOMINALS, Q), + /** SROQD language. */ SROQD("SROQD",S, ROLE_COMPLEX, NOMINALS, Q, D), + /** SROI language. */ SROI("SROI",S, ROLE_COMPLEX, NOMINALS, ROLE_INVERSE), + /** SROID language. */ SROID("SROID",S, ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, D), + /** SROIF language. */ SROIF("SROIF",S, ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, F), + /** SROIFD language. */ SROIFD("SROIFD",S, ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, F, D), + /** SROIN language. */ SROIN("SROIN",S, ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, N), + /** SROIND language. */ SROIND("SROIND",S, ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, N, D), + /** SROIQ language. */ SROIQ("SROIQ",S, ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, Q), + /** SROIQD language. */ SROIQD("SROIQD",S, ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, Q, D), + /** EL++ - Alias ELRO. */ ELPLUSPLUS("EL++", CONCEPT_INTERSECTION, FULL_EXISTENTIAL, ROLE_COMPLEX, NOMINALS, ROLE_TRANSITIVE, D); + //@formatter:on + + private final String s; + EnumSet components; + + Languages(String s, Languages ancestor, Construct c, Construct... components) { + this.s = s; + this.components = EnumSet.of(c, components); + this.components.addAll(ancestor.components()); + if (this.components.containsAll(Construct.incompatibleRoleFetures)) { + throw new IllegalArgumentException("Incompatible constructs: [" + + Construct.incompatibleRoleFetures + "] cannot appear together."); + } + } + + Languages(String s, Construct c, Construct... components) { + this.s = s; + this.components = EnumSet.of(c, components); + if (this.components.containsAll(Construct.incompatibleRoleFetures)) { + throw new IllegalArgumentException("Incompatible constructs: [" + + Construct.incompatibleRoleFetures + "] cannot appear together."); + } + } + + /** + * @return constructs occurring within this name. Plain constructs have no components. + */ + public EnumSet components() { + return components; + } + + @Override + public String toString() { + return s; + } + + /** + * @param l language to check + * @return true if this is a sublanguage of l + */ + public boolean isSubLanguageOf(Languages l) { + // assumption: no two languages have the same set of constructs + return this != l && l.components.containsAll(components); + } + + /** + * @param constructs constructs to compare + * @return true if all constructs appear in the components + */ + public boolean hasAllConstructs(Construct... constructs) { + return components.containsAll(Arrays.asList(constructs)); + } + + /** + * @param constructs constructs to compare + * @return true if all constructs appear in the components + */ + public boolean hasAllConstructs(Collection constructs) { + return components.containsAll(constructs); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/MaximumModalDepthFinder.java b/api/src/main/java/org/semanticweb/owlapi/util/MaximumModalDepthFinder.java new file mode 100644 index 0000000000..df30d02164 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/MaximumModalDepthFinder.java @@ -0,0 +1,170 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLObjectVisitorEx; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +public class MaximumModalDepthFinder implements OWLObjectVisitorEx { + + private static final Integer _1 = Integer.valueOf(1); + private static final Integer _0 = Integer.valueOf(0); + + @Override + public Integer doDefault(Object o) { + return _0; + } + + Integer counter(Stream stream) { + return Integer.valueOf(stream.mapToInt(o -> o.accept(this).intValue()).max().orElse(0)); + } + + @Override + public Integer visit(OWLSubClassOfAxiom axiom) { + int subClassModalDepth = axiom.getSubClass().accept(this).intValue(); + int superClassModalDepth = axiom.getSuperClass().accept(this).intValue(); + return Integer.valueOf(Math.max(subClassModalDepth, superClassModalDepth)); + } + + @Override + public Integer visit(OWLOntology ontology) { + return counter(ontology.logicalAxioms()); + } + + @Override + public Integer visit(OWLObjectIntersectionOf ce) { + return counter(ce.operands()); + } + + @Override + public Integer visit(OWLObjectUnionOf ce) { + return counter(ce.operands()); + } + + @Override + public Integer visit(OWLObjectComplementOf ce) { + return ce.getOperand().accept(this); + } + + @Override + public Integer visit(OWLObjectSomeValuesFrom ce) { + return Integer.valueOf(1 + ce.getFiller().accept(this).intValue()); + } + + @Override + public Integer visit(OWLObjectAllValuesFrom ce) { + return Integer.valueOf(1 + ce.getFiller().accept(this).intValue()); + } + + @Override + public Integer visit(OWLDisjointClassesAxiom axiom) { + return counter(axiom.classExpressions()); + } + + @Override + public Integer visit(OWLDataPropertyDomainAxiom axiom) { + return axiom.getDomain().accept(this); + } + + @Override + public Integer visit(OWLObjectMinCardinality ce) { + return Integer.valueOf(1 + ce.getFiller().accept(this).intValue()); + } + + @Override + public Integer visit(OWLObjectPropertyDomainAxiom axiom) { + return axiom.getDomain().accept(this); + } + + @Override + public Integer visit(OWLObjectExactCardinality ce) { + return Integer.valueOf(1 + ce.getFiller().accept(this).intValue()); + } + + @Override + public Integer visit(OWLObjectMaxCardinality ce) { + return Integer.valueOf(1 + ce.getFiller().accept(this).intValue()); + } + + @Override + public Integer visit(OWLObjectHasSelf ce) { + return _1; + } + + @Override + public Integer visit(OWLDataSomeValuesFrom ce) { + return _1; + } + + @Override + public Integer visit(OWLDataAllValuesFrom ce) { + return _1; + } + + @Override + public Integer visit(OWLDataHasValue ce) { + return _1; + } + + @Override + public Integer visit(OWLDataMinCardinality ce) { + return _1; + } + + @Override + public Integer visit(OWLDataExactCardinality ce) { + return _1; + } + + @Override + public Integer visit(OWLDataMaxCardinality ce) { + return _1; + } + + @Override + public Integer visit(OWLClassAssertionAxiom axiom) { + return axiom.getClassExpression().accept(this); + } + + @Override + public Integer visit(OWLEquivalentClassesAxiom axiom) { + return counter(axiom.classExpressions()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/Monitorable.java b/api/src/main/java/org/semanticweb/owlapi/util/Monitorable.java new file mode 100644 index 0000000000..6986dac0b2 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/Monitorable.java @@ -0,0 +1,46 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +/** + * Certain tasks or algorithms may take some time to accomplish. For example + * parsing, saving etc. In some situations, it is desirable to monitor the + * progress of such tasks, for example to provide feedback in user interfaces. + * Interfaces which represent long tasks can implement this progress monitor + * interface to provide a hook for a progress monitor. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface Monitorable { + + /** + * Sets the progress monitor which receives information about the progress + * of the this object which represents a long running task. + * + * @param progressMonitor progress monitor + */ + void setProgressMonitor(ProgressMonitor progressMonitor); + + /** + * Interrupts the long running task (if possible). + * + * @throws InterruptedException interrupted exception + */ + void interrupt() throws InterruptedException; + + /** + * @return true if this long running task can be cancelled. + */ + boolean canInterrupt(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/NNF.java b/api/src/main/java/org/semanticweb/owlapi/util/NNF.java new file mode 100644 index 0000000000..2a71732885 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/NNF.java @@ -0,0 +1,416 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLAxiomVisitorEx; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataComplementOf; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataIntersectionOf; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLDataRangeVisitorEx; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDataUnionOf; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; + +/** + * @author Matthew Horridge, The University Of Manchester, Information Management Group + * @since 2.2.0 + */ +public class NNF implements OWLAxiomVisitorEx { + + protected final OWLDataFactory df; + protected final OWLClassExpressionVisitorEx classVisitor = new ClassVisitor(); + protected final OWLDataRangeVisitorEx dataVisitor = new DataVisitor(); + protected boolean negated; + /** + * @param datafactory datafactory to use + */ + public NNF(OWLDataFactory datafactory) { + df = checkNotNull(datafactory, "dataFactory cannot be null"); + } + + /** + * @return class visitor + */ + public OWLClassExpressionVisitorEx getClassVisitor() { + return classVisitor; + } + + /** + * reset the negation. + */ + public void reset() { + negated = false; + } + + @Override + public OWLAxiom doDefault(T object) { + return (OWLAxiom) object; + } + + // Conversion of non-class expressions to NNF + @Override + public OWLAxiom visit(OWLSubClassOfAxiom axiom) { + return df.getOWLSubClassOfAxiom(axiom.getSubClass().accept(classVisitor), + axiom.getSuperClass().accept(classVisitor)); + } + + @Override + public OWLAxiom visit(OWLDisjointClassesAxiom axiom) { + return df + .getOWLDisjointClassesAxiom(axiom.classExpressions().map(p -> p.accept(classVisitor))); + } + + @Override + public OWLAxiom visit(OWLDataPropertyDomainAxiom axiom) { + return df.getOWLDataPropertyDomainAxiom(axiom.getProperty(), + axiom.getDomain().accept(classVisitor)); + } + + @Override + public OWLAxiom visit(OWLObjectPropertyDomainAxiom axiom) { + return df.getOWLObjectPropertyDomainAxiom(axiom.getProperty(), + axiom.getDomain().accept(classVisitor)); + } + + @Override + public OWLAxiom visit(OWLObjectPropertyRangeAxiom axiom) { + return df.getOWLObjectPropertyRangeAxiom(axiom.getProperty(), + axiom.getRange().accept(classVisitor)); + } + + @Override + public OWLAxiom visit(OWLDisjointUnionAxiom axiom) { + return df.getOWLDisjointUnionAxiom(axiom.getOWLClass(), + asList(axiom.classExpressions().map(p -> p.accept(classVisitor)))); + } + + @Override + public OWLAxiom visit(OWLDataPropertyRangeAxiom axiom) { + return df.getOWLDataPropertyRangeAxiom(axiom.getProperty(), + axiom.getRange().accept(dataVisitor)); + } + + @Override + public OWLAxiom visit(OWLClassAssertionAxiom axiom) { + if (axiom.getClassExpression().isAnonymous()) { + return df.getOWLClassAssertionAxiom(axiom.getClassExpression().accept(classVisitor), + axiom.getIndividual()); + } + return axiom; + } + + @Override + public OWLAxiom visit(OWLEquivalentClassesAxiom axiom) { + return df.getOWLEquivalentClassesAxiom( + axiom.classExpressions().map(p -> p.accept(classVisitor))); + } + + class DataVisitor implements OWLDataRangeVisitorEx { + + @Override + public OWLDataRange visit(OWLDatatype node) { + if (negated) { + return df.getOWLDataComplementOf(node); + } + return node; + } + + @Override + public OWLDataRange visit(OWLDataComplementOf node) { + if (negated) { + return node.getDataRange(); + } + return node; + } + + @Override + public OWLDataRange visit(OWLDataOneOf node) { + if (node.values().count() == 1) { + if (negated) { + return df.getOWLDataComplementOf(node); + } + return node; + } + return df.getOWLDataUnionOf(node.values().map(df::getOWLDataOneOf)).accept(this); + } + + @Override + public OWLDataRange visit(OWLDataIntersectionOf node) { + Stream ops = node.operands().map(p -> p.accept(this)); + if (negated) { + return df.getOWLDataUnionOf(ops); + } + return df.getOWLDataIntersectionOf(ops); + } + + @Override + public OWLDataRange visit(OWLDataUnionOf node) { + Stream ops = node.operands().map(p -> p.accept(this)); + if (negated) { + // Flip to an intersection + return df.getOWLDataIntersectionOf(ops); + } + return df.getOWLDataUnionOf(ops); + } + + @Override + public OWLDataRange visit(OWLDatatypeRestriction node) { + if (negated) { + return df.getOWLDataComplementOf(node); + } + return node; + } + } + + class ClassVisitor implements OWLClassExpressionVisitorEx { + + private OWLClassExpression getNegation(OWLClassExpression classExpression) { + return df.getOWLObjectComplementOf(classExpression); + } + + @Override + public OWLClassExpression visit(OWLClass ce) { + if (negated) { + if (ce.isOWLNothing()) { + return df.getOWLThing(); + } + if (ce.isOWLThing()) { + return df.getOWLNothing(); + } + return getNegation(ce); + } + return ce; + } + + @Override + public OWLClassExpression visit(OWLObjectIntersectionOf ce) { + Stream ops = ce.operands().map(p -> p.accept(this)); + if (negated) { + return df.getOWLObjectUnionOf(ops); + } + return df.getOWLObjectIntersectionOf(ops); + } + + @Override + public OWLClassExpression visit(OWLObjectUnionOf ce) { + Stream ops = ce.operands().map(p -> p.accept(this)); + if (negated) { + // Flip to an intersection + return df.getOWLObjectIntersectionOf(ops); + } + return df.getOWLObjectUnionOf(ops); + } + + @Override + public OWLClassExpression visit(OWLObjectComplementOf ce) { + if (negated) { + // Cancels out. + // Save and then restore. + boolean neg = negated; + negated = false; + OWLClassExpression negDesc = ce.getOperand().accept(this); + negated = neg; + return negDesc; + } + // Save and then restore + boolean neg = negated; + negated = true; + OWLClassExpression negDesc = ce.getOperand().accept(this); + negated = neg; + return negDesc; + } + + @Override + public OWLClassExpression visit(OWLObjectSomeValuesFrom ce) { + OWLClassExpression filler = ce.getFiller().accept(this); + if (negated) { + return df.getOWLObjectAllValuesFrom(ce.getProperty(), filler); + } + return df.getOWLObjectSomeValuesFrom(ce.getProperty(), filler); + } + + @Override + public OWLClassExpression visit(OWLObjectAllValuesFrom ce) { + OWLClassExpression filler = ce.getFiller().accept(this); + if (negated) { + return df.getOWLObjectSomeValuesFrom(ce.getProperty(), filler); + } + return df.getOWLObjectAllValuesFrom(ce.getProperty(), filler); + } + + @Override + public OWLClassExpression visit(OWLObjectHasValue ce) { + return ce.asSomeValuesFrom().accept(this); + } + + @Override + public OWLClassExpression visit(OWLObjectMinCardinality ce) { + boolean neg = negated; + int card = ce.getCardinality(); + if (negated) { + card = ce.getCardinality() - 1; + if (card < 0) { + card = 0; + } + } + negated = false; + OWLClassExpression filler = ce.getFiller().accept(this); + negated = neg; + if (neg) { + return df.getOWLObjectMaxCardinality(card, ce.getProperty(), filler); + } + return df.getOWLObjectMinCardinality(card, ce.getProperty(), filler); + } + + @Override + public OWLClassExpression visit(OWLObjectExactCardinality ce) { + return ce.asIntersectionOfMinMax().accept(this); + } + + @Override + public OWLClassExpression visit(OWLObjectMaxCardinality ce) { + boolean neg = negated; + int card = ce.getCardinality(); + if (negated) { + card = ce.getCardinality() + 1; + } + negated = false; + OWLClassExpression filler = ce.getFiller().accept(this); + negated = neg; + if (neg) { + return df.getOWLObjectMinCardinality(card, ce.getProperty(), filler); + } + return df.getOWLObjectMaxCardinality(card, ce.getProperty(), filler); + } + + @Override + public OWLClassExpression visit(OWLObjectHasSelf ce) { + if (negated) { + return getNegation(ce); + } else { + return ce; + } + } + + @Override + public OWLClassExpression visit(OWLObjectOneOf ce) { + if (ce.individuals().count() == 1) { + if (negated) { + return getNegation(ce); + } else { + return ce; + } + } + return ce.asObjectUnionOf().accept(this); + } + + @Override + public OWLClassExpression visit(OWLDataSomeValuesFrom ce) { + OWLDataRange filler = ce.getFiller().accept(dataVisitor); + if (negated) { + return df.getOWLDataAllValuesFrom(ce.getProperty(), filler); + } + return df.getOWLDataSomeValuesFrom(ce.getProperty(), filler); + } + + @Override + public OWLClassExpression visit(OWLDataAllValuesFrom ce) { + OWLDataRange filler = ce.getFiller().accept(dataVisitor); + if (negated) { + return df.getOWLDataSomeValuesFrom(ce.getProperty(), filler); + } + return df.getOWLDataAllValuesFrom(ce.getProperty(), filler); + } + + @Override + public OWLClassExpression visit(OWLDataHasValue ce) { + return ce.asSomeValuesFrom().accept(this); + } + + @Override + public OWLClassExpression visit(OWLDataExactCardinality ce) { + return ce.asIntersectionOfMinMax().accept(this); + } + + @Override + public OWLClassExpression visit(OWLDataMaxCardinality ce) { + boolean neg = negated; + int card = ce.getCardinality(); + if (negated) { + card = ce.getCardinality() + 1; + } + negated = false; + OWLDataRange filler = ce.getFiller().accept(dataVisitor); + negated = neg; + if (neg) { + return df.getOWLDataMinCardinality(card, ce.getProperty(), filler); + } + return df.getOWLDataMaxCardinality(card, ce.getProperty(), filler); + } + + @Override + public OWLClassExpression visit(OWLDataMinCardinality ce) { + boolean neg = negated; + int card = ce.getCardinality(); + if (negated) { + card = ce.getCardinality() - 1; + if (card < 0) { + card = 0; + } + } + negated = false; + OWLDataRange filler = ce.getFiller().accept(dataVisitor); + negated = neg; + if (neg) { + return df.getOWLDataMaxCardinality(card, ce.getProperty(), filler); + } + return df.getOWLDataMinCardinality(card, ce.getProperty(), filler); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/NamedConjunctChecker.java b/api/src/main/java/org/semanticweb/owlapi/util/NamedConjunctChecker.java new file mode 100644 index 0000000000..3358b52c21 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/NamedConjunctChecker.java @@ -0,0 +1,128 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLClassExpressionVisitor; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; + +/** + * A utility class which checks if a class expression has a named conjunct or a specific named + * conjunct. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class NamedConjunctChecker { + + final Set conjuncts = new HashSet<>(); + private final NamedConjunctCheckerVisitor visitor = new NamedConjunctCheckerVisitor(); + @Nullable + protected OWLClass conjunct; + boolean found; + boolean collect; + + /** + * @param conj The conjunct to check for + * @param classExpression The expression to be checked + * @return true if a named class is a conjunct in a given class expression. For class + * expressions which aren't named classes or object intersections this method will + * always return false. + */ + public boolean isNamedConjunct(OWLClass conj, OWLClassExpression classExpression) { + checkNotNull(conj, "conj cannot be null"); + checkNotNull(classExpression, "classExpression cannot be null"); + reset(); + conjunct = conj; + classExpression.accept(visitor); + return found; + } + + /** + * Checks whether the specified expression has a named conjunct. For For class expressions which + * aren't named classes or object intersections this method will always return false. + * + * @param classExpression The expression to be checked. + * @return {@code true} if the expression is in fact a named class ( {@code OWLClass}) or if the + * expression is an intersection that has a named operand (included nested + * intersections), otherwise {@code false} + */ + public boolean hasNamedConjunct(OWLClassExpression classExpression) { + checkNotNull(classExpression, "classExpression cannot be null"); + reset(); + conjunct = null; + classExpression.accept(visitor); + return found; + } + + private void reset() { + found = false; + collect = false; + } + + /** + * Gets the named conjuncts for the specified expression. + * + * @param classExpression The expression whose conjuncts are to be retrieved. + * @return A set containing the named conjuncts of the specified expression. If the expression + * is not a named class or an intersection then the set will definitely be empty. + */ + public Set getNamedConjuncts(OWLClassExpression classExpression) { + checkNotNull(classExpression, "classExpression cannot be null"); + conjuncts.clear(); + reset(); + collect = true; + classExpression.accept(visitor); + return conjuncts; + } + + private class NamedConjunctCheckerVisitor implements OWLClassExpressionVisitor { + + NamedConjunctCheckerVisitor() {} + + @Override + public void visit(OWLClass ce) { + if (conjunct == null) { + found = true; + if (collect) { + conjuncts.add(ce); + } + } else if (ce.equals(conjunct)) { + found = true; + if (collect) { + conjuncts.add(ce); + } + } + } + + @Override + public void visit(OWLObjectIntersectionOf ce) { + Iterator it = ce.operands().iterator(); + while (it.hasNext()) { + it.next().accept(this); + if (found && !collect) { + return; + } + } + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/NamespaceUtil.java b/api/src/main/java/org/semanticweb/owlapi/util/NamespaceUtil.java new file mode 100644 index 0000000000..b71274b6fe --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/NamespaceUtil.java @@ -0,0 +1,147 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import java.io.Serializable; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; + +import org.semanticweb.owlapi.io.XMLUtils; +import org.semanticweb.owlapi.vocab.DublinCoreVocabulary; +import org.semanticweb.owlapi.vocab.Namespaces; + +/** + * A utility class which can generate namespaces, local names and namespace prefixes in accordance + * with the XML specifications. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class NamespaceUtil implements Serializable { + + private final Map namespace2PrefixMap = new HashMap<>(); + private final Map standardNamespacePrefixMappings = new HashMap<>(); + private final AtomicInteger candidateIndex = new AtomicInteger(1); + + /** + * Default constructor. + */ + public NamespaceUtil() { + standardNamespacePrefixMappings.put(DublinCoreVocabulary.NAME_SPACE, "dc"); + standardNamespacePrefixMappings.put(Namespaces.SKOS.toString(), "skos"); + namespace2PrefixMap.put(Namespaces.OWL.toString(), "owl"); + namespace2PrefixMap.put(Namespaces.RDFS.toString(), "rdfs"); + namespace2PrefixMap.put(Namespaces.RDF.toString(), "rdf"); + namespace2PrefixMap.put(Namespaces.XSD.toString(), "xsd"); + } + + /** + * Gets a prefix for the given namespace. If a mapping has not been specified then a prefix will + * be computed and stored for the specified namespace. + * + * @param namespace The namespace whose prefix is to be retrieved. + * @return The prefix for the specified namespace. + */ + public String getPrefix(String namespace) { + checkNotNull(namespace, "namespace cannot be null"); + String prefix = namespace2PrefixMap.get(namespace); + if (prefix != null) { + return prefix; + } + // We need to generate a candidate prefix + prefix = generatePrefix(namespace); + namespace2PrefixMap.put(namespace, prefix); + return prefix; + } + + /** + * @return namespace to prefix map + */ + public Map getNamespace2PrefixMap() { + return Collections.unmodifiableMap(namespace2PrefixMap); + } + + /** + * Generates a candidate prefix for the specified namespace. + * + * @param namespace The namespace that a prefix should be generated for. The implementation + * attempts to generate a prefix based on the namespace. If it cannot do this, a prefix + * of the form pn is generated, where n is an integer. + * @return The generated prefix. Note that this method will not store the namespace to prefix + * mapping. + */ + private String generatePrefix(String namespace) { + checkNotNull(namespace, "namespace cannot be null"); + String prefix = standardNamespacePrefixMappings.get(namespace); + if (prefix != null) { + namespace2PrefixMap.put(namespace, prefix); + return prefix; + } + int startIndex = -1; + for (int i = namespace.length() - 1; i > -1; i--) { + char curChar = namespace.charAt(i); + boolean isStartChar = XMLUtils.isNCNameStartChar(curChar); + if (isStartChar || startIndex == -1) { + if (isStartChar) { + startIndex = i; + } + } else if (!XMLUtils.isNCNameChar(curChar)) { + break; + } + } + String computedPrefix = computePrefix(namespace, startIndex); + String candidatePrefix = computedPrefix; + while (namespace2PrefixMap.containsValue(candidatePrefix) + || standardNamespacePrefixMappings.containsValue(candidatePrefix)) { + candidatePrefix = computedPrefix + candidateIndex.getAndIncrement(); + } + return verifyNotNull(candidatePrefix); + } + + protected String computePrefix(String namespace, int startIndex) { + if (startIndex != -1) { + int endIndex = startIndex + 1; + for (int i = startIndex; endIndex < namespace.length() && i < namespace.length(); i++) { + char curChar = namespace.charAt(endIndex); + // We include any NCNameChar except a full stop (.) so + // that if the URI looks like a file with an extension the + // extension is removed. + if (XMLUtils.isNCNameChar(curChar) && curChar != '.') { + endIndex = i + 1; + } else { + break; + } + } + return namespace.substring(startIndex, endIndex); + } + return "p"; + } + + /** + * Sets the prefix for the specified namespace. This will override any computed prefix and take + * precedence over any computed prefix. + * + * @param namespace The namespace whose prefix is to be set. + * @param prefix The prefix for the namespace + */ + public void setPrefix(String namespace, String prefix) { + checkNotNull(namespace, "namespace cannot be null"); + checkNotNull(prefix, "prefix cannot be null"); + namespace2PrefixMap.put(namespace, prefix); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/NullProgressMonitor.java b/api/src/main/java/org/semanticweb/owlapi/util/NullProgressMonitor.java new file mode 100644 index 0000000000..6c1c9b7d6a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/NullProgressMonitor.java @@ -0,0 +1,21 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class NullProgressMonitor implements ProgressMonitor { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLAPIPreconditions.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLAPIPreconditions.java new file mode 100644 index 0000000000..58e32dfacc --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLAPIPreconditions.java @@ -0,0 +1,265 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.Collection; +import java.util.Optional; +import java.util.function.Supplier; + +import javax.annotation.Nonnegative; +import javax.annotation.Nullable; + +/** + * A set of personalized preconditions. + */ +public final class OWLAPIPreconditions { + + private OWLAPIPreconditions() {} + + /** + * Check that the argument is not null; if the argument is null, throw an IllegalStateException. + * This method is meant to be used to verify conditions on member variables rather than input + * parameters. + * + * @param object reference to check + * @param reference type + * @return the input reference if not null + * @throws IllegalStateException if object is null + */ + public static T verifyNotNull(@Nullable T object) { + return verifyNotNull(object, "value cannot be null at this stage"); + } + + /** + * Check that the argument is not null; if the argument is null, throw an IllegalStateException. + * This method is meant to be used to verify conditions on member variables rather than input + * parameters. + * + * @param object reference to check + * @param message message to use for the error + * @param reference type + * @return the input reference if not null + * @throws IllegalStateException if object is null + */ + public static T verifyNotNull(@Nullable T object, String message) { + if (object == null) { + throw new IllegalStateException(message); + } + return object; + } + + /** + * Check that the argument is not null; if the argument is null, throw an IllegalStateException. + * This method is meant to be used to verify conditions on member variables rather than input + * parameters. + * + * @param object reference to check + * @param message message to use for the error + * @param reference type + * @return the input reference if not null + * @throws IllegalStateException if object is null + */ + public static T verifyNotNull(@Nullable T object, Supplier message) { + if (object == null) { + throw new IllegalStateException(message.get()); + } + return object; + } + + /** + * Check for null and throw NullPointerException if null. + * + * @param object reference to check + * @param reference type + * @return the input reference if not null + * @throws NullPointerException if object is null + */ + public static T checkNotNull(@Nullable T object) { + return checkNotNull(object, () -> "this variable cannot be null"); + } + + /** + * Check for null and throw NullPointerException if null. + * + * @param object reference to check + * @param message message for the illegal argument exception + * @param reference type + * @return the input reference if not null + * @throws NullPointerException if object is null + */ + public static T checkNotNull(@Nullable T object, String message) { + if (object == null) { + throw new NullPointerException(message); + } + return object; + } + + /** + * Check for null or empty and throw NullPointerException if null or empty. + * + * @param object reference to check + * @param message message for the illegal argument exception + * @param collection type + * @param reference type + * @return the input reference if not null + * @throws NullPointerException if object is null + */ + public static > T checkValidForNAryExpressions(@Nullable T object, + String message) { + if (object == null || object.isEmpty()) { + throw new NullPointerException(message); + } + return object; + } + + /** + * Check for null and throw NullPointerException if null. + * + * @param object reference to check + * @param message message for the illegal argument exception + * @param reference type + * @return the input reference if not null + * @throws NullPointerException if object is null + */ + public static T checkNotNull(@Nullable T object, Supplier message) { + if (object == null) { + throw new NullPointerException(message.get()); + } + return object; + } + + /** + * Check for negative value and throw IllegalArgumentException if negative. + * + * @param object value to check + * @throws IllegalArgumentException if object is negative + */ + public static void checkNotNegative(@Nonnegative long object) { + checkNotNegative(object, () -> "this variable cannot be negative: " + object); + } + + /** + * Check for negative value and throw IllegalArgumentException if negative. + * + * @param object value to check + * @param message message for the illegal argument exception + * @throws IllegalArgumentException if object is negative + */ + public static void checkNotNegative(@Nonnegative long object, String message) { + checkNotNegative(object, () -> message); + } + + /** + * Check for negative value and throw IllegalArgumentException if negative. + * + * @param object value to check + * @param message message for the illegal argument exception + * @throws IllegalArgumentException if object is negative + */ + public static void checkNotNegative(@Nonnegative long object, Supplier message) { + if (object < 0) { + throw new IllegalArgumentException(message.get()); + } + } + + /** + * Check for absent and throw IllegalArgumentException if null or absent. + * + * @param object reference to check + * @param message message for the illegal argument exception + * @param reference type + * @return the input reference if not null + * @throws IllegalArgumentException if object is null + * @deprecated use {@link #checkNotNull(Object, Supplier)} + */ + @Deprecated + public static T checkNotNull(@Nullable Optional object, String message) { + return checkNotNull(object, () -> message); + } + + /** + * Check for absent and throw IllegalArgumentException if null or absent. + * + * @param object reference to check + * @param message message for the illegal argument exception + * @param reference type + * @return the input reference if not null + * @throws IllegalArgumentException if object is null + */ + public static T checkNotNull(@Nullable Optional object, Supplier message) { + if (object == null || !object.isPresent()) { + throw new IllegalArgumentException(message.get()); + } + return verifyNotNull(object.get()); + } + + /** + * @param o collection to check for nullness and null elements, and optionally for + * emptiness + * @param name message for error + * @param emptyAllowed true if the input can be empty + */ + public static void checkIterableNotNull(@Nullable Collection o, String name, + boolean emptyAllowed) { + checkNotNull(o, name); + assert o != null; + if (!emptyAllowed && o.isEmpty()) { + throw new IllegalArgumentException(name + " or empty"); + } + } + + /** + * @param o array to check for nullness and null elements, and optionally for + * emptiness + * @param name message for error + * @param emptyAllowed true if the input can be empty + */ + public static void checkIterableNotNull(Object[] o, String name, boolean emptyAllowed) { + checkNotNull(o, name); + if (!emptyAllowed && o.length == 0) { + throw new IllegalArgumentException(name + " or empty"); + } + } + + /** + * Wrapper to allow non null annotations. + * + * @param type + * @return empty optional instance + */ + public static Optional emptyOptional() { + return Optional.empty(); + } + + /** + * Wrapper to allow non null annotations. + * + * @param type + * @param t type for the returned optional + * @return empty optional instance + */ + public static Optional emptyOptional(@SuppressWarnings("unused") Class t) { + return Optional.empty(); + } + + /** + * Wrapper to allow non null annotations. + * + * @param type + * @param t instance to wrap. Can be null (the result will be Optional.empty()) + * @return optional instance (content can be absent) + */ + public static Optional optional(@Nullable T t) { + return Optional.ofNullable(t); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLAPIStreamUtils.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLAPIStreamUtils.java new file mode 100644 index 0000000000..a8d3493fbe --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLAPIStreamUtils.java @@ -0,0 +1,585 @@ +package org.semanticweb.owlapi.util; + +import static java.util.Spliterator.DISTINCT; +import static java.util.Spliterator.IMMUTABLE; +import static java.util.Spliterator.NONNULL; +import static java.util.Spliterator.SIZED; +import static java.util.Spliterator.SORTED; +import static java.util.stream.Collectors.toSet; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.SortedSet; +import java.util.Spliterators; +import java.util.TreeSet; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; + +import org.semanticweb.owlapi.model.HasComponents; +import org.semanticweb.owlapi.model.OWLObject; + +/** + * A few util methods for common stream operations. + */ +public class OWLAPIStreamUtils { + + private static final int CHARACTERISTICS = DISTINCT | IMMUTABLE | NONNULL | SORTED | SIZED; + + private OWLAPIStreamUtils() {} + + /** + * @param type + * @param type type of the returned array + * @param s stream to turn to sorted, duplicate free, no null, list + * @return sorted array containing all elements in the stream, minus nulls and duplicates. The + * list is immutable. + */ + public static List sorted(Class type, Stream s) { + // skip nulls, skip duplicates, ensure sorted + return Collections + .unmodifiableList(asList(s.filter(Objects::nonNull).distinct().sorted(), type)); + } + + /** + * @param type + * @param type type of the returned array + * @param c collection to turn to sorted, duplicate free, no null, list + * @return sorted array containing all elements in the collection, minus nulls and duplicates. + * The list is immutable. + */ + public static List sorted(Class type, Collection c) { + if (c.isEmpty()) { + return Collections.emptyList(); + } + if (c instanceof List) { + return sorted(type, (List) c); + } + if (c instanceof Set) { + return sorted(type, (Set) c); + } + return sorted(type, c.stream()); + } + + /** + * @param type + * @param type type of the returned array + * @param c collection to turn to sorted, duplicate free, no null, list + * @return sorted array containing all elements in the collection, minus nulls and duplicates. + * The list is immutable. + */ + public static List sorted(Class type, List c) { + List list = new ArrayList<>(c); + for (int i = 0; i < list.size();) { + if (list.get(i) == null) { + list.remove(i); + } else { + i++; + } + } + list.sort(null); + for (int i = 1; i < list.size();) { + if (list.get(i).equals(list.get(i - 1))) { + list.remove(i); + } else { + i++; + } + } + return Collections.unmodifiableList(list); + } + + /** + * @param type + * @param type type of the returned array + * @param c collection to turn to sorted, duplicate free, no null, list + * @return sorted array containing all elements in the collection, minus nulls and duplicates. + * The list is immutable. + */ + public static List sorted(Class type, Set c) { + List list = new ArrayList<>(c); + for (int i = 0; i < list.size();) { + if (list.get(i) == null) { + list.remove(i); + } else { + i++; + } + } + list.sort(null); + return Collections.unmodifiableList(list); + } + + /** + * @param type + * @param type type of the returned array + * @param c array to sort + * @return sorted list containing all elements in the collection, minus nulls and duplicates. + * The list is immutable. + */ + @SafeVarargs + public static List sorted(Class type, T... c) { + return sorted(type, Arrays.asList(c)); + } + + /** + * A method to be used on collections that are sorted, immutable and do not contain nulls. + * + * @param type + * @param c sorted collection of distinct, non null elements; the collection must be immutable + * @return stream that won't cause sorted() calls to sort the collection again + */ + public static Stream streamFromSorted(Collection c) { + return StreamSupport.stream(Spliterators.spliterator(c, CHARACTERISTICS), false); + } + + /** + * A method to be used on arrays that are sorted and do not contain nulls. + * + * @param type + * @param c sorted array of distinct, non null elements + * @return stream that won't cause sorted() calls to sort the array again + */ + public static Stream streamFromSorted(T[] c) { + return StreamSupport.stream(Spliterators.spliterator(c, CHARACTERISTICS), false); + } + + /** + * @param type + * @param s stream to turn to set. The stream is consumed by this operation. + * @return set including all elements in the stream + */ + public static Set asSet(Stream s) { + return s.collect(Collectors.toCollection(LinkedHashSet::new)); + } + + /** + * @param s stream to turn to set. The stream is consumed by this operation. + * @param type force return type to be exactly T + * @param type of return collection + * @return set including all elements in the stream + */ + public static Set asSet(Stream s, Class type) { + Set set = new LinkedHashSet<>(); + add(set, s.map(type::cast)); + return set; + } + + /** + * @param type + * @param s stream to turn to set. The stream is consumed by this operation. + * @return set including all elements in the stream + */ + public static Set asUnorderedSet(Stream s) { + return s.collect(toSet()); + } + + /** + * @param s stream to turn to set. The stream is consumed by this operation. + * @param type force return type to be exactly T + * @param type of return collection + * @return set including all elements in the stream + */ + public static Set asUnorderedSet(Stream s, Class type) { + return s.map(type::cast).collect(toSet()); + } + + /** + * @param type + * @param s stream to turn to list. The stream is consumed by this operation. + * @return list including all elements in the stream + */ + public static List asList(Stream s) { + return s.collect(Collectors.toList()); + } + + /** + * @param type + * @param s stream to turn to list. The stream is consumed by this operation. + * @return list including all elements in the stream + */ + public static List asListNullsForbidden(Stream s) { + return asList(s.map(OWLAPIPreconditions::checkNotNull)); + } + + /** + * @param s stream to turn to list. The stream is consumed by this operation. + * @param type force return type to be exactly T + * @param type of return collection + * @return list including all elements in the stream + */ + public static List asList(Stream s, Class type) { + return asList(s.map(type::cast)); + } + + /** + * @param s stream to turn to map. The stream is consumed by this operation. + * @param f function to create the key + * @param type of key + * @param type of input and value + * @return map including all elements in the stream, keyed by f + */ + public static Map asMap(Stream s, Function f) { + return asMap(s, f, v -> v); + } + + /** + * @param s stream to turn to map. The stream is consumed by this operation. + * @param key function to create the key + * @param val function to create the value + * @param type of key + * @param type of value + * @param type of input + * @return map including all elements in the stream, keyed by key and valued by val + */ + public static Map asMap(Stream s, Function key, Function val) { + return s.collect(Collectors.toConcurrentMap(key::apply, val::apply)); + } + + /** + * @param s stream to check for containment. The stream is consumed at least partially by this + * operation + * @param o object to search + * @return true if the stream contains the object + */ + public static boolean contains(Stream s, Object o) { + return s.anyMatch(x -> x.equals(o)); + } + + /** + * @param type + * @param s stream of elements to add + * @param c collection to add to + * @return true if any element in the stream is added to the collection + */ + public static boolean add(Collection c, Stream s) { + int size = c.size(); + s.forEach(c::add); + return c.size() != size; + } + + /** + * @param set1 collection to compare + * @param set2 collection to compare + * @return negative value if set1 comes before set2, positive value if set2 comes before set1, 0 + * if the two sets are equal or incomparable. + */ + public static int compareCollections(Collection set1, + Collection set2) { + SortedSet ss1; + if (set1 instanceof SortedSet) { + ss1 = (SortedSet) set1; + } else { + ss1 = new TreeSet<>(set1); + } + SortedSet ss2; + if (set2 instanceof SortedSet) { + ss2 = (SortedSet) set2; + } else { + ss2 = new TreeSet<>(set2); + } + return compareIterators(ss1.iterator(), ss2.iterator()); + } + + /** + * Compare streams through iterators (sensitive to order) + * + * @param set1 stream to compare + * @param set2 stream to compare + * @return negative value if set1 comes before set2, positive value if set2 comes before set1, 0 + * if the two sets are equal or incomparable. + */ + public static int compareStreams(Stream set1, Stream set2) { + return compareIterators(set1.sorted().iterator(), set2.sorted().iterator()); + } + + /** + * Compare iterators element by element (sensitive to order) + * + * @param set1 iterator to compare + * @param set2 iterator to compare + * @return negative value if set1 comes before set2, positive value if set2 comes before set1, 0 + * if the two sets are equal or incomparable. + */ + @SuppressWarnings({"unchecked", "rawtypes"}) + public static int compareIterators(Iterator set1, Iterator set2) { + while (set1.hasNext() && set2.hasNext()) { + Object o1 = set1.next(); + Object o2 = set2.next(); + int diff; + if (o1 instanceof Stream && o2 instanceof Stream) { + diff = compareIterators(((Stream) o1).iterator(), ((Stream) o2).iterator()); + } else if (o1 instanceof Collection && o2 instanceof Collection) { + diff = compareIterators(((Collection) o1).iterator(), + ((Collection) o2).iterator()); + } else if (o1 instanceof Comparable && o2 instanceof Comparable) { + diff = ((Comparable) o1).compareTo(o2); + } else { + throw new IllegalArgumentException( + "Incomparable types: '" + o1 + "' with class " + o1.getClass() + ", '" + o2 + + "' with class " + o2.getClass() + " found while comparing iterators"); + } + if (diff != 0) { + return diff; + } + } + return Boolean.compare(set1.hasNext(), set2.hasNext()); + } + + /** + * Check iterator contents for equality (sensitive to order) + * + * @param set1 iterator to compare + * @param set2 iterator to compare + * @return true if the iterators have the same content, false otherwise. + */ + public static boolean equalIterators(Iterator set1, Iterator set2) { + while (set1.hasNext() && set2.hasNext()) { + Object o1 = set1.next(); + Object o2 = set2.next(); + if (o1 instanceof Stream && o2 instanceof Stream) { + if (!equalStreams((Stream) o1, (Stream) o2)) { + return false; + } + } else { + if (!o1.equals(o2)) { + return false; + } + } + } + return set1.hasNext() == set2.hasNext(); + } + + /** + * Check streams for equality (sensitive to order) + * + * @param set1 stream to compare + * @param set2 stream to compare + * @return true if the streams have the same content, false otherwise. + */ + public static boolean equalStreams(Stream set1, Stream set2) { + return equalIterators(set1.iterator(), set2.iterator()); + } + + /** + * Check lists for equality (sensitive to order) + * + * @param set1 list to compare + * @param set2 list to compare + * @return true if the lists have the same content, false otherwise. + */ + public static int compareLists(List set1, List set2) { + return compareIterators(set1.iterator(), set2.iterator()); + } + + /** + * Annotated wrapper for Stream.empty() + * + * @param type + * @return empty stream + */ + public static Stream empty() { + return Stream.empty(); + } + + /** + * @param root the root for the invisit + * @return recursive invisit of all components included in the root component; includes the root + * and all intermediate nodes. Annotations and other groups of elements will be + * represented as streams or collections, same as if the accessor method on the object + * was used. + */ + public static Stream allComponents(HasComponents root) { + List> streams = new ArrayList<>(); + streams.add(Stream.of(root)); + root.components().forEach(o -> flat(root, streams, o)); + return streams.stream().flatMap(Function.identity()); + } + + protected static void flat(HasComponents root, List> streams, Object o) { + if (o == root) { + return; + } + if (o instanceof HasComponents) { + streams.add(allComponents((HasComponents) o)); + } else { + streams.add(Stream.of(o)); + } + } + + /** + * @param root the root for the invisit + * @return recursive invisit of all components included in the root component; includes the root + * and all intermediate nodes. Streams will be flattened. + */ + @SuppressWarnings({"rawtypes", "unchecked"}) + public static Stream flatComponents(HasComponents root) { + List streams = new ArrayList<>(); + streams.add(root); + root.components().filter(o -> o != root).forEach(o -> flatIteration(streams, o)); + return streams.stream(); + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + protected static void flatIteration(List streams, Object o) { + if (o instanceof Stream) { + ((Stream) o).forEach(o1 -> flatIteration(streams, o1)); + } else if (o instanceof Collection) { + ((Collection) o).forEach(o1 -> flatIteration(streams, o1)); + } else if (o instanceof HasComponents) { + streams.add(o); + ((HasComponents) o).components().forEach(o1 -> flatIteration(streams, o1)); + } else { + streams.add(o); + } + } + + /** + * @param size size of matrix + * @return a stream of coordinates for a triangular matrix of size {@code size}. For input 3, + * the values are (1,2), (1,3), (2,3) + */ + public static Stream pairs(int size) { + List values = new ArrayList<>((size * size - size) / 2); + for (int i = 0; i < size - 1; i++) { + for (int j = i + 1; j < size; j++) { + values.add(new int[] {i, j}); + } + } + return values.stream(); + } + + /** + * @param size size of matrix + * @return a stream of coordinates for a symmetric matrix of size {@code size}, excluding main + * diagonal. For input 3, the values are (1,2), (1,3), (2,3), (2,1),(3,1), (3,2) + */ + public static Stream allPairs(int size) { + List values = new ArrayList<>(size * size - size); + for (int i = 0; i < size; i++) { + for (int j = 0; j < size; j++) { + if (i != j) { + values.add(new int[] {i, j}); + } + } + } + return values.stream(); + } + + /** + * @param type + * @param input collection to partition + * @return a stream of elements for a triangular matrix of size {@code l.size()}, where l is the + * list corresponding to the input collection. For input of length 3, the values are + * (l.get(1),l.get(2)), (l.get(1),l.get(3)), (l.get(2),l.get(3)) + */ + public static Stream> pairs(Collection input) { + List l; + if (input instanceof List) { + l = (List) input; + } else { + l = new ArrayList<>(input); + } + int size = l.size(); + List> values = new ArrayList<>((size * size - size) / 2); + for (int i = 0; i < size - 1; i++) { + for (int j = i + 1; j < size; j++) { + values.add(pair(l.get(i), l.get(j))); + } + } + return values.stream(); + } + + /** + * @param type + * @param input collection to partition + * @return a stream of coordinates for a symmetric matrix of size {@code l.size()}, where l is + * the list corresponding to the input collection, excluding main diagonal. For input 3, + * the values are (l.get(1),l.get(2)), (l.get(1),l.get(3)), (l.get(2),l.get(3)), + * (l.get(2),l.get(1)),(l.get(3),l.get(1)), (l.get(3),l.get(2)) + */ + public static Stream> allPairs(Collection input) { + List l; + if (input instanceof List) { + l = (List) input; + } else { + l = new ArrayList<>(input); + } + int size = l.size(); + List> values = new ArrayList<>(size * size - size); + for (int i = 0; i < size; i++) { + for (int j = 0; j < size; j++) { + if (i != j) { + values.add(pair(l.get(i), l.get(j))); + } + } + } + return values.stream(); + } + + /** + * @param type + * @param input collection to partition + * @return a stream of elements for a triangular matrix of size {@code l.size()}, where l is the + * list corresponding to the input collection. For input of length 3, the values are + * (l.get(1),l.get(2)), (l.get(1),l.get(3)), (l.get(2),l.get(3)) + */ + public static Stream> pairs(Stream input) { + return pairs(asList(input)); + } + + /** + * @param type + * @param input collection to partition + * @return a stream of coordinates for a symmetric matrix of size {@code l.size()}, where l is + * the list corresponding to the input collection, excluding main diagonal. For input 3, + * the values are (l.get(1),l.get(2)), (l.get(1),l.get(3)), (l.get(2),l.get(3)), + * (l.get(2),l.get(1)),(l.get(3),l.get(1)), (l.get(3),l.get(2)) + */ + public static Stream> allPairs(Stream input) { + return allPairs(asList(input)); + } + + /** + * @param type + * @param i first + * @param j second + * @return pair of (i,j) + */ + public static Pair pair(T i, T j) { + return new Pair<>(i, j); + } + + /** + * Class for pairwise partition + * + * @param type + */ + public static class Pair { + + /** + * First element. + */ + public final T i; + /** + * Second element. + */ + public final T j; + + /** + * @param i first + * @param j second + */ + public Pair(T i, T j) { + this.i = i; + this.j = j; + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLAnnotationPropertyTransformer.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLAnnotationPropertyTransformer.java new file mode 100644 index 0000000000..f6549334b0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLAnnotationPropertyTransformer.java @@ -0,0 +1,805 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.EntityType; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationSubject; +import org.semanticweb.owlapi.model.OWLAnnotationValue; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataComplementOf; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataIntersectionOf; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDataUnionOf; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLHasKeyAxiom; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectInverseOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLObjectVisitor; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLProperty; +import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; +import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.SWRLBuiltInAtom; +import org.semanticweb.owlapi.model.SWRLClassAtom; +import org.semanticweb.owlapi.model.SWRLDataPropertyAtom; +import org.semanticweb.owlapi.model.SWRLDataRangeAtom; +import org.semanticweb.owlapi.model.SWRLDifferentIndividualsAtom; +import org.semanticweb.owlapi.model.SWRLIndividualArgument; +import org.semanticweb.owlapi.model.SWRLLiteralArgument; +import org.semanticweb.owlapi.model.SWRLObjectPropertyAtom; +import org.semanticweb.owlapi.model.SWRLObjectVisitor; +import org.semanticweb.owlapi.model.SWRLRule; +import org.semanticweb.owlapi.model.SWRLSameIndividualAtom; +import org.semanticweb.owlapi.model.SWRLVariable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLAnnotationPropertyTransformer implements OWLObjectVisitor, SWRLObjectVisitor { + + private static final Logger LOGGER = + LoggerFactory.getLogger(OWLAnnotationPropertyTransformer.class); + private final OWLDataFactory df; + private final Map replacementMap; + @Nullable + private Object obj; + + /** + * Creates an object duplicator that duplicates objects using the specified data factory. + * + * @param dataFactory The data factory to be used for the duplication. + */ + public OWLAnnotationPropertyTransformer(OWLDataFactory dataFactory) { + this(new HashMap(), dataFactory); + } + + /** + * Creates an object duplicator that duplicates objects using the specified data factory and uri + * replacement map. + * + * @param dataFactory The data factory to be used for the duplication. + * @param iriReplacementMap The map to use for the replacement of URIs. Any uris the appear in + * the map will be replaced as objects are duplicated. This can be used to "rename" + * entities. + */ + public OWLAnnotationPropertyTransformer(OWLDataFactory dataFactory, + Map iriReplacementMap) { + df = checkNotNull(dataFactory, "dataFactory cannot be null"); + checkNotNull(iriReplacementMap, "iriReplacementMap cannot be null"); + replacementMap = new HashMap<>(iriReplacementMap); + } + + /** + * Creates an object duplicator that duplicates objects using the specified data factory and uri + * replacement map. + * + * @param dataFactory The data factory to be used for the duplication. + * @param entityIRIReplacementMap The map to use for the replacement of URIs. Any uris the + * appear in the map will be replaced as objects are duplicated. This can be used to + * "rename" entities. + */ + public OWLAnnotationPropertyTransformer(Map entityIRIReplacementMap, + OWLDataFactory dataFactory) { + df = checkNotNull(dataFactory, "dataFactory cannot be null"); + replacementMap = new HashMap<>( + checkNotNull(entityIRIReplacementMap, "entityIRIReplacementMap cannot be null")); + } + + /** + * @param object the object to duplicate + * @param return type + * @return the duplicate + */ + public O transformObject(O object) { + checkNotNull(object, "object cannot be null"); + try { + return dup(object); + } catch (ClassCastException e) { + LOGGER.error( + "Attempt to transform an axiom to correct misuse of properties failed. Property replacement: {}, axiom: {}, error: {}", + replacementMap, object, e.getMessage()); + obj = object; + return object; + } + } + + protected void setLastObject(Object obj) { + this.obj = obj; + } + + @SuppressWarnings({"unchecked",}) + protected O dup(O o) { + o.accept(this); + return (O) verifyNotNull(obj); + } + + /** + * Given an IRI belonging to an entity, returns a IRI. This may be the same IRI that the entity + * has, or an alternative IRI if a replacement has been specified. + * + * @param entity The entity + * @return The IRI + */ + private OWLEntity getIRI(OWLEntity entity) { + OWLEntity replacement = replacementMap.get(entity); + if (replacement != null) { + return replacement; + } + return entity; + } + + private Collection anns(OWLAxiom ax) { + return set(ax.annotations()); + } + + @Override + public void visit(OWLAsymmetricObjectPropertyAxiom ax) { + obj = df.getOWLAsymmetricObjectPropertyAxiom(dup(ax.getProperty()), anns(ax)); + } + + @Override + public void visit(OWLClassAssertionAxiom ax) { + obj = df.getOWLClassAssertionAxiom(dup(ax.getClassExpression()), dup(ax.getIndividual()), + anns(ax)); + } + + @Override + public void visit(OWLDataPropertyAssertionAxiom ax) { + obj = df.getOWLDataPropertyAssertionAxiom(dup(ax.getProperty()), dup(ax.getSubject()), + dup(ax.getObject()), anns(ax)); + } + + @Override + public void visit(OWLDataPropertyDomainAxiom ax) { + obj = + df.getOWLDataPropertyDomainAxiom(dup(ax.getProperty()), dup(ax.getDomain()), anns(ax)); + } + + @Override + public void visit(OWLDataPropertyRangeAxiom ax) { + obj = df.getOWLDataPropertyRangeAxiom(dup(ax.getProperty()), dup(ax.getRange()), anns(ax)); + } + + @Override + public void visit(OWLSubDataPropertyOfAxiom ax) { + obj = df.getOWLSubDataPropertyOfAxiom(dup(ax.getSubProperty()), dup(ax.getSuperProperty()), + anns(ax)); + } + + @Override + public void visit(OWLDeclarationAxiom ax) { + obj = df.getOWLDeclarationAxiom(dup(ax.getEntity()), anns(ax)); + } + + @Override + public void visit(OWLDifferentIndividualsAxiom ax) { + obj = df.getOWLDifferentIndividualsAxiom(set(ax.individuals()), anns(ax)); + } + + @Override + public void visit(OWLDisjointClassesAxiom ax) { + obj = df.getOWLDisjointClassesAxiom(set(ax.classExpressions()), anns(ax)); + } + + @Override + public void visit(OWLDisjointDataPropertiesAxiom ax) { + obj = df.getOWLDisjointDataPropertiesAxiom(set(ax.properties()), anns(ax)); + } + + @Override + public void visit(OWLDisjointObjectPropertiesAxiom ax) { + obj = df.getOWLDisjointObjectPropertiesAxiom(set(ax.properties()), anns(ax)); + } + + @Override + public void visit(OWLDisjointUnionAxiom ax) { + obj = df.getOWLDisjointUnionAxiom(dup(ax.getOWLClass()), set(ax.classExpressions()), + anns(ax)); + } + + @Override + public void visit(OWLAnnotationAssertionAxiom ax) { + OWLAnnotationSubject subject = dup(ax.getSubject()); + OWLProperty prop = dup(ax.getProperty()); + OWLAnnotationValue value = dup(ax.getValue()); + if (prop.isObjectPropertyExpression()) { + // turn to object property assertion + OWLIndividual individual; + OWLIndividual relatedIndividual; + if (subject instanceof OWLAnonymousIndividual) { + individual = (OWLIndividual) subject; + } else { + individual = df.getOWLNamedIndividual((IRI) subject); + } + if (value instanceof OWLIndividual) { + relatedIndividual = (OWLIndividual) value; + } else { + relatedIndividual = df.getOWLNamedIndividual((IRI) value); + } + obj = df.getOWLObjectPropertyAssertionAxiom(prop.asOWLObjectProperty(), individual, + relatedIndividual, asList(ax.annotations())); + return; + } else if (prop.isDataPropertyExpression()) { + // turn to data property assertion + OWLIndividual individual; + if (subject instanceof OWLAnonymousIndividual) { + individual = (OWLIndividual) subject; + } else { + individual = df.getOWLNamedIndividual((IRI) subject); + } + obj = df.getOWLDataPropertyAssertionAxiom(prop.asOWLDataProperty(), individual, + (OWLLiteral) value, asList(ax.annotations())); + return; + } + obj = df.getOWLAnnotationAssertionAxiom(prop.asOWLAnnotationProperty(), subject, value, + anns(ax)); + } + + @Override + public void visit(OWLEquivalentClassesAxiom ax) { + obj = df.getOWLEquivalentClassesAxiom(set(ax.classExpressions()), anns(ax)); + } + + @Override + public void visit(OWLEquivalentDataPropertiesAxiom ax) { + obj = df.getOWLEquivalentDataPropertiesAxiom(set(ax.properties()), anns(ax)); + } + + @Override + public void visit(OWLEquivalentObjectPropertiesAxiom ax) { + obj = df.getOWLEquivalentObjectPropertiesAxiom(set(ax.properties()), anns(ax)); + } + + @Override + public void visit(OWLFunctionalDataPropertyAxiom ax) { + obj = df.getOWLFunctionalDataPropertyAxiom(dup(ax.getProperty()), anns(ax)); + } + + @Override + public void visit(OWLFunctionalObjectPropertyAxiom ax) { + obj = df.getOWLFunctionalObjectPropertyAxiom(dup(ax.getProperty()), anns(ax)); + } + + @Override + public void visit(OWLInverseFunctionalObjectPropertyAxiom ax) { + obj = df.getOWLInverseFunctionalObjectPropertyAxiom(dup(ax.getProperty()), anns(ax)); + } + + @Override + public void visit(OWLInverseObjectPropertiesAxiom ax) { + obj = df.getOWLInverseObjectPropertiesAxiom(dup(ax.getFirstProperty()), + dup(ax.getSecondProperty()), anns(ax)); + } + + @Override + public void visit(OWLIrreflexiveObjectPropertyAxiom ax) { + obj = df.getOWLIrreflexiveObjectPropertyAxiom(dup(ax.getProperty()), anns(ax)); + } + + @Override + public void visit(OWLNegativeDataPropertyAssertionAxiom ax) { + obj = df.getOWLNegativeDataPropertyAssertionAxiom(dup(ax.getProperty()), + dup(ax.getSubject()), dup(ax.getObject()), anns(ax)); + } + + @Override + public void visit(OWLNegativeObjectPropertyAssertionAxiom ax) { + obj = df.getOWLNegativeObjectPropertyAssertionAxiom(dup(ax.getProperty()), + dup(ax.getSubject()), dup(ax.getObject()), anns(ax)); + } + + @Override + public void visit(OWLObjectPropertyAssertionAxiom ax) { + obj = df.getOWLObjectPropertyAssertionAxiom(dup(ax.getProperty()), dup(ax.getSubject()), + dup(ax.getObject()), anns(ax)); + } + + @Override + public void visit(OWLSubPropertyChainOfAxiom ax) { + obj = + df.getOWLSubPropertyChainOfAxiom(asList(ax.getPropertyChain().stream().map(this::dup)), + dup(ax.getSuperProperty()), anns(ax)); + } + + @Override + public void visit(OWLObjectPropertyDomainAxiom ax) { + obj = df.getOWLObjectPropertyDomainAxiom(dup(ax.getProperty()), dup(ax.getDomain()), + anns(ax)); + } + + @Override + public void visit(OWLObjectPropertyRangeAxiom ax) { + obj = + df.getOWLObjectPropertyRangeAxiom(dup(ax.getProperty()), dup(ax.getRange()), anns(ax)); + } + + @Override + public void visit(OWLSubObjectPropertyOfAxiom ax) { + obj = df.getOWLSubObjectPropertyOfAxiom(dup(ax.getSubProperty()), + dup(ax.getSuperProperty()), anns(ax)); + } + + @Override + public void visit(OWLReflexiveObjectPropertyAxiom ax) { + obj = df.getOWLReflexiveObjectPropertyAxiom(dup(ax.getProperty()), anns(ax)); + } + + @Override + public void visit(OWLSameIndividualAxiom ax) { + obj = df.getOWLSameIndividualAxiom(set(ax.individuals()), anns(ax)); + } + + @Override + public void visit(OWLSubClassOfAxiom ax) { + obj = df.getOWLSubClassOfAxiom(dup(ax.getSubClass()), dup(ax.getSuperClass()), anns(ax)); + } + + @Override + public void visit(OWLSymmetricObjectPropertyAxiom ax) { + obj = df.getOWLSymmetricObjectPropertyAxiom(dup(ax.getProperty()), anns(ax)); + } + + @Override + public void visit(OWLTransitiveObjectPropertyAxiom ax) { + obj = df.getOWLTransitiveObjectPropertyAxiom(dup(ax.getProperty()), anns(ax)); + } + + @Override + public void visit(OWLClass ce) { + obj = getIRI(ce); + } + + @Override + public void visit(OWLDataAllValuesFrom ce) { + obj = df.getOWLDataAllValuesFrom(dup(ce.getProperty()), dup(ce.getFiller())); + } + + @Override + public void visit(OWLDataExactCardinality ce) { + obj = df.getOWLDataExactCardinality(ce.getCardinality(), dup(ce.getProperty()), + dup(ce.getFiller())); + } + + @Override + public void visit(OWLDataMaxCardinality ce) { + obj = df.getOWLDataMaxCardinality(ce.getCardinality(), dup(ce.getProperty()), + dup(ce.getFiller())); + } + + @Override + public void visit(OWLDataMinCardinality ce) { + obj = df.getOWLDataMinCardinality(ce.getCardinality(), dup(ce.getProperty()), + dup(ce.getFiller())); + } + + @Override + public void visit(OWLDataSomeValuesFrom ce) { + obj = df.getOWLDataSomeValuesFrom(dup(ce.getProperty()), dup(ce.getFiller())); + } + + @Override + public void visit(OWLDataHasValue ce) { + obj = df.getOWLDataHasValue(dup(ce.getProperty()), dup(ce.getFiller())); + } + + @Override + public void visit(OWLObjectAllValuesFrom ce) { + obj = df.getOWLObjectAllValuesFrom(dup(ce.getProperty()), dup(ce.getFiller())); + } + + @Override + public void visit(OWLObjectComplementOf ce) { + obj = df.getOWLObjectComplementOf(dup(ce.getOperand())); + } + + @Override + public void visit(OWLObjectExactCardinality ce) { + obj = df.getOWLObjectExactCardinality(ce.getCardinality(), dup(ce.getProperty()), + dup(ce.getFiller())); + } + + @Override + public void visit(OWLObjectIntersectionOf ce) { + obj = df.getOWLObjectIntersectionOf(set(ce.operands())); + } + + @Override + public void visit(OWLObjectMaxCardinality ce) { + obj = df.getOWLObjectMaxCardinality(ce.getCardinality(), dup(ce.getProperty()), + dup(ce.getFiller())); + } + + @Override + public void visit(OWLObjectMinCardinality ce) { + obj = df.getOWLObjectMinCardinality(ce.getCardinality(), dup(ce.getProperty()), + dup(ce.getFiller())); + } + + @Override + public void visit(OWLObjectOneOf ce) { + obj = df.getOWLObjectOneOf(set(ce.individuals())); + } + + @Override + public void visit(OWLObjectHasSelf ce) { + obj = df.getOWLObjectHasSelf(dup(ce.getProperty())); + } + + @Override + public void visit(OWLObjectSomeValuesFrom ce) { + obj = df.getOWLObjectSomeValuesFrom(dup(ce.getProperty()), dup(ce.getFiller())); + } + + @Override + public void visit(OWLObjectUnionOf ce) { + obj = df.getOWLObjectUnionOf(set(ce.operands())); + } + + @Override + public void visit(OWLObjectHasValue ce) { + obj = df.getOWLObjectHasValue(dup(ce.getProperty()), dup(ce.getFiller())); + } + + @Override + public void visit(OWLDataComplementOf node) { + obj = df.getOWLDataComplementOf(dup(node.getDataRange())); + } + + @Override + public void visit(OWLDataOneOf node) { + obj = df.getOWLDataOneOf(set(node.values())); + } + + @Override + public void visit(OWLDatatype node) { + obj = getIRI(node); + } + + @Override + public void visit(OWLDatatypeRestriction node) { + obj = df.getOWLDatatypeRestriction(dup(node.getDatatype()), + asList(node.facetRestrictions().map(this::dup))); + } + + @Override + public void visit(OWLFacetRestriction node) { + obj = df.getOWLFacetRestriction(node.getFacet(), dup(node.getFacetValue())); + } + + @Override + public void visit(OWLLiteral node) { + if (node.hasLang()) { + obj = df.getOWLLiteral(node.getLiteral(), node.getLang()); + } else { + obj = df.getOWLLiteral(node.getLiteral(), dup(node.getDatatype())); + } + } + + @Override + public void visit(OWLDataProperty property) { + obj = getIRI(property); + } + + @Override + public void visit(OWLObjectProperty property) { + obj = getIRI(property); + } + + @Override + public void visit(OWLObjectInverseOf property) { + obj = df.getOWLObjectInverseOf(dup(property.getInverse()).asOWLObjectProperty()); + } + + @Override + public void visit(OWLNamedIndividual individual) { + obj = getIRI(individual); + } + + @Override + public void visit(OWLOntology ontology) { + // Should we duplicate ontologies here? Probably not. + obj = ontology; + } + + @Override + public void visit(SWRLRule rule) { + obj = + df.getSWRLRule(asList(rule.body().map(this::dup)), asList(rule.head().map(this::dup))); + } + + @Override + public void visit(SWRLClassAtom node) { + obj = df.getSWRLClassAtom(dup(node.getPredicate()), dup(node.getArgument())); + } + + @Override + public void visit(SWRLDataRangeAtom node) { + obj = df.getSWRLDataRangeAtom(dup(node.getPredicate()), dup(node.getArgument())); + } + + @Override + public void visit(SWRLObjectPropertyAtom node) { + obj = df.getSWRLObjectPropertyAtom(dup(node.getPredicate()), dup(node.getFirstArgument()), + dup(node.getSecondArgument())); + } + + @Override + public void visit(SWRLDataPropertyAtom node) { + obj = df.getSWRLDataPropertyAtom(dup(node.getPredicate()), dup(node.getFirstArgument()), + dup(node.getSecondArgument())); + } + + @Override + public void visit(SWRLBuiltInAtom node) { + obj = df.getSWRLBuiltInAtom(node.getPredicate(), asList(node.arguments().map(this::dup))); + } + + @Override + public void visit(SWRLDifferentIndividualsAtom node) { + obj = df.getSWRLDifferentIndividualsAtom(dup(node.getFirstArgument()), + dup(node.getSecondArgument())); + } + + @Override + public void visit(SWRLSameIndividualAtom node) { + obj = df.getSWRLSameIndividualAtom(dup(node.getFirstArgument()), + dup(node.getSecondArgument())); + } + + @Override + public void visit(SWRLVariable node) { + obj = df.getSWRLVariable(dup(node.getIRI())); + } + + @Override + public void visit(SWRLIndividualArgument node) { + obj = df.getSWRLIndividualArgument(dup(node.getIndividual())); + } + + @Override + public void visit(SWRLLiteralArgument node) { + obj = df.getSWRLLiteralArgument(dup(node.getLiteral())); + } + + @Override + public void visit(OWLHasKeyAxiom ax) { + obj = df.getOWLHasKeyAxiom(dup(ax.getClassExpression()), set(ax.propertyExpressions()), + anns(ax)); + } + + @Override + public void visit(OWLDataIntersectionOf node) { + obj = df.getOWLDataIntersectionOf(set(node.operands())); + } + + @Override + public void visit(OWLDataUnionOf node) { + obj = df.getOWLDataUnionOf(set(node.operands())); + } + + @Override + public void visit(OWLAnnotationProperty property) { + obj = getIRI(property); + } + + @Override + public void visit(OWLAnnotationPropertyDomainAxiom ax) { + OWLProperty prop = dup(ax.getProperty()); + IRI domain = dup(ax.getDomain()); + if (prop.isObjectPropertyExpression()) { + // turn to object property domain + OWLClassExpression d = df.getOWLClass(domain); + LOGGER.warn( + "Annotation property domain axiom turned to object property domain after parsing. This could introduce errors if the original domain was an anonymous expression: {} is the new domain.", + domain); + obj = df.getOWLObjectPropertyDomainAxiom(prop.asOWLObjectProperty(), d, + asList(ax.annotations())); + return; + } else if (prop.isDataPropertyExpression()) { + // turn to data property domain + OWLClassExpression d = df.getOWLClass(domain); + LOGGER.warn( + "Annotation property domain axiom turned to data property domain after parsing. This could introduce errors if the original domain was an anonymous expression: {} is the new domain.", + domain); + obj = df.getOWLDataPropertyDomainAxiom(prop.asOWLDataProperty(), d, + asList(ax.annotations())); + return; + } + obj = df.getOWLAnnotationPropertyDomainAxiom(prop.asOWLAnnotationProperty(), domain, + anns(ax)); + } + + @Override + public void visit(OWLAnnotationPropertyRangeAxiom ax) { + OWLProperty prop = dup(ax.getProperty()); + IRI range = dup(ax.getRange()); + if (prop.isObjectPropertyExpression()) { + // turn to object property domain + OWLClassExpression d = df.getOWLClass(range); + LOGGER.warn( + "Annotation property range axiom turned to object property range after parsing. This could introduce errors if the original range was an anonymous expression: {} is the new domain.", + range); + obj = df.getOWLObjectPropertyRangeAxiom(prop.asOWLObjectProperty(), d, + asList(ax.annotations())); + return; + } else if (prop.isDataPropertyExpression()) { + // turn to data property domain + OWLDataRange d = df.getOWLDatatype(range); + LOGGER.warn( + "Annotation property range axiom turned to data property range after parsing. This could introduce errors if the original range was an anonymous expression: {} is the new domain.", + range); + obj = df.getOWLDataPropertyRangeAxiom(prop.asOWLDataProperty(), d, + asList(ax.annotations())); + return; + } + obj = + df.getOWLAnnotationPropertyRangeAxiom(prop.asOWLAnnotationProperty(), range, anns(ax)); + } + + @Override + public void visit(OWLSubAnnotationPropertyOfAxiom ax) { + OWLProperty sub = dup(ax.getSubProperty()); + OWLProperty sup = dup(ax.getSuperProperty()); + if (sub.isObjectPropertyExpression() || sup.isObjectPropertyExpression()) { + // check: it is possible that the properties represent an actual + // illegal punning, where this fix cannot be applied + if (sub.isOWLObjectProperty() && sup.isOWLObjectProperty()) { + obj = df.getOWLSubObjectPropertyOfAxiom(sub.asOWLObjectProperty(), + sup.asOWLObjectProperty(), asList(ax.annotations())); + } else { + // cannot repair: leave unchanged + obj = ax; + } + return; + } else if (sub.isDataPropertyExpression() || sup.isDataPropertyExpression()) { + if (sub.isOWLDataProperty() && sup.isOWLDataProperty()) { + obj = df.getOWLSubDataPropertyOfAxiom(sub.asOWLDataProperty(), + sup.asOWLDataProperty(), asList(ax.annotations())); + } else { + // cannot repair: leave unchanged + obj = ax; + } + return; + } + if (sub.isOWLAnnotationProperty() && sup.isOWLAnnotationProperty()) { + obj = df.getOWLSubAnnotationPropertyOfAxiom(sub.asOWLAnnotationProperty(), + sup.asOWLAnnotationProperty(), anns(ax)); + } else { + // cannot repair: leave unchanged + obj = ax; + } + } + + @Override + public void visit(OWLAnnotation node) { + obj = df.getOWLAnnotation(dup(node.getProperty()), dup(node.getValue())); + } + + @Override + public void visit(OWLAnonymousIndividual individual) { + obj = individual; + } + + @Override + public void visit(IRI iri) { + obj = iri; + for (EntityType entityType : EntityType.values()) { + assert entityType != null; + OWLEntity entity = df.getOWLEntity(entityType, iri); + OWLEntity replacementIRI = replacementMap.get(entity); + if (replacementIRI != null) { + obj = replacementIRI.getIRI(); + break; + } + } + } + + @Override + public void visit(OWLDatatypeDefinitionAxiom ax) { + obj = df.getOWLDatatypeDefinitionAxiom(dup(ax.getDatatype()), dup(ax.getDataRange()), + anns(ax)); + } + + /** + * A utility function that duplicates a set of objects. + * + * @param type + * @param objects The set of object to be duplicated + * @return The set of duplicated objects + */ + private Collection set(Stream objects) { + return asList(objects.map(this::dup)); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLAnonymousIndividualsWithMultipleOccurrences.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLAnonymousIndividualsWithMultipleOccurrences.java new file mode 100644 index 0000000000..0ca1af8c80 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLAnonymousIndividualsWithMultipleOccurrences.java @@ -0,0 +1,98 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.HashSet; +import java.util.Set; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * A utility class that visits axioms, class expressions etc. and accumulates the anonymous + * individuals objects that are referred to in those axioms, class expressions etc. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group, Date: + * 13-Nov-2006 + */ +public class OWLAnonymousIndividualsWithMultipleOccurrences extends AbstractCollector + implements IndividualAppearance { + + private final Set singleAppearanceAsSubject = new HashSet<>(); + private final Set singleAppearance = new HashSet<>(); + private final Set multipleAppearances = new HashSet<>(); + + @Override + public boolean appearsMultipleTimes(OWLAnonymousIndividual i) { + return multipleAppearances.contains(i); + } + + @Override + public void visit(OWLAnonymousIndividual individual) { + checkAppearanceAsObject(individual); + } + + @Override + public void visit(OWLAnnotation a) { + a.getValue().asAnonymousIndividual().ifPresent(this::checkAppearanceAsObject); + a.annotations().forEach(a1 -> a1.accept(this)); + } + + @Override + public void visit(OWLObjectPropertyAssertionAxiom axiom) { + axiom.getSubject().accept(this); + axiom.getObject().accept(this); + axiom.annotations().forEach(a1 -> a1.accept(this)); + } + + @Override + public void visit(OWLDataPropertyAssertionAxiom axiom) { + axiom.getSubject().accept(this); + axiom.annotations().forEach(a1 -> a1.accept(this)); + } + + @Override + public void visit(OWLOntology ontology) { + ontology.annotations().forEach(a1 -> a1.accept(this)); + AxiomType.AXIOM_TYPES.forEach(t -> ontology.axioms(t).forEach(ax -> ax.accept(this))); + singleAppearance.clear(); + singleAppearanceAsSubject.clear(); + } + + @Override + public void visit(OWLAnnotationAssertionAxiom axiom) { + axiom.getSubject().asAnonymousIndividual().ifPresent(this::checkAppearanceAsSubject); + axiom.getValue().asAnonymousIndividual().ifPresent(this::checkAppearanceAsObject); + } + + protected void checkAppearanceAsObject(OWLAnonymousIndividual a) { + if (!multipleAppearances.contains(a) && !singleAppearance.add(a)) { + // already seen, move it + singleAppearance.remove(a); + multipleAppearances.add(a); + } + } + + protected void checkAppearanceAsSubject(OWLAnonymousIndividual a) { + if (!multipleAppearances.contains(a) && !singleAppearanceAsSubject.add(a)) { + // already seen, move it + singleAppearanceAsSubject.remove(a); + multipleAppearances.add(a); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLAxiomFilter.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLAxiomFilter.java new file mode 100644 index 0000000000..0037a70c19 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLAxiomFilter.java @@ -0,0 +1,29 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import org.semanticweb.owlapi.model.OWLAxiom; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +@FunctionalInterface +public interface OWLAxiomFilter { + + /** + * @param axiom axiom to filter + * @return true if check passed + */ + boolean passes(OWLAxiom axiom); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLAxiomSearchFilter.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLAxiomSearchFilter.java new file mode 100644 index 0000000000..70532be2a0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLAxiomSearchFilter.java @@ -0,0 +1,36 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.io.Serializable; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAxiom; + +/** + * Search filter for axioms of various types, matching a pass condition on a + * key. + */ +public interface OWLAxiomSearchFilter extends Serializable { + + /** + * @return axiom types; expected to be one, but the filter could include multiple axiom types + */ + Iterable> getAxiomTypes(); + + /** + * @param axiom axiom to check + * @param key key + * @return true if passed + */ + boolean pass(OWLAxiom axiom, Object key); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLClassExpressionCollector.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLClassExpressionCollector.java new file mode 100644 index 0000000000..5ea9f98d3e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLClassExpressionCollector.java @@ -0,0 +1,169 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.Collection; +import java.util.HashSet; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * Collects all of the nested class expression that are used in some OWLObject. + * For example, given SubClassOf(ObjectUnionOf(D C) ObjectSomeValuesFrom(R F)) + * the collector could be used to obtain ObjectUnionOf(D C), D, C, + * ObjectSomeValuesFrom(R F), F + * + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +public class OWLClassExpressionCollector extends AbstractCollectorEx { + + /** + * The default collection is a set + */ + public OWLClassExpressionCollector() { + super(new HashSet<>()); + } + + @Override + public Collection visit(OWLOntology ontology) { + ontology.logicalAxioms().forEach(ax -> ax.accept(this)); + return objects; + } + + @Override + public Collection visit(OWLClass ce) { + objects.add(ce); + return objects; + } + + @Override + public Collection visit(OWLObjectIntersectionOf ce) { + objects.add(ce); + return super.visit(ce); + } + + @Override + public Collection visit(OWLObjectUnionOf ce) { + objects.add(ce); + return super.visit(ce); + } + + @Override + public Collection visit(OWLObjectComplementOf ce) { + objects.add(ce); + return super.visit(ce); + } + + @Override + public Collection visit(OWLObjectSomeValuesFrom ce) { + objects.add(ce); + return super.visit(ce); + } + + @Override + public Collection visit(OWLObjectAllValuesFrom ce) { + objects.add(ce); + return super.visit(ce); + } + + @Override + public Collection visit(OWLObjectHasValue ce) { + objects.add(ce); + return objects; + } + + @Override + public Collection visit(OWLObjectMinCardinality ce) { + objects.add(ce); + return super.visit(ce); + } + + @Override + public Collection visit(OWLObjectExactCardinality ce) { + objects.add(ce); + return super.visit(ce); + } + + @Override + public Collection visit(OWLObjectMaxCardinality ce) { + objects.add(ce); + return super.visit(ce); + } + + @Override + public Collection visit(OWLObjectHasSelf ce) { + objects.add(ce); + return objects; + } + + @Override + public Collection visit(OWLObjectOneOf ce) { + objects.add(ce); + return objects; + } + + @Override + public Collection visit(OWLDataSomeValuesFrom ce) { + objects.add(ce); + return objects; + } + + @Override + public Collection visit(OWLDataAllValuesFrom ce) { + objects.add(ce); + return objects; + } + + @Override + public Collection visit(OWLDataHasValue ce) { + objects.add(ce); + return objects; + } + + @Override + public Collection visit(OWLDataMinCardinality ce) { + objects.add(ce); + return objects; + } + + @Override + public Collection visit(OWLDataExactCardinality ce) { + objects.add(ce); + return objects; + } + + @Override + public Collection visit(OWLDataMaxCardinality ce) { + objects.add(ce); + return objects; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLClassLiteralCollector.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLClassLiteralCollector.java new file mode 100644 index 0000000000..86ff93cf60 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLClassLiteralCollector.java @@ -0,0 +1,93 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectVisitor; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class OWLClassLiteralCollector extends OWLObjectWalker { + + // XXX stateful visitor... + protected final Set pos = new HashSet<>(); + protected final Set neg = new HashSet<>(); + private boolean processed = false; + + /** + * @param objects the objects to visit + */ + public OWLClassLiteralCollector(Set objects) { + super(objects); + } + + /** + * @param objects the objects to visit + * @param visitDuplicates true if duplicates must be visited + */ + public OWLClassLiteralCollector(Set objects, boolean visitDuplicates) { + super(objects, visitDuplicates); + } + + private void process() { + if (!processed) { + processed = true; + walkStructure(new OWLClassLiteralCollectorVisitor()); + } + } + + /** + * @return positive literals + */ + public Set getPositiveLiterals() { + process(); + return new HashSet<>(pos); + } + + /** + * @return negative literals + */ + public Set getNegativeLiterals() { + process(); + return new HashSet<>(neg); + } + + private class OWLClassLiteralCollectorVisitor implements OWLObjectVisitor { + + OWLClassLiteralCollectorVisitor() { + } + + @Override + public void visit(OWLClass ce) { + List path = getClassExpressionPath(); + if (path.size() > 1) { + OWLClassExpression prev = path.get(path.size() - 2); + if (prev instanceof OWLObjectComplementOf) { + neg.add(ce); + } else { + pos.add(ce); + } + } else { + pos.add(ce); + } + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLDocumentFormatFactoryImpl.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLDocumentFormatFactoryImpl.java new file mode 100644 index 0000000000..af0a1747fb --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLDocumentFormatFactoryImpl.java @@ -0,0 +1,130 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLDocumentFormatFactory; + +/** + * A generic factory class for OWLDocumentFormats. This class can act as a + * factory for any OWLDocumentFormat type that has a no argument constructor + * (the default type of OWLDocumentFormat). + * + * @author ignazio + */ +public abstract class OWLDocumentFormatFactoryImpl implements OWLDocumentFormatFactory { + + private final List mimeTypes; + private final String key; + private final boolean isTextualFormat; + + /** + * Default, for a textual format with no mime types. + */ + protected OWLDocumentFormatFactoryImpl() { + this(new ArrayList(0), true); + } + + protected OWLDocumentFormatFactoryImpl(List mimeTypes) { + this(mimeTypes, true); + } + + protected OWLDocumentFormatFactoryImpl(List mimeTypes, boolean isTextualFormat) { + this.mimeTypes = new ArrayList<>(mimeTypes); + this.isTextualFormat = isTextualFormat; + key = this.getClass().getName(); + } + + protected OWLDocumentFormatFactoryImpl(List mimeTypes, boolean isTextualFormat, + String key) { + this.mimeTypes = new ArrayList<>(mimeTypes); + this.isTextualFormat = isTextualFormat; + this.key = key; + } + + @Override + public String getKey() { + return key; + } + + @Override + @Nullable + public String getDefaultMIMEType() { + if (mimeTypes.isEmpty()) { + return null; + } else { + return mimeTypes.get(0); + } + } + + @Override + public List getMIMETypes() { + if (mimeTypes.isEmpty()) { + return Collections.emptyList(); + } else { + return Collections.unmodifiableList(mimeTypes); + } + } + + @Override + public boolean handlesMimeType(String mimeType) { + String type = mimeType; + int semiColon = mimeType.indexOf(';'); + if (semiColon > -1) { + type = mimeType.substring(0, semiColon); + } + for (String nextMimeType : getMIMETypes()) { + if (mimeType.equalsIgnoreCase(nextMimeType)) { + return true; + } + if (mimeType != type && type.equalsIgnoreCase(nextMimeType)) { + return true; + } + } + return false; + } + + @Override + public boolean isTextual() { + return isTextualFormat; + } + + @Override + public OWLDocumentFormat get() { + return createFormat(); + } + + @Override + public int hashCode() { + return getKey().hashCode(); + } + + @Override + public boolean equals(@Nullable Object obj) { + if (null == obj) { + return false; + } + if (obj == this) { + return true; + } + if (!(obj instanceof OWLDocumentFormatFactory)) { + return false; + } + OWLDocumentFormatFactory otherFactory = (OWLDocumentFormatFactory) obj; + return getKey().equals(otherFactory.getKey()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityCollectingOntologyChangeListener.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityCollectingOntologyChangeListener.java new file mode 100644 index 0000000000..6be1899de7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityCollectingOntologyChangeListener.java @@ -0,0 +1,61 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import javax.annotation.Nonnull; +import org.semanticweb.owlapi.model.OWLAxiomChange; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyChangeListener; + +/** + * A convenience class which is an ontology change listener which collects the + * entities which are referenced in a set of ontology changes. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public abstract class OWLEntityCollectingOntologyChangeListener implements + OWLOntologyChangeListener { + + private final Set entities = new HashSet<>(); + + @Override + public void ontologiesChanged( + @Nonnull List changes) { + entities.clear(); + for (OWLOntologyChange change : changes) { + if (change.isAxiomChange()) { + entities.addAll(asList(((OWLAxiomChange) change).signature())); + } + } + ontologiesChanged(); + } + + /** + * Called when a set of changes have been applied. + */ + public abstract void ontologiesChanged(); + + /** + * @return the entities which were referenced in the last change set. + */ + public Set getEntities() { + return CollectionFactory.copyMutable(entities); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityCollector.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityCollector.java new file mode 100644 index 0000000000..4f60fd2319 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityCollector.java @@ -0,0 +1,89 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.add; + +import java.util.Collection; + +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * A utility class that visits axioms, class expressions etc. and accumulates the named objects that + * are referred to in those axioms, class expressions etc. For example, if the collector visited the + * axiom (propP some C) subClassOf (propQ some D), it would contain the objects propP, C, propQ and + * D. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLEntityCollector extends AbstractCollectorEx { + + /** + * @param toReturn the set that will contain the results + */ + public OWLEntityCollector(Collection toReturn) { + super(toReturn); + } + + // OWLClassExpressionVisitor + @Override + public Collection visit(OWLClass ce) { + objects.add(ce); + return objects; + } + + // Entity visitor + @Override + public Collection visit(OWLObjectProperty property) { + objects.add(property); + return objects; + } + + @Override + public Collection visit(OWLDataProperty property) { + objects.add(property); + return objects; + } + + @Override + public Collection visit(OWLNamedIndividual individual) { + objects.add(individual); + return objects; + } + + @Override + public Collection visit(OWLDatatype node) { + objects.add(node); + return objects; + } + + @Override + public Collection visit(OWLOntology ontology) { + add(objects, ontology.unsortedSignature()); + return objects; + } + + @Override + public Collection visit(OWLAnnotationProperty property) { + objects.add(property); + return objects; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityComparator.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityComparator.java new file mode 100644 index 0000000000..b8862d719b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityComparator.java @@ -0,0 +1,102 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import java.util.Comparator; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLEntityVisitor; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; + +/** + * A {@code Comparator} which compares entities. Entities are compared first by + * their type (in the following order: Class, Object property, Data property, + * Individual, Datatype) then by their short form (using the specified short + * form provider). + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLEntityComparator implements Comparator, OWLEntityVisitor { + + private final ShortFormProvider shortFormProvider; + int lastValue; + + /** + * Constructs an entity comparator which uses the specified short form + * provider. + * + * @param shortFormProvider the short form provider to use + */ + public OWLEntityComparator(ShortFormProvider shortFormProvider) { + this.shortFormProvider = checkNotNull(shortFormProvider, + "shortFormProvider cannot be null"); + } + + @Override + public int compare(@Nullable OWLEntity o1, @Nullable OWLEntity o2) { + verifyNotNull(o1).accept(this); + int i1 = lastValue; + verifyNotNull(o2).accept(this); + int i2 = lastValue; + int delta = i1 - i2; + if (delta != 0) { + return delta; + } + String s1 = getShortForm(verifyNotNull(o1)); + String s2 = getShortForm(verifyNotNull(o2)); + return s1.compareTo(s2); + } + + private String getShortForm(OWLEntity entity) { + return shortFormProvider.getShortForm(entity); + } + + @Override + public void visit(OWLClass cls) { + lastValue = 0; + } + + @Override + public void visit(OWLObjectProperty property) { + lastValue = 1; + } + + @Override + public void visit(OWLDataProperty property) { + lastValue = 2; + } + + @Override + public void visit(OWLNamedIndividual individual) { + lastValue = 3; + } + + @Override + public void visit(OWLAnnotationProperty property) { + lastValue = 4; + } + + @Override + public void visit(OWLDatatype datatype) { + lastValue = 5; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityFragmentProvider.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityFragmentProvider.java new file mode 100644 index 0000000000..2b4e4fae24 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityFragmentProvider.java @@ -0,0 +1,66 @@ +package org.semanticweb.owlapi.util; + +import java.util.concurrent.atomic.AtomicInteger; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLEntityVisitorEx; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; + +/** + * Convenience to create c1, c2, p1, p2... entities in replacement of input + * entities. + */ +public class OWLEntityFragmentProvider implements OWLEntityVisitorEx { + + private static final AtomicInteger classCount = new AtomicInteger(); + private static final AtomicInteger objectPropertyCount = new AtomicInteger(); + private static final AtomicInteger dataPropertyCount = new AtomicInteger(); + private static final AtomicInteger individualCount = new AtomicInteger(); + private static final AtomicInteger annotationPropertyCount = new AtomicInteger(); + private static final AtomicInteger datatypeCount = new AtomicInteger(); + + /** + * @param entity entity to rename + * @return new name + */ + public String getName(OWLEntity entity) { + if (entity.isBuiltIn()) { + return entity.getIRI().toString(); + } + return entity.accept(this); + } + + @Override + public String visit(OWLClass cls) { + return "c" + classCount.incrementAndGet(); + } + + @Override + public String visit(OWLDatatype datatype) { + return "dt" + datatypeCount.incrementAndGet(); + } + + @Override + public String visit(OWLNamedIndividual individual) { + return "i" + individualCount.incrementAndGet(); + } + + @Override + public String visit(OWLDataProperty property) { + return "dp" + dataPropertyCount.incrementAndGet(); + } + + @Override + public String visit(OWLObjectProperty property) { + return "op" + objectPropertyCount.incrementAndGet(); + } + + @Override + public String visit(OWLAnnotationProperty property) { + return "ap" + annotationPropertyCount.incrementAndGet(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityIRIComparator.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityIRIComparator.java new file mode 100644 index 0000000000..ef4ead6738 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityIRIComparator.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import java.io.Serializable; +import java.util.Comparator; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLEntity; + +/** + * Comparator that uses IRI ordering to order entities. + */ +public class OWLEntityIRIComparator implements Comparator, Serializable { + + @Override + public int compare(@Nullable OWLEntity o1, @Nullable OWLEntity o2) { + return verifyNotNull(o1).getIRI().compareTo(verifyNotNull(o2).getIRI()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityRemover.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityRemover.java new file mode 100644 index 0000000000..f251718911 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityRemover.java @@ -0,0 +1,134 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLEntityVisitor; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.RemoveAxiom; + +/** + * A convenience object that generates the changes which are necessary to remove + * an entity from a set of ontologies. This is accomplished by removing all + * axioms that refer to the entity. The entity remover follows the visitor + * design pattern, entities that need to be removed from an ontology should + * accept visits from the entity remover. Changes are accumulated as the entity + * remover visits various entities. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLEntityRemover implements OWLEntityVisitor { + + private final List changes = new ArrayList<>(); + private final Collection ontologies; + + /** + * Creates an entity remover, which will remove entities (axioms referring + * to the entities from the specified ontologies). + * + * @param ontologies The set of ontologies that contain references to axioms to be removed. + */ + public OWLEntityRemover(Collection ontologies) { + this(ontologies.stream()); + } + + /** + * Creates an entity remover, which will remove entities (axioms referring + * to the entities from the specified ontologies). + * + * @param ontologies The stream of ontologies that contain references to axioms to be removed. + */ + public OWLEntityRemover(Stream ontologies) { + this.ontologies = asList(checkNotNull(ontologies, "ontologies cannot be null")); + } + + /** + * Creates an entity remover, which will remove entities (axioms referring + * to the entities from the specified ontologies). + * + * @param ontology The ontology that contain references to axioms to be removed. + */ + public OWLEntityRemover(OWLOntology ontology) { + ontologies = Collections.singleton(checkNotNull(ontology, "ontology cannot be null")); + } + + /** + * @return the list of ontology changes that are required in order to remove visited entities + * from the set of ontologies. + */ + public List getChanges() { + return new ArrayList<>(changes); + } + + /** + * Clears any changes which have accumulated over the course of visiting + * different entities. + */ + public void reset() { + changes.clear(); + } + + private void generateChanges(OWLEntity entity) { + checkNotNull(entity, "entity cannot be null"); + for (OWLOntology ont : ontologies) { + ont.referencingAxioms(entity).forEach(ax -> changes.add(new RemoveAxiom(ont, ax))); + ont.annotationAssertionAxioms(entity.getIRI()) + .forEach(ax -> changes.add(new RemoveAxiom(ont, ax))); + } + } + + @Override + public void visit(OWLClass cls) { + generateChanges(cls); + } + + @Override + public void visit(OWLDatatype datatype) { + generateChanges(datatype); + } + + @Override + public void visit(OWLNamedIndividual individual) { + generateChanges(individual); + } + + @Override + public void visit(OWLDataProperty property) { + generateChanges(property); + } + + @Override + public void visit(OWLObjectProperty property) { + generateChanges(property); + } + + @Override + public void visit(OWLAnnotationProperty property) { + generateChanges(property); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityRenamer.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityRenamer.java new file mode 100644 index 0000000000..b22246b183 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityRenamer.java @@ -0,0 +1,162 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.AddOntologyAnnotation; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.RemoveAxiom; +import org.semanticweb.owlapi.model.RemoveOntologyAnnotation; + +/** + * Renames entities that have a particular IRI. Entities with the specified IRI are renamed + * regardless of whether they are classes, object properties, data properties, individuals or data + * types. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLEntityRenamer { + + private final OWLOntologyManager m; + private final Collection ontologies; + + /** + * @param owlOntologyManager the ontology manager to use + * @param ontologies the ontologies to use + */ + public OWLEntityRenamer(OWLOntologyManager owlOntologyManager, + Collection ontologies) { + m = owlOntologyManager; + this.ontologies = checkNotNull(ontologies, "ontologies cannot be null"); + } + + private static Stream getAxioms(OWLOntology ont, OWLEntity entity) { + return Stream.of(ont.referencingAxioms(entity), ont.declarationAxioms(entity), + ont.annotationAssertionAxioms(entity.getIRI())).flatMap(x -> x); + } + + /** + * Fills a list with ontology changes which will replace a set of axioms with + * duplicated/transformed axioms. + * + * @param changes A list that will be filled with ontology changes which will remove the + * specified axioms from the specified ontology, and add the duplicated/transformed + * version + * @param axioms The axioms to be duplicated/transformed + * @param ont The ontology to which the changed should be applied + * @param duplicator The duplicator that will do the duplicating + */ + private static void fillListWithTransformChanges(List changes, + Stream axioms, OWLOntology ont, OWLObjectDuplicator duplicator) { + axioms.forEach(ax -> { + OWLAxiom dupAx = duplicator.duplicateObject(ax); + if (!dupAx.equals(ax)) { + changes.add(new RemoveAxiom(ont, ax)); + changes.add(new AddAxiom(ont, dupAx)); + } + }); + fillListWithOntologyAnnotationTransformChanges(changes, ont, duplicator); + } + + /** + * Fills a list with ontology annotation changes which will replace ontology annotations. + * + * @param changes A list that will be filled with ontology changes which will remove the + * specified axioms from the specified ontology, and add the duplicated/transformed + * version + * @param ont The ontology to which the changed should be applied + * @param duplicator The duplicator that will do the duplicating + */ + private static void fillListWithOntologyAnnotationTransformChanges( + List changes, OWLOntology ont, OWLObjectDuplicator duplicator) { + ont.annotations().forEach(ax -> { + OWLAnnotation dupAx = duplicator.duplicateObject(ax); + if (!dupAx.equals(ax)) { + changes.add(new RemoveOntologyAnnotation(ont, ax)); + changes.add(new AddOntologyAnnotation(ont, dupAx)); + } + }); + } + + /** + * Changes a IRI for another IRI. This creates the appropriate changes to be applied in order to + * change a IRI. + * + * @param iri The IRI to be changed + * @param newIRI The IRI that the IRI should be changed to. + * @return A list of ontology changes that should be applied to change the specified IRI. + */ + public List changeIRI(IRI iri, IRI newIRI) { + checkNotNull(iri, "iri cannot be null"); + checkNotNull(newIRI, "newIRI cannot be null"); + Map uriMap = new HashMap<>(); + uriMap.put(iri, newIRI); + List changes = new ArrayList<>(); + OWLObjectDuplicator dup = new OWLObjectDuplicator(m, uriMap, + new RemappingIndividualProvider(false, m.getOWLDataFactory())); + ontologies + .forEach(o -> fillListWithTransformChanges(changes, o.referencingAxioms(iri), o, dup)); + return changes; + } + + /** + * Changes the IRI of an entity for another IRI. + * + * @param entity The entity whose IRI is to be changed. + * @param newIRI The new IRI + * @return A list of ontology changes that should be applied to change the specified entity IRI. + */ + public List changeIRI(OWLEntity entity, IRI newIRI) { + Map iriMap = new HashMap<>(); + iriMap.put(entity, newIRI); + List changes = new ArrayList<>(); + OWLObjectDuplicator duplicator = new OWLObjectDuplicator(iriMap, Collections.emptyMap(), m, + new RemappingIndividualProvider(false, m.getOWLDataFactory())); + ontologies.forEach( + o -> fillListWithTransformChanges(changes, getAxioms(o, entity), o, duplicator)); + return changes; + } + + /** + * @param entity2IRIMap map of IRIs to rename + * @return list of changes + */ + public List changeIRI(Map entity2IRIMap) { + List changes = new ArrayList<>(); + OWLObjectDuplicator duplicator = + new OWLObjectDuplicator(entity2IRIMap, Collections.emptyMap(), m, + new RemappingIndividualProvider(false, m.getOWLDataFactory())); + for (OWLOntology ont : ontologies) { + entity2IRIMap.keySet().forEach( + e -> fillListWithTransformChanges(changes, getAxioms(ont, e), ont, duplicator)); + } + return changes; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLEntitySetProvider.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntitySetProvider.java new file mode 100644 index 0000000000..65dca0d0f9 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntitySetProvider.java @@ -0,0 +1,44 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.OWLEntity; + +/** + * Provides a set of entities to inputs that require this. + * + * @param the entity type + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +@FunctionalInterface +public interface OWLEntitySetProvider { + + /** + * @return the entities that are provided by this provider. The set that is returned is a copy; + * modifications to the returned set will not be reflected in this object. + */ + default Set getEntities() { + return asSet(entities()); + } + + /** + * @return the entities that are provided by this provider. + */ + Stream entities(); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityTinyURIConversionStrategy.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityTinyURIConversionStrategy.java new file mode 100644 index 0000000000..25bed2107f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityTinyURIConversionStrategy.java @@ -0,0 +1,81 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.HashMap; +import java.util.Map; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLEntity; + +/** + * Provides an entity URI conversion strategy which converts entity URIs to a + * common base and alpha-numeric fragment. The fragment is of the form An, where + * n is an integer (starting at 1), and A is a string which depends on the type + * of entity: + *
    + *
  • For classes: A = "C"
  • + *
  • For object properties: A = "op"
  • + *
  • For data properties: A = "dp"
  • + *
  • For individuals: A = "i"
  • + *
+ * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class OWLEntityTinyURIConversionStrategy implements OWLEntityURIConverterStrategy { + + /** + * default base. + */ + public static final String DEFAULT_BASE = "http://tinyname.org#"; + private final String base; + private final Map entityNameMap = new HashMap<>(); + private final OWLEntityFragmentProvider fragmentProvider = new OWLEntityFragmentProvider(); + + /** + * Constructs an entity URI converter strategy, where the base of the + * generated URIs corresponds to the value specified by the DEFAULT_BASE + * constant. + */ + public OWLEntityTinyURIConversionStrategy() { + this(DEFAULT_BASE); + } + + /** + * Constructs an entity URI converter strategy, where the specified base is + * used for the base of the URIs generated by the generator. + * + * @param base The base to be used. + */ + public OWLEntityTinyURIConversionStrategy(String base) { + this.base = checkNotNull(base, "base cannot be null"); + } + + @Override + public IRI getConvertedIRI(OWLEntity entity) { + IRI iri = entityNameMap.get(entity); + if (iri != null) { + return iri; + } + if (entity instanceof OWLDatatype) { + return entity.getIRI(); + } + String name = fragmentProvider.getName(entity); + iri = IRI.create(base, name); + entityNameMap.put(entity, iri); + return iri; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityURIConverter.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityURIConverter.java new file mode 100644 index 0000000000..32c928c025 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityURIConverter.java @@ -0,0 +1,115 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.RemoveAxiom; + +/** + * Performs a bulk conversion/translation of entity URIs. This utility class can be used to replace + * entity names with IDs for example. The entity converter is supplied with a set of ontologies and + * a conversion strategy. All of the entities that are referenced in the specified ontologies will + * have their URIs converted according the specified conversion strategy. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class OWLEntityURIConverter { + + private final OWLOntologyManager manager; + // The ontologies that reference the + // entities whose names will be converted + private final Collection ontologies; + private final Map replacementMap = new HashMap<>(); + private final Set processedEntities = new HashSet<>(); + private final OWLEntityURIConverterStrategy strategy; + + /** + * Creates a converter that will convert the URIs of entities in the specified ontologies using + * the specified conversion strategy. + * + * @param manager The manager which managers the specified ontologies. + * @param ontologies The ontologies whose entity IRIs will be converted + * @param strategy The conversion strategy to be used. + */ + public OWLEntityURIConverter(OWLOntologyManager manager, Collection ontologies, + OWLEntityURIConverterStrategy strategy) { + this.manager = checkNotNull(manager, "manager cannot be null"); + this.ontologies = new ArrayList<>(checkNotNull(ontologies, "ontologies cannot be null")); + this.strategy = checkNotNull(strategy, "strategy cannot be null"); + } + + /** + * Gets the changes required to perform the conversion. + * + * @return A list of ontology changes that should be applied in order to convert the URI of + * entities in the specified ontologies. + */ + public List getChanges() { + replacementMap.clear(); + processedEntities.clear(); + List changes = new ArrayList<>(); + for (OWLOntology ont : ontologies) { + ont.classesInSignature().filter(c -> !c.isOWLThing() && !c.isOWLNothing()) + .forEach(this::processEntity); + ont.objectPropertiesInSignature().forEach(this::processEntity); + ont.dataPropertiesInSignature().forEach(this::processEntity); + ont.individualsInSignature().forEach(this::processEntity); + ont.annotationPropertiesInSignature().forEach(this::processEntity); + ont.datatypesInSignature().forEach(this::processEntity); + } + OWLObjectDuplicator dup = new OWLObjectDuplicator(replacementMap, Collections.emptyMap(), + manager, new RemappingIndividualProvider(false, manager.getOWLDataFactory())); + for (OWLOntology ont : ontologies) { + ont.axioms().forEach(ax -> { + OWLAxiom dupAx = dup.duplicateObject(ax); + if (!dupAx.equals(ax)) { + changes.add(new RemoveAxiom(ont, ax)); + changes.add(new AddAxiom(ont, dupAx)); + } + }); + } + return changes; + } + + private void processEntity(OWLEntity ent) { + if (processedEntities.contains(ent)) { + return; + } + // Add label? + IRI rep = getTinyIRI(ent); + replacementMap.put(ent, rep); + processedEntities.add(ent); + } + + private IRI getTinyIRI(OWLEntity ent) { + return strategy.getConvertedIRI(ent); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityURIConverterStrategy.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityURIConverterStrategy.java new file mode 100644 index 0000000000..57066a87b0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityURIConverterStrategy.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLEntity; + +/** + * An interface for customisation of entity URI conversions. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public interface OWLEntityURIConverterStrategy { + + /** + * @param entity the entity to convert + * @return the converted IRI + */ + IRI getConvertedIRI(OWLEntity entity); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityURIUnderscores2CamelBackConverterStrategy.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityURIUnderscores2CamelBackConverterStrategy.java new file mode 100644 index 0000000000..c5dbe0cea4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLEntityURIUnderscores2CamelBackConverterStrategy.java @@ -0,0 +1,88 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import javax.annotation.Nonnull; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLEntity; + +/** + * Converts the entity URI fragment or last path element if the fragment is not + * present to Camel Case. For example, if the URI is + * http://another.com/pathA/pathB#has_part then this will be converted to + * http://another.com/pathA/pathB#hasPart + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class OWLEntityURIUnderscores2CamelBackConverterStrategy implements + OWLEntityURIConverterStrategy { + + private final Map iriMap = new HashMap<>(); + + private static IRI convert(IRI iri) { + checkNotNull(iri, "iri cannot be null"); + Optional fragment = iri.getRemainder(); + if (fragment.isPresent()) { + String base = iri.getNamespace(); + String camelCaseFragment = toCamelCase(fragment.get()); + return IRI.create(base, camelCaseFragment); + } + // for an IRI without fragment, the part to modify is the previous + // fragment of the path. + String path = iri.toURI().getPath(); + if (!path.isEmpty()) { + int index = path.lastIndexOf('/'); + String lastPathElement = path.substring(index + 1, path.length()); + String camelCaseElement = toCamelCase(lastPathElement); + String iriString = iri.toString(); + String base = iriString.substring(0, iriString.lastIndexOf('/') + 1); + return IRI.create(base, camelCaseElement); + } + return iri; + } + + private static String toCamelCase(String s) { + StringBuilder sb = new StringBuilder(s.length()); + boolean nextIsUpperCase = false; + for (int i = 0; i < s.length(); i++) { + char ch = s.charAt(i); + if (ch == '_') { + nextIsUpperCase = true; + } else { + if (nextIsUpperCase) { + sb.append(Character.toUpperCase(ch)); + nextIsUpperCase = false; + } else { + sb.append(ch); + } + } + } + return sb.toString(); + } + + @Override + public IRI getConvertedIRI(@Nonnull OWLEntity entity) { + IRI convIRI = iriMap.get(entity.getIRI()); + if (convIRI == null) { + convIRI = convert(entity.getIRI()); + iriMap.put(entity.getIRI(), convIRI); + } + return convIRI; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLLiteralReplacer.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLLiteralReplacer.java new file mode 100644 index 0000000000..cf866d8af8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLLiteralReplacer.java @@ -0,0 +1,126 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.model.parameters.Imports.EXCLUDED; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.add; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.RemoveAxiom; + +/** + * Replaces a literal with another. + * + * @author Ignazio Palmisano + * @since 4.1.4 + */ +public class OWLLiteralReplacer { + + private final OWLOntologyManager owlOntologyManager; + private final Set ontologies; + + /** + * @param owlOntologyManager the ontology manager to use + * @param ontologies the ontologies to use + */ + public OWLLiteralReplacer(OWLOntologyManager owlOntologyManager, Set ontologies) { + this.owlOntologyManager = + checkNotNull(owlOntologyManager, "owlOntologyManager cannot be null"); + this.ontologies = checkNotNull(ontologies, "ontologies cannot be null"); + } + + private static Collection getAxioms(OWLOntology ont, OWLLiteral entity) { + List axioms = asList(ont.referencingAxioms(entity, EXCLUDED)); + add(axioms, ont.declarationAxioms(entity.getDatatype())); + return axioms; + } + + /** + * Fills a list with ontology changes which will replace a set of axioms with + * duplicated/transformed axioms. + * + * @param changes A list that will be filled with ontology changes which will remove the + * specified axioms from the specified ontology, and add the duplicated/transformed + * version + * @param axioms The axioms to be duplicated/transformed + * @param ont The ontology to which the changed should be applied + * @param duplicator The duplicator that will do the duplicating + */ + private static void fillListWithTransformChanges(List changes, + Collection axioms, OWLOntology ont, OWLObjectDuplicator duplicator) { + for (OWLAxiom ax : axioms) { + assert ax != null; + changes.add(new RemoveAxiom(ont, ax)); + OWLAxiom dupAx = duplicator.duplicateObject(ax); + changes.add(new AddAxiom(ont, dupAx)); + } + } + + /** + * Changes a literal for another literal. This creates the appropriate changes to be applied. + * + * @param literal The literal to be changed + * @param newLiteral The literal to use in replacements. + * @return A list of ontology changes that should be applied. + */ + public List changeLiteral(OWLLiteral literal, OWLLiteral newLiteral) { + checkNotNull(literal, "literal cannot be null"); + checkNotNull(newLiteral, "newLiteral cannot be null"); + Map uriMap = new HashMap<>(); + uriMap.put(literal, newLiteral); + List changes = new ArrayList<>(); + OWLObjectDuplicator dup = new OWLObjectDuplicator(Collections.emptyMap(), + uriMap, owlOntologyManager, + new RemappingIndividualProvider(false, owlOntologyManager.getOWLDataFactory())); + for (OWLOntology ont : ontologies) { + assert ont != null; + fillListWithTransformChanges(changes, getAxioms(ont, literal), ont, dup); + } + return changes; + } + + /** + * @param literalToLiteralMap map of literals to change + * @return list of changes + */ + public List changeLiterals(Map literalToLiteralMap) { + List changes = new ArrayList<>(); + OWLObjectDuplicator duplicator = new OWLObjectDuplicator( + Collections.emptyMap(), literalToLiteralMap, owlOntologyManager, + new RemappingIndividualProvider(false, owlOntologyManager.getOWLDataFactory())); + for (OWLOntology ont : ontologies) { + assert ont != null; + for (OWLLiteral ent : literalToLiteralMap.keySet()) { + assert ent != null; + fillListWithTransformChanges(changes, getAxioms(ont, ent), ont, duplicator); + } + } + return changes; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectComparator.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectComparator.java new file mode 100644 index 0000000000..55ad6b9368 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectComparator.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import java.util.Comparator; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLObject; + +/** + * A ShortFormProvider based comparator for {@code OWLObject} instances. OWLEntity instances are + * sorted according to their short forms. + * + * @author ignazio + * @since 4.0.0 + */ +public class OWLObjectComparator implements Comparator { + + private final OWLEntityComparator entityComparator; + + /** + * @param shortFormProvider short form provider to use + */ + public OWLObjectComparator(ShortFormProvider shortFormProvider) { + entityComparator = new OWLEntityComparator(shortFormProvider); + } + + @Override + public int compare(@Nullable OWLObject o1, @Nullable OWLObject o2) { + // if both objects are entities, compare their short forms + if (o1 instanceof OWLEntity && o2 instanceof OWLEntity) { + return entityComparator.compare((OWLEntity) o1, (OWLEntity) o2); + } + return verifyNotNull(o1).compareTo(o2); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectComponentCollector.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectComponentCollector.java new file mode 100644 index 0000000000..1b1e344ae4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectComponentCollector.java @@ -0,0 +1,162 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.Collection; +import java.util.HashSet; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.SWRLBuiltInAtom; +import org.semanticweb.owlapi.model.SWRLDifferentIndividualsAtom; +import org.semanticweb.owlapi.model.SWRLSameIndividualAtom; +import org.semanticweb.owlapi.model.SWRLVariable; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +// XXX all special cases in this class look a lot like bugs. +public class OWLObjectComponentCollector extends AbstractCollectorEx { + + /** + * Default constructor + */ + public OWLObjectComponentCollector() { + super(new HashSet<>()); + } + + /** + * A convenience method that obtains the components of an OWL object. Note + * that by definition, the components of the object include the object + * itself. + * + * @param object The object whose components are to be obtained. + * @return The component of the specified object. + */ + public Collection getComponents(OWLObject object) { + return object.accept(this); + } + + @Override + public Collection doDefault(Object object) { + if (object instanceof OWLObject) { + objects.add((OWLObject) object); + } + return super.doDefault(object); + } + + @Override + public Collection visit(OWLOntology ontology) { + ontology.axioms().forEach(a -> a.accept(this)); + return super.visit(ontology); + } + + @Override + public Collection visit(OWLLiteral l) { + objects.add(l); + l.getDatatype().accept(this); + return objects; + } + + @Override + public Collection visit(OWLAnnotation l) { + return objects; + } + + @Override + public Collection visit(OWLAnnotationAssertionAxiom l) { + objects.add(l); + l.getSubject().accept(this); + l.getAnnotation().accept(this); + return objects; + } + + @Override + public Collection visit(SWRLVariable node) { + objects.add(node); + return objects; + } + + @Override + public Collection visit(SWRLBuiltInAtom node) { + objects.add(node); + node.allArguments().forEach(a -> a.accept(this)); + return objects; + } + + @Override + public Collection visit(OWLDataSomeValuesFrom ce) { + objects.add(ce); + return ce.getProperty().accept(this); + } + + @Override + public Collection visit(OWLDataAllValuesFrom ce) { + objects.add(ce); + return ce.getProperty().accept(this); + } + + @Override + public Collection visit(OWLDataHasValue ce) { + objects.add(ce); + return ce.getProperty().accept(this); + } + + @Override + public Collection visit(OWLDataMinCardinality ce) { + objects.add(ce); + return ce.getProperty().accept(this); + } + + @Override + public Collection visit(OWLDataMaxCardinality ce) { + objects.add(ce); + return ce.getProperty().accept(this); + } + + @Override + public Collection visit(OWLDataExactCardinality ce) { + objects.add(ce); + return ce.getProperty().accept(this); + } + + @Override + public Collection visit(OWLDataPropertyDomainAxiom ce) { + objects.add(ce); + return ce.getProperty().accept(this); + } + + @Override + public Collection visit(SWRLDifferentIndividualsAtom node) { + objects.add(node); + node.allArguments().forEach(a -> a.accept(this)); + return objects; + } + + @Override + public Collection visit(SWRLSameIndividualAtom node) { + objects.add(node); + node.allArguments().forEach(a -> a.accept(this)); + return objects; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectDesharer.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectDesharer.java new file mode 100644 index 0000000000..07d40a3fea --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectDesharer.java @@ -0,0 +1,623 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.List; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.HasAnnotations; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataComplementOf; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataIntersectionOf; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDataUnionOf; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLHasKeyAxiom; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectInverseOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLObjectVisitorEx; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; +import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.SWRLBuiltInAtom; +import org.semanticweb.owlapi.model.SWRLClassAtom; +import org.semanticweb.owlapi.model.SWRLDataPropertyAtom; +import org.semanticweb.owlapi.model.SWRLDataRangeAtom; +import org.semanticweb.owlapi.model.SWRLDifferentIndividualsAtom; +import org.semanticweb.owlapi.model.SWRLIndividualArgument; +import org.semanticweb.owlapi.model.SWRLLiteralArgument; +import org.semanticweb.owlapi.model.SWRLObjectPropertyAtom; +import org.semanticweb.owlapi.model.SWRLRule; +import org.semanticweb.owlapi.model.SWRLSameIndividualAtom; +import org.semanticweb.owlapi.model.SWRLVariable; + +/** + * Class to remove structure sharing from OWL objects (Axioms or expressions) + * + * @author Ignazio Palmisano + * @since 4.2.8 + */ +public class OWLObjectDesharer implements OWLObjectVisitorEx { + + private final OWLDataFactory df; + + /** + * Creates an object duplicator that duplicates objects using the specified data factory and uri + * replacement map. + * + * @param m The manager providing data factory and config to be used for the duplication. + */ + public OWLObjectDesharer(OWLOntologyManager m) { + df = m.getOWLDataFactory(); + } + + /** + * @param object the object to duplicate + * @param return type + * @return the duplicate + */ + public O deshareObject(O object) { + checkNotNull(object, "object cannot be null"); + return get(object); + } + + private List anns(HasAnnotations axiom) { + checkNotNull(axiom, "axiom cannot be null"); + return asList(axiom.annotations().map(this::get)); + } + + @Override + public OWLAsymmetricObjectPropertyAxiom visit(OWLAsymmetricObjectPropertyAxiom axiom) { + return df.getOWLAsymmetricObjectPropertyAxiom(get(axiom.getProperty()), anns(axiom)); + } + + @Override + public OWLClassAssertionAxiom visit(OWLClassAssertionAxiom axiom) { + return df.getOWLClassAssertionAxiom(get(axiom.getClassExpression()), + get(axiom.getIndividual()), anns(axiom)); + } + + @Override + public OWLDataPropertyAssertionAxiom visit(OWLDataPropertyAssertionAxiom axiom) { + return df.getOWLDataPropertyAssertionAxiom(get(axiom.getProperty()), + get(axiom.getSubject()), get(axiom.getObject()), anns(axiom)); + } + + @Override + public OWLDataPropertyDomainAxiom visit(OWLDataPropertyDomainAxiom axiom) { + return df.getOWLDataPropertyDomainAxiom(get(axiom.getProperty()), get(axiom.getDomain()), + anns(axiom)); + } + + @Override + public OWLDataPropertyRangeAxiom visit(OWLDataPropertyRangeAxiom axiom) { + return df.getOWLDataPropertyRangeAxiom(get(axiom.getProperty()), get(axiom.getRange()), + anns(axiom)); + } + + @Override + public OWLSubDataPropertyOfAxiom visit(OWLSubDataPropertyOfAxiom axiom) { + return df.getOWLSubDataPropertyOfAxiom(get(axiom.getSubProperty()), + get(axiom.getSuperProperty()), anns(axiom)); + } + + @Override + public OWLDeclarationAxiom visit(OWLDeclarationAxiom axiom) { + return df.getOWLDeclarationAxiom(get(axiom.getEntity()), anns(axiom)); + } + + @Override + public OWLDifferentIndividualsAxiom visit(OWLDifferentIndividualsAxiom axiom) { + return df.getOWLDifferentIndividualsAxiom(list(axiom.individuals()), anns(axiom)); + } + + @Override + public OWLDisjointClassesAxiom visit(OWLDisjointClassesAxiom axiom) { + return df.getOWLDisjointClassesAxiom(list(axiom.classExpressions()), anns(axiom)); + } + + @Override + public OWLDisjointDataPropertiesAxiom visit(OWLDisjointDataPropertiesAxiom axiom) { + return df.getOWLDisjointDataPropertiesAxiom(list(axiom.properties()), anns(axiom)); + } + + @Override + public OWLDisjointObjectPropertiesAxiom visit(OWLDisjointObjectPropertiesAxiom axiom) { + return df.getOWLDisjointObjectPropertiesAxiom(list(axiom.properties()), anns(axiom)); + } + + @Override + public OWLDisjointUnionAxiom visit(OWLDisjointUnionAxiom axiom) { + return df.getOWLDisjointUnionAxiom(get(axiom.getOWLClass()), list(axiom.classExpressions()), + anns(axiom)); + } + + @Override + public OWLAnnotationAssertionAxiom visit(OWLAnnotationAssertionAxiom axiom) { + return df.getOWLAnnotationAssertionAxiom(get(axiom.getProperty()), get(axiom.getSubject()), + get(axiom.getValue()), anns(axiom)); + } + + @Override + public OWLEquivalentClassesAxiom visit(OWLEquivalentClassesAxiom axiom) { + return df.getOWLEquivalentClassesAxiom(list(axiom.classExpressions()), anns(axiom)); + } + + @Override + public OWLEquivalentDataPropertiesAxiom visit(OWLEquivalentDataPropertiesAxiom axiom) { + return df.getOWLEquivalentDataPropertiesAxiom(list(axiom.properties()), anns(axiom)); + } + + @Override + public OWLEquivalentObjectPropertiesAxiom visit(OWLEquivalentObjectPropertiesAxiom axiom) { + return df.getOWLEquivalentObjectPropertiesAxiom(list(axiom.properties()), anns(axiom)); + } + + @Override + public OWLFunctionalDataPropertyAxiom visit(OWLFunctionalDataPropertyAxiom axiom) { + return df.getOWLFunctionalDataPropertyAxiom(get(axiom.getProperty()), anns(axiom)); + } + + @Override + public OWLFunctionalObjectPropertyAxiom visit(OWLFunctionalObjectPropertyAxiom axiom) { + return df.getOWLFunctionalObjectPropertyAxiom(get(axiom.getProperty()), anns(axiom)); + } + + @Override + public OWLInverseFunctionalObjectPropertyAxiom visit( + OWLInverseFunctionalObjectPropertyAxiom axiom) { + return df.getOWLInverseFunctionalObjectPropertyAxiom(get(axiom.getProperty()), anns(axiom)); + } + + @Override + public OWLInverseObjectPropertiesAxiom visit(OWLInverseObjectPropertiesAxiom axiom) { + return df.getOWLInverseObjectPropertiesAxiom(get(axiom.getFirstProperty()), + get(axiom.getSecondProperty()), anns(axiom)); + } + + @Override + public OWLIrreflexiveObjectPropertyAxiom visit(OWLIrreflexiveObjectPropertyAxiom axiom) { + return df.getOWLIrreflexiveObjectPropertyAxiom(get(axiom.getProperty()), anns(axiom)); + } + + @Override + public OWLNegativeDataPropertyAssertionAxiom visit( + OWLNegativeDataPropertyAssertionAxiom axiom) { + return df.getOWLNegativeDataPropertyAssertionAxiom(get(axiom.getProperty()), + get(axiom.getSubject()), get(axiom.getObject()), anns(axiom)); + } + + @Override + public OWLNegativeObjectPropertyAssertionAxiom visit( + OWLNegativeObjectPropertyAssertionAxiom axiom) { + return df.getOWLNegativeObjectPropertyAssertionAxiom(get(axiom.getProperty()), + get(axiom.getSubject()), get(axiom.getObject()), anns(axiom)); + } + + @Override + public OWLObjectPropertyAssertionAxiom visit(OWLObjectPropertyAssertionAxiom axiom) { + return df.getOWLObjectPropertyAssertionAxiom(get(axiom.getProperty()), + get(axiom.getSubject()), get(axiom.getObject()), anns(axiom)); + } + + @Override + public OWLSubPropertyChainOfAxiom visit(OWLSubPropertyChainOfAxiom axiom) { + List chain = + asList(axiom.getPropertyChain().stream().map(this::get)); + return df.getOWLSubPropertyChainOfAxiom(chain, get(axiom.getSuperProperty()), anns(axiom)); + } + + @Override + public OWLObjectPropertyDomainAxiom visit(OWLObjectPropertyDomainAxiom axiom) { + return df.getOWLObjectPropertyDomainAxiom(get(axiom.getProperty()), get(axiom.getDomain()), + anns(axiom)); + } + + @Override + public OWLObjectPropertyRangeAxiom visit(OWLObjectPropertyRangeAxiom axiom) { + return df.getOWLObjectPropertyRangeAxiom(get(axiom.getProperty()), get(axiom.getRange()), + anns(axiom)); + } + + @Override + public OWLSubObjectPropertyOfAxiom visit(OWLSubObjectPropertyOfAxiom axiom) { + return df.getOWLSubObjectPropertyOfAxiom(get(axiom.getSubProperty()), + get(axiom.getSuperProperty()), anns(axiom)); + } + + @Override + public OWLReflexiveObjectPropertyAxiom visit(OWLReflexiveObjectPropertyAxiom axiom) { + return df.getOWLReflexiveObjectPropertyAxiom(get(axiom.getProperty()), anns(axiom)); + } + + @Override + public OWLSameIndividualAxiom visit(OWLSameIndividualAxiom axiom) { + return df.getOWLSameIndividualAxiom(list(axiom.individuals()), anns(axiom)); + } + + @Override + public OWLSubClassOfAxiom visit(OWLSubClassOfAxiom axiom) { + return df.getOWLSubClassOfAxiom(get(axiom.getSubClass()), get(axiom.getSuperClass()), + anns(axiom)); + } + + @Override + public OWLSymmetricObjectPropertyAxiom visit(OWLSymmetricObjectPropertyAxiom axiom) { + return df.getOWLSymmetricObjectPropertyAxiom(get(axiom.getProperty()), anns(axiom)); + } + + @Override + public OWLTransitiveObjectPropertyAxiom visit(OWLTransitiveObjectPropertyAxiom axiom) { + return df.getOWLTransitiveObjectPropertyAxiom(get(axiom.getProperty()), anns(axiom)); + } + + @Override + public OWLClass visit(OWLClass ce) { + return ce; + } + + @Override + public OWLDataAllValuesFrom visit(OWLDataAllValuesFrom ce) { + return df.getOWLDataAllValuesFrom(get(ce.getProperty()), get(ce.getFiller())); + } + + @Override + public OWLDataExactCardinality visit(OWLDataExactCardinality ce) { + return df.getOWLDataExactCardinality(ce.getCardinality(), get(ce.getProperty()), + get(ce.getFiller())); + } + + @Override + public OWLDataMaxCardinality visit(OWLDataMaxCardinality ce) { + return df.getOWLDataMaxCardinality(ce.getCardinality(), get(ce.getProperty()), + get(ce.getFiller())); + } + + @Override + public OWLDataMinCardinality visit(OWLDataMinCardinality ce) { + return df.getOWLDataMinCardinality(ce.getCardinality(), get(ce.getProperty()), + get(ce.getFiller())); + } + + @Override + public OWLDataSomeValuesFrom visit(OWLDataSomeValuesFrom ce) { + return df.getOWLDataSomeValuesFrom(get(ce.getProperty()), get(ce.getFiller())); + } + + @Override + public OWLDataHasValue visit(OWLDataHasValue ce) { + return df.getOWLDataHasValue(get(ce.getProperty()), get(ce.getFiller())); + } + + @Override + public OWLObjectAllValuesFrom visit(OWLObjectAllValuesFrom ce) { + return df.getOWLObjectAllValuesFrom(get(ce.getProperty()), get(ce.getFiller())); + } + + @Override + public OWLObjectComplementOf visit(OWLObjectComplementOf ce) { + return df.getOWLObjectComplementOf(get(ce.getOperand())); + } + + @Override + public OWLObjectExactCardinality visit(OWLObjectExactCardinality ce) { + return df.getOWLObjectExactCardinality(ce.getCardinality(), get(ce.getProperty()), + get(ce.getFiller())); + } + + @Override + public OWLObjectIntersectionOf visit(OWLObjectIntersectionOf ce) { + return df.getOWLObjectIntersectionOf(list(ce.operands())); + } + + @Override + public OWLObjectMaxCardinality visit(OWLObjectMaxCardinality ce) { + return df.getOWLObjectMaxCardinality(ce.getCardinality(), get(ce.getProperty()), + get(ce.getFiller())); + } + + @Override + public OWLObjectMinCardinality visit(OWLObjectMinCardinality ce) { + return df.getOWLObjectMinCardinality(ce.getCardinality(), get(ce.getProperty()), + get(ce.getFiller())); + } + + @Override + public OWLObjectOneOf visit(OWLObjectOneOf ce) { + return df.getOWLObjectOneOf(list(ce.individuals())); + } + + @Override + public OWLObjectHasSelf visit(OWLObjectHasSelf ce) { + return df.getOWLObjectHasSelf(get(ce.getProperty())); + } + + @Override + public OWLObjectSomeValuesFrom visit(OWLObjectSomeValuesFrom ce) { + return df.getOWLObjectSomeValuesFrom(get(ce.getProperty()), get(ce.getFiller())); + } + + @Override + public OWLObjectUnionOf visit(OWLObjectUnionOf ce) { + return df.getOWLObjectUnionOf(list(ce.operands())); + } + + @Override + public OWLObjectHasValue visit(OWLObjectHasValue ce) { + return df.getOWLObjectHasValue(get(ce.getProperty()), get(ce.getFiller())); + } + + @Override + public OWLDataComplementOf visit(OWLDataComplementOf node) { + return df.getOWLDataComplementOf(get(node.getDataRange())); + } + + @Override + public OWLDataOneOf visit(OWLDataOneOf node) { + return df.getOWLDataOneOf(list(node.values())); + } + + @Override + public OWLDatatype visit(OWLDatatype node) { + return node; + } + + @Override + public OWLDatatypeRestriction visit(OWLDatatypeRestriction node) { + return df.getOWLDatatypeRestriction(get(node.getDatatype()), + list(node.facetRestrictions())); + } + + @Override + public OWLFacetRestriction visit(OWLFacetRestriction node) { + return df.getOWLFacetRestriction(node.getFacet(), get(node.getFacetValue())); + } + + @Override + public OWLLiteral visit(OWLLiteral node) { + return node; + } + + @Override + public OWLDataProperty visit(OWLDataProperty property) { + return property; + } + + @Override + public OWLObjectProperty visit(OWLObjectProperty property) { + return property; + } + + @Override + public OWLObjectInverseOf visit(OWLObjectInverseOf property) { + OWLObjectPropertyExpression inverse = property.getInverse(); + if (inverse.isAnonymous()) { + return df.getOWLObjectInverseOf(get(property.getNamedProperty())); + } + return df.getOWLObjectInverseOf(get(inverse.asOWLObjectProperty())); + } + + @Override + public OWLNamedIndividual visit(OWLNamedIndividual individual) { + return individual; + } + + @Override + public OWLOntology visit(OWLOntology ontology) { + // Should we duplicate ontologies here? Probably not. + return ontology; + } + + @Override + public SWRLRule visit(SWRLRule rule) { + return df.getSWRLRule(list(rule.body()), list(rule.head()), anns(rule)); + } + + @Override + public SWRLClassAtom visit(SWRLClassAtom node) { + return df.getSWRLClassAtom(get(node.getPredicate()), get(node.getArgument())); + } + + @Override + public SWRLDataRangeAtom visit(SWRLDataRangeAtom node) { + return df.getSWRLDataRangeAtom(get(node.getPredicate()), get(node.getArgument())); + } + + @Override + public SWRLObjectPropertyAtom visit(SWRLObjectPropertyAtom node) { + return df.getSWRLObjectPropertyAtom(get(node.getPredicate()), get(node.getFirstArgument()), + get(node.getSecondArgument())); + } + + @Override + public SWRLDataPropertyAtom visit(SWRLDataPropertyAtom node) { + return df.getSWRLDataPropertyAtom(get(node.getPredicate()), get(node.getFirstArgument()), + get(node.getSecondArgument())); + } + + @Override + public SWRLBuiltInAtom visit(SWRLBuiltInAtom node) { + return df.getSWRLBuiltInAtom(get(node.getPredicate()), list(node.arguments())); + } + + @Override + public SWRLDifferentIndividualsAtom visit(SWRLDifferentIndividualsAtom node) { + return df.getSWRLDifferentIndividualsAtom(get(node.getFirstArgument()), + get(node.getSecondArgument())); + } + + @Override + public SWRLSameIndividualAtom visit(SWRLSameIndividualAtom node) { + return df.getSWRLSameIndividualAtom(get(node.getFirstArgument()), + get(node.getSecondArgument())); + } + + @Override + public SWRLVariable visit(SWRLVariable node) { + return df.getSWRLVariable(get(node.getIRI())); + } + + @Override + public SWRLIndividualArgument visit(SWRLIndividualArgument node) { + return df.getSWRLIndividualArgument(get(node.getIndividual())); + } + + @Override + public SWRLLiteralArgument visit(SWRLLiteralArgument node) { + return df.getSWRLLiteralArgument(get(node.getLiteral())); + } + + @Override + public OWLHasKeyAxiom visit(OWLHasKeyAxiom axiom) { + return df.getOWLHasKeyAxiom(get(axiom.getClassExpression()), + list(axiom.propertyExpressions()), anns(axiom)); + } + + @Override + public OWLDataIntersectionOf visit(OWLDataIntersectionOf node) { + return df.getOWLDataIntersectionOf(list(node.operands())); + } + + @Override + public OWLDataUnionOf visit(OWLDataUnionOf node) { + return df.getOWLDataUnionOf(list(node.operands())); + } + + @Override + public OWLAnnotationProperty visit(OWLAnnotationProperty property) { + return property; + } + + @Override + public OWLAnnotationPropertyDomainAxiom visit(OWLAnnotationPropertyDomainAxiom axiom) { + return df.getOWLAnnotationPropertyDomainAxiom(get(axiom.getProperty()), + get(axiom.getDomain()), anns(axiom)); + } + + @Override + public OWLAnnotationPropertyRangeAxiom visit(OWLAnnotationPropertyRangeAxiom axiom) { + return df.getOWLAnnotationPropertyRangeAxiom(get(axiom.getProperty()), + get(axiom.getRange()), anns(axiom)); + } + + @Override + public OWLSubAnnotationPropertyOfAxiom visit(OWLSubAnnotationPropertyOfAxiom axiom) { + return df.getOWLSubAnnotationPropertyOfAxiom(get(axiom.getSubProperty()), + get(axiom.getSuperProperty()), anns(axiom)); + } + + @Override + public OWLAnnotation visit(OWLAnnotation node) { + return df.getOWLAnnotation(get(node.getProperty()), get(node.getValue()), anns(node)); + } + + @Override + public OWLAnonymousIndividual visit(OWLAnonymousIndividual individual) { + return individual; + } + + @Override + public IRI visit(IRI iri) { + return iri; + } + + @Override + public OWLDatatypeDefinitionAxiom visit(OWLDatatypeDefinitionAxiom axiom) { + return df.getOWLDatatypeDefinitionAxiom(get(axiom.getDatatype()), get(axiom.getDataRange()), + anns(axiom)); + } + + /** + * A utility function that duplicates a set of objects. + * + * @param type + * @param objects The set of object to be duplicated + * @return The set of duplicated objects + */ + protected List list(Stream objects) { + return asList(objects.map(this::get)); + } + + @SuppressWarnings("unchecked") + protected O get(O o) { + return (O) o.accept(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectDuplicator.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectDuplicator.java new file mode 100644 index 0000000000..2824977302 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectDuplicator.java @@ -0,0 +1,745 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.EntityType; +import org.semanticweb.owlapi.model.HasAnnotations; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataComplementOf; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataIntersectionOf; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDataUnionOf; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLHasKeyAxiom; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectInverseOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLObjectVisitorEx; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; +import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.SWRLBuiltInAtom; +import org.semanticweb.owlapi.model.SWRLClassAtom; +import org.semanticweb.owlapi.model.SWRLDataPropertyAtom; +import org.semanticweb.owlapi.model.SWRLDataRangeAtom; +import org.semanticweb.owlapi.model.SWRLDifferentIndividualsAtom; +import org.semanticweb.owlapi.model.SWRLIndividualArgument; +import org.semanticweb.owlapi.model.SWRLLiteralArgument; +import org.semanticweb.owlapi.model.SWRLObjectPropertyAtom; +import org.semanticweb.owlapi.model.SWRLRule; +import org.semanticweb.owlapi.model.SWRLSameIndividualAtom; +import org.semanticweb.owlapi.model.SWRLVariable; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLObjectDuplicator implements OWLObjectVisitorEx { + + protected final RemappingIndividualProvider anonProvider; + private final OWLDataFactory df; + private final Map replacementMap; + private final Map replacementLiterals; + + /** + * Creates an object duplicator that duplicates objects using the specified data factory and uri + * replacement map. + * + * @param m The manager providing data factory and config to be used for the duplication. + * @param entityIRIReplacementMap The map to use for the replacement of URIs. Any uris the + * appear in the map will be replaced as objects are duplicated. This can be used to + * "rename" entities. + */ + public OWLObjectDuplicator(Map entityIRIReplacementMap, OWLOntologyManager m) { + this(entityIRIReplacementMap, Collections.emptyMap(), m); + } + + /** + * Creates an object duplicator that duplicates objects using the specified data factory and uri + * replacement map. + * + * @param m The manager providing data factory and config to be used for the duplication. + * @param entityIRIReplacementMap The map to use for the replacement of URIs. Any uris the + * appear in the map will be replaced as objects are duplicated. This can be used to + * "rename" entities. + * @param literals replacement literals + */ + public OWLObjectDuplicator(Map entityIRIReplacementMap, + Map literals, OWLOntologyManager m) { + this(entityIRIReplacementMap, literals, m, + new RemappingIndividualProvider(m.getOntologyConfigurator(), m.getOWLDataFactory())); + } + + /** + * Creates an object duplicator that duplicates objects using the specified data factory and uri + * replacement map. + * + * @param m The manager providing data factory and config to be used for the duplication. + * @param entityIRIReplacementMap The map to use for the replacement of URIs. Any uris the + * appear in the map will be replaced as objects are duplicated. This can be used to + * "rename" entities. + * @param literals replacement literals + * @param anonProvider anon provider + */ + public OWLObjectDuplicator(Map entityIRIReplacementMap, + Map literals, OWLOntologyManager m, + RemappingIndividualProvider anonProvider) { + df = checkNotNull(m, "ontology manager cannot be null").getOWLDataFactory(); + this.anonProvider = anonProvider; + replacementMap = new HashMap<>( + checkNotNull(entityIRIReplacementMap, "entityIRIReplacementMap cannot be null")); + checkNotNull(literals, "literals cannot be null"); + replacementLiterals = literals; + } + + /** + * Creates an object duplicator that duplicates objects using the specified data factory. + * + * @param m The manager providing data factory and config to be used for the duplication. + */ + public OWLObjectDuplicator(OWLOntologyManager m) { + this(Collections.emptyMap(), m); + } + + /** + * Creates an object duplicator that duplicates objects using the specified data factory and uri + * replacement map. + * + * @param m The manager providing data factory and config to be used for the duplication. + * @param iriReplacementMap The map to use for the replacement of URIs. Any uris the appear in + * the map will be replaced as objects are duplicated. This can be used to "rename" + * entities. + */ + public OWLObjectDuplicator(OWLOntologyManager m, Map iriReplacementMap) { + this(remap(iriReplacementMap, m.getOWLDataFactory()), m); + } + + /** + * Creates an object duplicator that duplicates objects using the specified data factory and uri + * replacement map. + * + * @param m The manager providing data factory and config to be used for the duplication. + * @param iriReplacementMap The map to use for the replacement of URIs. Any uris the appear in + * the map will be replaced as objects are duplicated. This can be used to "rename" + * entities. + * @param anonProvider anon provider + */ + public OWLObjectDuplicator(OWLOntologyManager m, Map iriReplacementMap, + RemappingIndividualProvider anonProvider) { + this(remap(iriReplacementMap, m.getOWLDataFactory()), Collections.emptyMap(), m, + anonProvider); + } + + private static Map remap(Map iriReplacementMap, OWLDataFactory df) { + Map map = new HashMap<>(); + iriReplacementMap.forEach((k, v) -> { + map.put(df.getOWLClass(k), v); + map.put(df.getOWLObjectProperty(k), v); + map.put(df.getOWLDataProperty(k), v); + map.put(df.getOWLNamedIndividual(k), v); + map.put(df.getOWLDatatype(k), v); + map.put(df.getOWLAnnotationProperty(k), v); + }); + return map; + } + + /** + * @param object the object to duplicate + * @param return type + * @return the duplicate + */ + public O duplicateObject(O object) { + checkNotNull(object, "object cannot be null"); + return t(object); + } + + /** + * Given an IRI belonging to an entity, returns a IRI. This may be the same IRI that the entity + * has, or an alternative IRI if a replacement has been specified. + * + * @param entity The entity + * @return The IRI + */ + private IRI getIRI(OWLEntity entity) { + checkNotNull(entity, "entity cannot be null"); + IRI replacement = replacementMap.get(entity); + if (replacement == null) { + return entity.getIRI(); + } + return replacement; + } + + private List a(HasAnnotations axiom) { + checkNotNull(axiom, "axiom cannot be null"); + return asList(axiom.annotations().map(this::t)); + } + + @Override + public OWLAsymmetricObjectPropertyAxiom visit(OWLAsymmetricObjectPropertyAxiom ax) { + return df.getOWLAsymmetricObjectPropertyAxiom(t(ax.getProperty()), a(ax)); + } + + @Override + public OWLClassAssertionAxiom visit(OWLClassAssertionAxiom ax) { + return df.getOWLClassAssertionAxiom(t(ax.getClassExpression()), t(ax.getIndividual()), + a(ax)); + } + + @Override + public OWLDataPropertyAssertionAxiom visit(OWLDataPropertyAssertionAxiom ax) { + return df.getOWLDataPropertyAssertionAxiom(t(ax.getProperty()), t(ax.getSubject()), + t(ax.getObject()), a(ax)); + } + + @Override + public OWLDataPropertyDomainAxiom visit(OWLDataPropertyDomainAxiom ax) { + return df.getOWLDataPropertyDomainAxiom(t(ax.getProperty()), t(ax.getDomain()), a(ax)); + } + + @Override + public OWLDataPropertyRangeAxiom visit(OWLDataPropertyRangeAxiom ax) { + return df.getOWLDataPropertyRangeAxiom(t(ax.getProperty()), t(ax.getRange()), a(ax)); + } + + @Override + public OWLSubDataPropertyOfAxiom visit(OWLSubDataPropertyOfAxiom ax) { + return df.getOWLSubDataPropertyOfAxiom(t(ax.getSubProperty()), t(ax.getSuperProperty()), + a(ax)); + } + + @Override + public OWLDeclarationAxiom visit(OWLDeclarationAxiom ax) { + return df.getOWLDeclarationAxiom(t(ax.getEntity()), a(ax)); + } + + @Override + public OWLDifferentIndividualsAxiom visit(OWLDifferentIndividualsAxiom ax) { + return df.getOWLDifferentIndividualsAxiom(list(ax.individuals()), a(ax)); + } + + @Override + public OWLDisjointClassesAxiom visit(OWLDisjointClassesAxiom ax) { + return df.getOWLDisjointClassesAxiom(list(ax.classExpressions()), a(ax)); + } + + @Override + public OWLDisjointDataPropertiesAxiom visit(OWLDisjointDataPropertiesAxiom ax) { + return df.getOWLDisjointDataPropertiesAxiom(list(ax.properties()), a(ax)); + } + + @Override + public OWLDisjointObjectPropertiesAxiom visit(OWLDisjointObjectPropertiesAxiom ax) { + return df.getOWLDisjointObjectPropertiesAxiom(list(ax.properties()), a(ax)); + } + + @Override + public OWLDisjointUnionAxiom visit(OWLDisjointUnionAxiom ax) { + return df.getOWLDisjointUnionAxiom(t(ax.getOWLClass()), list(ax.classExpressions()), a(ax)); + } + + @Override + public OWLAnnotationAssertionAxiom visit(OWLAnnotationAssertionAxiom ax) { + return df.getOWLAnnotationAssertionAxiom(t(ax.getProperty()), t(ax.getSubject()), + t(ax.getValue()), a(ax)); + } + + @Override + public OWLEquivalentClassesAxiom visit(OWLEquivalentClassesAxiom ax) { + return df.getOWLEquivalentClassesAxiom(list(ax.classExpressions()), a(ax)); + } + + @Override + public OWLEquivalentDataPropertiesAxiom visit(OWLEquivalentDataPropertiesAxiom ax) { + return df.getOWLEquivalentDataPropertiesAxiom(list(ax.properties()), a(ax)); + } + + @Override + public OWLEquivalentObjectPropertiesAxiom visit(OWLEquivalentObjectPropertiesAxiom ax) { + return df.getOWLEquivalentObjectPropertiesAxiom(list(ax.properties()), a(ax)); + } + + @Override + public OWLFunctionalDataPropertyAxiom visit(OWLFunctionalDataPropertyAxiom ax) { + return df.getOWLFunctionalDataPropertyAxiom(t(ax.getProperty()), a(ax)); + } + + @Override + public OWLFunctionalObjectPropertyAxiom visit(OWLFunctionalObjectPropertyAxiom ax) { + return df.getOWLFunctionalObjectPropertyAxiom(t(ax.getProperty()), a(ax)); + } + + @Override + public OWLInverseFunctionalObjectPropertyAxiom visit( + OWLInverseFunctionalObjectPropertyAxiom ax) { + return df.getOWLInverseFunctionalObjectPropertyAxiom(t(ax.getProperty()), a(ax)); + } + + @Override + public OWLInverseObjectPropertiesAxiom visit(OWLInverseObjectPropertiesAxiom ax) { + return df.getOWLInverseObjectPropertiesAxiom(t(ax.getFirstProperty()), + t(ax.getSecondProperty()), a(ax)); + } + + @Override + public OWLIrreflexiveObjectPropertyAxiom visit(OWLIrreflexiveObjectPropertyAxiom ax) { + return df.getOWLIrreflexiveObjectPropertyAxiom(t(ax.getProperty()), a(ax)); + } + + @Override + public OWLNegativeDataPropertyAssertionAxiom visit(OWLNegativeDataPropertyAssertionAxiom ax) { + return df.getOWLNegativeDataPropertyAssertionAxiom(t(ax.getProperty()), t(ax.getSubject()), + t(ax.getObject()), a(ax)); + } + + @Override + public OWLNegativeObjectPropertyAssertionAxiom visit( + OWLNegativeObjectPropertyAssertionAxiom ax) { + return df.getOWLNegativeObjectPropertyAssertionAxiom(t(ax.getProperty()), + t(ax.getSubject()), t(ax.getObject()), a(ax)); + } + + @Override + public OWLObjectPropertyAssertionAxiom visit(OWLObjectPropertyAssertionAxiom ax) { + return df.getOWLObjectPropertyAssertionAxiom(t(ax.getProperty()), t(ax.getSubject()), + t(ax.getObject()), a(ax)); + } + + @Override + public OWLSubPropertyChainOfAxiom visit(OWLSubPropertyChainOfAxiom ax) { + List chain = + asList(ax.getPropertyChain().stream().map(this::t)); + return df.getOWLSubPropertyChainOfAxiom(chain, t(ax.getSuperProperty()), a(ax)); + } + + @Override + public OWLObjectPropertyDomainAxiom visit(OWLObjectPropertyDomainAxiom ax) { + return df.getOWLObjectPropertyDomainAxiom(t(ax.getProperty()), t(ax.getDomain()), a(ax)); + } + + @Override + public OWLObjectPropertyRangeAxiom visit(OWLObjectPropertyRangeAxiom ax) { + return df.getOWLObjectPropertyRangeAxiom(t(ax.getProperty()), t(ax.getRange()), a(ax)); + } + + @Override + public OWLSubObjectPropertyOfAxiom visit(OWLSubObjectPropertyOfAxiom ax) { + return df.getOWLSubObjectPropertyOfAxiom(t(ax.getSubProperty()), t(ax.getSuperProperty()), + a(ax)); + } + + @Override + public OWLReflexiveObjectPropertyAxiom visit(OWLReflexiveObjectPropertyAxiom ax) { + return df.getOWLReflexiveObjectPropertyAxiom(t(ax.getProperty()), a(ax)); + } + + @Override + public OWLSameIndividualAxiom visit(OWLSameIndividualAxiom ax) { + return df.getOWLSameIndividualAxiom(list(ax.individuals()), a(ax)); + } + + @Override + public OWLSubClassOfAxiom visit(OWLSubClassOfAxiom ax) { + return df.getOWLSubClassOfAxiom(t(ax.getSubClass()), t(ax.getSuperClass()), a(ax)); + } + + @Override + public OWLSymmetricObjectPropertyAxiom visit(OWLSymmetricObjectPropertyAxiom ax) { + return df.getOWLSymmetricObjectPropertyAxiom(t(ax.getProperty()), a(ax)); + } + + @Override + public OWLTransitiveObjectPropertyAxiom visit(OWLTransitiveObjectPropertyAxiom ax) { + return df.getOWLTransitiveObjectPropertyAxiom(t(ax.getProperty()), a(ax)); + } + + @Override + public OWLClass visit(OWLClass ce) { + return df.getOWLClass(getIRI(ce)); + } + + @Override + public OWLDataAllValuesFrom visit(OWLDataAllValuesFrom ce) { + return df.getOWLDataAllValuesFrom(t(ce.getProperty()), t(ce.getFiller())); + } + + @Override + public OWLDataExactCardinality visit(OWLDataExactCardinality ce) { + return df.getOWLDataExactCardinality(ce.getCardinality(), t(ce.getProperty()), + t(ce.getFiller())); + } + + @Override + public OWLDataMaxCardinality visit(OWLDataMaxCardinality ce) { + return df.getOWLDataMaxCardinality(ce.getCardinality(), t(ce.getProperty()), + t(ce.getFiller())); + } + + @Override + public OWLDataMinCardinality visit(OWLDataMinCardinality ce) { + return df.getOWLDataMinCardinality(ce.getCardinality(), t(ce.getProperty()), + t(ce.getFiller())); + } + + @Override + public OWLDataSomeValuesFrom visit(OWLDataSomeValuesFrom ce) { + return df.getOWLDataSomeValuesFrom(t(ce.getProperty()), t(ce.getFiller())); + } + + @Override + public OWLDataHasValue visit(OWLDataHasValue ce) { + return df.getOWLDataHasValue(t(ce.getProperty()), t(ce.getFiller())); + } + + @Override + public OWLObjectAllValuesFrom visit(OWLObjectAllValuesFrom ce) { + return df.getOWLObjectAllValuesFrom(t(ce.getProperty()), t(ce.getFiller())); + } + + @Override + public OWLObjectComplementOf visit(OWLObjectComplementOf ce) { + return df.getOWLObjectComplementOf(t(ce.getOperand())); + } + + @Override + public OWLObjectExactCardinality visit(OWLObjectExactCardinality ce) { + return df.getOWLObjectExactCardinality(ce.getCardinality(), t(ce.getProperty()), + t(ce.getFiller())); + } + + @Override + public OWLObjectIntersectionOf visit(OWLObjectIntersectionOf ce) { + return df.getOWLObjectIntersectionOf(list(ce.operands())); + } + + @Override + public OWLObjectMaxCardinality visit(OWLObjectMaxCardinality ce) { + return df.getOWLObjectMaxCardinality(ce.getCardinality(), t(ce.getProperty()), + t(ce.getFiller())); + } + + @Override + public OWLObjectMinCardinality visit(OWLObjectMinCardinality ce) { + OWLObjectPropertyExpression prop = t(ce.getProperty()); + return df.getOWLObjectMinCardinality(ce.getCardinality(), prop, t(ce.getFiller())); + } + + @Override + public OWLObjectOneOf visit(OWLObjectOneOf ce) { + return df.getOWLObjectOneOf(list(ce.individuals())); + } + + @Override + public OWLObjectHasSelf visit(OWLObjectHasSelf ce) { + return df.getOWLObjectHasSelf(t(ce.getProperty())); + } + + @Override + public OWLObjectSomeValuesFrom visit(OWLObjectSomeValuesFrom ce) { + return df.getOWLObjectSomeValuesFrom(t(ce.getProperty()), t(ce.getFiller())); + } + + @Override + public OWLObjectUnionOf visit(OWLObjectUnionOf ce) { + return df.getOWLObjectUnionOf(list(ce.operands())); + } + + @Override + public OWLObjectHasValue visit(OWLObjectHasValue ce) { + return df.getOWLObjectHasValue(t(ce.getProperty()), t(ce.getFiller())); + } + + @Override + public OWLDataComplementOf visit(OWLDataComplementOf node) { + return df.getOWLDataComplementOf(t(node.getDataRange())); + } + + @Override + public OWLDataOneOf visit(OWLDataOneOf node) { + return df.getOWLDataOneOf(list(node.values())); + } + + @Override + public OWLDatatype visit(OWLDatatype node) { + return df.getOWLDatatype(getIRI(node)); + } + + @Override + public OWLDatatypeRestriction visit(OWLDatatypeRestriction node) { + return df.getOWLDatatypeRestriction(t(node.getDatatype()), list(node.facetRestrictions())); + } + + @Override + public OWLFacetRestriction visit(OWLFacetRestriction node) { + return df.getOWLFacetRestriction(node.getFacet(), t(node.getFacetValue())); + } + + @Override + public OWLLiteral visit(OWLLiteral node) { + OWLLiteral l = replacementLiterals.get(node); + if (l != null) { + return l; + } + if (node.hasLang()) { + return df.getOWLLiteral(node.getLiteral(), node.getLang()); + } + return df.getOWLLiteral(node.getLiteral(), t(node.getDatatype())); + } + + @Override + public OWLDataProperty visit(OWLDataProperty property) { + return df.getOWLDataProperty(getIRI(property)); + } + + @Override + public OWLObjectProperty visit(OWLObjectProperty property) { + return df.getOWLObjectProperty(getIRI(property)); + } + + @Override + public OWLObjectInverseOf visit(OWLObjectInverseOf property) { + OWLObjectPropertyExpression inverse = property.getInverse(); + if (inverse.isAnonymous()) { + return df.getOWLObjectInverseOf(t(property.getNamedProperty())); + } + return df.getOWLObjectInverseOf(t(inverse.asOWLObjectProperty())); + } + + @Override + public OWLNamedIndividual visit(OWLNamedIndividual individual) { + return df.getOWLNamedIndividual(getIRI(individual)); + } + + @Override + public OWLOntology visit(OWLOntology ontology) { + // Should we duplicate ontologies here? Probably not. + return ontology; + } + + @Override + public SWRLRule visit(SWRLRule rule) { + return df.getSWRLRule(list(rule.body()), list(rule.head()), a(rule)); + } + + @Override + public SWRLClassAtom visit(SWRLClassAtom node) { + return df.getSWRLClassAtom(t(node.getPredicate()), t(node.getArgument())); + } + + @Override + public SWRLDataRangeAtom visit(SWRLDataRangeAtom node) { + return df.getSWRLDataRangeAtom(t(node.getPredicate()), t(node.getArgument())); + } + + @Override + public SWRLObjectPropertyAtom visit(SWRLObjectPropertyAtom node) { + return df.getSWRLObjectPropertyAtom(t(node.getPredicate()), t(node.getFirstArgument()), + t(node.getSecondArgument())); + } + + @Override + public SWRLDataPropertyAtom visit(SWRLDataPropertyAtom node) { + return df.getSWRLDataPropertyAtom(t(node.getPredicate()), t(node.getFirstArgument()), + t(node.getSecondArgument())); + } + + @Override + public SWRLBuiltInAtom visit(SWRLBuiltInAtom node) { + return df.getSWRLBuiltInAtom(node.getPredicate(), list(node.arguments())); + } + + @Override + public SWRLDifferentIndividualsAtom visit(SWRLDifferentIndividualsAtom node) { + return df.getSWRLDifferentIndividualsAtom(t(node.getFirstArgument()), + t(node.getSecondArgument())); + } + + @Override + public SWRLSameIndividualAtom visit(SWRLSameIndividualAtom node) { + return df.getSWRLSameIndividualAtom(t(node.getFirstArgument()), + t(node.getSecondArgument())); + } + + @Override + public SWRLVariable visit(SWRLVariable node) { + return df.getSWRLVariable(t(node.getIRI())); + } + + @Override + public SWRLIndividualArgument visit(SWRLIndividualArgument node) { + return df.getSWRLIndividualArgument(t(node.getIndividual())); + } + + @Override + public SWRLLiteralArgument visit(SWRLLiteralArgument node) { + return df.getSWRLLiteralArgument(t(node.getLiteral())); + } + + @Override + public OWLHasKeyAxiom visit(OWLHasKeyAxiom ax) { + return df.getOWLHasKeyAxiom(t(ax.getClassExpression()), list(ax.propertyExpressions()), + a(ax)); + } + + @Override + public OWLDataIntersectionOf visit(OWLDataIntersectionOf node) { + return df.getOWLDataIntersectionOf(list(node.operands())); + } + + @Override + public OWLDataUnionOf visit(OWLDataUnionOf node) { + return df.getOWLDataUnionOf(list(node.operands())); + } + + @Override + public OWLAnnotationProperty visit(OWLAnnotationProperty property) { + return df.getOWLAnnotationProperty(getIRI(property)); + } + + @Override + public OWLAnnotationPropertyDomainAxiom visit(OWLAnnotationPropertyDomainAxiom ax) { + return df.getOWLAnnotationPropertyDomainAxiom(t(ax.getProperty()), t(ax.getDomain()), + a(ax)); + } + + @Override + public OWLAnnotationPropertyRangeAxiom visit(OWLAnnotationPropertyRangeAxiom ax) { + return df.getOWLAnnotationPropertyRangeAxiom(t(ax.getProperty()), t(ax.getRange()), a(ax)); + } + + @Override + public OWLSubAnnotationPropertyOfAxiom visit(OWLSubAnnotationPropertyOfAxiom ax) { + return df.getOWLSubAnnotationPropertyOfAxiom(t(ax.getSubProperty()), + t(ax.getSuperProperty()), a(ax)); + } + + @Override + public OWLAnnotation visit(OWLAnnotation node) { + if (node.annotationsAsList().isEmpty()) { + return df.getOWLAnnotation(t(node.getProperty()), t(node.getValue())); + } + return df.getOWLAnnotation(t(node.getProperty()), t(node.getValue()), + node.annotations().map(this::t)); + } + + @Override + public OWLAnonymousIndividual visit(OWLAnonymousIndividual individual) { + return anonProvider.getOWLAnonymousIndividual(individual.getID().getID()); + } + + @Override + public IRI visit(IRI iri) { + for (EntityType entityType : EntityType.values()) { + OWLEntity entity = df.getOWLEntity(entityType, iri); + IRI replacementIRI = replacementMap.get(entity); + if (replacementIRI != null) { + return replacementIRI; + } + } + return iri; + } + + @Override + public OWLDatatypeDefinitionAxiom visit(OWLDatatypeDefinitionAxiom ax) { + return df.getOWLDatatypeDefinitionAxiom(t(ax.getDatatype()), t(ax.getDataRange()), a(ax)); + } + + /** + * A utility function that duplicates a set of objects. + * + * @param type + * @param objects The set of object to be duplicated + * @return The set of duplicated objects + */ + protected List list(Stream objects) { + return asList(objects.map(this::t)); + } + + @SuppressWarnings("unchecked") + protected O t(O o) { + return (O) o.accept(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectPropertyManager.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectPropertyManager.java new file mode 100644 index 0000000000..d698846cd4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectPropertyManager.java @@ -0,0 +1,458 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.model.AxiomType.EQUIVALENT_OBJECT_PROPERTIES; +import static org.semanticweb.owlapi.model.AxiomType.INVERSE_OBJECT_PROPERTIES; +import static org.semanticweb.owlapi.model.AxiomType.SUB_OBJECT_PROPERTY; +import static org.semanticweb.owlapi.model.AxiomType.SUB_PROPERTY_CHAIN_OF; +import static org.semanticweb.owlapi.model.AxiomType.SYMMETRIC_OBJECT_PROPERTY; +import static org.semanticweb.owlapi.model.AxiomType.TRANSITIVE_OBJECT_PROPERTY; +import static org.semanticweb.owlapi.search.Searcher.inverse; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Deque; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.model.parameters.Imports; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class OWLObjectPropertyManager { + + private final OWLDataFactory df; + private final OWLOntology ontology; + private final Map> hierarchy = + new HashMap<>(); + private final Map> reflexiveTransitiveClosure = + new HashMap<>(); + private final Set compositeProperties = new HashSet<>(); + private final Set nonSimpleProperties = new HashSet<>(); + private final Map> partialOrdering = + new HashMap<>(); + private boolean compositeDirty; + private boolean hierarchyDirty; + private boolean reflexiveTransitiveClosureDirty; + private boolean simpleDirty; + private boolean partialOrderingDirty; + + /** + * @param ont the ontology to use + */ + public OWLObjectPropertyManager(OWLOntology ont) { + ontology = checkNotNull(ont, "ontology cannot be null"); + df = ontology.getOWLOntologyManager().getOWLDataFactory(); + reset(); + } + + /** + * @param ontologies ontologies to search + * @return sets of equivalent properties + */ + public static Collection> getEquivalentObjectProperties( + Stream ontologies) { + checkNotNull(ontologies, "ontologies cannot be null"); + Set> result = new HashSet<>(); + Set processed = new HashSet<>(); + Stream properties = + ontologies.flatMap(OWLOntology::objectPropertiesInSignature); + properties.forEach(p -> { + if (!processed.contains(p)) { + tarjan(ontologies, p, 0, new LinkedList(), + new HashMap(), + new HashMap(), result, processed, + new HashSet()); + } + }); + // Get maximal + List> equivs = new ArrayList<>(result); + Collections.sort(equivs, (o1, o2) -> Integer.compare(o1.size(), o2.size())); + for (int i = 0; i < equivs.size(); i++) { + for (int j = i; j < equivs.size(); j++) { + if (equivs.get(j).containsAll(equivs.get(i))) { + equivs.remove(i); + break; + } + } + } + return equivs; + } + + /** + * @param ontologies The ontologies + * @param prop the property + * @param index index + * @param stack stack + * @param indexMap index map + * @param lowlinkMap low link map + * @param result result + * @param processed processed + * @param stackProps stack entities + */ + public static void tarjan(Stream ontologies, OWLObjectPropertyExpression prop, + int index, Deque stack, + Map indexMap, + Map lowlinkMap, + Set> result, Set processed, + Set stackProps) { + checkNotNull(ontologies, "ontologies cannot be null"); + checkNotNull(prop, "prop cannot be null"); + checkNotNull(stack, "stack cannot be null"); + checkNotNull(indexMap, "indexMap cannot be null"); + checkNotNull(lowlinkMap, "lowlinkMap cannot be null"); + checkNotNull(result, "result cannot be null"); + checkNotNull(processed, "processed cannot be null"); + checkNotNull(stackProps, "stackProps cannot be null"); + processed.add(prop); + indexMap.put(prop, Integer.valueOf(index)); + lowlinkMap.put(prop, Integer.valueOf(index)); + stack.push(prop); + stackProps.add(prop); + ontologies.flatMap(ont -> ont.objectSubPropertyAxiomsForSubProperty(prop)) + .filter(ax -> ax.getSubProperty().equals(prop)) + .forEach(ax -> callTarjanAndPut(ontologies, prop, index, stack, indexMap, lowlinkMap, + result, processed, stackProps, ax.getSuperProperty())); + if (lowlinkMap.get(prop).equals(indexMap.get(prop))) { + Set scc = new HashSet<>(); + OWLObjectPropertyExpression propPrime; + while (true) { + propPrime = stack.pop(); + stackProps.remove(propPrime); + scc.add(propPrime); + if (propPrime.equals(prop)) { + break; + } + } + if (scc.size() > 1) { + result.add(scc); + } + } + } + + protected static void callTarjanAndPut(Stream ontologies, + OWLObjectPropertyExpression prop, int index, Deque stack, + Map indexMap, + Map lowlinkMap, + Set> result, Set processed, + Set stackProps, OWLObjectPropertyExpression supProp) { + if (!indexMap.containsKey(supProp)) { + tarjan(ontologies, supProp, index + 1, stack, indexMap, lowlinkMap, result, processed, + stackProps); + put(prop, lowlinkMap, supProp); + } else if (stackProps.contains(supProp)) { + putIndex(prop, indexMap, lowlinkMap, supProp); + } + } + + protected static void putIndex(OWLObjectPropertyExpression prop, + Map indexMap, + Map lowlinkMap, OWLObjectPropertyExpression supProp) { + lowlinkMap.put(prop, Integer + .valueOf(Math.min(lowlinkMap.get(prop).intValue(), indexMap.get(supProp).intValue()))); + } + + protected static void put(OWLObjectPropertyExpression prop, + Map lowlinkMap, OWLObjectPropertyExpression supProp) { + putIndex(prop, lowlinkMap, lowlinkMap, supProp); + } + + // Util methods + private static Set getReflexiveTransitiveClosure( + OWLObjectPropertyExpression prop, + Map> map, + Set rtc, Set processed) { + checkNotNull(prop, "prop cannot be null"); + checkNotNull(map, "map cannot be null"); + checkNotNull(rtc, "rtc cannot be null"); + checkNotNull(processed, "processed cannot be null"); + if (processed.contains(prop)) { + return rtc; + } + rtc.add(prop); + processed.add(prop); + Set supers = map.get(prop); + if (supers == null) { + return rtc; + } + supers.forEach(sup -> getReflexiveTransitiveClosure(sup, map, rtc, processed)); + return rtc; + } + + private static Set getKeyValue(OWLObjectPropertyExpression key, + Map> map) { + return map.computeIfAbsent(key, k -> new HashSet<>(4)); + } + + private void reset() { + compositeDirty = true; + hierarchyDirty = true; + reflexiveTransitiveClosureDirty = true; + simpleDirty = true; + partialOrderingDirty = true; + } + + /** + * An object property expression PE is composite in Ax if Ax contains an axiom of the form + * SubObjectPropertyOf(SubObjectPropertyChain(PE1 ... PEn) PE) with n greater than 1, or + * SubObjectPropertyOf(SubObjectPropertyChain(PE1 ... PEn) INV(PE)) with n greater than 1, or + * TransitiveObjectProperty(PE), or TransitiveObjectProperty(INV(PE)). + * + * @param expression The object property expression to be tested + * @return {@code true} if the object property is composite (according to the above definition) + * or {@code false} if the object property is not composite. + */ + public boolean isComposite(OWLObjectPropertyExpression expression) { + checkNotNull(expression, "expression cannot be null"); + return getCompositeProperties().contains(expression); + } + + protected Stream inverseProperties( + OWLObjectPropertyExpression p1) { + return inverse(ontology.inverseObjectPropertyAxioms(p1), p1); + } + + protected Stream ontologies() { + return Imports.INCLUDED.stream(ontology); + } + + protected Stream axioms(AxiomType t) { + return ontologies().flatMap(o -> o.axioms(t)); + } + + /** + * @return the property expressions + */ + public Set getCompositeProperties() { + if (compositeDirty) { + compositeProperties.clear(); + compositeProperties.add(df.getOWLTopObjectProperty()); + compositeProperties.add(df.getOWLBottomObjectProperty()); + // We only depend on: + // 1) Property chain axioms + // 2) Transitive property axioms + axioms(TRANSITIVE_OBJECT_PROPERTY).forEach(ax -> mark(ax.getProperty())); + axioms(SUB_PROPERTY_CHAIN_OF).forEach(ax -> mark(ax.getSuperProperty())); + compositeDirty = false; + } + return compositeProperties; + } + + protected void mark(OWLObjectPropertyExpression p) { + compositeProperties.add(p); + compositeProperties.add(p.getInverseProperty()); + inverseProperties(p).forEach(i -> { + compositeProperties.add(i); + compositeProperties.add(i.getInverseProperty()); + }); + } + + /** + * The object property hierarchy relation -> is the smallest relation on object property + * expressions for which the following conditions hold (A -> B means that -> holds for A + * and B): if Ax contains an axiom SubObjectPropertyOf(PE1 PE2), then PE1 -> PE2 holds; and + * if Ax contains an axiom EquivalentObjectProperties(PE1 PE2), then PE1 -> PE2 and PE2 -> + * PE1 hold; and if Ax contains an axiom InverseObjectProperties(PE1 PE2), then PE1 -> + * INV(PE2) and INV(PE2) -> PE1 hold; and if Ax contains an axiom + * SymmetricObjectProperty(PE), then PE -> INV(PE) holds; and if PE1 -> PE2 holds, then + * INV(PE1) -> INV(PE2) holds as well. + * + * @return A Map that maps sub properties to sets of super properties. + */ + public Map> getPropertyHierarchy() { + if (hierarchyDirty) { + Map> map = + new HashMap<>(); + // Examine: SubObjectPropertyOf + // EquivalentObjectProperties + // InverseObjectProperties + // SymmetricObjectProperty + axioms(SUB_OBJECT_PROPERTY).forEach( + ax -> getKeyValueSymmetric(map, ax.getSubProperty(), ax.getSuperProperty())); + axioms(EQUIVALENT_OBJECT_PROPERTIES).forEach(ax -> pairwise(map, ax)); + axioms(INVERSE_OBJECT_PROPERTIES).forEach(ax -> { + getKeyValueASymmetric(map, ax.getFirstProperty(), ax.getSecondProperty()); + getKeyValueASymmetric(map, ax.getSecondProperty(), ax.getFirstProperty()); + }); + axioms(SYMMETRIC_OBJECT_PROPERTY) + .forEach(ax -> getKeyValueASymmetric(map, ax.getProperty(), ax.getProperty())); + hierarchy.clear(); + hierarchy.putAll(map); + hierarchyDirty = false; + } + return hierarchy; + } + + protected void pairwise(Map> map, + OWLEquivalentObjectPropertiesAxiom ax) { + // Do pairwise + ax.walkPairwise((p1, p2) -> { + if (!p1.equals(p2)) { + getKeyValueSymmetric(map, p1, p2); + getKeyValueSymmetric(map, p2, p1); + } + return null; + }); + } + + protected void getKeyValueSymmetric( + Map> map, + OWLObjectPropertyExpression p1, OWLObjectPropertyExpression p2) { + getKeyValue(p1, map).add(p2); + getKeyValue(p1.getInverseProperty(), map).add(p2.getInverseProperty()); + } + + protected void getKeyValueASymmetric( + Map> map, + OWLObjectPropertyExpression p1, OWLObjectPropertyExpression p2) { + getKeyValue(p1, map).add(p2.getInverseProperty()); + getKeyValue(p1.getInverseProperty(), map).add(p2); + } + + /** + * @return transitive reflexive closure + */ + public Map> getHierarchyReflexiveTransitiveClosure() { + if (reflexiveTransitiveClosureDirty) { + // Produce a map of the transitive reflexive closure of this + Map> rtcMap = + new HashMap<>(); + Map> propertyHierarchy = + getPropertyHierarchy(); + getReferencedProperties() + .forEach(prop -> rtcMap.put(prop, getReflexiveTransitiveClosure(prop, + propertyHierarchy, new HashSet<>(), new HashSet<>()))); + reflexiveTransitiveClosure.clear(); + reflexiveTransitiveClosure.putAll(rtcMap); + reflexiveTransitiveClosureDirty = false; + } + return reflexiveTransitiveClosure; + } + + /** + * Tests to see if one property is a sub property of another property in the reflexive + * transitive closure of the property hierarchy. + * + * @param sub The sub property + * @param sup The super property + * @return {@code true} if sub is the sub-property of sup, otherwise {@code false} + */ + public boolean isSubPropertyOf(OWLObjectPropertyExpression sub, + OWLObjectPropertyExpression sup) { + checkNotNull(sub, "sub cannot be null"); + checkNotNull(sup, "sup cannot be null"); + return getHierarchyReflexiveTransitiveClosure().get(sub).contains(sup); + } + + /** + * The relation ->* is the reflexive-transitive closure of ->. An object property + * expression PE is simple in Ax if, for each object property expression PE' such that PE' + * ->* PE holds, PE' is not composite. + * + * @param expression The expression to be tested. + * @return {@code true} if the object property expression is simple, otherwise false. + */ + public boolean isNonSimple(OWLObjectPropertyExpression expression) { + checkNotNull(expression, "expression cannot be null"); + return getNonSimpleProperties().contains(expression); + } + + /** + * @return non simple properties + */ + public Set getNonSimpleProperties() { + if (simpleDirty) { + nonSimpleProperties.clear(); + Map> reflexiveTransitiveClosureMap = + getHierarchyReflexiveTransitiveClosure(); + getReferencedProperties().filter(this::isComposite).forEach(prop -> { + // Supers are not simple + nonSimpleProperties.add(prop); + nonSimpleProperties.addAll(reflexiveTransitiveClosureMap.get(prop)); + }); + nonSimpleProperties + .addAll(asList(nonSimpleProperties.stream().map(p -> p.getInverseProperty()))); + simpleDirty = false; + } + return nonSimpleProperties; + } + + /** + * @return partial ordering + */ + public Map> getPropertyPartialOrdering() { + if (partialOrderingDirty) { + partialOrdering.clear(); + Map> map = + new HashMap<>(getPropertyHierarchy()); + axioms(SUB_PROPERTY_CHAIN_OF) + .forEach(ax -> ax.getPropertyChain().forEach(p -> map(map, ax, p))); + Map> ordering = + new HashMap<>(); + getReferencedProperties().forEach(prop -> ordering.put(prop, + getReflexiveTransitiveClosure(prop, map, new HashSet<>(), new HashSet<>()))); + partialOrdering.putAll(ordering); + partialOrderingDirty = false; + } + return partialOrdering; + } + + protected void map(Map> map, + OWLSubPropertyChainOfAxiom ax, OWLObjectPropertyExpression prop) { + map.computeIfAbsent(prop, k -> new HashSet<>()).add(ax.getSuperProperty()); + map.computeIfAbsent(prop.getInverseProperty(), k -> new HashSet<>()) + .add(ax.getSuperProperty().getInverseProperty()); + } + + /** + * @param propA first property + * @param propB second property + * @return true if first property comes first in the default ordering + */ + public boolean isLessThan(OWLObjectPropertyExpression propA, + OWLObjectPropertyExpression propB) { + checkNotNull(propA, "propA cannot be null"); + checkNotNull(propB, "propB cannot be null"); + Set set = getPropertyPartialOrdering().get(propA); + return set != null && set.contains(propB); + } + + private Stream getReferencedProperties() { + return ontologies().flatMap(OWLOntology::objectPropertiesInSignature); + } + + /** + * @return sets of equivalent properties + */ + public Collection> getEquivalentObjectProperties() { + return getEquivalentObjectProperties(ontology.importsClosure()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectTransformer.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectTransformer.java new file mode 100644 index 0000000000..995d141ac5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectTransformer.java @@ -0,0 +1,853 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.function.Supplier; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.change.AddAxiomData; +import org.semanticweb.owlapi.change.AxiomChangeData; +import org.semanticweb.owlapi.change.RemoveAxiomData; +import org.semanticweb.owlapi.model.AddImport; +import org.semanticweb.owlapi.model.AddOntologyAnnotation; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataComplementOf; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataIntersectionOf; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDataUnionOf; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLHasKeyAxiom; +import org.semanticweb.owlapi.model.OWLImportsDeclaration; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectInverseOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLObjectVisitorEx; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; +import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.RemoveImport; +import org.semanticweb.owlapi.model.RemoveOntologyAnnotation; +import org.semanticweb.owlapi.model.SWRLBuiltInAtom; +import org.semanticweb.owlapi.model.SWRLClassAtom; +import org.semanticweb.owlapi.model.SWRLDataPropertyAtom; +import org.semanticweb.owlapi.model.SWRLDataRangeAtom; +import org.semanticweb.owlapi.model.SWRLDifferentIndividualsAtom; +import org.semanticweb.owlapi.model.SWRLIndividualArgument; +import org.semanticweb.owlapi.model.SWRLLiteralArgument; +import org.semanticweb.owlapi.model.SWRLObjectPropertyAtom; +import org.semanticweb.owlapi.model.SWRLRule; +import org.semanticweb.owlapi.model.SWRLSameIndividualAtom; +import org.semanticweb.owlapi.model.SWRLVariable; +import org.semanticweb.owlapi.model.SetOntologyID; +import org.semanticweb.owlapi.vocab.OWLFacet; + +/** + * Transform axioms by rewriting parts of them. + * + * @param type to transform + * @author Ignazio + * @since 4.1.4 + */ +public class OWLObjectTransformer { + + private final Function transformer; + private final Predicate predicate; + private final Class witness; + private final OWLDataFactory df; + + /** + * @param predicate the predicate to match the axioms to rebuild + * @param transformer the transformer to apply + * @param df data factory to use for changes + * @param witness witness class for the transformer + */ + public OWLObjectTransformer(Predicate predicate, Function transformer, + OWLDataFactory df, Class witness) { + this.predicate = checkNotNull(predicate, "predicate cannot be null"); + this.transformer = checkNotNull(transformer, "transformer cannot be null"); + this.df = checkNotNull(df, "df cannot be null"); + this.witness = checkNotNull(witness, "witness cannot be null"); + } + + /** + * Create the required changes for this transformation to be applied to the input. Note: these + * are AxiomChangeData changes, not ontology specific changes. There is no requirement for the + * input to be an ontology or included in an ontology. + * + * @param o object to transform. Must be an axiom or an ontology for the change to be + * meaningful. + * @return A list of axiom changes that should be applied. + */ + public List change(OWLObject o) { + checkNotNull(o, "o cannot be null"); + List changes = new ArrayList<>(); + // no ontology changes will be collected + Visitor v = new Visitor<>(new ArrayList(), changes, predicate, + transformer, df, witness); + o.accept(v); + return changes; + } + + /** + * Create the required changes for this transformation to be applied to the input. These changes + * are specific to the input ontology. + * + * @param ontology ontology to transform. + * @return A list of changes that should be applied. + */ + public List change(OWLOntology ontology) { + checkNotNull(ontology, "ontology cannot be null"); + List changes = new ArrayList<>(); + List ontologyChanges = new ArrayList<>(); + Visitor v = new Visitor<>(ontologyChanges, changes, predicate, transformer, df, witness); + ontology.accept(v); + for (AxiomChangeData change : changes) { + ontologyChanges.add(change.createOntologyChange(ontology)); + } + return ontologyChanges; + } + + private static class Visitor implements OWLObjectVisitorEx { + + private final List changes; + private final List ontologyChanges; + private final Predicate predicate; + private final Function transformer; + private final Class witness; + private final OWLDataFactory df; + + Visitor(List ontologyChanges, List changes, + Predicate predicate, Function transformer, OWLDataFactory df, + Class witness) { + this.changes = changes; + this.ontologyChanges = ontologyChanges; + this.predicate = predicate; + this.transformer = transformer; + this.df = df; + this.witness = witness; + } + + /** + * Check and transform an axiom. + * + * @param axiom axiom to check + * @return the transformed axiom, or null if the axiom was not transformed + */ + @SuppressWarnings({"unchecked"}) + @Nullable + protected OWLAxiom checkAxiom(OWLAxiom axiom) { + if (witness.isInstance(axiom)) { + OWLAxiom transform = ((Function) transformer).apply(axiom); + if (update(transform, axiom) == transform) { + return transform; + } + } + return null; + } + + protected OWLAxiom update(OWLAxiom transform, OWLAxiom axiom) { + if (!axiom.equals(transform)) { + changes.add(new RemoveAxiomData(axiom)); + changes.add(new AddAxiomData(transform)); + return transform; + } + return axiom; + } + + /** + * Check and transform an object. + * + * @param type + * @param o object to check + * @return the transformed object, or null if the axiom was not transformed + */ + @SuppressWarnings({"unchecked"}) + @Nullable + protected Q check(Q o) { + if (witness.isInstance(o)) { + Q transform = (Q) transformer.apply(witness.cast(o)); + if (transform != o) { + return transform; + } + } + return null; + } + + @SuppressWarnings("unchecked") + protected Q t(Q t) { + return (Q) t.accept(this); + } + + @SuppressWarnings("unchecked") + protected OWLFacet t(OWLFacet t) { + return (OWLFacet) transformer.apply((T) t); + } + + protected Collection t(Stream c) { + return asList(c.map(this::t)); + } + + protected List t(List c) { + List list = new ArrayList<>(); + for (Q t : c) { + list.add(t(t)); + } + return list; + } + + @Override + public Object visit(OWLDeclarationAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLDeclarationAxiom(t(axiom.getEntity()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLDatatypeDefinitionAxiom axiom) { + return visitAxiom(axiom, () -> df.getOWLDatatypeDefinitionAxiom(t(axiom.getDatatype()), + t(axiom.getDataRange()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLAnnotationAssertionAxiom axiom) { + return visitAxiom(axiom, () -> df.getOWLAnnotationAssertionAxiom(t(axiom.getSubject()), + t(axiom.getAnnotation()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLSubAnnotationPropertyOfAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLSubAnnotationPropertyOfAxiom(t(axiom.getSubProperty()), + t(axiom.getSuperProperty()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLAnnotationPropertyDomainAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLAnnotationPropertyDomainAxiom(t(axiom.getProperty()), + t(axiom.getDomain()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLAnnotationPropertyRangeAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLAnnotationPropertyRangeAxiom(t(axiom.getProperty()), + t(axiom.getRange()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLSubClassOfAxiom axiom) { + return visitAxiom(axiom, () -> df.getOWLSubClassOfAxiom(t(axiom.getSubClass()), + t(axiom.getSuperClass()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLNegativeObjectPropertyAssertionAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLNegativeObjectPropertyAssertionAxiom(t(axiom.getProperty()), + t(axiom.getSubject()), t(axiom.getObject()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLAsymmetricObjectPropertyAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLAsymmetricObjectPropertyAxiom(t(axiom.getProperty()), + t(axiom.annotations()))); + } + + @Override + public Object visit(OWLReflexiveObjectPropertyAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLReflexiveObjectPropertyAxiom(t(axiom.getProperty()), + t(axiom.annotations()))); + } + + @Override + public Object visit(OWLDisjointClassesAxiom axiom) { + return visitAxiom(axiom, () -> df + .getOWLDisjointClassesAxiom(t(axiom.classExpressions()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLDataPropertyDomainAxiom axiom) { + return visitAxiom(axiom, () -> df.getOWLDataPropertyDomainAxiom(t(axiom.getProperty()), + t(axiom.getDomain()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLObjectPropertyDomainAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLObjectPropertyDomainAxiom(t(axiom.getProperty()), + t(axiom.getDomain()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLEquivalentObjectPropertiesAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLEquivalentObjectPropertiesAxiom(t(axiom.properties()), + t(axiom.annotations()))); + } + + @Override + public Object visit(OWLNegativeDataPropertyAssertionAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLNegativeDataPropertyAssertionAxiom(t(axiom.getProperty()), + t(axiom.getSubject()), t(axiom.getObject()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLDifferentIndividualsAxiom axiom) { + return visitAxiom(axiom, () -> df + .getOWLDifferentIndividualsAxiom(t(axiom.individuals()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLDisjointDataPropertiesAxiom axiom) { + return visitAxiom(axiom, () -> df + .getOWLDisjointDataPropertiesAxiom(t(axiom.properties()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLDisjointObjectPropertiesAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLDisjointObjectPropertiesAxiom(t(axiom.properties()), + t(axiom.annotations()))); + } + + @Override + public Object visit(OWLObjectPropertyRangeAxiom axiom) { + return visitAxiom(axiom, () -> df.getOWLObjectPropertyRangeAxiom(t(axiom.getProperty()), + t(axiom.getRange()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLObjectPropertyAssertionAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLObjectPropertyAssertionAxiom(t(axiom.getProperty()), + t(axiom.getSubject()), t(axiom.getObject()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLFunctionalObjectPropertyAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLFunctionalObjectPropertyAxiom(t(axiom.getProperty()), + t(axiom.annotations()))); + } + + @Override + public Object visit(OWLSubObjectPropertyOfAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLSubObjectPropertyOfAxiom(t(axiom.getSubProperty()), + t(axiom.getSuperProperty()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLDisjointUnionAxiom axiom) { + return visitAxiom(axiom, () -> df.getOWLDisjointUnionAxiom(t(axiom.getOWLClass()), + t(axiom.classExpressions()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLSymmetricObjectPropertyAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLSymmetricObjectPropertyAxiom(t(axiom.getProperty()), + t(axiom.annotations()))); + } + + @Override + public Object visit(OWLDataPropertyRangeAxiom axiom) { + return visitAxiom(axiom, () -> df.getOWLDataPropertyRangeAxiom(t(axiom.getProperty()), + t(axiom.getRange()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLFunctionalDataPropertyAxiom axiom) { + return visitAxiom(axiom, () -> df + .getOWLFunctionalDataPropertyAxiom(t(axiom.getProperty()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLEquivalentDataPropertiesAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLEquivalentDataPropertiesAxiom(t(axiom.properties()), + t(axiom.annotations()))); + } + + @Override + public Object visit(OWLClassAssertionAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLClassAssertionAxiom(t(axiom.getClassExpression()), + t(axiom.getIndividual()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLEquivalentClassesAxiom axiom) { + return visitAxiom(axiom, () -> df + .getOWLEquivalentClassesAxiom(t(axiom.classExpressions()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLDataPropertyAssertionAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLDataPropertyAssertionAxiom(t(axiom.getProperty()), + t(axiom.getSubject()), t(axiom.getObject()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLTransitiveObjectPropertyAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLTransitiveObjectPropertyAxiom(t(axiom.getProperty()), + t(axiom.annotations()))); + } + + @Override + public Object visit(OWLIrreflexiveObjectPropertyAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLIrreflexiveObjectPropertyAxiom(t(axiom.getProperty()), + t(axiom.annotations()))); + } + + @Override + public Object visit(OWLSubDataPropertyOfAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLSubDataPropertyOfAxiom(t(axiom.getSubProperty()), + t(axiom.getSuperProperty()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLInverseFunctionalObjectPropertyAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLInverseFunctionalObjectPropertyAxiom(t(axiom.getProperty()), + t(axiom.annotations()))); + } + + @Override + public Object visit(OWLSameIndividualAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLSameIndividualAxiom(t(axiom.individuals()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLSubPropertyChainOfAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLSubPropertyChainOfAxiom(t(axiom.getPropertyChain()), + t(axiom.getSuperProperty()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLInverseObjectPropertiesAxiom axiom) { + return visitAxiom(axiom, + () -> df.getOWLInverseObjectPropertiesAxiom(t(axiom.getFirstProperty()), + t(axiom.getSecondProperty()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLHasKeyAxiom axiom) { + return visitAxiom(axiom, () -> df.getOWLHasKeyAxiom(t(axiom.getClassExpression()), + t(axiom.propertyExpressions()), t(axiom.annotations()))); + } + + @Override + public Object visit(SWRLRule axiom) { + return visitAxiom(axiom, + () -> df.getSWRLRule(t(axiom.body()), t(axiom.head()), t(axiom.annotations()))); + } + + @Override + public Object visit(OWLClass ce) { + return visit(ce, () -> df.getOWLClass(t(ce.getIRI()))); + } + + @Override + public Object visit(OWLObjectIntersectionOf ce) { + return visit(ce, () -> df.getOWLObjectIntersectionOf(t(ce.operands()))); + } + + @Override + public Object visit(OWLObjectUnionOf ce) { + return visit(ce, () -> df.getOWLObjectUnionOf(t(ce.operands()))); + } + + @Override + public Object visit(OWLObjectComplementOf ce) { + return visit(ce, () -> df.getOWLObjectComplementOf(t(ce.getOperand()))); + } + + @Override + public Object visit(OWLObjectSomeValuesFrom ce) { + return visit(ce, + () -> df.getOWLObjectSomeValuesFrom(t(ce.getProperty()), t(ce.getFiller()))); + } + + @Override + public Object visit(OWLObjectAllValuesFrom ce) { + return visit(ce, + () -> df.getOWLObjectAllValuesFrom(t(ce.getProperty()), t(ce.getFiller()))); + } + + @Override + public Object visit(OWLObjectHasValue ce) { + return visit(ce, () -> df.getOWLObjectHasValue(t(ce.getProperty()), t(ce.getFiller()))); + } + + @Override + public Object visit(OWLObjectMinCardinality ce) { + return visit(ce, () -> df.getOWLObjectMinCardinality(ce.getCardinality(), + t(ce.getProperty()), t(ce.getFiller()))); + } + + @Override + public Object visit(OWLObjectExactCardinality ce) { + return visit(ce, () -> df.getOWLObjectExactCardinality(ce.getCardinality(), + t(ce.getProperty()), t(ce.getFiller()))); + } + + @Override + public Object visit(OWLObjectMaxCardinality ce) { + return visit(ce, () -> df.getOWLObjectMaxCardinality(ce.getCardinality(), + t(ce.getProperty()), t(ce.getFiller()))); + } + + @Override + public Object visit(OWLObjectHasSelf ce) { + return visit(ce, () -> df.getOWLObjectHasSelf(t(ce.getProperty()))); + } + + @Override + public Object visit(OWLObjectOneOf ce) { + return visit(ce, () -> df.getOWLObjectOneOf(t(ce.individuals()))); + } + + @Override + public Object visit(OWLDataSomeValuesFrom ce) { + return visit(ce, + () -> df.getOWLDataSomeValuesFrom(t(ce.getProperty()), t(ce.getFiller()))); + } + + @Override + public Object visit(OWLDataAllValuesFrom ce) { + return visit(ce, + () -> df.getOWLDataAllValuesFrom(t(ce.getProperty()), t(ce.getFiller()))); + } + + @Override + public Object visit(OWLDataHasValue ce) { + return visit(ce, () -> df.getOWLDataHasValue(t(ce.getProperty()), t(ce.getFiller()))); + } + + @Override + public Object visit(OWLDataMinCardinality ce) { + return visit(ce, () -> df.getOWLDataMinCardinality(ce.getCardinality(), + t(ce.getProperty()), t(ce.getFiller()))); + } + + @Override + public Object visit(OWLDataExactCardinality ce) { + return visit(ce, () -> df.getOWLDataExactCardinality(ce.getCardinality(), + t(ce.getProperty()), t(ce.getFiller()))); + } + + @Override + public Object visit(OWLDataMaxCardinality ce) { + return visit(ce, () -> df.getOWLDataMaxCardinality(ce.getCardinality(), + t(ce.getProperty()), t(ce.getFiller()))); + } + + @Override + public Object visit(OWLDatatype node) { + return visit(node, () -> df.getOWLDatatype(t(node.getIRI()))); + } + + @Override + public Object visit(OWLDataComplementOf node) { + return visit(node, () -> df.getOWLDataComplementOf(t(node.getDataRange()))); + } + + @Override + public Object visit(OWLDataOneOf node) { + return visit(node, () -> df.getOWLDataOneOf(t(node.values()))); + } + + @Override + public Object visit(OWLDataIntersectionOf node) { + return visit(node, () -> df.getOWLDataIntersectionOf(t(node.operands()))); + } + + @Override + public Object visit(OWLDataUnionOf node) { + return visit(node, () -> df.getOWLDataUnionOf(t(node.operands()))); + } + + @Override + public Object visit(OWLDatatypeRestriction node) { + return visit(node, () -> df.getOWLDatatypeRestriction(t(node.getDatatype()), + t(node.facetRestrictions()))); + } + + @Override + public Object visit(OWLLiteral node) { + OWLObject transform = check(node); + if (transform != null) { + return transform; + } + if (!predicate.test(node)) { + return node; + } + // plain literal is a terminal; if the transform did not make a + // change, then no change is required + if (node.isRDFPlainLiteral()) { + return node; + } + return df.getOWLLiteral(node.getLiteral(), t(node.getDatatype())); + } + + @Override + public Object visit(OWLFacetRestriction node) { + return visit(node, + () -> df.getOWLFacetRestriction(t(node.getFacet()), t(node.getFacetValue()))); + } + + @Override + public Object visit(OWLObjectProperty property) { + return visit(property, () -> df.getOWLObjectProperty(t(property.getIRI()))); + } + + @Override + public Object visit(OWLObjectInverseOf property) { + return visit(property, () -> df.getOWLObjectInverseOf(t(property.getNamedProperty()))); + } + + @Override + public Object visit(OWLDataProperty property) { + return visit(property, () -> df.getOWLDataProperty(t(property.getIRI()))); + } + + @Override + public Object visit(OWLAnnotationProperty property) { + return visit(property, () -> df.getOWLAnnotationProperty(t(property.getIRI()))); + } + + @Override + public Object visit(OWLNamedIndividual individual) { + return visit(individual, () -> df.getOWLNamedIndividual(t(individual.getIRI()))); + } + + @Override + public Object visit(OWLAnnotation node) { + return visit(node, () -> df.getOWLAnnotation(t(node.getProperty()), t(node.getValue()), + t(node.annotations()))); + } + + @Override + public Object visit(IRI iri) { + OWLObject transform = check(iri); + if (transform != null) { + return transform; + } + // IRI is a terminal; if the transform did not make a change, then + // no change is required + return iri; + } + + @Override + public Object visit(OWLAnonymousIndividual individual) { + OWLObject transform = check(individual); + if (transform != null) { + return transform; + } + // OWLAnonymousIndividual is a terminal; if the transform did not + // make a change, then no change is required + return individual; + } + + @Override + public Object visit(SWRLClassAtom node) { + return visit(node, + () -> df.getSWRLClassAtom(t(node.getPredicate()), t(node.getArgument()))); + } + + @Override + public Object visit(SWRLDataRangeAtom node) { + return visit(node, + () -> df.getSWRLDataRangeAtom(t(node.getPredicate()), t(node.getArgument()))); + } + + @Override + public Object visit(SWRLObjectPropertyAtom node) { + return visit(node, () -> df.getSWRLObjectPropertyAtom(t(node.getPredicate()), + t(node.getFirstArgument()), t(node.getSecondArgument()))); + } + + @Override + public Object visit(SWRLDataPropertyAtom node) { + return visit(node, () -> df.getSWRLDataPropertyAtom(t(node.getPredicate()), + t(node.getFirstArgument()), t(node.getSecondArgument()))); + } + + @Override + public Object visit(SWRLBuiltInAtom node) { + return visit(node, + () -> df.getSWRLBuiltInAtom(t(node.getPredicate()), t(node.getArguments()))); + } + + @Override + public Object visit(SWRLVariable node) { + return visit(node, () -> df.getSWRLVariable(t(node.getIRI()))); + } + + @Override + public Object visit(SWRLIndividualArgument node) { + return visit(node, () -> df.getSWRLIndividualArgument(t(node.getIndividual()))); + } + + @Override + public Object visit(SWRLLiteralArgument node) { + return visit(node, () -> df.getSWRLLiteralArgument(t(node.getLiteral()))); + } + + @Override + public Object visit(SWRLSameIndividualAtom node) { + return visit(node, () -> df.getSWRLSameIndividualAtom(t(node.getFirstArgument()), + t(node.getSecondArgument()))); + } + + @Override + public Object visit(SWRLDifferentIndividualsAtom node) { + return visit(node, () -> df.getSWRLDifferentIndividualsAtom(t(node.getFirstArgument()), + t(node.getSecondArgument()))); + } + + protected Object visit(OWLObject node, Supplier rebuilder) { + OWLObject transform = check(node); + if (transform != null) { + return transform; + } + if (!predicate.test(node)) { + return node; + } + return rebuilder.get(); + } + + protected Object visitAxiom(OWLAxiom node, Supplier rebuilder) { + OWLObject transform = checkAxiom(node); + if (transform != null) { + return transform; + } + if (!predicate.test(node)) { + return node; + } + return update(rebuilder.get(), node); + } + + @Override + public Object visit(OWLOntology ontology) { + AxiomType.AXIOM_TYPES.stream().flatMap(t -> ontology.axioms(t)) + .forEach(ax -> ax.accept(this)); + ontology.annotations().forEach(a -> { + OWLAnnotation transform = t(a); + if (transform != a) { + ontologyChanges.add(new RemoveOntologyAnnotation(ontology, a)); + ontologyChanges.add(new AddOntologyAnnotation(ontology, transform)); + } + }); + ontology.importsDeclarations().forEach(id -> { + OWLImportsDeclaration transform = check(id); + if (transform != null) { + ontologyChanges.add(new RemoveImport(ontology, id)); + ontologyChanges.add(new AddImport(ontology, transform)); + } + }); + OWLOntologyID transform = check(ontology.getOntologyID()); + if (transform != null) { + ontologyChanges.add(new SetOntologyID(ontology, transform)); + } + // the ontology object is never modified + return ontology; + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectWalker.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectWalker.java new file mode 100644 index 0000000000..e8ef9113c0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLObjectWalker.java @@ -0,0 +1,282 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.stream.Stream; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectVisitor; +import org.semanticweb.owlapi.model.OWLObjectVisitorEx; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @param the returned type + * @author Matthew Horridge, The University Of Manchester, Information Management Group + * @since 2.2.0 + */ +public class OWLObjectWalker { + + protected final boolean visitDuplicates; + private final Collection objects; + private final List classExpressionPath = new ArrayList<>(); + private final List dataRangePath = new ArrayList<>(); + @Nullable + protected OWLOntology ontology; + @Nullable + protected OWLObjectVisitor visitor; + @Nullable + protected OWLAxiom ax; + @Nullable + protected OWLAnnotation annotation; + @Nullable + private OWLObjectVisitorEx visitorEx; + private StructureWalker walker; + + /** + * @param objects objects to visit + */ + public OWLObjectWalker(Collection objects) { + this(objects.stream(), true, AnnotationWalkingControl.WALK_ONTOLOGY_ANNOTATIONS_ONLY); + } + + /** + * @param objects objects to visit + */ + public OWLObjectWalker(Stream objects) { + this(objects, true, AnnotationWalkingControl.WALK_ONTOLOGY_ANNOTATIONS_ONLY); + } + + /** + * @param walkDuplicates true if duplicates should be visited + * @param objects objects to visit + */ + public OWLObjectWalker(Collection objects, boolean walkDuplicates) { + this(objects.stream(), walkDuplicates, + AnnotationWalkingControl.WALK_ONTOLOGY_ANNOTATIONS_ONLY); + } + + /** + * @param walkDuplicates true if duplicates should be visited + * @param objects objects to visit + */ + public OWLObjectWalker(Stream objects, boolean walkDuplicates) { + this(objects, walkDuplicates, AnnotationWalkingControl.WALK_ONTOLOGY_ANNOTATIONS_ONLY); + } + + /** + * @param walkDuplicates true if duplicates should be visited + * @param objects objects to visit + * @param walkFlag control which annotations to visit + */ + public OWLObjectWalker(Stream objects, boolean walkDuplicates, + AnnotationWalkingControl walkFlag) { + this.objects = asList(checkNotNull(objects, "objects cannot be null")); + this.visitDuplicates = walkDuplicates; + this.walker = new StructureWalker<>(this, walkFlag); + } + + /** + * @param visitDuplicates true if duplicates should be visited + * @param objects the set of objects to visit + * @param walkFlag control which annotations to visit + */ + public OWLObjectWalker(Collection objects, boolean visitDuplicates, + AnnotationWalkingControl walkFlag) { + this(objects.stream(), visitDuplicates, walkFlag); + } + + @Nullable + protected Object passToVisitor(OWLObject o) { + if (visitor != null) { + o.accept(visitor); + return null; + } + return o.accept(verifyNotNull(visitorEx)); + } + + protected void setVisitor(OWLObjectVisitorEx visitor) { + visitorEx = visitor; + this.visitor = null; + } + + protected void setVisitor(OWLObjectVisitor visitor) { + this.visitor = visitor; + visitorEx = null; + } + + /** + * @param walker the structure walker to use with this object walker + */ + public void setStructureWalker(StructureWalker walker) { + this.walker = walker; + } + + /** + * @param v visitor to use over the objects + */ + public void walkStructure(OWLObjectVisitorEx v) { + setVisitor(checkNotNull(v, "v cannot be null")); + objects.forEach(o -> o.accept(walker)); + } + + /** + * @param v visitor to use over the objects + */ + public void walkStructure(OWLObjectVisitor v) { + setVisitor(checkNotNull(v, "v cannot be null")); + objects.forEach(o -> o.accept(walker)); + } + + /** + * Gets the last ontology to be visited. + * + * @return The last ontology to be visited + */ + @Nullable + public OWLOntology getOntology() { + return ontology; + } + + /** + * Gets the last axiom to be visited. + * + * @return The last axiom to be visited, or {@code null} if an axiom has not be visited + */ + @Nullable + public OWLAxiom getAxiom() { + return ax; + } + + /** + * Allow the structure walker to set the current axiom. + * + * @param axiom the axiom to set + */ + public void setAxiom(@Nullable OWLAxiom axiom) { + ax = axiom; + } + + /** + * Gets the last annotation to be visited. + * + * @return The last annotation to be visited (may be {@code null}) + */ + @Nullable + public OWLAnnotation getAnnotation() { + return annotation; + } + + /** + * Allow the structure walker to set the current annotation. + * + * @param node the annotation to set + */ + public void setAnnotation(OWLAnnotation node) { + annotation = node; + } + + /** + * Gets the current class expression path. The current class expression path + * is a list of class expressions that represents the containing expressions + * for the current class expressions. The first item in the path (list) is + * the root class expression that was visited. For i between 0 and + * pathLength, the item at index i+1 is a direct sub-expression of the item + * at index i. The last item in the path is the current class expression + * being visited. + * + * @return A list of class expressions that represents the path of class expressions, with the + * root of the class expression being the first element in the list. + */ + public List getClassExpressionPath() { + return new ArrayList<>(classExpressionPath); + } + + /** + * Determines if a particular class expression is the first (or root) class + * expression in the current class expression path. + * + * @param classExpression The class expression + * @return {@code true} if the specified class expression is the first class expression in the + * current class expression path, otherwise {@code false} ({@code false} if the path is empty) + */ + public boolean isFirstClassExpressionInPath(OWLClassExpression classExpression) { + checkNotNull(classExpression, "classExpression cannot be null"); + return !classExpressionPath.isEmpty() && classExpressionPath.get(0).equals(classExpression); + } + + /** + * Pushes a class expression onto the class expression path. + * + * @param ce The class expression to be pushed onto the path + */ + protected void pushClassExpression(OWLClassExpression ce) { + checkNotNull(ce, "ce cannot be null"); + classExpressionPath.add(ce); + } + + /** + * Pops a class expression from the class expression path. If the path is + * empty then this method has no effect. + */ + protected void popClassExpression() { + if (!classExpressionPath.isEmpty()) { + classExpressionPath.remove(classExpressionPath.size() - 1); + } + } + + /** + * Gets the current data range path. The current data range path is a list + * of data ranges that represents the containing expressions for the current + * data ranges. The first item in the path (list) is the root data range + * that was visited. For i between 0 and pathLength, the item at index i+1 + * is a direct sub-expression of the item at index i. The last item in the + * path is the current data range being visited. + * + * @return A list of data ranges that represents the path of data ranges, with the root of the + * data range being the first element in the list. + */ + public List getDataRangePath() { + return new ArrayList<>(dataRangePath); + } + + /** + * Pushes a data range on to the data range path. + * + * @param dr The data range to be pushed onto the path + */ + protected void pushDataRange(OWLDataRange dr) { + checkNotNull(dr, "dr cannot be null"); + dataRangePath.add(dr); + } + + /** + * Pops a data range from the data range expression path. If the path is + * empty then this method has no effect. + */ + protected void popDataRange() { + if (!dataRangePath.isEmpty()) { + dataRangePath.remove(dataRangePath.size() - 1); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyChangeFilter.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyChangeFilter.java new file mode 100644 index 0000000000..e215d7db0d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyChangeFilter.java @@ -0,0 +1,121 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.List; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.OWLAxiomChange; +import org.semanticweb.owlapi.model.OWLAxiomVisitor; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyChangeVisitor; +import org.semanticweb.owlapi.model.RemoveAxiom; + +/** + * Provides a convenient method to filter add/remove axiom changes based on the type of axiom that + * is being added or removed from an ontology.
+ * The general pattern of use is to simply create an instance of the {@code OWLOntologyChangeFilter} + * and override the appropriate visit methods corresponding to the types of axioms that are of + * interest. Each visit corresponds to a single change and the {@code isAdd} or {@code isRemove} + * methods can be used to determine if the axiom corresponding to the change is being added or + * removed from an ontology - the ontology can be obtained via the {@code getOntology} method.
+ * Example: Suppose we are interested in changes that alter the domain of an object property. We + * receive a list of changes, {@code ontChanges}, from an ontology change listener. We can use the + * {@code OWLOntologyChangeFilter} to filter out the changes that alter the domain of an object + * property in the following way:
+ * + *
+ * OWLOntologyChangeFilter filter = new OWLOntologyChangeFilter() {
+ * 
+ * // Override the object property domain visit method + * public void visit(OWLObjectPropertyDomainAxiom axiom) { + * // Determine if the axiom is being added or removed + * if(isAdd()) { + * // Get hold of the ontology that the change applied to + * OWLOntology ont = getOntology(); + * // Do something here + * } + * } + * } + * // Process the list of changes + * filter.processChanges(ontChanges); + *
+ * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLOntologyChangeFilter implements OWLAxiomVisitor, OWLOntologyChangeVisitor { + + protected boolean add; + @Nullable + protected OWLOntology ontology; + + /** + * @param changes changes to process + */ + public void processChanges(List changes) { + checkNotNull(changes, "changes cannot be null"); + changes.forEach(c -> c.accept(this)); + } + + protected void processChange(OWLAxiomChange change) { + checkNotNull(change, "change cannot be null"); + ontology = change.getOntology(); + change.getAxiom().accept(this); + ontology = null; + } + + /** + * @return Determines if the current change caused an axiom to be added to an ontology. + */ + protected boolean isAdd() { + return add; + } + + /** + * @return Determines if the current change caused an axiom to be removed from an ontology. + */ + protected boolean isRemove() { + return !add; + } + + /** + * Gets the ontology which the current change being visited was applied to. + * + * @return The ontology or {@code null} if the filter is not in a change visit cycle. When + * called from within a {@code visit} method, the return value is guaranteed not to be + * {@code + * null}. + */ + @Nullable + protected OWLOntology getOntology() { + return ontology; + } + + @Override + public void visit(AddAxiom change) { + add = true; + processChange(change); + } + + @Override + public void visit(RemoveAxiom change) { + add = false; + processChange(change); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyIRIChanger.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyIRIChanger.java new file mode 100644 index 0000000000..253d6fc60a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyIRIChanger.java @@ -0,0 +1,73 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.util.ArrayList; +import java.util.List; + +import org.semanticweb.owlapi.model.AddImport; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLImportsDeclaration; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.RemoveImport; +import org.semanticweb.owlapi.model.SetOntologyID; + +/** + * Changes the URI of an ontology and ensures that ontologies which import the ontology have their + * imports statements updated. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLOntologyIRIChanger { + + private final OWLOntologyManager owlOntologyManager; + + /** + * @param owlOntologyManager the ontology manager to use + */ + public OWLOntologyIRIChanger(OWLOntologyManager owlOntologyManager) { + this.owlOntologyManager = + checkNotNull(owlOntologyManager, "owlOntologyManager cannot be null"); + } + + /** + * Changes the URI of the specified ontology to the new URI. + * + * @param ontology The ontology whose URI is to be changed. + * @param newIRI the new IRI + * @return A list of changes, which when applied will change the URI of the specified ontology, + * and also update the imports declarations in any ontologies which import the specified + * ontology. + */ + public List getChanges(OWLOntology ontology, IRI newIRI) { + List changes = new ArrayList<>(); + changes.add(new SetOntologyID(ontology, + new OWLOntologyID(optional(newIRI), ontology.getOntologyID().getVersionIRI()))); + OWLImportsDeclaration owlImport = + owlOntologyManager.getOWLDataFactory().getOWLImportsDeclaration(newIRI); + IRI ontIRI = ontology.getOntologyID().getOntologyIRI().orElse(null); + owlOntologyManager.ontologies().forEach(ont -> ont.importsDeclarations() + .filter(decl -> decl.getIRI().equals(ontIRI)).forEach(decl -> { + changes.add(new RemoveImport(ont, decl)); + changes.add(new AddImport(ont, owlImport)); + })); + return changes; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyImportsClosureSetProvider.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyImportsClosureSetProvider.java new file mode 100644 index 0000000000..27349f08d2 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyImportsClosureSetProvider.java @@ -0,0 +1,52 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLOntologySetProvider; + +/** + * An {@code OWLOntologySetProvider} which provides a set of ontologies which + * correspond to the imports closure of a given ontology. Note that the set of + * provided ontologies will be updated if the imports closure gets updated. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLOntologyImportsClosureSetProvider implements OWLOntologySetProvider { + + private final OWLOntologyManager manager; + private final OWLOntology rootOntology; + + /** + * Constructs an {@code OWLOntologySetProvider} which provides a set + * containing the imports closure of a given ontology. + * + * @param manager The manager which should be used to determine the imports closure. + * @param rootOntology The ontology which is the "root" of the imports closure. + */ + public OWLOntologyImportsClosureSetProvider(OWLOntologyManager manager, + OWLOntology rootOntology) { + this.manager = checkNotNull(manager, "manager cannot be null"); + this.rootOntology = checkNotNull(rootOntology, "rootOntology cannot be null"); + } + + @Override + public Stream ontologies() { + return manager.importsClosure(rootOntology); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyMerger.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyMerger.java new file mode 100644 index 0000000000..7e017abd38 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyMerger.java @@ -0,0 +1,106 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLOntologySetProvider; + +/** + * A very very simple merger, which just creates an ontology which contains the union of axioms from + * a set of ontologies. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLOntologyMerger implements OWLAxiomFilter { + + private final OWLOntologySetProvider setProvider; + private final OWLAxiomFilter axiomFilter; + private final boolean mergeOnlyLogicalAxioms; + + /** + * @param setProvider the ontology provider + */ + public OWLOntologyMerger(OWLOntologySetProvider setProvider) { + this.setProvider = checkNotNull(setProvider, "setProvider cannot be null"); + axiomFilter = this; + mergeOnlyLogicalAxioms = false; + } + + /** + * @param setProvider the ontology provider + * @param mergeOnlyLogicalAxioms true if only logical axioms should be included + */ + public OWLOntologyMerger(OWLOntologySetProvider setProvider, boolean mergeOnlyLogicalAxioms) { + this.setProvider = checkNotNull(setProvider, "setProvider cannot be null"); + this.mergeOnlyLogicalAxioms = mergeOnlyLogicalAxioms; + axiomFilter = this; + } + + /** + * @param setProvider the ontology provider + * @param axiomFilter the filter to use + */ + public OWLOntologyMerger(OWLOntologySetProvider setProvider, OWLAxiomFilter axiomFilter) { + this.setProvider = checkNotNull(setProvider, "setProvider cannot be null"); + this.axiomFilter = axiomFilter; + mergeOnlyLogicalAxioms = false; + } + + /** + * @param ontologyManager the manager containing the ontologies + * @param ontologyIRI the new ontology IRI + * @return the new ontology + * @throws OWLOntologyCreationException if any creation exception arises + */ + public OWLOntology createMergedOntology(OWLOntologyManager ontologyManager, + @Nullable IRI ontologyIRI) throws OWLOntologyCreationException { + OWLOntology ontology; + if (ontologyIRI != null) { + ontology = ontologyManager.createOntology(ontologyIRI); + } else { + ontology = ontologyManager.createOntology(); + } + setProvider.ontologies() + // avoid including the merge ontology in the list of ontologies to merge, if the + // ontology manager is the same as the set provider + .filter(o -> o != ontology) + .flatMap(this::getAxioms) + .filter(axiomFilter::passes) + .forEach(ontology::add); + return ontology; + } + + private Stream getAxioms(OWLOntology ont) { + if (mergeOnlyLogicalAxioms) { + return ont.logicalAxioms(); + } else { + return ont.axioms(); + } + } + + @Override + public boolean passes(OWLAxiom axiom) { + return true; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologySingletonSetProvider.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologySingletonSetProvider.java new file mode 100644 index 0000000000..aa8c68c73d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologySingletonSetProvider.java @@ -0,0 +1,47 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologySetProvider; + +/** + * An ontology set provider which provides a singleton set - i.e. a set + * containing just one ontology. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLOntologySingletonSetProvider implements OWLOntologySetProvider { + + private final OWLOntology o; + + /** + * Constructs an {@code OWLOntologySingletonSetProvider} which provides a + * singleton set contain the specified ontology. + * + * @param ontology The one and only ontology which should be contained in the sets provided by + * this provider. + */ + public OWLOntologySingletonSetProvider(OWLOntology ontology) { + o = checkNotNull(ontology, "ontology cannot be null"); + } + + @Override + public Stream ontologies() { + return Stream.of(o); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyWalker.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyWalker.java new file mode 100644 index 0000000000..fa8d01bf41 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyWalker.java @@ -0,0 +1,30 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.Collection; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Matthew Horridge, The University Of Manchester, Information Management Group + * @since 2.2.0 + */ +public class OWLOntologyWalker extends OWLObjectWalker { + + /** + * @param objects objects to walk + */ + public OWLOntologyWalker(Collection objects) { + super(objects); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyWalkerVisitor.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyWalkerVisitor.java new file mode 100644 index 0000000000..d8e5c72a27 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyWalkerVisitor.java @@ -0,0 +1,66 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLObjectVisitor; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLRuntimeException; + +/** + * @author Matthew Horridge, The University Of Manchester, Information Management Group + * @since 2.2.0 + */ +public class OWLOntologyWalkerVisitor implements OWLObjectVisitor { + + private final OWLOntologyWalker walker; + + /** + * @param walker ontology walker + */ + public OWLOntologyWalkerVisitor(OWLOntologyWalker walker) { + this.walker = checkNotNull(walker, "walker cannot be null"); + } + + /** + * @return current axiom from walker + */ + @Nullable + public OWLAxiom getCurrentAxiom() { + return walker.getAxiom(); + } + + /** + * @return current ontology from walker + */ + public OWLOntology getCurrentOntology() { + OWLOntology ontology = walker.getOntology(); + if (ontology == null) { + throw new OWLRuntimeException( + "No current ontology; is the walker being used outside of an ontology visit?"); + } + return ontology; + } + + /** + * @return current annotation from walker + */ + @Nullable + public OWLAnnotation getCurrentAnnotation() { + return walker.getAnnotation(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyWalkerVisitorEx.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyWalkerVisitorEx.java new file mode 100644 index 0000000000..66435f5626 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLOntologyWalkerVisitorEx.java @@ -0,0 +1,67 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLObjectVisitorEx; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLRuntimeException; + +/** + * @param visitor type + * @author Matthew Horridge, The University Of Manchester, Information Management Group + * @since 2.2.0 + */ +public class OWLOntologyWalkerVisitorEx implements OWLObjectVisitorEx { + + private final OWLOntologyWalker walker; + + /** + * @param walker walker + */ + public OWLOntologyWalkerVisitorEx(OWLOntologyWalker walker) { + this.walker = checkNotNull(walker, "walker cannot be null"); + } + + /** + * @return current axiom + */ + @Nullable + public OWLAxiom getCurrentAxiom() { + return walker.getAxiom(); + } + + /** + * @return current ontology + */ + public OWLOntology getCurrentOntology() { + OWLOntology ontology = walker.getOntology(); + if (ontology == null) { + throw new OWLRuntimeException( + "No current ontology; is the walker being used outside of an ontology visit?"); + } + return ontology; + } + + /** + * @return annotation + */ + @Nullable + public OWLAnnotation getCurrentAnnotation() { + return walker.getAnnotation(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLStorerFactoryImpl.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLStorerFactoryImpl.java new file mode 100644 index 0000000000..5b7b9babf6 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLStorerFactoryImpl.java @@ -0,0 +1,41 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import org.semanticweb.owlapi.model.OWLDocumentFormatFactory; +import org.semanticweb.owlapi.model.OWLStorer; +import org.semanticweb.owlapi.model.OWLStorerFactory; + +/** + * A factory class for OWLOntologyStorers. + * + * @author ignazio + */ +public abstract class OWLStorerFactoryImpl implements OWLStorerFactory { + + private final OWLDocumentFormatFactory format; + + protected OWLStorerFactoryImpl(OWLDocumentFormatFactory format) { + this.format = format; + } + + @Override + public final OWLDocumentFormatFactory getFormatFactory() { + return format; + } + + @Override + public final OWLStorer get() { + return createStorer(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLZipClosureIRIMapper.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLZipClosureIRIMapper.java new file mode 100644 index 0000000000..6715ff7938 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLZipClosureIRIMapper.java @@ -0,0 +1,133 @@ +package org.semanticweb.owlapi.util; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; +import java.util.regex.Pattern; +import java.util.stream.Stream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import javax.annotation.Nullable; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntologyIRIMapper; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +/** + * An IRI mapper that uses a zip file and its owlzip.properties content to map logical IRIs to + * {@code jar:} IRIs. This enables access to zipped imports closures. + */ +public class OWLZipClosureIRIMapper implements OWLOntologyIRIMapper { + private static final Pattern CATALOG_PATTERN = Pattern.compile("catalog[\\-v0-9]*\\.xml"); + private final List physicalRoots = new ArrayList<>(); + private final Map logicalToPhysicalIRI = new ConcurrentHashMap<>(); + + /** + * @param f zip file + * @throws IOException thrown if access to the file is impossible + */ + public OWLZipClosureIRIMapper(File f) throws IOException { + String basePhysicalIRI = "jar:" + f.toURI() + "!/"; + try (ZipFile z = new ZipFile(f)) { + // owlzip.properties index + if (loadFromOwlzipProperties(basePhysicalIRI, z)) { + return; + } + // catalog.xml index + if (loadFromCatalog(basePhysicalIRI, z)) { + return; + } + // no index: look up root.owl for root ontologies, others imported as usual + ZipEntry root = z.getEntry("root.owl"); + if (root != null) { + physicalRoots.add(IRI.create(basePhysicalIRI + "root.owl")); + } + ZipIRIMapper mapper = new ZipIRIMapper(z, basePhysicalIRI); + mapper.iriMappings().forEach(e -> logicalToPhysicalIRI.put(e.getKey(), e.getValue())); + // TODO OBO compressed files are not mapped according to the ontology IRI + // but according to the file name in AutoIRIMapper and ZipIRIMapper. This needs + // sorting. + } + } + + protected boolean loadFromCatalog(String basePhysicalIRI, ZipFile z) throws IOException { + ZipEntry yaml = z.stream().filter(e -> CATALOG_PATTERN.matcher(e.getName()).matches()) + .findFirst().orElse(null); + if (yaml == null) { + return false; + } + try { + Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder() + .parse(z.getInputStream(yaml)); + NodeList uris = doc.getElementsByTagName("uri"); + for (int i = 0; i < uris.getLength(); i++) { + // Catalogs do not have a way to indicate root ontologies; all ontologies will be + // considered root. + // Duplicate entries are unsupported; entries whose name starts with duplicate: will + // cause mismatches + Element e = (Element) uris.item(i); + IRI physicalIRI = IRI.create(basePhysicalIRI + e.getAttribute("uri")); + physicalRoots.add(physicalIRI); + String name = e.getAttribute("name"); + if (name.startsWith("duplicate:")) { + name = name.replace("duplicate:", ""); + } + logicalToPhysicalIRI.put(IRI.create(name), physicalIRI); + } + return true; + } catch (SAXException | ParserConfigurationException e1) { + throw new IOException(e1); + } + } + + protected boolean loadFromOwlzipProperties(String basePhysicalIRI, ZipFile z) + throws IOException { + ZipEntry yaml = z.getEntry("owlzip.properties"); + if (yaml == null) { + return false; + } + Properties p = new Properties(); + p.load(z.getInputStream(yaml)); + String[] roots = p.getProperty("roots", "").split(", "); + for (String s : roots) { + String name = s.trim(); + if (!name.isEmpty()) { + physicalRoots.add(IRI.create(basePhysicalIRI + name.trim())); + } + p.entrySet().stream().filter(e -> !e.getKey().equals("roots")) + .forEach(e -> logicalToPhysicalIRI.put(IRI.create(e.getValue().toString()), + IRI.create(basePhysicalIRI + e.getKey()))); + } + return true; + } + + @Nullable + @Override + public IRI getDocumentIRI(IRI ontologyIRI) { + return logicalToPhysicalIRI.get(ontologyIRI); + } + + /** + * @return stream of known roots; can be empty + */ + public Stream roots() { + return physicalRoots.stream(); + } + + /** + * @return all known mappings + */ + public Stream> mappedEntries() { + return logicalToPhysicalIRI.entrySet().stream(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OWLZipSaver.java b/api/src/main/java/org/semanticweb/owlapi/util/OWLZipSaver.java new file mode 100644 index 0000000000..f35f303b66 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OWLZipSaver.java @@ -0,0 +1,247 @@ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Collection; +import java.util.Collections; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Supplier; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +import org.semanticweb.owlapi.io.XMLUtils; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; + +/** + * Class for saving ontologies to zip files with an optional index. + * + * @author ignazio + */ +public class OWLZipSaver { + /** YAML entry name */ + public static final String YAML_INDEX_NAME = "owlzip.yaml"; + /** Properties entry name */ + public static final String PROPERTIES_INDEX_NAME = "owlzip.properties"; + /** Catalog entry name */ + public static final String CATALOG_INDEX_NAME = "catalog.xml"; + private Function entryPath = this::entryPath; + private BiFunction, Collection, String> index = + this::yamlIndex; + private Supplier indexName = () -> YAML_INDEX_NAME; + + /** + * @param entryPath function to use to generate the path in the zip file for an ontology. The + * default strategy is to use the last part of the ontology IRI. + */ + public void setEntryPath(Function entryPath) { + this.entryPath = entryPath; + } + + /** + * @param index function to use to generate the index content. The default strategy is to create + * a YAML file. The methods on this class can be passed here to switch to different + * strategies, or a user defined strategy can be used. + */ + public void setIndex( + BiFunction, Collection, String> index) { + this.index = index; + } + + /** + * @param indexName the name for the index entry. This defaults to owlzip.yaml; other known + * values are owlzip.poperties and catalog-v001.xml. A supplier that returns a null or + * empty string will cause the class to skip creating an index; in that case, the + * ontologies will just be compressed. + */ + public void setIndexName(Supplier indexName) { + this.indexName = indexName; + } + + /** + * Save the root ontology as root in the index and its imports closure as companion ontologies. + * + * @param root root ontology to save + * @param out output stream; to be created by the caller, closed in this method + * @throws IOException if writing to the file fails + * @throws OWLOntologyStorageException if serializing the ontologies fails + */ + public void saveImportsClosure(OWLOntology root, OutputStream out) + throws IOException, OWLOntologyStorageException { + saveOntologies(Collections.singletonList(root), + asList(root.importsClosure().filter(x -> x != root)), out); + } + + /** + * Save the root ontologies as root in the index and their imports closures as companion + * ontologies. + * + * @param roots root ontologies to save + * @param out output stream; to be created by the caller, closed in this method + * @throws IOException if writing to the file fails + * @throws OWLOntologyStorageException if serializing the ontologies fails + */ + public void saveImportsClosures(Collection roots, OutputStream out) + throws IOException, OWLOntologyStorageException { + saveOntologies(roots, asList( + roots.stream().flatMap(OWLOntology::importsClosure).filter(x -> !roots.contains(x))), + out); + } + + /** + * Save the ontologies in the index and their content as companion ontologies; no ontology will + * be marked as root. + * + * @param ontologies ontologies to save + * @param out output stream; to be created by the caller, closed in this method + * @throws IOException if writing to the file fails + * @throws OWLOntologyStorageException if serializing the ontologies fails + */ + public void saveOntologies(Collection ontologies, OutputStream out) + throws IOException, OWLOntologyStorageException { + saveOntologies(Collections.emptyList(), ontologies, out); + } + + /** + * Save the ontologies in the index, marking as root the ontologies in the roots collection; the + * other ontologies will be saved as companion ontologies. This method assumes the caller takes + * care of flattening ontology imports closures, and will not navigate imports statements. + * + * @param roots root ontologies + * @param ontologies ontologies to save + * @param out output stream; to be created by the caller, closed in this method + * @throws IOException if writing to the file fails + * @throws OWLOntologyStorageException if serializing the ontologies fails + */ + public void saveOntologies(Collection roots, Collection ontologies, + OutputStream out) throws IOException, OWLOntologyStorageException { + try (ZipOutputStream f = new ZipOutputStream(out)) { + addIndex(roots, ontologies, f); + for (OWLOntology o : roots) { + ZipEntry next = new ZipEntry(entryPath.apply(o.getOntologyID())); + f.putNextEntry(next); + ByteArrayOutputStream temp = new ByteArrayOutputStream(); + o.saveOntology(temp); + f.write(temp.toByteArray()); + } + for (OWLOntology o : ontologies) { + ZipEntry next = new ZipEntry(entryPath.apply(o.getOntologyID())); + f.putNextEntry(next); + ByteArrayOutputStream temp = new ByteArrayOutputStream(); + o.saveOntology(temp); + f.write(temp.toByteArray()); + } + f.close(); + } + } + + protected void addIndex(Collection roots, Collection ontologies, + ZipOutputStream f) throws IOException { + String name = indexName.get(); + if (name != null && !name.isEmpty()) { + ZipEntry e = new ZipEntry(name); + f.putNextEntry(e); + String entrydata = index.apply(roots, ontologies); + f.write(entrydata.getBytes()); + f.closeEntry(); + } + } + + /** + * Prepare a catalog index; this method can be used as a {@link java.util.function.BiFunction} + * for {@link #setIndex(BiFunction)}. Imports statements are not navigated; all ontologies + * required have to appear explicitly in the collections. + * + * @param roots collection of roots, if any + * @param ontologies collection of ontologies, if any + * @return content of a catalog index for the input ontologies + */ + public String catalogIndex(Collection roots, Collection ontologies) { + StringBuilder b = new StringBuilder(1000).append( + "\n\n \n"); + int id = 1; + if (roots.size() + ontologies.size() > 0) { + for (OWLOntology o : roots) { + b.append(" \n"); + id++; + } + for (OWLOntology o : ontologies) { + b.append(" \n"); + id++; + } + } + b.append(" \n\n"); + return b.toString(); + } + + /** + * Prepare a yaml index; this method can be used as a {@link java.util.function.BiFunction} for + * {@link #setIndex(BiFunction)}. Imports statements are not navigated; all ontologies required + * have to appear explicitly in the collections. + * + * @param roots collection of roots, if any + * @param ontologies collection of ontologies, if any + * @return content of a yaml index for the input ontologies + */ + public String yamlIndex(Collection roots, Collection ontologies) { + StringBuilder b = new StringBuilder(); + if (roots.size() + ontologies.size() > 0) { + b.append("ontologies:\n"); + roots.stream().map(OWLOntology::getOntologyID) + .forEach(o -> b.append("- iri: ").append(o.getOntologyIRI().get()) + .append("\n path: ").append(entryPath.apply(o)).append("\n root: true\n")); + ontologies.stream().map(OWLOntology::getOntologyID) + .forEach(o -> b.append("- iri: ").append(o.getOntologyIRI().get()) + .append("\n path: ").append(entryPath.apply(o)).append("\n")); + } + return b.toString(); + } + + /** + * Prepare a properties index; this method can be used as a + * {@link java.util.function.BiFunction} for {@link #setIndex(BiFunction)}. Imports statements + * are not navigated; all ontologies required have to appear explicitly in the collections. + * + * @param roots collection of roots, if any + * @param ontologies collection of ontologies, if any + * @return content of a properties index for the input ontologies + */ + public String propertiesIndex(Collection roots, + Collection ontologies) { + StringBuilder b = new StringBuilder(); + if (!roots.isEmpty()) { + String rootsEntry = roots.stream().map(OWLOntology::getOntologyID).map(entryPath) + .collect(Collectors.joining(", ")); + b.append("roots=").append(rootsEntry).append("\n"); + } + ontologies.stream().map(OWLOntology::getOntologyID).forEach(o -> b + .append(entryPath.apply(o)).append("=").append(o.getOntologyIRI().get()).append("\n")); + return b.toString(); + } + + /** + * Prepare a zip name for an ontology id; this method can be used as a Function for + * {@code setEntryPath}. + * + * @param id ontology id + * @return zip entry name for the ontology + */ + public String entryPath(OWLOntologyID id) { + String string = id.getOntologyIRI().get().toString(); + if (string.endsWith("/") || string.endsWith("#")) { + string = XMLUtils.getNCNameSuffix(string.subSequence(0, string.length() - 1)); + } + return verifyNotNull(string); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OntologyAxiomPair.java b/api/src/main/java/org/semanticweb/owlapi/util/OntologyAxiomPair.java new file mode 100644 index 0000000000..0d3b35edfd --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OntologyAxiomPair.java @@ -0,0 +1,88 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class OntologyAxiomPair { + + @Nullable + private final OWLOntology ontology; + private final OWLAxiom axiom; + + /** + * @param ontology ontology + * @param axiom axiom + */ + public OntologyAxiomPair(@Nullable OWLOntology ontology, OWLAxiom axiom) { + this.ontology = ontology; + this.axiom = axiom; + } + + /** + * @return the ontology + */ + @Nullable + public OWLOntology getOntology() { + return ontology; + } + + /** + * @return the axiom + */ + public OWLAxiom getAxiom() { + return axiom; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (!(obj instanceof OntologyAxiomPair)) { + return false; + } + OntologyAxiomPair other = (OntologyAxiomPair) obj; + if (ontology != null && other.ontology != null) { + return verifyNotNull(ontology).equals(other.ontology) && axiom.equals(other.axiom); + } + if (ontology != other.ontology) { + return false; + } + return axiom.equals(other.axiom); + } + + @Override + public int hashCode() { + if (ontology != null) { + return verifyNotNull(ontology).hashCode() + axiom.hashCode(); + } + return 37 + axiom.hashCode(); + } + + @Override + public String toString() { + return axiom + " in " + (ontology != null ? verifyNotNull(ontology).toString() : ""); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/OntologyIRIShortFormProvider.java b/api/src/main/java/org/semanticweb/owlapi/util/OntologyIRIShortFormProvider.java new file mode 100644 index 0000000000..de223dfd30 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/OntologyIRIShortFormProvider.java @@ -0,0 +1,174 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import java.net.URI; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.vocab.Namespaces; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class OntologyIRIShortFormProvider implements IRIShortFormProvider { + + /* + * IMPLEMENTATION NOTE. I've avoided using Pattern (regexps) here so that this code can be compiled + * with the GWT compiler. + */ + private static final String OWL_EXTENSION = ".owl"; + private static final String RDF_EXTENSION = ".rdf"; + private static final String XML_EXTENSION = ".xml"; + private static final String OBO_EXTENSION = ".obo"; + private static final String[] EXTENSIONS = {OWL_EXTENSION, RDF_EXTENSION, XML_EXTENSION, + OBO_EXTENSION}; + private static final Map WELL_KNOWN_SHORTFORMS = initWellKnownShortForms(); + + private static Map initWellKnownShortForms() { + Map map = new HashMap<>(); + for (Namespaces ns : Namespaces.values()) { + String iriPrefix = ns.getPrefixIRI(); + String iri; + if (iriPrefix.endsWith("#") || iriPrefix.endsWith("/")) { + iri = iriPrefix.substring(0, iriPrefix.length() - 1); + } else { + iri = iriPrefix; + } + map.put(IRI.create(iri, ""), ns.getPrefixName().toLowerCase()); + map.put(IRI.create(iri + '/', ""), ns.getPrefixName().toLowerCase()); + } + return Collections.unmodifiableMap(map); + } + + @Nullable + private static String getWellKnownShortForm(IRI iri) { + String wellKnownShortForm = WELL_KNOWN_SHORTFORMS.get(iri); + if (wellKnownShortForm != null) { + return wellKnownShortForm; + } + return null; + } + + /** + * Removes commonly used file name extensions to make the resulting short + * form look nicer. + * + * @param shortForm The short form. + * @return The short form with the extension removed if it was present, or the original short + * form if no extension was present. + */ + private static String stripExtensionIfPresent(String shortForm) { + String lowerCaseShortForm = shortForm.toLowerCase(); + for (String extension : EXTENSIONS) { + if (lowerCaseShortForm.endsWith(extension)) { + return shortForm.substring(0, shortForm.length() - extension.length()); + } + } + return shortForm; + } + + /** + * Determines if the specified path element is a candidate short form. + * + * @param pathElement The path element to test. Not {@code null}. + * @return {@code true} if the specified path element is a candidate short form, otherwise + * {@code false}. + */ + private static boolean isCandidatePathElement(String pathElement) { + return !pathElement.isEmpty() && !isVersionString(pathElement); + } + + /** + * Determines if the specified string is a version number string. A version + * string is a sequence of digits and periods. + * + * @param s The string to test for. + * @return {@code true} if the string is a version string, otherwise {@code false}. + */ + private static boolean isVersionString(String s) { + for (int i = 0; i < s.length(); i++) { + char ch = s.charAt(i); + if (!isVersionStringChar(ch)) { + return false; + } + } + return true; + } + + /** + * Determines if the specified character is a version string character + * (either a digit or a period). + * + * @param ch The character to test for. + * @return {@code true} of the specified char is a version string char, otherwise {@code false}. + */ + private static boolean isVersionStringChar(char ch) { + return isDigit(ch) || ch == '.' || ch == 'v'; + } + + /** + * Determines if the specified char is a digit. + * + * @param ch The char to test for. + * @return {@code true} if the specified char is a digit, otherwise {@code false}. + */ + private static boolean isDigit(char ch) { + return ch >= '0' && ch <= '9'; + } + + /** + * @param ont ontology to use + * @return short form of the ontology IRI + */ + public String getShortForm(OWLOntology ont) { + OWLOntologyID ontologyID = ont.getOntologyID(); + if (ontologyID.getOntologyIRI().isPresent()) { + return getShortForm(verifyNotNull(ontologyID.getOntologyIRI().get())); + } else { + return ontologyID.toString(); + } + } + + @Override + public String getShortForm(IRI iri) { + String wellKnownShortForm = getWellKnownShortForm(iri); + if (wellKnownShortForm != null) { + return wellKnownShortForm; + } + URI uri = iri.toURI(); + String path = uri.getPath(); + if (path != null && !path.isEmpty()) { + String candidatePathElement = ""; + for (String tok : path.split("/")) { + if (isCandidatePathElement(tok)) { + candidatePathElement = stripExtensionIfPresent(tok); + } + } + return candidatePathElement; + } + if (uri.getHost() != null) { + return iri.toString(); + } + return iri.toString(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/PriorityCollection.java b/api/src/main/java/org/semanticweb/owlapi/util/PriorityCollection.java new file mode 100644 index 0000000000..7aa48a1edd --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/PriorityCollection.java @@ -0,0 +1,194 @@ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.semanticweb.owlapi.model.MIMETypeAware; +import org.semanticweb.owlapi.model.PriorityCollectionSorting; + +/** + * A collection that is sorted by HasPriority annotation on its members. + * + * @param type of the collection + * @author ignazio + * @since 4.0.0 + */ +public class PriorityCollection implements Iterable, Serializable { + + private final List delegate = Collections.synchronizedList(new ArrayList()); + private final PriorityCollectionSorting configurationHolder; + + /** + * @param sorting the configuration holder for sort settings. + */ + public PriorityCollection(PriorityCollectionSorting sorting) { + this.configurationHolder = sorting; + } + + /** + * @return true if the collection is empty + */ + public boolean isEmpty() { + return delegate.isEmpty(); + } + + /** + * @return size of the collection + */ + public int size() { + return delegate.size(); + } + + private void sort() { + configurationHolder.sort(delegate); + } + + private void sortSet() { + configurationHolder.sortInputSet(delegate); + } + + /** + * @param c collection of elements to set. Existing elements will be removed, and the priority + * collection will be sorted according to the PriorityCollectionSorting value for the + * manager configuration. + */ + public void set(Iterable c) { + clear(); + add(c); + } + + /** + * @param c collection of elements to set. Existing elements will be removed, and the priority + * collection will be sorted according to the PriorityCollectionSorting value for the + * manager configuration. + */ + public void set(Set c) { + clear(); + for (T t : c) { + delegate.add(t); + } + sortSet(); + } + + /** + * Remove all elements, replace with the arguments and sort according to priority. + * + * @param c list of elements to set + */ + public void set(@SuppressWarnings("unchecked") T... c) { + clear(); + add(c); + } + + /** + * Add the arguments and sort according to the PriorityCollectionSorting value for the manager + * configuration. + * + * @param c list of elements to add + */ + public void add(@SuppressWarnings("unchecked") T... c) { + int i = 0; + for (T t : c) { + delegate.add(i++, t); + } + sort(); + } + + /** + * Add the argument and sort according to the PriorityCollectionSorting value for the manager + * configuration. + * + * @param t element to add + */ + public void add(T t) { + delegate.add(0, t); + sort(); + } + + /** + * Add the arguments and sort according to the PriorityCollectionSorting value for the manager + * configuration. + * + * @param c list of elements to add + */ + public void add(Iterable c) { + int i = 0; + for (T t : c) { + delegate.add(i++, t); + } + sort(); + } + + /** + * Remove the arguments. + * + * @param c list of elements to remove + */ + public void remove(@SuppressWarnings("unchecked") T... c) { + for (T t : c) { + delegate.remove(t); + } + } + + /** + * Remove the argument. + * + * @param c element to remove + */ + public void remove(T c) { + delegate.remove(c); + } + + /** + * Remove all elements from the collection. + */ + public void clear() { + delegate.clear(); + } + + @Override + public Iterator iterator() { + return Collections.unmodifiableList(delegate).iterator(); + } + + /** + * Returns the first item matching the mime type
+ * NOTE: The order in which the services are loaded an examined is not deterministic so this + * method may return different results if the MIME-Type matches more than one item. However, if + * the default MIME-Types are always unique, the correct item will always be chosen + * + * @param mimeType A MIME type to use for choosing an item + * @return An item matching the given mime type or null if none were found. + */ + public PriorityCollection getByMIMEType(String mimeType) { + checkNotNull(mimeType, "MIME-Type cannot be null"); + PriorityCollection pc = new PriorityCollection<>(configurationHolder); + // adding directly to the delegate. No need to order because insertion + // will be ordered as in this PriorityCollection + for (T t : delegate) { + // if the instance has MIME types associated + if (t instanceof MIMETypeAware) { + MIMETypeAware mimeTypeAware = (MIMETypeAware) t; + if (mimeType.equals(mimeTypeAware.getDefaultMIMEType())) { + pc.add(t); + } else { + if (mimeTypeAware.getMIMETypes().contains(mimeType)) { + pc.add(t); + } + } + } + } + return pc; + } + + @Override + public String toString() { + return delegate.toString(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/ProgressMonitor.java b/api/src/main/java/org/semanticweb/owlapi/util/ProgressMonitor.java new file mode 100644 index 0000000000..6b415156be --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/ProgressMonitor.java @@ -0,0 +1,66 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +/** + * A general interface for things whose progress can be monitored. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +@SuppressWarnings("unused") +public interface ProgressMonitor { + + /** + * start of the process. + */ + default void setStarted() { + } + + /** + * @param size size of the process + */ + default void setSize(long size) { + } + + /** + * @param progress new progress + */ + default void setProgress(long progress) { + } + + /** + * @param message the message to be displayed + */ + default void setMessage(String message) { + } + + /** + * @param b true if the state is indeterminate + */ + default void setIndeterminate(boolean b) { + } + + /** + * progress completed. + */ + default void setFinished() { + } + + /** + * @return true if the process has been cancelled + */ + default boolean isCancelled() { + return false; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/PropertyAssertionValueShortFormProvider.java b/api/src/main/java/org/semanticweb/owlapi/util/PropertyAssertionValueShortFormProvider.java new file mode 100644 index 0000000000..83696f6292 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/PropertyAssertionValueShortFormProvider.java @@ -0,0 +1,189 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.List; +import java.util.Map; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologySetProvider; +import org.semanticweb.owlapi.model.OWLPropertyExpression; + +/** + * A short form provider that generates short forms from the values of object + * property assertions or data property assertions if the entity is an + * individual. If the entity whose short form is not being generated is not an + * individual (i.e. it is a class, property etc.) then an alternate short form + * provider is used. (As a side note, the use case for this particular short + * form provider came from the SKOS community, which have individuals that have + * preferredLabel property assertions). + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class PropertyAssertionValueShortFormProvider implements ShortFormProvider { + + private final List properties; + private final Map> preferredLanguageMap; + private final OWLOntologySetProvider ontologySetProvider; + private final ShortFormProvider alternateShortFormProvider; + + /** + * Constructs a property value short form provider. Using + * {@code SimpleShortFormProvider} as the alternate short form provider (see + * other constructor for details). + * + * @param properties set of properties + * @param preferredLanguageMap language map + * @param ontologySetProvider the ontology container + */ + public PropertyAssertionValueShortFormProvider(List properties, + Map> preferredLanguageMap, + OWLOntologySetProvider ontologySetProvider) { + this(properties, preferredLanguageMap, ontologySetProvider, new SimpleShortFormProvider()); + } + + /** + * Constructs a property value short form provider. + * + * @param properties A {@code List} of preferred properties. The list is searched from start to + * end, so that property assertions whose property is at the start of the list have a higher + * priority and are selected over properties that appear towards or at the end of the list. + * @param preferredLanguageMap A map which maps data properties to preferred languages. For any + * given data property there may be a list of preferred languages for the values of that + * property Languages at the start of the list have a higher priority over languages at the end + * of the list. This parameter may be empty but it must not be {@code null}. + * @param ontologySetProvider An {@code OWLOntologySetProvider} which provides a set of ontology + * from which candidate annotation axioms should be taken. For a given entity, all ontologies + * are examined. + * @param alternateShortFormProvider A short form provider which will be used to generate the + * short form for an entity that does not have any property values (e.g. class, property). This + * provider will also be used in the case where the value of an annotation is an {@code + * OWLIndividual} for providing the short form of the individual. + */ + public PropertyAssertionValueShortFormProvider(List properties, + Map> preferredLanguageMap, + OWLOntologySetProvider ontologySetProvider, + ShortFormProvider alternateShortFormProvider) { + this.properties = checkNotNull(properties, "properties cannot be null"); + this.preferredLanguageMap = checkNotNull(preferredLanguageMap, + "preferredLanguageMap cannot be null"); + this.ontologySetProvider = checkNotNull(ontologySetProvider, + "ontologySetProvider cannot be null"); + this.alternateShortFormProvider = checkNotNull(alternateShortFormProvider, + "alternateShortFormProvider cannot be null"); + } + + @Override + public String getShortForm(OWLEntity entity) { + checkNotNull(entity, "entity cannot be null"); + if (!(entity instanceof OWLIndividual)) { + return alternateShortFormProvider.getShortForm(entity); + } + OWLIndividual individual = (OWLIndividual) entity; + // The candidate value to be rendered, we select this based on + // ranking of annotation URI and ranking of lang (if present) + OWLObject candidateValue = null; + int lastURIMatchIndex = Integer.MAX_VALUE; + int lastLangMatchIndex = Integer.MAX_VALUE; + for (OWLOntology ontology : asList(ontologySetProvider.ontologies())) { + for (OWLObjectPropertyAssertionAxiom ax : asList( + ontology.objectPropertyAssertionAxioms(individual))) { + int index = properties.indexOf(ax.getProperty()); + if (index == -1) { + continue; + } + if (index < lastURIMatchIndex) { + candidateValue = ax.getObject(); + } + } + for (OWLDataPropertyAssertionAxiom ax : asList( + ontology.dataPropertyAssertionAxioms(individual))) { + int index = properties.indexOf(ax.getProperty()); + if (index == -1) { + continue; + } + if (index == lastURIMatchIndex) { + // Different property value but same prop, as previous + // candidate - look at lang tag for that URI + // and see if we take priority over the previous one + OWLObject obj = ax.getObject(); + if (obj instanceof OWLLiteral) { + List langList = preferredLanguageMap.get(ax.getProperty()); + if (langList != null) { + // There is no need to check if lang is null. It may + // well be that no + // lang is preferred over any other lang. + OWLLiteral lit = (OWLLiteral) obj; + int langIndex = langList.indexOf(lit.getLang()); + if (langIndex != -1 && langIndex < lastLangMatchIndex) { + lastLangMatchIndex = langIndex; + candidateValue = ax.getObject(); + } + } + } + } else if (index < lastURIMatchIndex) { + // Better match than previous URI - wipe out previous match! + lastURIMatchIndex = index; + candidateValue = ax.getObject(); + } + } + } + if (candidateValue != null) { + return getRendering(candidateValue); + } + return alternateShortFormProvider.getShortForm(entity); + } + + /** + * Obtains the rendering of the specified object. If the object is a + * constant then the rendering is equal to the literal value, if the object + * is an individual then the rendering is equal to the rendering of the + * individual as provided by the alternate short form provider + * + * @param object The object to the rendered + * @return The rendering of the object. + */ + private String getRendering(OWLObject object) { + // We return the literal value of constants or use the alternate + // short form provider to render individuals. + if (object instanceof OWLLiteral) { + return ((OWLLiteral) object).getLiteral(); + } else { + return alternateShortFormProvider.getShortForm((OWLEntity) object); + } + } + + /** + * @return the properties + */ + public List getProperties() { + return properties; + } + + /** + * @return the language map + */ + public Map> getPreferredLanguageMap() { + return preferredLanguageMap; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/QNameShortFormProvider.java b/api/src/main/java/org/semanticweb/owlapi/util/QNameShortFormProvider.java new file mode 100644 index 0000000000..98e4221b09 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/QNameShortFormProvider.java @@ -0,0 +1,66 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.HashMap; +import java.util.Map; +import org.semanticweb.owlapi.model.OWLEntity; + +/** + * A short form provider which creates QNames for entities. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class QNameShortFormProvider implements ShortFormProvider { + + private final NamespaceUtil namespaceUtil = new NamespaceUtil(); + + /** + * Creates a QNameShortFormProvider where namespace prefix mappings will + * automatically be generated. + */ + public QNameShortFormProvider() { + this(new HashMap()); + } + + /** + * Creates a QNameShortFormProvider where the specified map overrides any + * auto-generated prefix namespace mappings. + * + * @param prefix2Ns The map which contains a prefix to namespace mapping. The prefix must not + * have a trailing ":"; if one is there, it will be removed + */ + public QNameShortFormProvider(Map prefix2Ns) { + checkNotNull(prefix2Ns, "prefix2NamespaceMap cannot be null"); + prefix2Ns.forEach((key, v) -> namespaceUtil.setPrefix(v, removeColon(key))); + } + + protected String removeColon(String key) { + int lastChar = key.length() - 1; + if (key.charAt(lastChar) == ':') { + return key.substring(0, lastChar); + } + return key; + } + + @Override + public String getShortForm(OWLEntity entity) { + checkNotNull(entity, "entity cannot be null"); + String namespace = entity.getIRI().getNamespace(); + String prefix = namespaceUtil.getPrefix(namespace); + return entity.getIRI().prefixedBy(prefix + ':'); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/RemappingIndividualProvider.java b/api/src/main/java/org/semanticweb/owlapi/util/RemappingIndividualProvider.java new file mode 100644 index 0000000000..93b0cd70e4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/RemappingIndividualProvider.java @@ -0,0 +1,56 @@ +package org.semanticweb.owlapi.util; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OntologyConfigurator; +import org.semanticweb.owlapi.model.providers.AnonymousIndividualByIdProvider; + +/** + * A provider for anonymous individuals that remaps input ids consistently across all requests. This + * class obeys the preferences set in {@link OWLOntologyManager#getOntologyWriterConfiguration()}. + */ +public class RemappingIndividualProvider implements AnonymousIndividualByIdProvider { + + private OWLDataFactory df; + private boolean shouldRemapAllAnonymousIndividualsIds; + private Map map; + + /** + * @param m ontology configurator + * @param df data factory + */ + public RemappingIndividualProvider(OntologyConfigurator m, OWLDataFactory df) { + this(m.buildWriterConfiguration().shouldRemapAllAnonymousIndividualsIds(), df); + } + + /** + * @param remap enable remap + * @param df data factory + */ + public RemappingIndividualProvider(boolean remap, OWLDataFactory df) { + this.df = df; + shouldRemapAllAnonymousIndividualsIds = remap; + if (shouldRemapAllAnonymousIndividualsIds) { + map = new HashMap<>(); + } else { + map = Collections.emptyMap(); + } + } + + @Override + public OWLAnonymousIndividual getOWLAnonymousIndividual(String nodeId) { + if (!shouldRemapAllAnonymousIndividualsIds) { + return df.getOWLAnonymousIndividual(nodeId); + } + OWLAnonymousIndividual toReturn = map.get(nodeId); + if (toReturn == null) { + toReturn = df.getOWLAnonymousIndividual(); + map.put(nodeId, toReturn); + } + return toReturn; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/RootClassChecker.java b/api/src/main/java/org/semanticweb/owlapi/util/RootClassChecker.java new file mode 100644 index 0000000000..40b85d0921 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/RootClassChecker.java @@ -0,0 +1,33 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import org.semanticweb.owlapi.model.OWLClass; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +@FunctionalInterface +public interface RootClassChecker { + + /** + * Determines if the specified class is a direct syntactic subclass of + * owl:Thing. + * + * @param cls The class to be checked. + * @return {@code true} if the class is a direct syntactic root class of owl:Thing, otherwise + * {@code false}. + */ + boolean isRootClass(OWLClass cls); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/SAXParsers.java b/api/src/main/java/org/semanticweb/owlapi/util/SAXParsers.java new file mode 100644 index 0000000000..d6267388dd --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/SAXParsers.java @@ -0,0 +1,130 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import javax.annotation.Nullable; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.xml.sax.SAXException; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.SAXNotSupportedException; +import org.xml.sax.ext.DeclHandler; + +/** + * @author ignazio + * @since 4.0.0 + */ +public final class SAXParsers { + + private static final String VALIDATION = "http://xml.org/sax/features/validation"; + private static final String LOAD_EXTERNAL_DTD = + "http://apache.org/xml/features/nonvalidating/load-external-dtd"; + private static final String ERROR_TEMPLATE = + " not supported by parser type {}, error message: {}"; + private static final String DECLARATION_HANDLER = + "http://xml.org/sax/properties/declaration-handler"; + private static final String EXPANSION_LIMIT = "entityExpansionLimit"; + private static final String ORACLE_EXPANSION_LIMIT = + "http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit"; + private static final String GENERAL_ENTITIES = + "http://xml.org/sax/features/external-general-entities"; + private static final String PARAMETER_ENTITIES = + "http://xml.org/sax/features/external-parameter-entities"; + private static final Logger LOGGER = LoggerFactory.getLogger(SAXParsers.class); + + private SAXParsers() {} + + /** + * @return a new factory, set up to be namespace aware, non validating and not loading external + * dtds. + */ + public static SAXParserFactory initFactory() { + SAXParserFactory factory = SAXParserFactory.newInstance(); + factory.setValidating(false); + disableFeature(LOAD_EXTERNAL_DTD, factory); + disableFeature(VALIDATION, factory); + disableFeature(GENERAL_ENTITIES, factory); + disableFeature(PARAMETER_ENTITIES, factory); + factory.setNamespaceAware(true); + return factory; + } + + private static void disableFeature(String feature, SAXParserFactory factory) { + try { + factory.setFeature(feature, false); + } catch (ParserConfigurationException | SAXException e) { + LOGGER.warn(factory.getClass().getName() + " does not support " + feature, e); + } + } + + /** + * @param handler declaration handler, optional. Used for entity detection for reuse in parser + * output. + * @param expansion entity expansion limit. See + * {@link org.semanticweb.owlapi.model.parameters.ConfigurationOptions} for instructions + * on how to set the value. + * @return new SaxParser, initialized with optional declaration handler and larger entity + * expansion limit + */ + public static SAXParser initParserWithOWLAPIStandards(@Nullable DeclHandler handler, + String expansion) { + try { + SAXParser parser = initFactory().newSAXParser(); + if (!addOracleExpansionLimit(parser, expansion)) { + addExpansionLimit(parser, expansion); + } + addHandler(handler, parser); + return parser; + } catch (ParserConfigurationException | SAXException e) { + throw new OWLRuntimeException(e); + } + } + + protected static void addExpansionLimit(SAXParser parser, String expansion) { + try { + parser.setProperty(EXPANSION_LIMIT, expansion); + } catch (SAXNotRecognizedException | SAXNotSupportedException ex) { + LOGGER.warn(EXPANSION_LIMIT + ERROR_TEMPLATE, parser.getClass().getName(), + ex.getMessage()); + } + } + + protected static boolean addOracleExpansionLimit(SAXParser parser, String expansion) { + try { + parser.setProperty(ORACLE_EXPANSION_LIMIT, expansion); + return true; + } catch (SAXNotRecognizedException | SAXNotSupportedException e) { + LOGGER.warn(ORACLE_EXPANSION_LIMIT + ERROR_TEMPLATE, parser.getClass().getName(), + e.getMessage()); + return false; + } + } + + protected static void addHandler(@Nullable DeclHandler handler, SAXParser parser) { + if (handler != null) { + try { + parser.setProperty(DECLARATION_HANDLER, handler); + } catch (SAXNotRecognizedException | SAXNotSupportedException e) { + LOGGER.warn( + DECLARATION_HANDLER + ERROR_TEMPLATE + + " Entity declarations will not be roundtripped.", + parser.getClass().getName(), e.getMessage()); + } + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/SLF4JSilencer.java b/api/src/main/java/org/semanticweb/owlapi/util/SLF4JSilencer.java new file mode 100644 index 0000000000..86acabbb01 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/SLF4JSilencer.java @@ -0,0 +1,39 @@ +package org.semanticweb.owlapi.util; + +import java.io.PrintStream; +import javax.annotation.Nullable; + +/** + * A small wrapper class that allows SLF4J error messages about not having a + * binding (or more than one) silenced. Just add {@code SLF4J.silence();} before + * any logger is initialised - ideally as first instruction in your main. If the + * default behaviour becomes useful, {@code SLF4J.deSilence();} will restore + * things. + */ +public class SLF4JSilencer { + + private static final PrintStream originalErr = System.err; + private static final PrintStream filterOut = new PrintStream(System.err) { + + @Override + public void println(@Nullable String l) { + if (l == null || !l.startsWith("SLF4J")) { + super.println(l); + } + } + }; + + /** + * Silence SLF4J warnings. + */ + public static void silence() { + System.setErr(filterOut); + } + + /** + * Restore regular behaviour. + */ + public static void deSilence() { + System.setErr(originalErr); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/SWRLVariableExtractor.java b/api/src/main/java/org/semanticweb/owlapi/util/SWRLVariableExtractor.java new file mode 100644 index 0000000000..369e9db044 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/SWRLVariableExtractor.java @@ -0,0 +1,115 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.Collection; +import java.util.LinkedHashSet; +import org.semanticweb.owlapi.model.SWRLBuiltInAtom; +import org.semanticweb.owlapi.model.SWRLClassAtom; +import org.semanticweb.owlapi.model.SWRLDataPropertyAtom; +import org.semanticweb.owlapi.model.SWRLDataRangeAtom; +import org.semanticweb.owlapi.model.SWRLDifferentIndividualsAtom; +import org.semanticweb.owlapi.model.SWRLIndividualArgument; +import org.semanticweb.owlapi.model.SWRLLiteralArgument; +import org.semanticweb.owlapi.model.SWRLObjectPropertyAtom; +import org.semanticweb.owlapi.model.SWRLObjectVisitorEx; +import org.semanticweb.owlapi.model.SWRLRule; +import org.semanticweb.owlapi.model.SWRLSameIndividualAtom; +import org.semanticweb.owlapi.model.SWRLVariable; + +/** + * Extracts the variables from rules. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.0 + */ +public class SWRLVariableExtractor implements SWRLObjectVisitorEx> { + + private final LinkedHashSet variables = new LinkedHashSet<>(); + + /** + * @return the set of variables + */ + public LinkedHashSet getVariables() { + return variables; + } + + @Override + public Collection visit(SWRLRule node) { + node.body().forEach(a -> a.accept(this)); + node.head().forEach(a -> a.accept(this)); + return variables; + } + + @Override + public Collection visit(SWRLClassAtom node) { + node.getArgument().accept(this); + return variables; + } + + @Override + public Collection visit(SWRLDataRangeAtom node) { + node.getArgument().accept(this); + return variables; + } + + @Override + public Collection visit(SWRLObjectPropertyAtom node) { + node.getFirstArgument().accept(this); + node.getSecondArgument().accept(this); + return variables; + } + + @Override + public Collection visit(SWRLDataPropertyAtom node) { + node.getFirstArgument().accept(this); + node.getSecondArgument().accept(this); + return variables; + } + + @Override + public Collection visit(SWRLBuiltInAtom node) { + node.getArguments().forEach(a -> a.accept(this)); + return variables; + } + + @Override + public Collection visit(SWRLVariable node) { + variables.add(node); + return variables; + } + + @Override + public Collection visit(SWRLIndividualArgument node) { + return variables; + } + + @Override + public Collection visit(SWRLLiteralArgument node) { + return variables; + } + + @Override + public Collection visit(SWRLSameIndividualAtom node) { + node.getFirstArgument().accept(this); + node.getSecondArgument().accept(this); + return variables; + } + + @Override + public Collection visit(SWRLDifferentIndividualsAtom node) { + node.getFirstArgument().accept(this); + node.getSecondArgument().accept(this); + return variables; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/SWRLVariableShortFormProvider.java b/api/src/main/java/org/semanticweb/owlapi/util/SWRLVariableShortFormProvider.java new file mode 100644 index 0000000000..19779cc8a1 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/SWRLVariableShortFormProvider.java @@ -0,0 +1,29 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import org.semanticweb.owlapi.model.SWRLVariable; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +@FunctionalInterface +public interface SWRLVariableShortFormProvider { + + /** + * @param variable variable to shorten + * @return short form + */ + String getShortForm(SWRLVariable variable); +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/ShortFormFromRDFSLabelAxiomListProvider.java b/api/src/main/java/org/semanticweb/owlapi/util/ShortFormFromRDFSLabelAxiomListProvider.java new file mode 100644 index 0000000000..452f7fe7f7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/ShortFormFromRDFSLabelAxiomListProvider.java @@ -0,0 +1,184 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.Collections; +import java.util.List; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectVisitor; +import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; + +/** + * A short form provider that generates short forms based on {@code rdfs:label} annotation values + * taken from a list of axioms. A list of preferred annotation URIs and preferred annotation + * languages is used to determine which annotation value to select if there are multiple annotations + * for the entity whose short form is being generated. If there are multiple annotations the these + * annotations are ranked by preferred IRI and then by preferred language. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 5.1.12 + */ +public class ShortFormFromRDFSLabelAxiomListProvider implements ShortFormProvider { + + private final ShortFormProvider alternateShortFormProvider; + private final IRIShortFormProvider alternateIRIShortFormProvider; + private final List preferredLanguages; + private final StringAnnotationVisitor literalRenderer = new StringAnnotationVisitor(); + private final List axioms; + + /** + * Constructs an annotation value short form provider. Using {@code SimpleShortFormProvider} as + * the alternate short form provider + * + * @param preferredLanguages Languages at the start of the list have a higher priority over + * languages at the end of the list. This parameter may be empty but it must not be + * {@code null}. + * @param axioms axioms to use. + */ + public ShortFormFromRDFSLabelAxiomListProvider(List preferredLanguages, + List axioms) { + this(preferredLanguages, axioms, new SimpleShortFormProvider()); + } + + /** + * Constructs an annotation short form provider. + * + * @param preferredLanguages Languages at the start of the list have a higher priority over + * languages at the end of the list. This parameter may be empty but it must not be + * {@code null}. + * @param axioms axioms to use. + * @param alternateShortFormProvider A short form provider which will be used to generate the + * short form for an entity that does not have any annotations. This provider will also + * be used in the case where the value of an annotation is an {@code OWLIndividual} for + * providing the short form of the individual. + */ + public ShortFormFromRDFSLabelAxiomListProvider(List preferredLanguages, + List axioms, ShortFormProvider alternateShortFormProvider) { + this(axioms, alternateShortFormProvider, new SimpleIRIShortFormProvider(), + preferredLanguages); + } + + /** + * @param axioms axioms to use. + * @param alternateShortFormProvider short form provider + * @param alternateIRIShortFormProvider iri short form provider + * @param preferredLanguages preferred languages + */ + public ShortFormFromRDFSLabelAxiomListProvider(List axioms, + ShortFormProvider alternateShortFormProvider, + IRIShortFormProvider alternateIRIShortFormProvider, List preferredLanguages) { + this.axioms = asList(checkNotNull(axioms, "axioms cannot be null").stream() + .filter(x -> x.getAxiomType().equals(AxiomType.ANNOTATION_ASSERTION)) + .map(x -> (OWLAnnotationAssertionAxiom) x).sorted()); + this.alternateShortFormProvider = + checkNotNull(alternateShortFormProvider, "alternateShortFormProvider cannot be null"); + this.alternateIRIShortFormProvider = checkNotNull(alternateIRIShortFormProvider, + "alternateIRIShortFormProvider cannot be null"); + this.preferredLanguages = + checkNotNull(preferredLanguages, "preferredLanguages cannot be null"); + } + + @Override + public String getShortForm(OWLEntity entity) { + List flatMap = + asList(axioms.stream().filter(x -> x.getSubject().equals(entity.getIRI()))); + AnnotationLanguageFilter checker = new AnnotationLanguageFilter(preferredLanguages); + flatMap.forEach(ax -> ax.accept(checker)); + OWLObject match = checker.getMatch(); + if (match != null) { + return getRendering(match); + } + return alternateShortFormProvider.getShortForm(entity); + } + + /** + * Obtains the rendering of the specified object. If the object is a constant then the rendering + * is equal to the literal value, if the object is an individual then the rendering is equal to + * the rendering of the individual as provided by the alternate short form provider + * + * @param object The object to the rendered + * @return The rendering of the object. + */ + private String getRendering(OWLObject object) { + // We return the literal value of constants or use the alternate + // short form provider to render individuals. + if (object instanceof OWLLiteral) { + // TODO refactor this method to use the annotation value visitor + return literalRenderer.visit((OWLLiteral) object); + } else if (object.isIRI()) { + return alternateIRIShortFormProvider.getShortForm((IRI) object); + } else { + return alternateShortFormProvider.getShortForm((OWLEntity) object); + } + } + + private static class AnnotationLanguageFilter implements OWLObjectVisitor { + + private final IRI prop = OWLRDFVocabulary.RDFS_LABEL.getIRI(); + private final List preferredLanguages; + @Nullable + protected OWLObject candidateValue = null; + int lastLangMatchIndex = Integer.MAX_VALUE; + + AnnotationLanguageFilter(@Nullable List preferredLanguages) { + this.preferredLanguages = + preferredLanguages == null ? Collections.emptyList() : preferredLanguages; + } + + @Nullable + public OWLObject getMatch() { + return candidateValue; + } + + @Override + public void visit(OWLAnnotationAssertionAxiom axiom) { + if (lastLangMatchIndex > 0 && axiom.getProperty().getIRI().equals(prop)) { + // a perfect match - no need to carry on search + axiom.getValue().accept(this); + } + } + + @Override + public void visit(OWLLiteral node) { + if (preferredLanguages.isEmpty()) { + // if there are no languages just match the first thing + lastLangMatchIndex = 0; + candidateValue = node; + } else { + int index = preferredLanguages.indexOf(node.getLang()); + if (index >= 0 && index < lastLangMatchIndex) { + lastLangMatchIndex = index; + candidateValue = node; + } + } + } + + @Override + public void visit(IRI iri) { + // No language + candidateValue = iri; + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/ShortFormProvider.java b/api/src/main/java/org/semanticweb/owlapi/util/ShortFormProvider.java new file mode 100644 index 0000000000..ba94ff0624 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/ShortFormProvider.java @@ -0,0 +1,44 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import org.semanticweb.owlapi.model.OWLEntity; + +/** + * A short form provider produces renderings of entities. These renderings are strings which in + * general can be used for display and serialisation purposes. A given entity only has one short + * form for a given short form provider. However, a short form may map to multiple entities for a + * given short form provider. In other words, for a given short form provider the mapping from + * entity to short form is functional, but is not inverse functional i.e. an injective mapping. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public interface ShortFormProvider { + + /** + * Gets the short form for the specified entity. + * + * @param entity The entity. + * @return A string which represents a short rendering of the specified entity. The returned + * value will not be null but might be an empty string. + */ + String getShortForm(OWLEntity entity); + + /** + * Disposes of the short form provider. This frees any resources and clears any caches. + */ + default void dispose() { + // nothing to dispose + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/SimpleIRIMapper.java b/api/src/main/java/org/semanticweb/owlapi/util/SimpleIRIMapper.java new file mode 100644 index 0000000000..13415b69ca --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/SimpleIRIMapper.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import javax.annotation.Nullable; +import org.semanticweb.owlapi.annotations.HasPriority; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntologyIRIMapper; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +@HasPriority(0) +public class SimpleIRIMapper implements OWLOntologyIRIMapper { + + private final IRI iri; + private final IRI documentIRI; + + /** + * @param ontologyIRI ontology IRI + * @param documentIRI document IRI + */ + public SimpleIRIMapper(IRI ontologyIRI, IRI documentIRI) { + iri = checkNotNull(ontologyIRI, "ontologyIRI cannot be null"); + this.documentIRI = checkNotNull(documentIRI, "documentIRI cannot be null"); + } + + @Override + @Nullable + public IRI getDocumentIRI(IRI ontologyIRI) { + if (iri.equals(ontologyIRI)) { + return documentIRI; + } else { + return null; + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/SimpleIRIShortFormProvider.java b/api/src/main/java/org/semanticweb/owlapi/util/SimpleIRIShortFormProvider.java new file mode 100644 index 0000000000..5a912145f2 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/SimpleIRIShortFormProvider.java @@ -0,0 +1,34 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.io.Serializable; +import org.semanticweb.owlapi.model.IRI; + +/** + * A IRI short form provider that generates short forms from the IRI fragment if + * there is one, or the IRI last path component if there is one. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class SimpleIRIShortFormProvider implements IRIShortFormProvider, Serializable { + + @Override + public String getShortForm(IRI iri) { + checkNotNull(iri); + return iri.getShortForm(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/SimpleRenderer.java b/api/src/main/java/org/semanticweb/owlapi/util/SimpleRenderer.java new file mode 100644 index 0000000000..1c3985f0a7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/SimpleRenderer.java @@ -0,0 +1,1000 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.Iterator; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.formats.PrefixDocumentFormat; +import org.semanticweb.owlapi.io.OWLObjectRenderer; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataComplementOf; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataIntersectionOf; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDataUnionOf; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLHasKeyAxiom; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectInverseOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLObjectVisitor; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; +import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.SWRLBuiltInAtom; +import org.semanticweb.owlapi.model.SWRLClassAtom; +import org.semanticweb.owlapi.model.SWRLDataPropertyAtom; +import org.semanticweb.owlapi.model.SWRLDataRangeAtom; +import org.semanticweb.owlapi.model.SWRLDifferentIndividualsAtom; +import org.semanticweb.owlapi.model.SWRLIndividualArgument; +import org.semanticweb.owlapi.model.SWRLLiteralArgument; +import org.semanticweb.owlapi.model.SWRLObjectPropertyAtom; +import org.semanticweb.owlapi.model.SWRLRule; +import org.semanticweb.owlapi.model.SWRLSameIndividualAtom; +import org.semanticweb.owlapi.model.SWRLVariable; +import org.semanticweb.owlapi.model.parameters.Imports; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * A simple renderer that can be used for debugging purposes and provide an implementation of the + * toString method for different implementations. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class SimpleRenderer implements OWLObjectVisitor, OWLObjectRenderer { + + private StringBuilder sb; + private ShortFormProvider shortFormProvider; + private IRIShortFormProvider iriShortFormProvider; + + /** + * Default constructor. + */ + public SimpleRenderer() { + sb = new StringBuilder(); + resetShortFormProvider(); + } + + /** + * reset the renderer. + */ + public void reset() { + sb = new StringBuilder(); + } + + /** + * @return true if default is used + */ + public boolean isUsingDefaultShortFormProvider() { + return shortFormProvider instanceof DefaultPrefixManager; + } + + /** + * Resets the short form provider to the default short form provider, which is a PrefixManager + * with the default set of prefixes. + */ + public final void resetShortFormProvider() { + DefaultPrefixManager defaultPrefixManager = new DefaultPrefixManager(); + shortFormProvider = defaultPrefixManager; + iriShortFormProvider = defaultPrefixManager; + } + + /** + * Resets the short form provider and adds prefix name to prefix mappings based on the specified + * ontology's format (if it is a prefix format) and possibly the ontologies in the imports + * closure. + * + * @param ontology The ontology whose format will be used to obtain prefix mappings + * @param processImportedOntologies Specifies whether or not the prefix mapping should be + * obtained from imported ontologies. + */ + public void setPrefixesFromOntologyFormat(OWLOntology ontology, + boolean processImportedOntologies) { + resetShortFormProvider(); + Imports.fromBoolean(processImportedOntologies).stream(ontology) + .forEach(o -> copyPrefixes(o.getNonnullFormat())); + } + + private void copyPrefixes(OWLDocumentFormat ontologyFormat) { + if (!(ontologyFormat instanceof PrefixDocumentFormat)) { + return; + } + PrefixDocumentFormat prefixFormat = (PrefixDocumentFormat) ontologyFormat; + if (!isUsingDefaultShortFormProvider()) { + resetShortFormProvider(); + } + ((DefaultPrefixManager) shortFormProvider) + .copyPrefixesFrom(prefixFormat.getPrefixName2PrefixMap()); + } + + /** + * Sets a prefix name for a given prefix. Note that prefix names MUST end with a colon. + * + * @param prefixName The prefix name (ending with a colon) + * @param prefix The prefix that the prefix name maps to + */ + public void setPrefix(String prefixName, String prefix) { + if (!isUsingDefaultShortFormProvider()) { + resetShortFormProvider(); + } + ((DefaultPrefixManager) shortFormProvider).setPrefix(prefixName, prefix); + } + + @Override + public void setShortFormProvider(ShortFormProvider shortFormProvider) { + this.shortFormProvider = shortFormProvider; + } + + /** + * @param iri the iri to shorten + * @return the short form + */ + public String getShortForm(IRI iri) { + return iriShortFormProvider.getShortForm(iri); + } + + @Override + public String render(OWLObject object) { + reset(); + object.accept(this); + return sb.toString(); + } + + protected void render(Stream objects) { + Iterator it = objects.iterator(); + while (it.hasNext()) { + it.next().accept(this); + if (it.hasNext()) { + insertSpace(); + } + } + } + + @Override + public void visit(OWLOntology ontology) { + sb.append("Ontology(").append(ontology.getOntologyID()).append(" [Axioms: ") + .append(ontology.getAxiomCount()).append("] [Logical axioms: ") + .append(ontology.getLogicalAxiomCount()).append("])"); + } + + private void insertSpace() { + sb.append(' '); + } + + /** + * @param axiom the axiom whose annotations should be written + */ + public void writeAnnotations(OWLAxiom axiom) { + axiom.annotations().forEach(a -> { + a.accept(this); + insertSpace(); + }); + } + + @Override + public void visit(OWLSubClassOfAxiom axiom) { + sb.append("SubClassOf("); + writeAnnotations(axiom); + axiom.getSubClass().accept(this); + insertSpace(); + axiom.getSuperClass().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLNegativeObjectPropertyAssertionAxiom axiom) { + sb.append("NegativeObjectPropertyAssertion("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getSubject().accept(this); + insertSpace(); + axiom.getObject().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLAsymmetricObjectPropertyAxiom axiom) { + sb.append("AsymmetricObjectProperty("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLReflexiveObjectPropertyAxiom axiom) { + sb.append("ReflexiveObjectProperty("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLDisjointClassesAxiom axiom) { + sb.append("DisjointClasses("); + writeAnnotations(axiom); + render(axiom.classExpressions()); + sb.append(')'); + } + + @Override + public void visit(OWLDataPropertyDomainAxiom axiom) { + sb.append("DataPropertyDomain("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getDomain().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLObjectPropertyDomainAxiom axiom) { + sb.append("ObjectPropertyDomain("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getDomain().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLEquivalentObjectPropertiesAxiom axiom) { + sb.append("EquivalentObjectProperties("); + writeAnnotations(axiom); + render(axiom.properties()); + sb.append(')'); + } + + @Override + public void visit(OWLNegativeDataPropertyAssertionAxiom axiom) { + sb.append("NegativeDataPropertyAssertion("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getSubject().accept(this); + insertSpace(); + axiom.getObject().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLDifferentIndividualsAxiom axiom) { + sb.append("DifferentIndividuals("); + writeAnnotations(axiom); + render(axiom.individuals()); + sb.append(')'); + } + + @Override + public void visit(OWLDisjointDataPropertiesAxiom axiom) { + sb.append("DisjointDataProperties("); + writeAnnotations(axiom); + render(axiom.properties()); + sb.append(')'); + } + + @Override + public void visit(OWLDisjointObjectPropertiesAxiom axiom) { + sb.append("DisjointObjectProperties("); + writeAnnotations(axiom); + render(axiom.properties()); + sb.append(')'); + } + + @Override + public void visit(OWLObjectPropertyRangeAxiom axiom) { + sb.append("ObjectPropertyRange("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getRange().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLObjectPropertyAssertionAxiom axiom) { + sb.append("ObjectPropertyAssertion("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getSubject().accept(this); + insertSpace(); + axiom.getObject().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLFunctionalObjectPropertyAxiom axiom) { + sb.append("FunctionalObjectProperty("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLSubObjectPropertyOfAxiom axiom) { + sb.append("SubObjectPropertyOf("); + writeAnnotations(axiom); + axiom.getSubProperty().accept(this); + insertSpace(); + axiom.getSuperProperty().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLDisjointUnionAxiom axiom) { + sb.append("DisjointUnion("); + writeAnnotations(axiom); + axiom.getOWLClass().accept(this); + insertSpace(); + render(axiom.classExpressions()); + sb.append(')'); + } + + @Override + public void visit(OWLDeclarationAxiom axiom) { + sb.append("Declaration("); + writeAnnotations(axiom); + OWLEntity entity = axiom.getEntity(); + if (entity.isOWLClass()) { + sb.append("Class("); + } else if (entity.isOWLObjectProperty()) { + sb.append("ObjectProperty("); + } else if (entity.isOWLDataProperty()) { + sb.append("DataProperty("); + } else if (entity.isOWLNamedIndividual()) { + sb.append("NamedIndividual("); + } else if (entity.isOWLDatatype()) { + sb.append("Datatype("); + } else if (entity.isOWLAnnotationProperty()) { + sb.append("AnnotationProperty("); + } + axiom.getEntity().accept(this); + sb.append("))"); + } + + @Override + public void visit(OWLAnnotationAssertionAxiom axiom) { + sb.append("AnnotationAssertion("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getSubject().accept(this); + insertSpace(); + axiom.getValue().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLSymmetricObjectPropertyAxiom axiom) { + sb.append("SymmetricObjectProperty("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLDataPropertyRangeAxiom axiom) { + sb.append("DataPropertyRange("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getRange().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLFunctionalDataPropertyAxiom axiom) { + sb.append("FunctionalDataProperty("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLEquivalentDataPropertiesAxiom axiom) { + sb.append("EquivalentDataProperties("); + writeAnnotations(axiom); + render(axiom.properties()); + sb.append(')'); + } + + @Override + public void visit(OWLClassAssertionAxiom axiom) { + sb.append("ClassAssertion("); + writeAnnotations(axiom); + axiom.getClassExpression().accept(this); + insertSpace(); + axiom.getIndividual().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLEquivalentClassesAxiom axiom) { + sb.append("EquivalentClasses("); + writeAnnotations(axiom); + render(axiom.classExpressions()); + sb.append(')'); + } + + @Override + public void visit(OWLDataPropertyAssertionAxiom axiom) { + sb.append("DataPropertyAssertion("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getSubject().accept(this); + insertSpace(); + axiom.getObject().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLTransitiveObjectPropertyAxiom axiom) { + sb.append("TransitiveObjectProperty("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLIrreflexiveObjectPropertyAxiom axiom) { + sb.append("IrreflexiveObjectProperty("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLSubDataPropertyOfAxiom axiom) { + sb.append("SubDataPropertyOf("); + writeAnnotations(axiom); + axiom.getSubProperty().accept(this); + insertSpace(); + axiom.getSuperProperty().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLInverseFunctionalObjectPropertyAxiom axiom) { + sb.append("InverseFunctionalObjectProperty("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLSameIndividualAxiom axiom) { + sb.append("SameIndividual("); + writeAnnotations(axiom); + render(axiom.individuals()); + sb.append(')'); + } + + @Override + public void visit(OWLSubPropertyChainOfAxiom axiom) { + sb.append("SubObjectPropertyOf("); + writeAnnotations(axiom); + sb.append("ObjectPropertyChain("); + render(axiom.getPropertyChain().stream()); + sb.append(')'); + insertSpace(); + axiom.getSuperProperty().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLClass ce) { + sb.append(shortFormProvider.getShortForm(ce)); + } + + @Override + public void visit(OWLObjectIntersectionOf ce) { + sb.append("ObjectIntersectionOf("); + render(ce.operands()); + sb.append(')'); + } + + @Override + public void visit(OWLObjectUnionOf ce) { + sb.append("ObjectUnionOf("); + render(ce.operands()); + sb.append(')'); + } + + @Override + public void visit(OWLObjectComplementOf ce) { + sb.append("ObjectComplementOf("); + ce.getOperand().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLObjectSomeValuesFrom ce) { + sb.append("ObjectSomeValuesFrom("); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLObjectAllValuesFrom ce) { + sb.append("ObjectAllValuesFrom("); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLObjectHasValue ce) { + sb.append("ObjectHasValue("); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLObjectMinCardinality ce) { + sb.append("ObjectMinCardinality("); + sb.append(ce.getCardinality()); + insertSpace(); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLObjectExactCardinality ce) { + sb.append("ObjectExactCardinality("); + sb.append(ce.getCardinality()); + insertSpace(); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLObjectMaxCardinality ce) { + sb.append("ObjectMaxCardinality("); + sb.append(ce.getCardinality()); + insertSpace(); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLObjectHasSelf ce) { + sb.append("ObjectHasSelf("); + ce.getProperty().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLObjectOneOf ce) { + sb.append("ObjectOneOf("); + render(ce.individuals()); + sb.append(')'); + } + + @Override + public void visit(OWLDataSomeValuesFrom ce) { + sb.append("DataSomeValuesFrom("); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLDataAllValuesFrom ce) { + sb.append("DataAllValuesFrom("); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLDataHasValue ce) { + sb.append("DataHasValue("); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLDataMinCardinality ce) { + sb.append("DataMinCardinality("); + sb.append(ce.getCardinality()); + insertSpace(); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLDataExactCardinality ce) { + sb.append("DataExactCardinality("); + sb.append(ce.getCardinality()); + insertSpace(); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLDataMaxCardinality ce) { + sb.append("DataMaxCardinality("); + sb.append(ce.getCardinality()); + insertSpace(); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLDatatype node) { + sb.append(shortFormProvider.getShortForm(node)); + } + + @Override + public void visit(OWLDataComplementOf node) { + sb.append("DataComplementOf("); + node.getDataRange().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLDataOneOf node) { + sb.append("DataOneOf("); + render(node.values()); + sb.append(')'); + } + + @Override + public void visit(OWLDatatypeRestriction node) { + sb.append("DatatypeRestriction("); + node.getDatatype().accept(this); + node.facetRestrictions().forEach(r -> { + insertSpace(); + r.accept(this); + }); + sb.append(')'); + } + + @Override + public void visit(OWLFacetRestriction node) { + sb.append("facetRestriction("); + sb.append(node.getFacet()); + insertSpace(); + node.getFacetValue().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLLiteral node) { + String literal = EscapeUtils.escapeString(node.getLiteral()); + if (node.isRDFPlainLiteral() + || node.getDatatype().getIRI().equals(OWL2Datatype.RDF_LANG_STRING.getIRI())) { + // We can use a syntactic shortcut + sb.append('"').append(literal).append('"'); + if (node.hasLang()) { + sb.append('@').append(node.getLang()); + } + } else { + sb.append('"').append(literal).append("\"^^"); + node.getDatatype().accept(this); + } + } + + @Override + public void visit(OWLObjectProperty property) { + sb.append(shortFormProvider.getShortForm(property)); + } + + @Override + public void visit(OWLObjectInverseOf property) { + sb.append("ObjectInverseOf("); + property.getInverse().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLDataProperty property) { + sb.append(shortFormProvider.getShortForm(property)); + } + + @Override + public void visit(OWLNamedIndividual individual) { + sb.append(shortFormProvider.getShortForm(individual)); + } + + @Override + public void visit(OWLInverseObjectPropertiesAxiom axiom) { + sb.append("InverseObjectProperties("); + writeAnnotations(axiom); + axiom.getFirstProperty().accept(this); + insertSpace(); + axiom.getSecondProperty().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLHasKeyAxiom axiom) { + sb.append("HasKey("); + writeAnnotations(axiom); + axiom.getClassExpression().accept(this); + sb.append(" ("); + render(axiom.objectPropertyExpressions()); + sb.append(") ("); + render(axiom.dataPropertyExpressions()); + sb.append("))"); + } + + @Override + public void visit(OWLDataIntersectionOf node) { + sb.append("DataIntersectionOf("); + render(node.operands()); + sb.append(')'); + } + + @Override + public void visit(OWLDataUnionOf node) { + sb.append("DataUnionOf("); + render(node.operands()); + sb.append(')'); + } + + @Override + public void visit(OWLAnnotationProperty property) { + sb.append(shortFormProvider.getShortForm(property)); + } + + @Override + public void visit(OWLAnnotationPropertyDomainAxiom axiom) { + sb.append("AnnotationPropertyDomain("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getDomain().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLAnnotationPropertyRangeAxiom axiom) { + sb.append("AnnotationPropertyRange("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getRange().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLSubAnnotationPropertyOfAxiom axiom) { + sb.append("SubAnnotationPropertyOf("); + writeAnnotations(axiom); + axiom.getSubProperty().accept(this); + insertSpace(); + axiom.getSuperProperty().accept(this); + sb.append(')'); + } + + @Override + public void visit(OWLAnonymousIndividual individual) { + sb.append(individual.getID()); + } + + @Override + public void visit(IRI iri) { + sb.append('<').append(iri).append('>'); + } + + @Override + public void visit(OWLAnnotation node) { + sb.append("Annotation("); + render(node.annotations()); + node.getProperty().accept(this); + insertSpace(); + node.getValue().accept(this); + sb.append(')'); + } + + @Override + public void visit(SWRLRule rule) { + sb.append("DLSafeRule("); + writeAnnotations(rule); + sb.append("Body("); + render(rule.body()); + sb.append(')'); + sb.append(" Head("); + render(rule.head()); + sb.append(')'); + sb.append(')'); + } + + @Override + public void visit(SWRLClassAtom node) { + sb.append("ClassAtom("); + node.getPredicate().accept(this); + insertSpace(); + node.getArgument().accept(this); + sb.append(')'); + } + + @Override + public void visit(SWRLDataRangeAtom node) { + sb.append("DataRangeAtom("); + node.getPredicate().accept(this); + insertSpace(); + node.getArgument().accept(this); + sb.append(')'); + } + + @Override + public void visit(SWRLDifferentIndividualsAtom node) { + sb.append("DifferentFromAtom("); + node.getFirstArgument().accept(this); + insertSpace(); + node.getSecondArgument().accept(this); + sb.append(')'); + } + + @Override + public void visit(SWRLSameIndividualAtom node) { + sb.append("SameAsAtom("); + node.getFirstArgument().accept(this); + insertSpace(); + node.getSecondArgument().accept(this); + sb.append(')'); + } + + @Override + public void visit(SWRLObjectPropertyAtom node) { + sb.append("ObjectPropertyAtom("); + node.getPredicate().accept(this); + insertSpace(); + node.getFirstArgument().accept(this); + insertSpace(); + node.getSecondArgument().accept(this); + sb.append(')'); + } + + @Override + public void visit(SWRLDataPropertyAtom node) { + sb.append("DataPropertyAtom("); + node.getPredicate().accept(this); + insertSpace(); + node.getFirstArgument().accept(this); + insertSpace(); + node.getSecondArgument().accept(this); + sb.append(')'); + } + + @Override + public void visit(SWRLBuiltInAtom node) { + sb.append("BuiltInAtom("); + sb.append(getShortForm(node.getPredicate())); + insertSpace(); + render(node.arguments()); + sb.append(')'); + } + + @Override + public void visit(OWLDatatypeDefinitionAxiom axiom) { + sb.append("DatatypeDefinition("); + writeAnnotations(axiom); + axiom.getDatatype().accept(this); + insertSpace(); + axiom.getDataRange().accept(this); + sb.append(')'); + } + + @Override + public void visit(SWRLVariable node) { + sb.append("Variable("); + sb.append(getShortForm(node.getIRI())); + sb.append(')'); + } + + @Override + public void visit(SWRLIndividualArgument node) { + node.getIndividual().accept(this); + } + + @Override + public void visit(SWRLLiteralArgument node) { + node.getLiteral().accept(this); + } + + @Override + public String toString() { + return sb.toString(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/SimpleRendererDebug.java b/api/src/main/java/org/semanticweb/owlapi/util/SimpleRendererDebug.java new file mode 100644 index 0000000000..567a9d4920 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/SimpleRendererDebug.java @@ -0,0 +1,1025 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.Iterator; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.formats.PrefixDocumentFormat; +import org.semanticweb.owlapi.io.OWLObjectRenderer; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataComplementOf; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataIntersectionOf; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDataUnionOf; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLHasKeyAxiom; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectInverseOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLObjectVisitor; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; +import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.SWRLArgument; +import org.semanticweb.owlapi.model.SWRLBuiltInAtom; +import org.semanticweb.owlapi.model.SWRLClassAtom; +import org.semanticweb.owlapi.model.SWRLDataPropertyAtom; +import org.semanticweb.owlapi.model.SWRLDataRangeAtom; +import org.semanticweb.owlapi.model.SWRLDifferentIndividualsAtom; +import org.semanticweb.owlapi.model.SWRLIndividualArgument; +import org.semanticweb.owlapi.model.SWRLLiteralArgument; +import org.semanticweb.owlapi.model.SWRLObjectPropertyAtom; +import org.semanticweb.owlapi.model.SWRLRule; +import org.semanticweb.owlapi.model.SWRLSameIndividualAtom; +import org.semanticweb.owlapi.model.SWRLVariable; +import org.semanticweb.owlapi.model.parameters.Imports; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * A simple renderer that can be used for debugging purposes and provide an implementation of the + * toString method for different implementations. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class SimpleRendererDebug implements OWLObjectVisitor, OWLObjectRenderer { + + private StringBuilder _sb; + private ShortFormProvider shortFormProvider; + private IRIShortFormProvider iriShortFormProvider; + + /** + * Default constructor. + */ + public SimpleRendererDebug() { + _sb = new StringBuilder(); + resetShortFormProvider(); + } + + /** + * reset the renderer. + */ + public void reset() { + _sb = new StringBuilder(); + } + + private StringBuilder sb(Object o) { + _sb.append("(:" + System.identityHashCode(o) + ")"); + return _sb; + } + + /** + * @return true if default is used + */ + public boolean isUsingDefaultShortFormProvider() { + return shortFormProvider instanceof DefaultPrefixManager; + } + + /** + * Resets the short form provider to the default short form provider, which is a PrefixManager + * with the default set of prefixes. + */ + public final void resetShortFormProvider() { + DefaultPrefixManager defaultPrefixManager = new DefaultPrefixManager(); + shortFormProvider = defaultPrefixManager; + iriShortFormProvider = defaultPrefixManager; + } + + /** + * Resets the short form provider and adds prefix name to prefix mappings based on the specified + * ontology's format (if it is a prefix format) and possibly the ontologies in the imports + * closure. + * + * @param ontology The ontology whose format will be used to obtain prefix mappings + * @param processImportedOntologies Specifies whether or not the prefix mapping should be + * obtained from imported ontologies. + */ + public void setPrefixesFromOntologyFormat(OWLOntology ontology, + boolean processImportedOntologies) { + resetShortFormProvider(); + Imports.fromBoolean(processImportedOntologies).stream(ontology) + .forEach(o -> copyPrefixes(o.getNonnullFormat())); + } + + private void copyPrefixes(OWLDocumentFormat ontologyFormat) { + if (!(ontologyFormat instanceof PrefixDocumentFormat)) { + return; + } + PrefixDocumentFormat prefixFormat = (PrefixDocumentFormat) ontologyFormat; + if (!isUsingDefaultShortFormProvider()) { + resetShortFormProvider(); + } + ((DefaultPrefixManager) shortFormProvider) + .copyPrefixesFrom(prefixFormat.getPrefixName2PrefixMap()); + } + + /** + * Sets a prefix name for a given prefix. Note that prefix names MUST end with a colon. + * + * @param prefixName The prefix name (ending with a colon) + * @param prefix The prefix that the prefix name maps to + */ + public void setPrefix(String prefixName, String prefix) { + if (!isUsingDefaultShortFormProvider()) { + resetShortFormProvider(); + } + ((DefaultPrefixManager) shortFormProvider).setPrefix(prefixName, prefix); + } + + @Override + public void setShortFormProvider(ShortFormProvider shortFormProvider) { + this.shortFormProvider = shortFormProvider; + } + + /** + * @param iri the iri to shorten + * @return the short form + */ + public String getShortForm(IRI iri) { + return iriShortFormProvider.getShortForm(iri); + } + + @Override + public String render(OWLObject object) { + reset(); + object.accept(this); + return _sb.toString(); + } + + protected void render(Stream objects) { + Iterator it = objects.iterator(); + while (it.hasNext()) { + it.next().accept(this); + if (it.hasNext()) { + insertSpace(); + } + } + } + + @Override + public void visit(OWLOntology ontology) { + sb(ontology).append("Ontology(").append(ontology.getOntologyID()).append(" [Axioms: ") + .append(ontology.getAxiomCount()).append("] [Logical axioms: ") + .append(ontology.getLogicalAxiomCount()).append("])"); + } + + private void insertSpace() { + _sb.append(' '); + } + + /** + * @param axiom the axiom whose annotations should be written + */ + public void writeAnnotations(OWLAxiom axiom) { + axiom.annotations().forEach(a -> { + a.accept(this); + insertSpace(); + }); + } + + @Override + public void visit(OWLSubClassOfAxiom axiom) { + sb(axiom).append("SubClassOf("); + writeAnnotations(axiom); + axiom.getSubClass().accept(this); + insertSpace(); + axiom.getSuperClass().accept(this); + closeBracket(); + } + + protected StringBuilder closeBracket() { + return _sb.append(')'); + } + + @Override + public void visit(OWLNegativeObjectPropertyAssertionAxiom axiom) { + sb(axiom).append("NegativeObjectPropertyAssertion("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getSubject().accept(this); + insertSpace(); + axiom.getObject().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLAsymmetricObjectPropertyAxiom axiom) { + sb(axiom).append("AsymmetricObjectProperty("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLReflexiveObjectPropertyAxiom axiom) { + sb(axiom).append("ReflexiveObjectProperty("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLDisjointClassesAxiom axiom) { + sb(axiom).append("DisjointClasses("); + writeAnnotations(axiom); + render(axiom.classExpressions()); + closeBracket(); + } + + @Override + public void visit(OWLDataPropertyDomainAxiom axiom) { + sb(axiom).append("DataPropertyDomain("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getDomain().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLObjectPropertyDomainAxiom axiom) { + sb(axiom).append("ObjectPropertyDomain("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getDomain().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLEquivalentObjectPropertiesAxiom axiom) { + sb(axiom).append("EquivalentObjectProperties("); + writeAnnotations(axiom); + render(axiom.properties()); + closeBracket(); + } + + @Override + public void visit(OWLNegativeDataPropertyAssertionAxiom axiom) { + sb(axiom).append("NegativeDataPropertyAssertion("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getSubject().accept(this); + insertSpace(); + axiom.getObject().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLDifferentIndividualsAxiom axiom) { + sb(axiom).append("DifferentIndividuals("); + writeAnnotations(axiom); + render(axiom.individuals()); + closeBracket(); + } + + @Override + public void visit(OWLDisjointDataPropertiesAxiom axiom) { + sb(axiom).append("DisjointDataProperties("); + writeAnnotations(axiom); + render(axiom.properties()); + closeBracket(); + } + + @Override + public void visit(OWLDisjointObjectPropertiesAxiom axiom) { + sb(axiom).append("DisjointObjectProperties("); + writeAnnotations(axiom); + render(axiom.properties()); + closeBracket(); + } + + @Override + public void visit(OWLObjectPropertyRangeAxiom axiom) { + sb(axiom).append("ObjectPropertyRange("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getRange().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLObjectPropertyAssertionAxiom axiom) { + sb(axiom).append("ObjectPropertyAssertion("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getSubject().accept(this); + insertSpace(); + axiom.getObject().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLFunctionalObjectPropertyAxiom axiom) { + sb(axiom).append("FunctionalObjectProperty("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLSubObjectPropertyOfAxiom axiom) { + sb(axiom).append("SubObjectPropertyOf("); + writeAnnotations(axiom); + axiom.getSubProperty().accept(this); + insertSpace(); + axiom.getSuperProperty().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLDisjointUnionAxiom axiom) { + sb(axiom).append("DisjointUnion("); + writeAnnotations(axiom); + axiom.getOWLClass().accept(this); + insertSpace(); + render(axiom.classExpressions()); + closeBracket(); + } + + @Override + public void visit(OWLDeclarationAxiom axiom) { + sb(axiom).append("Declaration("); + writeAnnotations(axiom); + OWLEntity entity = axiom.getEntity(); + if (entity.isOWLClass()) { + sb(entity).append("Class("); + } else if (entity.isOWLObjectProperty()) { + sb(entity).append("ObjectProperty("); + } else if (entity.isOWLDataProperty()) { + sb(entity).append("DataProperty("); + } else if (entity.isOWLNamedIndividual()) { + sb(entity).append("NamedIndividual("); + } else if (entity.isOWLDatatype()) { + sb(entity).append("Datatype("); + } else if (entity.isOWLAnnotationProperty()) { + sb(entity).append("AnnotationProperty("); + } + axiom.getEntity().accept(this); + closeBracket(); + closeBracket(); + } + + @Override + public void visit(OWLAnnotationAssertionAxiom axiom) { + sb(axiom).append("AnnotationAssertion("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getSubject().accept(this); + insertSpace(); + axiom.getValue().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLSymmetricObjectPropertyAxiom axiom) { + sb(axiom).append("SymmetricObjectProperty("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLDataPropertyRangeAxiom axiom) { + sb(axiom).append("DataPropertyRange("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getRange().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLFunctionalDataPropertyAxiom axiom) { + sb(axiom).append("FunctionalDataProperty("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLEquivalentDataPropertiesAxiom axiom) { + sb(axiom).append("EquivalentDataProperties("); + writeAnnotations(axiom); + render(axiom.properties()); + closeBracket(); + } + + @Override + public void visit(OWLClassAssertionAxiom axiom) { + sb(axiom).append("ClassAssertion("); + writeAnnotations(axiom); + axiom.getClassExpression().accept(this); + insertSpace(); + axiom.getIndividual().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLEquivalentClassesAxiom axiom) { + sb(axiom).append("EquivalentClasses("); + writeAnnotations(axiom); + render(axiom.classExpressions()); + closeBracket(); + } + + @Override + public void visit(OWLDataPropertyAssertionAxiom axiom) { + sb(axiom).append("DataPropertyAssertion("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getSubject().accept(this); + insertSpace(); + axiom.getObject().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLTransitiveObjectPropertyAxiom axiom) { + sb(axiom).append("TransitiveObjectProperty("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLIrreflexiveObjectPropertyAxiom axiom) { + sb(axiom).append("IrreflexiveObjectProperty("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLSubDataPropertyOfAxiom axiom) { + sb(axiom).append("SubDataPropertyOf("); + writeAnnotations(axiom); + axiom.getSubProperty().accept(this); + insertSpace(); + axiom.getSuperProperty().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLInverseFunctionalObjectPropertyAxiom axiom) { + sb(axiom).append("InverseFunctionalObjectProperty("); + writeAnnotations(axiom); + axiom.getProperty().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLSameIndividualAxiom axiom) { + sb(axiom).append("SameIndividual("); + writeAnnotations(axiom); + render(axiom.individuals()); + closeBracket(); + } + + @Override + public void visit(OWLSubPropertyChainOfAxiom axiom) { + sb(axiom).append("SubObjectPropertyOf("); + writeAnnotations(axiom); + _sb.append("ObjectPropertyChain("); + for (OWLObjectPropertyExpression prop : axiom.getPropertyChain()) { + insertSpace(); + prop.accept(this); + } + closeBracket(); + insertSpace(); + axiom.getSuperProperty().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLClass ce) { + sb(ce).append(shortFormProvider.getShortForm(ce)); + } + + @Override + public void visit(OWLObjectIntersectionOf ce) { + sb(ce).append("ObjectIntersectionOf("); + render(ce.operands()); + closeBracket(); + } + + @Override + public void visit(OWLObjectUnionOf ce) { + sb(ce).append("ObjectUnionOf("); + render(ce.operands()); + closeBracket(); + } + + @Override + public void visit(OWLObjectComplementOf ce) { + sb(ce).append("ObjectComplementOf("); + ce.getOperand().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLObjectSomeValuesFrom ce) { + sb(ce).append("ObjectSomeValuesFrom("); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLObjectAllValuesFrom ce) { + sb(ce).append("ObjectAllValuesFrom("); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLObjectHasValue ce) { + sb(ce).append("ObjectHasValue("); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLObjectMinCardinality ce) { + sb(ce).append("ObjectMinCardinality(").append(ce.getCardinality()); + insertSpace(); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLObjectExactCardinality ce) { + sb(ce).append("ObjectExactCardinality(").append(ce.getCardinality()); + insertSpace(); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLObjectMaxCardinality ce) { + sb(ce).append("ObjectMaxCardinality(").append(ce.getCardinality()); + insertSpace(); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLObjectHasSelf ce) { + sb(ce).append("ObjectHasSelf("); + ce.getProperty().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLObjectOneOf ce) { + sb(ce).append("ObjectOneOf("); + render(ce.individuals()); + closeBracket(); + } + + @Override + public void visit(OWLDataSomeValuesFrom ce) { + sb(ce).append("DataSomeValuesFrom("); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLDataAllValuesFrom ce) { + sb(ce).append("DataAllValuesFrom("); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLDataHasValue ce) { + sb(ce).append("DataHasValue("); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLDataMinCardinality ce) { + sb(ce).append("DataMinCardinality(").append(ce.getCardinality()); + insertSpace(); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLDataExactCardinality ce) { + sb(ce).append("DataExactCardinality(").append(ce.getCardinality()); + insertSpace(); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLDataMaxCardinality ce) { + sb(ce).append("DataMaxCardinality(").append(ce.getCardinality()); + insertSpace(); + ce.getProperty().accept(this); + insertSpace(); + ce.getFiller().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLDatatype node) { + sb(node).append(shortFormProvider.getShortForm(node)); + } + + @Override + public void visit(OWLDataComplementOf node) { + sb(node).append("DataComplementOf("); + node.getDataRange().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLDataOneOf node) { + sb(node).append("DataOneOf("); + render(node.values()); + closeBracket(); + } + + @Override + public void visit(OWLDatatypeRestriction node) { + sb(node).append("DataRangeRestriction("); + node.getDatatype().accept(this); + node.facetRestrictions().forEach(r -> { + insertSpace(); + r.accept(this); + }); + closeBracket(); + } + + @Override + public void visit(OWLFacetRestriction node) { + sb(node).append("facetRestriction(").append(node.getFacet()); + insertSpace(); + node.getFacetValue().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLLiteral node) { + StringBuilder sb = sb(node); + String literal = EscapeUtils.escapeString(node.getLiteral()); + if (node.isRDFPlainLiteral() + || node.getDatatype().getIRI().equals(OWL2Datatype.RDF_LANG_STRING.getIRI())) { + // We can use a syntactic shortcut + sb.append('"').append(literal).append('"'); + if (node.hasLang()) { + sb.append('@').append(node.getLang()); + } + } else { + sb.append('"').append(literal).append("\"^^"); + node.getDatatype().accept(this); + } + } + + @Override + public void visit(OWLObjectProperty property) { + sb(property).append(shortFormProvider.getShortForm(property)); + } + + @Override + public void visit(OWLObjectInverseOf property) { + sb(property).append("ObjectInverseOf("); + property.getInverse().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLDataProperty property) { + sb(property).append(shortFormProvider.getShortForm(property)); + } + + @Override + public void visit(OWLNamedIndividual individual) { + sb(individual).append(shortFormProvider.getShortForm(individual)); + } + + @Override + public void visit(OWLInverseObjectPropertiesAxiom axiom) { + sb(axiom).append("InverseObjectProperties("); + writeAnnotations(axiom); + axiom.getFirstProperty().accept(this); + insertSpace(); + axiom.getSecondProperty().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLHasKeyAxiom axiom) { + sb(axiom).append("HasKey("); + writeAnnotations(axiom); + axiom.getClassExpression().accept(this); + _sb.append(" ("); + axiom.objectPropertyExpressions().forEach(p -> { + p.accept(this); + insertSpace(); + }); + _sb.append(") ("); + axiom.dataPropertyExpressions().forEach(p -> { + p.accept(this); + insertSpace(); + }); + closeBracket(); + closeBracket(); + } + + @Override + public void visit(OWLDataIntersectionOf node) { + sb(node).append("DataIntersectionOf("); + node.operands().forEach(r -> { + r.accept(this); + insertSpace(); + }); + closeBracket(); + } + + @Override + public void visit(OWLDataUnionOf node) { + sb(node).append("DataUnionOf("); + node.operands().forEach(r -> { + r.accept(this); + insertSpace(); + }); + closeBracket(); + } + + @Override + public void visit(OWLAnnotationProperty property) { + sb(property).append(shortFormProvider.getShortForm(property)); + } + + @Override + public void visit(OWLAnnotationPropertyDomainAxiom axiom) { + sb(axiom).append("AnnotationPropertyDomain("); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getDomain().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLAnnotationPropertyRangeAxiom axiom) { + sb(axiom).append("AnnotationPropertyRange("); + axiom.getProperty().accept(this); + insertSpace(); + axiom.getRange().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLSubAnnotationPropertyOfAxiom axiom) { + sb(axiom).append("SubAnnotationPropertyOf("); + writeAnnotations(axiom); + axiom.getSubProperty().accept(this); + insertSpace(); + axiom.getSuperProperty().accept(this); + closeBracket(); + } + + @Override + public void visit(OWLAnonymousIndividual individual) { + sb(individual).append(individual.getID()); + } + + @Override + public void visit(IRI iri) { + sb(iri).append('<').append(iri).append('>'); + } + + @Override + public void visit(OWLAnnotation node) { + sb(node).append("Annotation("); + node.annotations().forEach(a -> { + a.accept(this); + insertSpace(); + }); + node.getProperty().accept(this); + insertSpace(); + node.getValue().accept(this); + closeBracket(); + } + + @Override + public void visit(SWRLRule rule) { + sb(rule).append("DLSafeRule("); + writeAnnotations(rule); + _sb.append(" Body("); + render(rule.body()); + closeBracket(); + _sb.append(" Head("); + render(rule.head()); + closeBracket(); + closeBracket(); + } + + @Override + public void visit(SWRLClassAtom node) { + sb(node).append("ClassAtom("); + node.getPredicate().accept(this); + insertSpace(); + node.getArgument().accept(this); + closeBracket(); + } + + @Override + public void visit(SWRLDataRangeAtom node) { + sb(node).append("DataRangeAtom("); + node.getPredicate().accept(this); + insertSpace(); + node.getArgument().accept(this); + closeBracket(); + } + + @Override + public void visit(SWRLDifferentIndividualsAtom node) { + sb(node).append("DifferentFromAtom("); + node.getFirstArgument().accept(this); + insertSpace(); + node.getSecondArgument().accept(this); + closeBracket(); + } + + @Override + public void visit(SWRLSameIndividualAtom node) { + sb(node).append("SameAsAtom("); + node.getFirstArgument().accept(this); + insertSpace(); + node.getSecondArgument().accept(this); + closeBracket(); + } + + @Override + public void visit(SWRLObjectPropertyAtom node) { + sb(node).append("ObjectPropertyAtom("); + node.getPredicate().accept(this); + insertSpace(); + node.getFirstArgument().accept(this); + insertSpace(); + node.getSecondArgument().accept(this); + closeBracket(); + } + + @Override + public void visit(SWRLDataPropertyAtom node) { + sb(node).append("DataPropertyAtom("); + node.getPredicate().accept(this); + insertSpace(); + node.getFirstArgument().accept(this); + insertSpace(); + node.getSecondArgument().accept(this); + closeBracket(); + } + + @Override + public void visit(SWRLBuiltInAtom node) { + sb(node).append("BuiltInAtom(").append(getShortForm(node.getPredicate())); + insertSpace(); + for (SWRLArgument arg : node.getArguments()) { + arg.accept(this); + insertSpace(); + } + closeBracket(); + } + + @Override + public void visit(OWLDatatypeDefinitionAxiom axiom) { + sb(axiom).append("DatatypeDefinition("); + writeAnnotations(axiom); + axiom.getDatatype().accept(this); + insertSpace(); + axiom.getDataRange().accept(this); + closeBracket(); + } + + @Override + public void visit(SWRLVariable node) { + sb(node).append("Variable("); + _sb.append(getShortForm(node.getIRI())); + closeBracket(); + } + + @Override + public void visit(SWRLIndividualArgument node) { + node.getIndividual().accept(this); + } + + @Override + public void visit(SWRLLiteralArgument node) { + node.getLiteral().accept(this); + } + + @Override + public String toString() { + return _sb.toString(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/SimpleRootClassChecker.java b/api/src/main/java/org/semanticweb/owlapi/util/SimpleRootClassChecker.java new file mode 100644 index 0000000000..6bc36cf220 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/SimpleRootClassChecker.java @@ -0,0 +1,179 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.contains; + +import java.util.Collection; +import java.util.Iterator; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLAxiomVisitorEx; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; + +/** + * A utility class that can be used to determine is a class is a syntactic + * direct subclass of owl:Thing. A class is considered NOT to be a syntactic + * direct subclass of owl:Thing if ANY of the following conditions apply: + *
    + *
  1. It is equal to the left hand side of a subclass axiom, where the right + * hand side is a named class other than owl:Thing
  2. + *
  3. It is an operand in an equivalent class axiom where at least one of the + * other other operands is an intersection class that has a named operand other + * than the class in question. For example + * {@code EquivalentClasses(A, (B and prop some C))}
  4. + *
+ * This functionality is provided because it is useful for displaying class + * hierarchies in editors and browsers. In these situations it is needed because + * not all "orphan" classes are asserted to be subclasses of owl:Thing. For + * example, if the only referencing axiom of class A was ObjectDomain(propP A) + * then A is a syntactic subclass of owl:Thing. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class SimpleRootClassChecker implements RootClassChecker { + + private final Collection ontologies; + // Rules for determining if a class is a direct subclass of Thing + // 1) It isn't referenced by ANY subclass axiom or equivalent class axioms + // 2) It is reference only by subclass axioms, but doesn't appear on the LHS + // of these axioms + // 3) It is on the LHS of a subclass axiom where the RHS is Thing + // 4) It is referenced only by equivalent class axioms, where all other + // operands in these axioms are named + // 5) It is not referenced by subclass axioms and is not referenced by any + // equivalent class axiom where there is + // at least one operand in the equivalent class axiom which is an + // intersection containing a named operand i.e. + // EquivalentClasses(A (B and hasP some C)) would not be a subclass of Thing + private final RootClassCheckerHelper checker = new RootClassCheckerHelper(); + private final NamedSuperChecker superChecker = new NamedSuperChecker(); + + /** + * Creates a root class checker, which examines axioms contained in + * ontologies from the specified set in order to determine if a class is a + * syntactic subclass of owl:Thing. + * + * @param ontologies The ontologies whose axioms are to be taken into consideration when + * determining if a class is a syntactic direct subclass of owl:Thing + */ + public SimpleRootClassChecker(Collection ontologies) { + this.ontologies = checkNotNull(ontologies, "ontologies cannot be null"); + } + + @Override + public boolean isRootClass(OWLClass cls) { + return !ontologies.stream().flatMap(o -> o.referencingAxioms(cls)) + .anyMatch(ax -> isRootClass(cls, ax)); + } + + private boolean isRootClass(OWLClass cls, OWLAxiom ax) { + return !ax.accept(checker.setOWLClass(cls)).booleanValue(); + } + + protected boolean check(OWLClassExpression e) { + superChecker.reset(); + e.accept(superChecker); + return !superChecker.namedSuper; + } + + private static class NamedSuperChecker implements OWLClassExpressionVisitorEx { + + protected boolean namedSuper; + + NamedSuperChecker() { + } + + public void reset() { + namedSuper = false; + } + + @Override + public Boolean visit(OWLClass ce) { + namedSuper = true; + return Boolean.TRUE; + } + + @Override + public Boolean visit(OWLObjectIntersectionOf ce) { + return Boolean.valueOf(ce.operands().anyMatch(op -> op.accept(this).booleanValue())); + } + } + + /** + * A utility class that checks if an axiom gives rise to a class being a + * subclass of Thing. + */ + private class RootClassCheckerHelper implements OWLAxiomVisitorEx { + + private Boolean isRoot = Boolean.TRUE; + @Nullable + private OWLClass cls = null; + + public RootClassCheckerHelper() { + } + + public RootClassCheckerHelper setOWLClass(OWLClass cls) { + // Start off with the assumption that the class is + // a root class. This means if the class isn't referenced + // by any equivalent class axioms or subclass axioms then + // we correctly identify it as a root + isRoot = Boolean.TRUE; + this.cls = cls; + return this; + } + + private OWLClass cls() { + return verifyNotNull(cls, + "cls cannot be null. Has the helper been initialised with a valid value?"); + } + + @Override + public Boolean visit(OWLSubClassOfAxiom axiom) { + if (axiom.getSubClass().equals(cls())) { + isRoot = Boolean.valueOf(check(axiom.getSuperClass())); + } + return isRoot; + } + + @Override + public Boolean visit(OWLEquivalentClassesAxiom axiom) { + if (!contains(axiom.classExpressions(), cls())) { + return isRoot; + } + boolean check = false; + Iterator it = axiom.classExpressions().iterator(); + while (it.hasNext()) { + OWLClassExpression desc = it.next(); + if (!desc.equals(cls)) { + check = check(desc); + if (check) { + isRoot = Boolean.FALSE; + return isRoot; + } + } + } + isRoot = Boolean.valueOf(check); + return isRoot; + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/SimpleShortFormProvider.java b/api/src/main/java/org/semanticweb/owlapi/util/SimpleShortFormProvider.java new file mode 100644 index 0000000000..a6260556f8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/SimpleShortFormProvider.java @@ -0,0 +1,38 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.io.Serializable; +import org.semanticweb.owlapi.model.OWLEntity; + +/** + * A very simple short form provider which is intended to provide human readable + * display names for entities. The following strategy is used: 1) If the entity + * URI has a fragment then that fragment is returned e.g. http://an.other.com#A + * would have a short form of "A". 2) If the entity URI does not have a fragment + * then the last segment of the URI path is used e.g. http://an.other.com/A/B + * would have a short form of "B". 3) If the entity URI does not have a path + * then the full URI is returned as a string. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class SimpleShortFormProvider implements ShortFormProvider, Serializable { + + private final SimpleIRIShortFormProvider uriShortFormProvider = new SimpleIRIShortFormProvider(); + + @Override + public String getShortForm(OWLEntity entity) { + return uriShortFormProvider.getShortForm(entity.getIRI()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/SmallSet.java b/api/src/main/java/org/semanticweb/owlapi/util/SmallSet.java new file mode 100644 index 0000000000..b83c615aa3 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/SmallSet.java @@ -0,0 +1,190 @@ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.AbstractSet; +import java.util.Collection; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +/** + * This class provides a compact implementation of a very small sets - less than or equal to three + * elements + * + * @param set element type + */ +public class SmallSet extends AbstractSet { + + @Nullable + T element1; + @Nullable + T element2; + @Nullable + T element3; + + /** + * @param collection collection to copy + */ + public SmallSet(Collection collection) { + if (collection.size() > 3) { + throw new IllegalArgumentException( + "Trying to create a small set with too many elements - max 3, requested: " + + collection.size()); + } + for (T t : collection) { + add(t); + } + } + + @Override + public boolean add(@Nullable T t) { + checkNotNull(t, "SmallSet cannot store null values"); + if (contains(t)) { + return false; + } + if (element1 == null) { + element1 = t; + return true; + } else if (element2 == null) { + element2 = t; + return true; + } else if (element3 == null) { + element3 = t; + return true; + } else { + throw new IllegalStateException("cannot store more than 3 elements in a small set"); + } + } + + @Override + public boolean remove(@Nullable Object o) { + if (o == null) { + return false; + } + int oHash = o.hashCode(); + if (checkMatch(o, oHash, element1)) { + element1 = null; + return true; + } else if (checkMatch(o, oHash, element2)) { + element2 = null; + return true; + } else if (checkMatch(o, oHash, element3)) { + element3 = null; + return true; + } else { + return false; + } + } + + @Override + public boolean contains(@Nullable Object o) { + if (o == null) { + return false; + } + int oHash = o.hashCode(); + return checkMatch(o, oHash, element1) || checkMatch(o, oHash, element2) + || checkMatch(o, oHash, element3); + } + + protected boolean checkMatch(Object o, int oHash, @Nullable T element) { + return element != null && oHash == element.hashCode() && o.equals(element); + } + + @Override + public Iterator iterator() { + return new Iterator() { + + int cp = 1; + + @Override + public void remove() { + throw new UnsupportedOperationException("remove"); + } + + @Override + public boolean hasNext() { + switch (cp) { + case 1: + if (element1 != null) { + return true; + } else { + cp++; + } + //$FALL-THROUGH$ + case 2: + if (element2 != null) { + return true; + } else { + cp++; + } + //$FALL-THROUGH$ + case 3: + if (element3 != null) { + return true; + } else { + cp++; + } + //$FALL-THROUGH$ + default: + return false; + } + } + + @Override + public T next() { + if (!hasNext()) { + throw new NoSuchElementException("No Next Element"); + } + switch (cp++) { + case 1: + return element1; + case 2: + return element2; + case 3: + return element3; + default: + throw new IllegalStateException( + "Iterator pointing past end of virtual array"); + } + } + }; + } + + @Override + public Stream stream() { + Stream stream = Stream.empty(); + if (element1 != null) { + stream = Stream.of(element1); + } + if (element2 != null) { + stream = Stream.concat(stream, Stream.of(element2)); + } + if (element3 != null) { + stream = Stream.concat(stream, Stream.of(element3)); + } + return stream; + } + + @Override + public int size() { + int count = 0; + if (element1 != null) { + count++; + } + if (element2 != null) { + count++; + } + if (element3 != null) { + count++; + } + return count; + } + + @Override + public String toString() { + return String.format("#", element1, element2, element3); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/StringAnnotationVisitor.java b/api/src/main/java/org/semanticweb/owlapi/util/StringAnnotationVisitor.java new file mode 100644 index 0000000000..8a69dc1ec5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/StringAnnotationVisitor.java @@ -0,0 +1,44 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.io.Serializable; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationValueVisitorEx; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; + +/** + * Annotation visitor that returns literal's lexical form, or empty string for + * IRI and blank nodes. + * + * @since 4.0.0 + */ +public class StringAnnotationVisitor implements OWLAnnotationValueVisitorEx, Serializable { + + @Override + public String visit(IRI iri) { + // TODO refactor the short form providers in here + return ""; + } + + @Override + public String visit(OWLAnonymousIndividual individual) { + return ""; + } + + @Override + public String visit(OWLLiteral literal) { + return literal.getLiteral(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/StringComparator.java b/api/src/main/java/org/semanticweb/owlapi/util/StringComparator.java new file mode 100644 index 0000000000..3f94cc9e64 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/StringComparator.java @@ -0,0 +1,26 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.io.Serializable; +import java.util.Comparator; + +/** + * String comparator interface (allows to store comparators without + * serialization complaints). + * + * @since 4.0.0 + */ +public interface StringComparator extends Comparator, Serializable { + +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/StringLengthComparator.java b/api/src/main/java/org/semanticweb/owlapi/util/StringLengthComparator.java new file mode 100644 index 0000000000..6dffafb519 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/StringLengthComparator.java @@ -0,0 +1,32 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; + +/** + * String comparator that takes length into account before natural ordering. + */ +public class StringLengthComparator implements StringComparator { + + @Override + public int compare(@Nullable String o1, @Nullable String o2) { + int diff = verifyNotNull(o1).length() - verifyNotNull(o2).length(); + if (diff != 0) { + return diff; + } + return verifyNotNull(o1).compareTo(o2); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/StructuralTransformation.java b/api/src/main/java/org/semanticweb/owlapi/util/StructuralTransformation.java new file mode 100644 index 0000000000..0aab8355a0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/StructuralTransformation.java @@ -0,0 +1,388 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.add; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLAxiomVisitorEx; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; + +/** + * @author Matthew Horridge, The University Of Manchester, Information Management Group + * @since 2.2.0 + */ +public class StructuralTransformation implements Serializable { + + protected final OWLDataFactory df; + protected final Set signature = new HashSet<>(); + private int nameCounter = 0; + + /** + * @param dataFactory factory to use + */ + public StructuralTransformation(OWLDataFactory dataFactory) { + df = checkNotNull(dataFactory, "dataFactory cannot be null"); + } + + protected OWLClass createNewName() { + OWLClass cls = df.getOWLClass("http://www.semanticweb.org/ontology#", "X" + nameCounter); + nameCounter++; + return cls; + } + + /** + * @param axioms axioms to transform + * @return transformed axioms + */ + public Set getTransformedAxioms(Set axioms) { + checkNotNull(axioms, "axioms cannot be null"); + signature.clear(); + axioms.forEach(ax -> add(signature, ax.signature())); + AxiomRewriter rewriter = new AxiomRewriter(); + Set transformedAxioms = new HashSet<>(); + for (OWLAxiom ax : axioms) { + for (OWLAxiom transAx : ax.accept(rewriter)) { + if (transAx instanceof OWLSubClassOfAxiom) { + AxiomFlattener flattener = + new AxiomFlattener(df, ((OWLSubClassOfAxiom) transAx).getSuperClass()); + Set flattenedAxioms = flattener.getAxioms(); + if (!flattenedAxioms.isEmpty()) { + transformedAxioms.addAll(flattenedAxioms); + } else { + transformedAxioms.add(transAx); + } + } else { + transformedAxioms.add(transAx); + } + } + } + return transformedAxioms; + } + + private class AxiomFlattener implements OWLClassExpressionVisitorEx { + + private final OWLDataFactory ldf; + private final Set axioms = new HashSet<>(); + private final OWLClassExpression rhs; + + AxiomFlattener(OWLDataFactory df, OWLClassExpression rhs) { + ldf = df; + this.rhs = rhs; + } + + @Override + public OWLClassExpression doDefault(Object o) { + return (OWLClassExpression) o; + } + + private OWLSubClassOfAxiom getSCA(OWLClass lhs, OWLClassExpression ce) { + return ldf.getOWLSubClassOfAxiom(lhs, ce); + } + + public Set getAxioms() { + axioms.clear(); + OWLClass lhs = ldf.getOWLThing(); + axioms.add(getSCA(lhs, rhs.accept(this))); + return axioms; + } + + @Override + public OWLClassExpression visit(OWLObjectAllValuesFrom ce) { + if (signature.containsAll(asList(ce.getFiller().signature()))) { + OWLClass name = createNewName(); + axioms.add(getSCA(name, ce.getFiller().accept(this))); + return ldf.getOWLObjectAllValuesFrom(ce.getProperty(), name); + } + return ce; + } + + @Override + public OWLClassExpression visit(OWLObjectComplementOf ce) { + // Should be a literal + if (ce.getOperand().isAnonymous()) { + throw new IllegalStateException( + "Negation of arbitrary class expressions not allowed"); + } + return ce; + } + + @Override + public OWLClassExpression visit(OWLObjectExactCardinality ce) { + if (signature.containsAll(asList(ce.getFiller().signature()))) { + OWLClass name = createNewName(); + axioms.add(getSCA(name, ce.getFiller().accept(this))); + return ldf.getOWLObjectExactCardinality(ce.getCardinality(), ce.getProperty(), + name); + } + return ce; + } + + @Override + public OWLClassExpression visit(OWLObjectIntersectionOf ce) { + OWLClass name = createNewName(); + ce.operands().forEach(op -> axioms.add(getSCA(name, op.accept(this)))); + return name; + } + + @Override + public OWLClassExpression visit(OWLObjectMaxCardinality ce) { + if (signature.containsAll(asList(ce.getFiller().signature()))) { + OWLClass name = createNewName(); + axioms.add(getSCA(name, ce.getFiller().accept(this))); + return ldf.getOWLObjectMaxCardinality(ce.getCardinality(), ce.getProperty(), name); + } + return ce; + } + + @Override + public OWLClassExpression visit(OWLObjectMinCardinality ce) { + if (signature.containsAll(asList(ce.getFiller().signature()))) { + OWLClass name = createNewName(); + axioms.add(getSCA(name, ce.getFiller().accept(this))); + return ldf.getOWLObjectMinCardinality(ce.getCardinality(), ce.getProperty(), name); + } + return ce; + } + + @Override + public OWLClassExpression visit(OWLObjectOneOf ce) { + if (ce.individuals().count() > 1) { + throw new IllegalStateException("ObjectOneOf with more than one individual!"); + } + return ce; + } + + @Override + public OWLClassExpression visit(OWLObjectSomeValuesFrom ce) { + if (ce.getFiller().isAnonymous()) { + OWLClass name = createNewName(); + axioms.add(getSCA(name, ce.getFiller().accept(this))); + return ldf.getOWLObjectSomeValuesFrom(ce.getProperty(), name); + } + return ce; + } + + @Override + public OWLClassExpression visit(OWLObjectUnionOf ce) { + Set descs = new HashSet<>(); + ce.operands().forEach(op -> visitOperand(descs, op)); + return ldf.getOWLObjectUnionOf(descs); + } + + protected void visitOperand(Set descs, OWLClassExpression op) { + OWLClassExpression flatOp = op.accept(this); + if (flatOp.isAnonymous() || signature.contains(flatOp.asOWLClass())) { + OWLClass name = createNewName(); + descs.add(name); + axioms.add(ldf.getOWLSubClassOfAxiom(name, flatOp)); + } else { + descs.add(flatOp); + } + } + } + + /** + * Rewrites axioms into GCIs.
+ * For example: SubClassOf(A, C) becomes SubClassOf(TOP, not(A) or C) + */ + private class AxiomRewriter implements OWLAxiomVisitorEx> { + + AxiomRewriter() {} + + private Collection subClassOf(OWLClassExpression sub, OWLClassExpression sup) { + return doDefault(df.getOWLSubClassOfAxiom(df.getOWLThing(), + df.getOWLObjectUnionOf(df.getOWLObjectComplementOf(sub), sup).getNNF())); + } + + private OWLAxiom subClassOfSingle(OWLClassExpression sub, OWLClassExpression sup) { + return df.getOWLSubClassOfAxiom(df.getOWLThing(), + df.getOWLObjectUnionOf(df.getOWLObjectComplementOf(sub), sup).getNNF()); + } + + @Override + public Collection doDefault(Object o) { + return Collections.singleton((OWLAxiom) o); + } + + @Override + public Collection visit(OWLClassAssertionAxiom axiom) { + return subClassOf(df.getOWLObjectOneOf(axiom.getIndividual()), + axiom.getClassExpression()); + } + + @Override + public Collection visit(OWLDataPropertyDomainAxiom axiom) { + return subClassOf(df.getOWLDataSomeValuesFrom(axiom.getProperty(), df.getTopDatatype()), + axiom.getDomain()); + } + + @Override + public Collection visit(OWLDataPropertyRangeAxiom axiom) { + return doDefault(df.getOWLSubClassOfAxiom(df.getOWLThing(), + df.getOWLDataAllValuesFrom(axiom.getProperty(), axiom.getRange()))); + } + + @Override + public Collection visit(OWLDifferentIndividualsAxiom axiom) { + return axiom.walkPairwise( + (a, b) -> subClassOfSingle(df.getOWLObjectOneOf(a), df.getOWLObjectOneOf(b))); + } + + @Override + public Collection visit(OWLDisjointClassesAxiom axiom) { + // Explode + return axiom.asOWLSubClassOfAxioms(); + } + + @Override + public Collection visit(OWLDisjointUnionAxiom axiom) { + Set axioms = new HashSet<>(); + axioms.addAll(df.getOWLEquivalentClassesAxiom(axiom.getOWLClass(), + df.getOWLObjectUnionOf(axiom.classExpressions())).accept(this)); + axioms.addAll(df.getOWLDisjointClassesAxiom(axiom.classExpressions()).accept(this)); + return axioms; + } + + @Override + public Collection visit(OWLEquivalentClassesAxiom axiom) { + return axiom.asOWLSubClassOfAxioms(); + } + + @Override + public Collection visit(OWLEquivalentDataPropertiesAxiom axiom) { + return axiom.walkPairwise(df::getOWLEquivalentDataPropertiesAxiom); + } + + @Override + public Collection visit(OWLEquivalentObjectPropertiesAxiom axiom) { + return axiom.walkPairwise(df::getOWLEquivalentObjectPropertiesAxiom); + } + + @Override + public Collection visit(OWLDisjointDataPropertiesAxiom axiom) { + return axiom.walkPairwise(df::getOWLDisjointDataPropertiesAxiom); + } + + @Override + public Collection visit(OWLDisjointObjectPropertiesAxiom axiom) { + return axiom.walkPairwise(df::getOWLDisjointObjectPropertiesAxiom); + } + + @Override + public Collection visit(OWLFunctionalDataPropertyAxiom axiom) { + return doDefault(df.getOWLSubClassOfAxiom(df.getOWLThing(), + df.getOWLDataMaxCardinality(1, axiom.getProperty()))); + } + + @Override + public Collection visit(OWLFunctionalObjectPropertyAxiom axiom) { + return doDefault(df.getOWLSubClassOfAxiom(df.getOWLThing(), + df.getOWLObjectMaxCardinality(1, axiom.getProperty()))); + } + + @Override + public Collection visit(OWLInverseFunctionalObjectPropertyAxiom axiom) { + return doDefault(df.getOWLSubClassOfAxiom(df.getOWLThing(), + df.getOWLObjectMaxCardinality(1, axiom.getProperty().getInverseProperty()))); + } + + @Override + public Collection visit(OWLInverseObjectPropertiesAxiom axiom) { + Set axioms = new HashSet<>(); + axioms.add(df.getOWLSubObjectPropertyOfAxiom(axiom.getFirstProperty(), + axiom.getSecondProperty().getInverseProperty())); + axioms.add(df.getOWLSubObjectPropertyOfAxiom(axiom.getSecondProperty(), + axiom.getFirstProperty().getInverseProperty())); + return axioms; + } + + @Override + public Collection visit(OWLNegativeDataPropertyAssertionAxiom axiom) { + return subClassOf(df.getOWLObjectOneOf(axiom.getSubject()), + df.getOWLDataAllValuesFrom(axiom.getProperty(), + df.getOWLDataComplementOf(df.getOWLDataOneOf(axiom.getObject())))); + } + + @Override + public Collection visit(OWLNegativeObjectPropertyAssertionAxiom axiom) { + return subClassOf(df.getOWLObjectOneOf(axiom.getSubject()), + df.getOWLObjectAllValuesFrom(axiom.getProperty(), + df.getOWLObjectComplementOf(df.getOWLObjectOneOf(axiom.getObject())))); + } + + @Override + public Collection visit(OWLObjectPropertyDomainAxiom axiom) { + return subClassOf(df.getOWLObjectSomeValuesFrom(axiom.getProperty(), df.getOWLThing()), + axiom.getDomain()); + } + + @Override + public Collection visit(OWLObjectPropertyRangeAxiom axiom) { + return doDefault(df.getOWLSubClassOfAxiom(df.getOWLThing(), + df.getOWLObjectAllValuesFrom(axiom.getProperty(), axiom.getRange()))); + } + + @Override + public Collection visit(OWLSameIndividualAxiom axiom) { + return Collections.emptySet(); + } + + @Override + public Collection visit(OWLSubClassOfAxiom axiom) { + return subClassOf(axiom.getSubClass(), axiom.getSuperClass()); + } + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/StructureWalker.java b/api/src/main/java/org/semanticweb/owlapi/util/StructureWalker.java new file mode 100644 index 0000000000..09bf528ff8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/StructureWalker.java @@ -0,0 +1,751 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.util.HashSet; +import java.util.Set; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataComplementOf; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataIntersectionOf; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDataUnionOf; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLHasKeyAxiom; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectInverseOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLObjectVisitor; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; +import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.SWRLBuiltInAtom; +import org.semanticweb.owlapi.model.SWRLClassAtom; +import org.semanticweb.owlapi.model.SWRLDataPropertyAtom; +import org.semanticweb.owlapi.model.SWRLDataRangeAtom; +import org.semanticweb.owlapi.model.SWRLDifferentIndividualsAtom; +import org.semanticweb.owlapi.model.SWRLIndividualArgument; +import org.semanticweb.owlapi.model.SWRLLiteralArgument; +import org.semanticweb.owlapi.model.SWRLObjectPropertyAtom; +import org.semanticweb.owlapi.model.SWRLRule; +import org.semanticweb.owlapi.model.SWRLSameIndividualAtom; +import org.semanticweb.owlapi.model.SWRLVariable; + +/** + * Structure walker for object walkers. + * + * @param type to visit + */ +public class StructureWalker implements OWLObjectVisitor { + + protected final OWLObjectWalker walkerCallback; + protected final Set visited = new HashSet<>(); + protected final AnnotationWalkingControl annotationWalkFlag; + + /** + * @param owlObjectWalker callback object walker + */ + public StructureWalker(OWLObjectWalker owlObjectWalker) { + this(owlObjectWalker, AnnotationWalkingControl.WALK_ONTOLOGY_ANNOTATIONS_ONLY); + } + + /** + * @param owlObjectWalker callback object walker + * @param annotationWalkFlag control flag for annotation walking + */ + public StructureWalker(OWLObjectWalker owlObjectWalker, + AnnotationWalkingControl annotationWalkFlag) { + this.walkerCallback = owlObjectWalker; + this.annotationWalkFlag = annotationWalkFlag; + } + + protected void process(OWLObject object) { + if (object instanceof OWLAxiom) { + walkerCallback.setAxiom((OWLAxiom) object); + } + if (object instanceof OWLAnnotation) { + walkerCallback.setAnnotation((OWLAnnotation) object); + } + if (!walkerCallback.visitDuplicates) { + if (visited.add(object)) { + walkerCallback.passToVisitor(object); + } + } else { + walkerCallback.passToVisitor(object); + } + annotationWalkFlag.walk(this, object); + } + + @Override + public void visit(IRI iri) { + process(iri); + } + + @Override + public void visit(OWLOntology ontology) { + walkerCallback.ontology = ontology; + walkerCallback.setAxiom(null); + process(ontology); + ontology.axioms().forEach(a -> a.accept(this)); + } + + @Override + public void visit(OWLAsymmetricObjectPropertyAxiom axiom) { + process(axiom); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLClassAssertionAxiom axiom) { + process(axiom); + axiom.getIndividual().accept(this); + axiom.getClassExpression().accept(this); + } + + @Override + public void visit(OWLDataPropertyAssertionAxiom axiom) { + process(axiom); + axiom.getSubject().accept(this); + axiom.getProperty().accept(this); + axiom.getObject().accept(this); + } + + @Override + public void visit(OWLDataPropertyDomainAxiom axiom) { + process(axiom); + axiom.getDomain().accept(this); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLDataPropertyRangeAxiom axiom) { + process(axiom); + axiom.getRange().accept(this); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLSubDataPropertyOfAxiom axiom) { + process(axiom); + axiom.getSubProperty().accept(this); + axiom.getSuperProperty().accept(this); + } + + @Override + public void visit(OWLDeclarationAxiom axiom) { + process(axiom); + axiom.getEntity().accept(this); + } + + @Override + public void visit(OWLDifferentIndividualsAxiom axiom) { + process(axiom); + axiom.individuals().forEach(a -> a.accept(this)); + } + + @Override + public void visit(OWLDisjointClassesAxiom axiom) { + process(axiom); + axiom.classExpressions().forEach(a -> a.accept(this)); + } + + @Override + public void visit(OWLDisjointDataPropertiesAxiom axiom) { + process(axiom); + axiom.properties().forEach(a -> a.accept(this)); + } + + @Override + public void visit(OWLDisjointObjectPropertiesAxiom axiom) { + process(axiom); + axiom.properties().forEach(a -> a.accept(this)); + } + + @Override + public void visit(OWLDisjointUnionAxiom axiom) { + process(axiom); + axiom.getOWLClass().accept(this); + axiom.classExpressions().forEach(a -> a.accept(this)); + } + + @Override + public void visit(OWLAnnotationAssertionAxiom axiom) { + process(axiom); + axiom.getSubject().accept(this); + axiom.getAnnotation().accept(this); + } + + @Override + public void visit(OWLAnnotationPropertyDomainAxiom axiom) { + process(axiom); + axiom.getProperty().accept(this); + axiom.getDomain().accept(this); + } + + @Override + public void visit(OWLAnnotationPropertyRangeAxiom axiom) { + process(axiom); + axiom.getProperty().accept(this); + axiom.getRange().accept(this); + } + + @Override + public void visit(OWLSubAnnotationPropertyOfAxiom axiom) { + process(axiom); + axiom.getSubProperty().accept(this); + axiom.getSuperProperty().accept(this); + } + + @Override + public void visit(OWLAnnotation node) { + process(node); + node.getProperty().accept(this); + node.getValue().accept(this); + } + + @Override + public void visit(OWLEquivalentClassesAxiom axiom) { + process(axiom); + axiom.classExpressions().forEach(a -> a.accept(this)); + } + + @Override + public void visit(OWLEquivalentDataPropertiesAxiom axiom) { + process(axiom); + axiom.properties().forEach(a -> a.accept(this)); + } + + @Override + public void visit(OWLEquivalentObjectPropertiesAxiom axiom) { + process(axiom); + axiom.properties().forEach(a -> a.accept(this)); + } + + @Override + public void visit(OWLFunctionalDataPropertyAxiom axiom) { + process(axiom); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLFunctionalObjectPropertyAxiom axiom) { + process(axiom); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLInverseFunctionalObjectPropertyAxiom axiom) { + process(axiom); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLInverseObjectPropertiesAxiom axiom) { + process(axiom); + axiom.getFirstProperty().accept(this); + axiom.getSecondProperty().accept(this); + } + + @Override + public void visit(OWLIrreflexiveObjectPropertyAxiom axiom) { + process(axiom); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLNegativeDataPropertyAssertionAxiom axiom) { + process(axiom); + axiom.getSubject().accept(this); + axiom.getProperty().accept(this); + axiom.getObject().accept(this); + } + + @Override + public void visit(OWLNegativeObjectPropertyAssertionAxiom axiom) { + process(axiom); + axiom.getSubject().accept(this); + axiom.getProperty().accept(this); + axiom.getObject().accept(this); + } + + @Override + public void visit(OWLObjectPropertyAssertionAxiom axiom) { + process(axiom); + axiom.getSubject().accept(this); + axiom.getProperty().accept(this); + axiom.getObject().accept(this); + } + + @Override + public void visit(OWLSubPropertyChainOfAxiom axiom) { + process(axiom); + axiom.getPropertyChain().forEach(a -> a.accept(this)); + axiom.getSuperProperty().accept(this); + } + + @Override + public void visit(OWLObjectPropertyDomainAxiom axiom) { + process(axiom); + axiom.getDomain().accept(this); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLObjectPropertyRangeAxiom axiom) { + process(axiom); + axiom.getProperty().accept(this); + axiom.getRange().accept(this); + } + + @Override + public void visit(OWLSubObjectPropertyOfAxiom axiom) { + process(axiom); + axiom.getSubProperty().accept(this); + axiom.getSuperProperty().accept(this); + } + + @Override + public void visit(OWLReflexiveObjectPropertyAxiom axiom) { + process(axiom); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLSameIndividualAxiom axiom) { + process(axiom); + axiom.individuals().forEach(a -> a.accept(this)); + } + + @Override + public void visit(OWLSubClassOfAxiom axiom) { + process(axiom); + // -ve polarity + axiom.getSubClass().accept(this); + // +ve polarity + axiom.getSuperClass().accept(this); + } + + @Override + public void visit(OWLSymmetricObjectPropertyAxiom axiom) { + process(axiom); + axiom.getProperty().accept(this); + } + + @Override + public void visit(OWLTransitiveObjectPropertyAxiom axiom) { + process(axiom); + axiom.getProperty().accept(this); + } + + @Override + public void visit(SWRLRule rule) { + process(rule); + rule.body().forEach(a -> a.accept(this)); + rule.head().forEach(a -> a.accept(this)); + } + + @Override + public void visit(OWLHasKeyAxiom axiom) { + process(axiom); + axiom.getClassExpression().accept(this); + axiom.objectPropertyExpressions().forEach(a -> a.accept(this)); + axiom.dataPropertyExpressions().forEach(a -> a.accept(this)); + } + + @Override + public void visit(OWLClass ce) { + walkerCallback.pushClassExpression(ce); + process(ce); + ce.getIRI().accept(this); + walkerCallback.popClassExpression(); + } + + @Override + public void visit(OWLDataAllValuesFrom ce) { + walkerCallback.pushClassExpression(ce); + process(ce); + ce.getProperty().accept(this); + ce.getFiller().accept(this); + walkerCallback.popClassExpression(); + } + + @Override + public void visit(OWLDataExactCardinality ce) { + walkerCallback.pushClassExpression(ce); + process(ce); + ce.getProperty().accept(this); + ce.getFiller().accept(this); + walkerCallback.popClassExpression(); + } + + @Override + public void visit(OWLDataMaxCardinality ce) { + walkerCallback.pushClassExpression(ce); + process(ce); + ce.getProperty().accept(this); + ce.getFiller().accept(this); + walkerCallback.popClassExpression(); + } + + @Override + public void visit(OWLDataMinCardinality ce) { + walkerCallback.pushClassExpression(ce); + process(ce); + ce.getProperty().accept(this); + ce.getFiller().accept(this); + walkerCallback.popClassExpression(); + } + + @Override + public void visit(OWLDataSomeValuesFrom ce) { + walkerCallback.pushClassExpression(ce); + process(ce); + ce.getProperty().accept(this); + ce.getFiller().accept(this); + walkerCallback.popClassExpression(); + } + + @Override + public void visit(OWLDataHasValue ce) { + walkerCallback.pushClassExpression(ce); + process(ce); + ce.getProperty().accept(this); + ce.getFiller().accept(this); + walkerCallback.popClassExpression(); + } + + @Override + public void visit(OWLObjectAllValuesFrom ce) { + walkerCallback.pushClassExpression(ce); + process(ce); + ce.getProperty().accept(this); + ce.getFiller().accept(this); + walkerCallback.popClassExpression(); + } + + @Override + public void visit(OWLObjectComplementOf ce) { + walkerCallback.pushClassExpression(ce); + process(ce); + ce.getOperand().accept(this); + walkerCallback.popClassExpression(); + } + + @Override + public void visit(OWLObjectExactCardinality ce) { + walkerCallback.pushClassExpression(ce); + process(ce); + ce.getProperty().accept(this); + ce.getFiller().accept(this); + walkerCallback.popClassExpression(); + } + + @Override + public void visit(OWLObjectIntersectionOf ce) { + walkerCallback.pushClassExpression(ce); + process(ce); + ce.operands().forEach(a -> a.accept(this)); + walkerCallback.popClassExpression(); + } + + @Override + public void visit(OWLObjectMaxCardinality ce) { + walkerCallback.pushClassExpression(ce); + process(ce); + ce.getProperty().accept(this); + ce.getFiller().accept(this); + walkerCallback.popClassExpression(); + } + + @Override + public void visit(OWLObjectMinCardinality ce) { + walkerCallback.pushClassExpression(ce); + process(ce); + ce.getProperty().accept(this); + ce.getFiller().accept(this); + walkerCallback.popClassExpression(); + } + + @Override + public void visit(OWLObjectOneOf ce) { + walkerCallback.pushClassExpression(ce); + process(ce); + ce.individuals().forEach(a -> a.accept(this)); + walkerCallback.popClassExpression(); + } + + @Override + public void visit(OWLObjectHasSelf ce) { + walkerCallback.pushClassExpression(ce); + process(ce); + ce.getProperty().accept(this); + walkerCallback.popClassExpression(); + } + + @Override + public void visit(OWLObjectSomeValuesFrom ce) { + walkerCallback.pushClassExpression(ce); + process(ce); + ce.getProperty().accept(this); + ce.getFiller().accept(this); + walkerCallback.popClassExpression(); + } + + @Override + public void visit(OWLObjectUnionOf ce) { + walkerCallback.pushClassExpression(ce); + process(ce); + ce.operands().forEach(a -> a.accept(this)); + walkerCallback.popClassExpression(); + } + + @Override + public void visit(OWLObjectHasValue ce) { + walkerCallback.pushClassExpression(ce); + process(ce); + ce.getProperty().accept(this); + ce.getFiller().accept(this); + walkerCallback.popClassExpression(); + } + + @Override + public void visit(OWLDataComplementOf node) { + walkerCallback.pushDataRange(node); + process(node); + node.getDataRange().accept(this); + walkerCallback.popDataRange(); + } + + @Override + public void visit(OWLDataOneOf node) { + walkerCallback.pushDataRange(node); + process(node); + node.values().forEach(a -> a.accept(this)); + walkerCallback.popDataRange(); + } + + @Override + public void visit(OWLDataIntersectionOf node) { + walkerCallback.pushDataRange(node); + process(node); + node.operands().forEach(a -> a.accept(this)); + walkerCallback.popDataRange(); + } + + @Override + public void visit(OWLDataUnionOf node) { + walkerCallback.pushDataRange(node); + process(node); + node.operands().forEach(a -> a.accept(this)); + walkerCallback.popDataRange(); + } + + @Override + public void visit(OWLFacetRestriction node) { + process(node); + node.getFacetValue().accept(this); + } + + @Override + public void visit(OWLDatatypeRestriction node) { + walkerCallback.pushDataRange(node); + process(node); + node.getDatatype().accept(this); + node.facetRestrictions().forEach(a -> a.accept(this)); + walkerCallback.popDataRange(); + } + + @Override + public void visit(OWLDatatype node) { + walkerCallback.pushDataRange(node); + process(node); + walkerCallback.popDataRange(); + } + + @Override + public void visit(OWLLiteral node) { + process(node); + node.getDatatype().accept(this); + walkerCallback.popDataRange(); + } + + @Override + public void visit(OWLAnnotationProperty property) { + process(property); + property.getIRI().accept(this); + } + + @Override + public void visit(OWLDataProperty property) { + process(property); + property.getIRI().accept(this); + } + + @Override + public void visit(OWLObjectProperty property) { + process(property); + property.getIRI().accept(this); + } + + @Override + public void visit(OWLObjectInverseOf property) { + process(property); + property.getInverse().accept(this); + } + + @Override + public void visit(OWLNamedIndividual individual) { + process(individual); + individual.getIRI().accept(this); + } + + @Override + public void visit(OWLAnonymousIndividual individual) { + process(individual); + } + + @Override + public void visit(SWRLLiteralArgument node) { + process(node); + node.getLiteral().accept(this); + } + + @Override + public void visit(SWRLVariable node) { + process(node); + } + + @Override + public void visit(SWRLIndividualArgument node) { + process(node); + node.getIndividual().accept(this); + } + + @Override + public void visit(SWRLBuiltInAtom node) { + process(node); + node.getArguments().forEach(a -> a.accept(this)); + } + + @Override + public void visit(SWRLClassAtom node) { + process(node); + node.getArgument().accept(this); + node.getPredicate().accept(this); + } + + @Override + public void visit(SWRLDataRangeAtom node) { + process(node); + node.getArgument().accept(this); + node.getPredicate().accept(this); + } + + @Override + public void visit(SWRLDataPropertyAtom node) { + process(node); + node.getPredicate().accept(this); + node.getFirstArgument().accept(this); + node.getSecondArgument().accept(this); + } + + @Override + public void visit(SWRLDifferentIndividualsAtom node) { + process(node); + node.getFirstArgument().accept(this); + node.getSecondArgument().accept(this); + } + + @Override + public void visit(SWRLObjectPropertyAtom node) { + process(node); + node.getPredicate().accept(this); + node.getFirstArgument().accept(this); + node.getSecondArgument().accept(this); + } + + @Override + public void visit(SWRLSameIndividualAtom node) { + process(node); + node.getFirstArgument().accept(this); + node.getSecondArgument().accept(this); + } + + @Override + public void visit(OWLDatatypeDefinitionAxiom axiom) { + process(axiom); + axiom.getDatatype().accept(this); + axiom.getDataRange().accept(this); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/Version.java b/api/src/main/java/org/semanticweb/owlapi/util/Version.java new file mode 100644 index 0000000000..750ee68778 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/Version.java @@ -0,0 +1,103 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import javax.annotation.Nullable; + +/** + * A simple utility class that describes the version of a piece of software e.g. reasoner version. + *
+ * A version number is assumed to be the following format: major.minor.patch.build. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class Version { + + private final int major; + private final int minor; + private final int patch; + private final int build; + private final String buildString; + + /** + * @param major major version number + * @param minor minor version number + * @param patch patch number + * @param build build number + */ + public Version(int major, int minor, int patch, int build) { + this(major, minor, patch, build, ""); + } + + /** + * @param major major version number + * @param minor minor version number + * @param patch patch number + * @param build build number + * @param buildString for systems where the build number is not fully numeric (snapshots, + * versions with a timestamp build) + */ + public Version(int major, int minor, int patch, int build, @Nullable String buildString) { + this.major = major; + this.minor = minor; + this.patch = patch; + this.build = build; + this.buildString = buildString == null ? "" : buildString; + } + + /** + * @return major version + */ + public int getMajor() { + return major; + } + + /** + * @return minor version + */ + public int getMinor() { + return minor; + } + + /** + * @return patch version + */ + public int getPatch() { + return patch; + } + + /** + * @return build version + */ + public int getBuild() { + return build; + } + + @Override + public String toString() { + String string = major + "." + minor + "." + patch; + if (build != 0) { + string = string + "." + build; + } + if (!buildString.isEmpty()) { + if (buildString.startsWith("-")) { + // for -SNAPSHOT strings, do not add a dot + string = string + buildString; + } else { + string = string + "." + buildString; + } + } + return string; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/VersionInfo.java b/api/src/main/java/org/semanticweb/owlapi/util/VersionInfo.java new file mode 100644 index 0000000000..c679d1ccfa --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/VersionInfo.java @@ -0,0 +1,66 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +/** + * A place holder for the current release number. + * + * @author Matthew Horridge, The University Of Manchester, Information Management Group + * @since 2.2.0 + */ +public class VersionInfo { + + private static final VersionInfo INSTANCE = new VersionInfo(); + private final String version; + + protected VersionInfo() { + String v = VersionInfo.class.getPackage().getImplementationVersion(); + if (v != null) { + version = v; + } else { + version = "5.1.18"; + } + } + + /** + * @return the version info + */ + public static VersionInfo getVersionInfo() { + return INSTANCE; + } + + /** + * Gets a string that contains the version of this build. This is generated from the manifest of + * the jar that this class is packaged in. + * + * @return The version info string (if available). + */ + public String getVersion() { + return version; + } + + /** + * Gets a message saying "Generated by the OWL API (version x.x.x)". + * + * @return The message. + */ + public String getGeneratedByMessage() { + return "Generated by the OWL API (version " + version + + ") https://github.com/owlcs/owlapi/"; + } + + @Override + public String toString() { + return "The OWL API (version " + version + ')'; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/WeakCache.java b/api/src/main/java/org/semanticweb/owlapi/util/WeakCache.java new file mode 100644 index 0000000000..022615c1b1 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/WeakCache.java @@ -0,0 +1,74 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.Serializable; +import java.lang.ref.WeakReference; +import java.util.Map; + +/** + * A weakly linked cache - elements in the cache can be garbage collected. + * + * @param cached type + */ +public class WeakCache implements Serializable { + + private transient Map> prefixCache = CollectionFactory.createSyncWeakMap(); + + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + in.defaultReadObject(); + prefixCache = CollectionFactory.createSyncWeakMap(); + } + + /** + * @param s the value to cache + * @return the cached value + */ + public K cache(K s) { + WeakReference w = prefixCache.get(s); + if (w != null) { + K toReturn = w.get(); + if (toReturn != null) { + return toReturn; + } + } + // need to add the new key and return it + prefixCache.put(s, new WeakReference<>(s)); + return s; + } + + /** + * @param k the key to check + * @return true if the cache contains k as a key; note that, due to the nature of this cache, by + * the time the method returns the key may no longer be in the map. + */ + public boolean contains(K k) { + WeakReference w = prefixCache.get(k); + if (w != null) { + K toReturn = w.get(); + if (toReturn != null) { + return true; + } + } + return false; + } + + /** + * empty the cache. + */ + public void clear() { + prefixCache.clear(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/WeakIndexCache.java b/api/src/main/java/org/semanticweb/owlapi/util/WeakIndexCache.java new file mode 100644 index 0000000000..3f8d749b37 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/WeakIndexCache.java @@ -0,0 +1,91 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.Serializable; +import java.lang.ref.WeakReference; +import java.util.Map; +import javax.annotation.Nullable; + +/** + * A weakly linked cache - elements in the cache can be garbage collected. + * + * @param key type + * @param value type + */ +public class WeakIndexCache implements Serializable { + + protected transient Map> prefixCache = CollectionFactory + .createSyncWeakMap(); + + /** + * @param s the cache key + * @param v the cache value + * @return the cached value + */ + public V cache(K s, V v) { + WeakReference w = prefixCache.get(s); + if (w != null) { + V toReturn = w.get(); + if (toReturn != null) { + return toReturn; + } + } + // need to add the new key and return it + prefixCache.put(s, new WeakReference<>(v)); + return v; + } + + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + in.defaultReadObject(); + prefixCache = CollectionFactory.createSyncWeakMap(); + } + + /** + * @param k the key + * @return the value + */ + @Nullable + public V get(K k) { + WeakReference w = prefixCache.get(k); + if (w != null) { + return w.get(); + } + return null; + } + + /** + * @param k the key to check + * @return true if the cache contains k as a key; note that, due to the nature of this cache, by + * the time the method returns the key may no longer be in the map. + */ + public boolean contains(K k) { + WeakReference w = prefixCache.get(k); + if (w != null) { + V toReturn = w.get(); + if (toReturn != null) { + return true; + } + } + return false; + } + + /** + * empty the cache. + */ + public void clear() { + prefixCache.clear(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/ZipIRIMapper.java b/api/src/main/java/org/semanticweb/owlapi/util/ZipIRIMapper.java new file mode 100644 index 0000000000..6f7871b5e7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/ZipIRIMapper.java @@ -0,0 +1,354 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.CollectionFactory.createMap; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.Serializable; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.Collection; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Stream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.annotations.HasPriority; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntologyIRIMapper; +import org.semanticweb.owlapi.vocab.Namespaces; +import org.semanticweb.owlapi.vocab.OWLXMLVocabulary; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +/** + * A mapper which given a root folder attempts to automatically discover and map files to + * ontologies. The mapper is only capable of mapping ontologies in RDF/XML and OWL/XML (other + * serialisations are not supported). + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +@HasPriority(1) +public class ZipIRIMapper extends DefaultHandler implements OWLOntologyIRIMapper, Serializable { + + static final Pattern pattern = Pattern.compile("Ontology\\(<([^>]+)>"); + private static final Logger LOGGER = LoggerFactory.getLogger(ZipIRIMapper.class); + private final Set fileExtensions = + new HashSet<>(Arrays.asList(".owl", ".xml", ".rdf", ".omn", ".ofn", ".obo")); + private final Map handlerMap = createMap(); + private final Map ontologyIRI2PhysicalURIMap = createMap(); + private final Map oboFileMap = createMap(); + @Nullable + private IRI currentFile; + + /** + * Creates an auto-mapper which examines ontologies that reside in the specified zip file. + * + * @param zip The zip file to map. + * @param baseIRI base iri for physical IRIs + * @throws IOException if an exception reading from input is raised + */ + public ZipIRIMapper(File zip, String baseIRI) throws IOException { + this(new ZipFile(zip), baseIRI); + } + + /** + * Creates an auto-mapper which examines ontologies that reside in the specified zip file. + * + * @param zip The zip file to map. + * @param baseIRI base iri for physical IRIs + * @throws IOException if an exception reading from input is raised + */ + public ZipIRIMapper(ZipFile zip, String baseIRI) throws IOException { + /** + * A handler to handle RDF/XML files. The xml:base (if present) is taken to be the ontology + * URI of the ontology document being parsed. + */ + handlerMap.put(Namespaces.RDF + "RDF", this::baseIRI); + /** A handler that can handle OWL/XML files. */ + handlerMap.put(OWLXMLVocabulary.ONTOLOGY.toString(), this::ontologyIRI); + processFile(zip, baseIRI); + + } + + @Nullable + protected IRI ontologyIRI(Attributes attributes) { + String ontURI = attributes.getValue(Namespaces.OWL.toString(), "ontologyIRI"); + if (ontURI == null) { + ontURI = attributes.getValue("ontologyIRI"); + } + if (ontURI == null) { + return null; + } + return IRI.create(ontURI); + } + + @Nullable + protected IRI baseIRI(Attributes attributes) { + String baseValue = attributes.getValue(Namespaces.XML.toString(), "base"); + if (baseValue == null) { + return null; + } + return IRI.create(baseValue); + } + + /** + * @param tok token + * @return IRI without quotes (< and >) + */ + static IRI unquote(String tok) { + String substring = tok.substring(1, tok.length() - 1); + assert substring != null; + return IRI.create(substring); + } + + /** + * The mapper only examines files that have specified file extensions. This method returns the + * file extensions that cause a file to be examined. + * + * @return A {@code Set} of file extensions. + */ + public Set getFileExtensions() { + return new HashSet<>(fileExtensions); + } + + /** + * Sets the extensions of files that are to be examined for ontological content. (By default the + * extensions are, owl, xml and rdf). Only files that have the specified extensions will be + * examined to see if they contain ontologies. + * + * @param extensions the set of extensions + */ + public void setFileExtensions(Collection extensions) { + fileExtensions.clear(); + fileExtensions.addAll(extensions); + } + + /** + * Gets the mappings of ontology IRIs that this mapper has found. + * + * @return A {@code Stream} of map entries, from logical to physical IRI + */ + public Stream> mappedEntries() { + return ontologyIRI2PhysicalURIMap.entrySet().stream(); + } + + @Override + @Nullable + public IRI getDocumentIRI(IRI ontologyIRI) { + if (ontologyIRI.toString().endsWith(".obo")) { + String path = ontologyIRI.toURI().getPath(); + if (path != null) { + int lastSepIndex = path.lastIndexOf('/'); + String name = path.substring(lastSepIndex + 1, path.length()); + IRI documentIRI = oboFileMap.get(name); + if (documentIRI != null) { + return documentIRI; + } + } + } + return ontologyIRI2PhysicalURIMap.get(ontologyIRI); + } + + /** + * @return obo mappings + */ + public Stream> oboMappings() { + return oboFileMap.entrySet().stream(); + } + + /** + * @return iri mappings + */ + public Stream> iriMappings() { + return ontologyIRI2PhysicalURIMap.entrySet().stream(); + } + + private void processFile(ZipFile archive, String baseIRI) throws IOException { + Enumeration entries = archive.entries(); + while (entries.hasMoreElements()) { + parseIfExtensionSupported(archive, entries.nextElement(), baseIRI); + } + } + + protected void parseIfExtensionSupported(ZipFile file, ZipEntry e, String baseIRI) + throws IOException { + String name = e.getName(); + int lastIndexOf = name.lastIndexOf('.'); + if (lastIndexOf < 0) { + // no extension for the file, nothing to do + return; + } + IRI physicalIRI = IRI.create(baseIRI + name); + String extension = name.substring(lastIndexOf); + if (".obo".equals(extension)) { + oboFileMap.put(name, physicalIRI); + } else { + try (InputStream in = file.getInputStream(e)) { + if (".ofn".equals(extension)) { + IRI logical = parseFSSFile(in); + if (logical != null) { + ontologyIRI2PhysicalURIMap.put(logical, physicalIRI); + } + } else if (".omn".equals(extension)) { + IRI logical = parseManchesterSyntaxFile(in); + if (logical != null) { + ontologyIRI2PhysicalURIMap.put(logical, physicalIRI); + } + } else if (fileExtensions.contains(extension)) { + IRI logical = parseFile(in); + if (logical != null) { + ontologyIRI2PhysicalURIMap.put(logical, physicalIRI); + } + } + } + } + } + + /** + * Search first 100 lines for FSS style Ontology(<IRI> ... + * + * @param input the file to parse + * @return iri + */ + @Nullable + private static IRI parseFSSFile(InputStream input) { + try (Reader reader = new InputStreamReader(input, "UTF-8"); + BufferedReader br = new BufferedReader(reader)) { + String line = ""; + Matcher m = pattern.matcher(line); + int n = 0; + while ((line = br.readLine()) != null && n++ < 100) { + m.reset(line); + if (m.matches()) { + String group = m.group(1); + assert group != null; + return IRI.create(group); + } + } + } catch (IOException e) { + // if we can't parse a file, then we can't map it + LOGGER.debug("Exception reading file", e); + } + return null; + } + + @Nullable + private IRI parseFile(InputStream file) { + try { + currentFile = null; + // Using the default expansion limit. If the ontology IRI cannot be + // found before 64000 entities are expanded, the file is too + // expensive to parse. + SAXParsers.initParserWithOWLAPIStandards(null, "64000").parse(file, this); + } catch (SAXException | IOException e) { + // if we can't parse a file, then we can't map it + LOGGER.debug("Exception reading file", e); + } + return currentFile; + } + + @Nullable + private static IRI parseManchesterSyntaxFile(InputStream input) { + try (InputStreamReader reader = new InputStreamReader(input, StandardCharsets.UTF_8); + BufferedReader br = new BufferedReader(reader)) { + // Ontology: + String line = br.readLine(); + while (line != null) { + IRI iri = parseManLine(line); + if (iri != null) { + return iri; + } + line = br.readLine(); + } + } catch (IOException e) { + // if we can't parse a file, then we can't map it + LOGGER.debug("Exception reading file", e); + } + return null; + } + + @Nullable + private static IRI parseManLine(String line) { + for (String tok : line.split(" ")) { + if (tok.startsWith("<") && tok.endsWith(">")) { + return unquote(tok); + } + } + return null; + } + + @Override + public void startElement(@Nullable String uri, @Nullable String localName, + @Nullable String qName, @Nullable Attributes attributes) throws SAXException { + OntologyRootElementHandler handler = handlerMap.get(uri + localName); + if (handler != null) { + IRI ontologyIRI = handler.handle(checkNotNull(attributes)); + if (ontologyIRI != null && currentFile == null) { + currentFile = ontologyIRI; + } + throw new SAXException(); + } + } + + /** + * @param ontologyIRI ontology + * @param file file + */ + protected void addMapping(IRI ontologyIRI, File file) { + ontologyIRI2PhysicalURIMap.put(ontologyIRI, IRI.create(file)); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("AutoIRIMapper: ("); + sb.append(ontologyIRI2PhysicalURIMap.size()).append(" ontologies)\n"); + ontologyIRI2PhysicalURIMap.forEach((k, v) -> sb.append(" ").append(k.toQuotedString()) + .append(" -> ").append(v).append('\n')); + return sb.toString(); + } + + /** + * A simple interface which extracts an ontology IRI from a set of element attributes. + */ + @FunctionalInterface + private interface OntologyRootElementHandler extends Serializable { + + /** + * Gets the ontology IRI. + * + * @param attributes The attributes which will be examined for the ontology IRI. + * @return The ontology IRI or {@code null} if no ontology IRI could be found. + */ + @Nullable + IRI handle(Attributes attributes); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/mansyntax/ManchesterOWLSyntaxParser.java b/api/src/main/java/org/semanticweb/owlapi/util/mansyntax/ManchesterOWLSyntaxParser.java new file mode 100644 index 0000000000..091407fbcd --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/mansyntax/ManchesterOWLSyntaxParser.java @@ -0,0 +1,234 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util.mansyntax; + +import java.util.List; +import java.util.Set; + +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; + +import org.semanticweb.owlapi.expression.OWLEntityChecker; +import org.semanticweb.owlapi.expression.OWLOntologyChecker; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.io.OWLParserException; +import org.semanticweb.owlapi.model.HasOntologyLoaderConfiguration; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClassAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLPropertyExpression; +import org.semanticweb.owlapi.model.UnloadableImportException; +import org.semanticweb.owlapi.util.OntologyAxiomPair; + +/** + * Interface for a parser able to parse Manchester OWL Syntax. This covers Protege use of the + * parser. + * + * @author ignazio + */ +@ParametersAreNonnullByDefault +public interface ManchesterOWLSyntaxParser extends HasOntologyLoaderConfiguration { + + /** + * @param s String to parse + */ + void setStringToParse(String s); + + /** + * @param defaultOntology ontology to use to resolve classes and entities during parsing + */ + void setDefaultOntology(OWLOntology defaultOntology); + + /** + * @return frames + */ + Set parseFrames(); + + /** + * Parsing "Inline" Axioms. + * + * @return axiom + * @throws OWLParserException parsing error + */ + OWLAxiom parseAxiom(); + + /** + * Parsing "Inline" class Axioms. + * + * @return axiom + * @throws OWLParserException parsing error + * @deprecated use {@link #parseAxiom()}. {@code parseClassAxiom()} only casts the result of + * {@code parseAxiom()} to OWLClassAxiom. + */ + @Deprecated + OWLClassAxiom parseClassAxiom(); + + /** + * Parses an OWL class expression that is represented in Manchester OWL Syntax. + * + * @return The parsed class expression + * @throws OWLParserException If a class expression could not be parsed. + */ + OWLClassExpression parseClassExpression(); + + /** + * @return class frames (parsing with EOF true) + * @throws OWLParserException parsing error + */ + Set parseClassFrameEOF(); + + /** + * @return value partition frames + * @throws OWLParserException parsing error + */ + Set parseValuePartitionFrame(); + + /** + * @return datatype frames + * @throws OWLParserException parsing error + */ + Set parseDatatypeFrame(); + + /** + * @return class frames + * @throws OWLParserException parsing error + */ + Set parseClassFrame(); + + /** + * @return object property frames + * @throws OWLParserException parsing error + */ + Set parseObjectPropertyFrame(); + + /** + * @return individual frames + * @throws OWLParserException parsing error + */ + Set parseIndividualFrame(); + + /** + * @return data property frames + * @throws OWLParserException parsing error + */ + Set parseDataPropertyFrame(); + + /** + * @return annotation frames + * @throws OWLParserException parsing error + */ + Set parseAnnotationPropertyFrame(); + + /** + * @param datatype datatype to use, if one exists in the context. If null, the datatype will be + * decided by the literal itself. + * @return parsed literal + */ + OWLLiteral parseLiteral(@Nullable OWLDatatype datatype); + + /** + * @param owlEntityChecker entity checker + */ + void setOWLEntityChecker(OWLEntityChecker owlEntityChecker); + + /** + * @param owlOntologyChecker ontology checker + */ + void setOWLOntologyChecker(OWLOntologyChecker owlOntologyChecker); + + /** + * @return object property chain + */ + List parseObjectPropertyChain(); + + /** + * @param ont ontology + * @return format + * @throws OWLParserException parsing error + * @throws UnloadableImportException import error + */ + ManchesterSyntaxDocumentFormat parseOntology(OWLOntology ont); + + /** + * @return list of class expressions + */ + Set parseClassExpressionList(); + + /** + * @return list of object properties + * @throws OWLParserException if a parser exception is raised + */ + Set parseObjectPropertyList(); + + /** + * @return list of object properties + * @throws OWLParserException if a parser exception is raised + */ + Set parseDataPropertyList(); + + /** + * @return parsed list of individuals + */ + Set parseIndividualList(); + + /** + * @return parsed list of data ranges + */ + Set parseDataRangeList(); + + /** + * @return parsed list of annotation properties + */ + Set parseAnnotationPropertyList(); + + /** + * @return data range + */ + OWLDataRange parseDataRange(); + + /** + * @return property list (object or data) + */ + Set parsePropertyList(); + + /** + * @return list of rule frames + */ + List parseRuleFrame(); + + /** + * @return IRI for a SWRL variable + * @throws OWLParserException if a parser exception is raised + */ + IRI parseVariable(); + + /** + * Convenience method equivalent to {@code setStringToParse("string"}; parseClassexpression();} + * + * @param s String to parse + * @return parsed class expression + */ + default OWLClassExpression parseClassExpression(String s) { + setStringToParse(s); + return parseClassExpression(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/util/mansyntax/packageinfo b/api/src/main/java/org/semanticweb/owlapi/util/mansyntax/packageinfo new file mode 100644 index 0000000000..8ce0371286 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/mansyntax/packageinfo @@ -0,0 +1 @@ +version 5.0.0 diff --git a/api/src/main/java/org/semanticweb/owlapi/util/package-info.java b/api/src/main/java/org/semanticweb/owlapi/util/package-info.java new file mode 100644 index 0000000000..65891bb4c1 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Utilities package. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.util; diff --git a/api/src/main/java/org/semanticweb/owlapi/util/packageinfo b/api/src/main/java/org/semanticweb/owlapi/util/packageinfo new file mode 100644 index 0000000000..131c449ad4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/util/packageinfo @@ -0,0 +1 @@ +version 7.0.1 diff --git a/api/src/main/java/org/semanticweb/owlapi/utilities/Injector.java b/api/src/main/java/org/semanticweb/owlapi/utilities/Injector.java new file mode 100644 index 0000000000..9fe15cf079 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/utilities/Injector.java @@ -0,0 +1,428 @@ +package org.semanticweb.owlapi.utilities; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.annotation.Annotation; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +import java.lang.reflect.ParameterizedType; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Supplier; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import javax.inject.Qualifier; +import javax.inject.Singleton; + +import org.semanticweb.owlapi.model.OntologyConfigurator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Basic dependency injection utility, to replace the use of Guice and wrap calls to ServiceLoader. + */ +public class Injector { + private static final Logger LOGGER = LoggerFactory.getLogger(Injector.class); + private final Map>> supplierOverrides = + new ConcurrentHashMap<>(16, 0.75F, 1); + private final Map> typesOverrides = new ConcurrentHashMap<>(16, 0.75F, 1); + private final Map>> typesCache = new ConcurrentHashMap<>(16, 0.75F, 1); + + /** + * Key class for caches + * + * @author ignazio + */ + public static class Key { + Class c; + Annotation[] anns; + int hash = 0; + + @Override + public boolean equals(@Nullable Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Key)) { + return false; + } + Key k = (Key) obj; + return Objects.equals(c, k.c) && Arrays.equals(anns, k.anns); + } + + /** + * @param cl class + * @param a annotations + * @return modified key + */ + public Key with(Class cl, Annotation[] a) { + c = cl; + anns = a; + hash = c.hashCode() * 37 + Arrays.hashCode(anns); + return this; + } + + @Override + public int hashCode() { + return hash; + } + } + + /** + * Default constructor + */ + public Injector() {} + + /** + * @param i injector to copy + */ + public Injector(Injector i) { + supplierOverrides.putAll(i.supplierOverrides); + typesOverrides.putAll(i.typesOverrides); + typesCache.putAll(i.typesCache); + + } + + /** + * Associate a key made of interface type and optional annotations with an implementation type + * + * @param t implementation type + * @param c interface type + * @param annotations annotations + * @return modified injector + */ + public Injector bind(Class t, Class c, Annotation... annotations) { + typesOverrides.put(key(c, annotations), t); + return this; + } + + /** + * Associate a key made of interface type and optional annotations with an instance, replacing + * existing associations + * + * @param t instance + * @param c interface type + * @param annotations annotations + * @return modified injector + */ + public Injector bindToOne(Object t, Class c, Annotation... annotations) { + Supplier s = () -> t; + return bindToOne(s, c, annotations); + } + + /** + * Associate a key made of interface type and optional annotations with a supplier of instances, + * replacing existing associations + * + * @param t supplier + * @param c interface type + * @param annotations annotations + * @return modified injector + */ + public Injector bindToOne(Supplier t, Class c, Annotation... annotations) { + supplierOverrides.put(key(c, annotations), Collections.singletonList(t)); + return this; + } + + /** + * Associate a key made of interface type and optional annotations with an instance, adding to + * existing associations + * + * @param type + * @param t instance + * @param c interface type + * @param annotations annotations + * @return modified injector + */ + public Injector bindOneMore(T t, Class c, Annotation... annotations) { + Supplier s = () -> t; + return bindOneMore(s, c, annotations); + } + + /** + * Associate a key made of interface type and optional annotations with a supplier of instances, + * adding to existing associations + * + * @param type + * @param t supplier + * @param c interface type + * @param annotations annotations + * @return modified injector + */ + public Injector bindOneMore(Supplier t, Class c, Annotation... annotations) { + supplierOverrides.computeIfAbsent(key(c, annotations), x -> new ArrayList<>()).add(t); + return this; + } + + protected Object key(Class c, Annotation... annotations) { + if (annotations.length == 0) { + // for input without annotations, use the class as cache key + return c; + } + return new Key().with(c, annotations); + } + + /** + * @param type + * @param t object to inject + * @return input object with all methods annotated with @Inject having been set with instances. + */ + public T inject(T t) { + LOGGER.debug("Injecting object {}", t); + List methodsToInject = new ArrayList<>(); + Class c = t.getClass(); + while (c != null) { + for (Method m : c.getDeclaredMethods()) { + Inject annotation = m.getAnnotation(Inject.class); + if (annotation != null) { + methodsToInject.add(m); + } + } + c = c.getSuperclass(); + } + for (Method m : methodsToInject) { + Parameter[] parameterTypes = m.getParameters(); + Object[] args = new Object[parameterTypes.length]; + for (int i = 0; i < parameterTypes.length; i++) { + Parameter arg = parameterTypes[i]; + Annotation[] qualifiers = qualifiers(arg.getAnnotations()); + if (Collection.class.isAssignableFrom(arg.getType())) { + Class type = (Class) ((ParameterizedType) arg.getParameterizedType()) + .getActualTypeArguments()[0]; + args[i] = load(type, qualifiers).collect(Collectors.toSet()); + } else { + args[i] = load(arg.getType(), qualifiers).findAny().orElse(null); + } + } + try { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Injecting values {} on method {}.", Arrays.toString(args), m); + } + m.invoke(t, args); + } catch (IllegalAccessException | IllegalArgumentException + | InvocationTargetException e) { + LOGGER.error("Injection failed", e); + } + } + return t; + } + + private static Annotation[] qualifiers(Annotation[] anns) { + List qualifiers = new ArrayList<>(); + for (Annotation a : anns) { + if (a instanceof Qualifier + || a.annotationType().getAnnotation(Qualifier.class) != null) { + qualifiers.add(a); + } + } + return qualifiers.toArray(new Qualifier[qualifiers.size()]); + } + + /** + * @param type + * @param c class + * @param qualifiers optional annotations + * @return instance + */ + public T getImplementation(Class c, Annotation... qualifiers) { + return load(c, qualifiers).findAny().orElse(null); + } + + /** + * @param type + * @param c class + * @param v configuration options + * @param qualifiers optional annotations + * @return instance + */ + public T getImplementation(Class c, OntologyConfigurator v, Annotation... qualifiers) { + return new Injector(this).bindToOne(v, OntologyConfigurator.class).getImplementation(c, + qualifiers); + } + + /** + * @param type + * @param c class + * @param overrides local overrides of existing bindings + * @param qualifiers optional annotations + * @return instance + */ + public T getImplementation(Class c, Map>> overrides, + Annotation... qualifiers) { + Injector i = new Injector(this); + overrides.forEach((a, b) -> i.supplierOverrides.put(a, b)); + return i.getImplementation(c, qualifiers); + } + + protected List classLoaders() { + // in OSGi, the context class loader is likely null. + // This would trigger the use of the system class loader, which would + // not see the OWLAPI jar, nor any other jar containing implementations. + // In that case, use this class classloader to load, at a minimum, the + // services provided by the OWLAPI jar itself. + return Arrays.asList(Thread.currentThread().getContextClassLoader(), + ClassLoader.getSystemClassLoader(), getClass().getClassLoader()); + } + + /** + * @param type type to load + * @param qualifiers qualifying annotations + * @param return type + * @return iterable over T implementations + */ + protected Stream load(Class type, Annotation... qualifiers) { + Object key = key(type, qualifiers); + Class c = typesOverrides.get(key); + if (c != null) { + return Stream.of(type.cast(instantiate(c, key))); + } + List> suppliers = supplierOverrides.getOrDefault(key, Collections.emptyList()); + if (!suppliers.isEmpty()) { + // cached suppliers + return suppliers.stream().map(Supplier::get).map(type::cast); + } + List> cached = typesCache.getOrDefault(key, Collections.emptyList()); + if (!cached.isEmpty()) { + return cached.stream().map(s -> instantiate(s, key)).map(type::cast); + } + String name = "META-INF/services/" + type.getName(); + LOGGER.debug("Loading file {}", name); + // J2EE compatible search + return prepareClass(urls(name).flatMap(this::entries).distinct(), key, type) + .map(s -> instantiate(s, key)); + } + + @SuppressWarnings("unchecked") + private static Constructor injectableConstructor(Class c) { + try { + Constructor[] constructors = c.getConstructors(); + if (constructors.length == 1) { + return (Constructor) constructors[0]; + } + Optional> findAny = Arrays.stream(constructors) + .filter(m -> m.getAnnotation(Inject.class) != null).findAny(); + if (!findAny.isPresent()) { + LOGGER.error("No injectable constructor found for {}", c); + } + return (Constructor) findAny.orElse(null); + } catch (SecurityException e) { + LOGGER.error("No injectable constructor found for {} because of security restrictions", + c); + LOGGER.error("Security restriction accessing constructor list", e); + return null; + } + } + + private Object[] paramInstances(Parameter[] params) { + Object[] toReturn = new Object[params.length]; + for (int i = 0; i < toReturn.length; i++) { + Iterator iterator = load(params[i].getType(), params[i].getAnnotations()).iterator(); + if (iterator.hasNext()) { + toReturn[i] = iterator.next(); + } else { + LOGGER.error("No instantiation found for {}", params[i]); + } + } + return toReturn; + } + + @SuppressWarnings("unchecked") + private Stream> prepareClass(Stream types, Object key, + @SuppressWarnings("unused") Class witness) { + List> l = typesCache.get(key); + if (l != null) { + return l.stream().map(x -> (Class) x); + } + List> list = new ArrayList<>(); + try { + Iterator iterator = types.iterator(); + while (iterator.hasNext()) { + list.add((Class) Class.forName(iterator.next())); + } + List> listToCache = new ArrayList<>(list); + typesCache.computeIfAbsent(key, x -> listToCache); + return list.stream(); + } catch (ClassNotFoundException | IllegalArgumentException | SecurityException e) { + LOGGER.error("Instantiation failed", e); + return null; + } + } + + + private T instantiate(Class s, Object key) { + try { + Constructor c = injectableConstructor(s); + if (c == null) { + LOGGER.error("Instantiation failed: no constructors found for {}", s); + return null; + } + Object[] paramInstances = paramInstances(c.getParameters()); + Object newInstance = c.newInstance(paramInstances); + if (s.getAnnotation(Singleton.class) != null) { + // cache singletons for next call + supplierOverrides.put(key, Collections.singletonList(() -> newInstance)); + } + return s.cast(newInstance); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException | SecurityException e) { + LOGGER.error("Instantiation failed", e); + return null; + } + } + + private Stream urls(String name) { + List l = new ArrayList<>(); + try { + for (ClassLoader cl : classLoaders()) { + if (cl != null) { + Enumeration resources = cl.getResources(name); + while (resources.hasMoreElements()) { + URL e = resources.nextElement(); + l.add(e); + LOGGER.debug("Loading URL for service {}", e); + } + } + } + if (l.isEmpty()) { + LOGGER.debug("No files found for {}", name); + } + } catch (IOException e) { + LOGGER.error("Error accessing services files", e); + } + return l.stream(); + } + + private Stream entries(URL c) { + try (InputStream in = c.openStream(); + InputStreamReader in2 = new InputStreamReader(in, StandardCharsets.UTF_8); + BufferedReader r = new BufferedReader(in2)) { + return r.lines().map(String::trim).filter(Injector::notBlankAndNotCmoment) + .collect(Collectors.toList()).stream(); + } catch (IOException e) { + LOGGER.error("Error reading services files: " + c, e); + } + return Stream.empty(); + } + + private static boolean notBlankAndNotCmoment(String s) { + return !s.isEmpty() && !s.startsWith("#"); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/vocab/BuiltInVocabulary.java b/api/src/main/java/org/semanticweb/owlapi/vocab/BuiltInVocabulary.java new file mode 100644 index 0000000000..9fa8ec94ae --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/vocab/BuiltInVocabulary.java @@ -0,0 +1,32 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.vocab; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +public enum BuiltInVocabulary { + /** + * Dublin core. + */ + DUBLIN_CORE, + /** + * SKOS. + */ + SKOS, + /** + * SWRL. + */ + SWRL +} diff --git a/api/src/main/java/org/semanticweb/owlapi/vocab/DublinCoreVocabulary.java b/api/src/main/java/org/semanticweb/owlapi/vocab/DublinCoreVocabulary.java new file mode 100644 index 0000000000..425cf49dac --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/vocab/DublinCoreVocabulary.java @@ -0,0 +1,83 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.vocab; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.HasPrefixedName; +import org.semanticweb.owlapi.model.HasShortForm; +import org.semanticweb.owlapi.model.IRI; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public enum DublinCoreVocabulary implements HasShortForm, HasIRI, HasPrefixedName { +//@formatter:off + /** http://purl.org/dc/elements/1.1/contributor. */ CONTRIBUTOR("contributor"), + /** http://purl.org/dc/elements/1.1/coverage. */ COVERAGE ("coverage" ), + /** http://purl.org/dc/elements/1.1/creator. */ CREATOR ("creator" ), + /** http://purl.org/dc/elements/1.1/date. */ DATE ("date" ), + /** http://purl.org/dc/elements/1.1/description. */ DESCRIPTION("description"), + /** http://purl.org/dc/elements/1.1/format. */ FORMAT ("format" ), + /** http://purl.org/dc/elements/1.1/identifier. */ IDENTIFIER ("identifier" ), + /** http://purl.org/dc/elements/1.1/language. */ LANGUAGE ("language" ), + /** http://purl.org/dc/elements/1.1/publisher. */ PUBLISHER ("publisher" ), + /** http://purl.org/dc/elements/1.1/relation. */ RELATION ("relation" ), + /** http://purl.org/dc/elements/1.1/rights. */ RIGHTS ("rights" ), + /** http://purl.org/dc/elements/1.1/source. */ SOURCE ("source" ), + /** http://purl.org/dc/elements/1.1/subject. */ SUBJECT ("subject" ), + /** http://purl.org/dc/elements/1.1/title. */ TITLE ("title" ), + /** http://purl.org/dc/elements/1.1/type. */ TYPE ("type" ); + //@formatter:on + /** + * Dublin Core name space. + */ + public static final String NAME_SPACE = "http://purl.org/dc/elements/1.1/"; + /** + * All IRIs. + */ + public static final Set ALL_URIS = asSet(Stream.of(values()).map(x -> x.getIRI())); + private final String shortName; + private final String qname; + private final IRI iri; + + DublinCoreVocabulary(String name) { + shortName = name; + qname = Namespaces.DC.getPrefixName() + ':' + name; + iri = IRI.create(NAME_SPACE, name); + } + + @Override + public String getShortForm() { + return shortName; + } + + @Override + public String getPrefixedName() { + return qname; + } + + @Override + public IRI getIRI() { + return iri; + } + + @Override + public String toString() { + return iri.toString(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/vocab/Extensions.java b/api/src/main/java/org/semanticweb/owlapi/vocab/Extensions.java new file mode 100644 index 0000000000..c8a1f82ca6 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/vocab/Extensions.java @@ -0,0 +1,57 @@ +package org.semanticweb.owlapi.vocab; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.OBODocumentFormat; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.model.OWLDocumentFormat; + +/** + * A mapping between some known ontology formats and the common file extensions used for them. This + * mapping is not necessarily complete and file extensions are not mandatory, so do not rely on this + * as a filter to determine what is the format of an input file. + */ +public enum Extensions { + //@formatter:off + /** RDF/XML, common extensions: owl, rdf, rdfs */ RDFXML (RDFXMLDocumentFormat.class, ".owl", ".rdf", ".rdfs"), + /** OWL/XML, common extensions: xml, owl, rdf */ OWLXML (OWLXMLDocumentFormat.class, ".xml", ".owl", ".rdf"), + /** Turtle, common extensions: ttl, owl */ TURTLE (TurtleDocumentFormat.class, ".ttl", ".owl"), + /** OBO, common extensions: obo */ OBO (OBODocumentFormat.class, ".obo"), + /** Manchester OWL syntax, common extensions: omn, owl */ MANCHESTERSYNTAX (ManchesterSyntaxDocumentFormat.class, ".omn", ".owl"), + /** Functional syntax, common extensions: fss, owl */ FUNCTIONALSYNTAX (FunctionalSyntaxDocumentFormat.class, ".fss", ".owl"); + //@formatter:on + + private List extensions; + private Class documentFormat; + + private Extensions(Class d, String... knownExtensions) { + documentFormat = d; + extensions = Arrays.asList(knownExtensions); + } + + /** + * @param format the format for which extensions are desired + * @return common extensions list. Empty list if no matching type is found. + */ + public static Iterable getCommonExtensions(Class format) { + for (Extensions e : values()) { + if (e.documentFormat.equals(format)) { + return e.getCommonExtensions(); + } + } + return Collections.emptyList(); + } + + /** + * @return common extensions for this type + */ + public Iterable getCommonExtensions() { + return extensions; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/vocab/Namespaces.java b/api/src/main/java/org/semanticweb/owlapi/vocab/Namespaces.java new file mode 100644 index 0000000000..87b7ee973f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/vocab/Namespaces.java @@ -0,0 +1,223 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.vocab; + +import static org.semanticweb.owlapi.vocab.Namespaces.BuiltIn.BUILT_IN; +import static org.semanticweb.owlapi.vocab.Namespaces.BuiltIn.NOT_BUILT_IN; +import static org.semanticweb.owlapi.vocab.Namespaces.Status.IN_USE; + +import java.util.EnumSet; + +import org.semanticweb.owlapi.model.IRI; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public enum Namespaces { + //@formatter:off + // OWL2XML("http://www.w3.org/2006/12/owl2-xml#"), + /** The OWL 2 namespace. */ OWL2 ("owl2", "http://www.w3.org/2006/12/owl2#", Status.LEGACY), + /** Status.LEGACY. */ OWL11XML ("owl11xml", "http://www.w3.org/2006/12/owl11-xml#", Status.LEGACY), + /** The OWL 1.1 namespace. */ OWL11 ("owl11", "http://www.w3.org/2006/12/owl11#", Status.LEGACY), + /**The OWL namespace. */ OWL ("owl", "http://www.w3.org/2002/07/owl#", IN_USE), + /**The RDFS namespace. */ RDFS ("rdfs", "http://www.w3.org/2000/01/rdf-schema#", IN_USE), + /** The RDF namespace. */ RDF ("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#", IN_USE), + /** The XSD namespace. */ XSD ("xsd", "http://www.w3.org/2001/XMLSchema#", IN_USE), + /** The XML namespace. */ XML ("xml", "http://www.w3.org/XML/1998/namespace"), + /** The SWRL namespace. */ SWRL ("swrl", "http://www.w3.org/2003/11/swrl#"), + /** The SWRLB namespace. */ SWRLB ("swrlb", "http://www.w3.org/2003/11/swrlb#"), + /** The SKOS namespace. */ SKOS ("skos", "http://www.w3.org/2004/02/skos/core#"), + /** The Time namespace */ TIME ("time", "http://www.w3.org/2006/time#", IN_USE), + + // Further namespaces from the RDFa Core Initial Context + // http://www.w3.org/2011/rdfa-context/rdfa-1.1 + /** The GRDDL namespace. */ GRDDL ("grddl", "http://www.w3.org/2003/g/data-view#"), + /** The MA namespace. */ MA ("ma", "http://www.w3.org/ns/ma-ont#"), + /** The PROV namespace. */ PROV ("prov", "http://www.w3.org/ns/prov#"), + /** The RDFA namespace. */ RDFA ("rdfa", "http://www.w3.org/ns/rdfa#"), + /** The RIF namespace. */ RIF ("rif", "http://www.w3.org/2007/rif#"), + /** The R2RML namespace. */ R2RML ("rr", "http://www.w3.org/ns/r2rml#"), + /** The SD namespace. */ SD ("sd", "http://www.w3.org/ns/sparql-service-description#"), + /** The SKOSXL namespace. */ SKOSXL ("skosxl", "http://www.w3.org/2008/05/skos-xl#"), + /** The POWDER namespace. */ POWDER ("wdr", "http://www.w3.org/2007/05/powder#"), + /** The VOID namespace. */ VOID ("void", "http://rdfs.org/ns/void#"), + /** The POWDERS namespace. */ POWDERS ("wdrs", "http://www.w3.org/2007/05/powder-s#"), + /** The XHV namespace. */ XHV ("xhv", "http://www.w3.org/1999/xhtml/vocab#"), + /** The ORG namespace. */ ORG ("org", "http://www.w3.org/ns/org#"), + /** The GLDP namespace. */ GLDP ("gldp", "http://www.w3.org/ns/people#"), + /** The CNT namespace. */ CNT ("cnt", "http://www.w3.org/2008/content#"), + /** The DCAT namespace. */ DCAT ("dcat", "http://www.w3.org/ns/dcat#"), + /** The EARL namespace. */ EARL ("earl", "http://www.w3.org/ns/earl#"), + /** The HT namespace. */ HT ("ht", "http://www.w3.org/2006/http#"), + /** The PTR namespace. */ PTR ("ptr", "http://www.w3.org/2009/pointers#"), + + // Other widely used Semantic Web prefixes + /** The CC namespace. */ CC ("cc", "http://creativecommons.org/ns#"), + /** The CTAG namespace. */ CTAG ("ctag", "http://commontag.org/ns#"), + /** The DCTERMS namespace. */ DCTERMS ("dcterms", "http://purl.org/dc/terms/"), + /** The DC namespace. */ DC ("dc", "http://purl.org/dc/elements/1.1/"), + /** The FOAF namespace. */ FOAF ("foaf", "http://xmlns.com/foaf/0.1/"), + /** The GR namespace. */ GR ("gr", "http://purl.org/goodrelations/v1#"), + /** The ICAL namespace. */ ICAL ("ical", "http://www.w3.org/2002/12/cal/icaltzd#"), + /** The OG namespace. */ OG ("og", "http://ogp.me/ns#"), + /** The REV namespace. */ REV ("rev", "http://purl.org/stuff/rev#"), + /** The SIOC namespace. */ SIOC ("sioc", "http://rdfs.org/sioc/ns#"), + /** The VCARD namespace. */ VCARD ("vcard", "http://www.w3.org/2006/vcard/ns#"), + /** The SCHEMA namespace. */ SCHEMA ("schema", "http://schema.org/"), + /** The GEO namespace. */ GEO ("geo", "http://www.w3.org/2003/01/geo/wgs84_pos#"), + /** The SC namespace. */ SC ("sc", "http://purl.org/science/owl/sciencecommons/"), + /** The FB namespace. */ FB ("fb", "http://rdf.freebase.com/ns/", Status.LEGACY), + /** The GEONAMES namespace. */ GEONAMES ("geonames", "http://www.geonames.org/ontology#", Status.LEGACY), + + // DBpedia + /** The DBPEDIA namespace. */ DBPEDIA ("dbpedia", "http://dbpedia.org/resource/"), + /** The DBP namespace. */ DBP ("dbp", "http://dbpedia.org/property/"), + /** The DBO namespace. */ DBO ("dbo", "http://dbpedia.org/ontology/"), + /** The YAGO namespace. */ YAGO ("yago", "http://dbpedia.org/class/yago/"); + //@formatter:on + /** + * Ignored imports. + */ + public static final EnumSet defaultIgnoredImports = + EnumSet.of(OWL, RDF, RDFS, SWRL, SWRLB, XML, XSD); + final Status status; + final BuiltIn builtIn; + final String hashless; + private final String prefix; + private final String ns; + + Namespaces(String prefix, String ns) { + this(prefix, ns, IN_USE, NOT_BUILT_IN); + } + + Namespaces(String prefix, String ns, Status status) { + this(prefix, ns, status, status == Status.LEGACY ? NOT_BUILT_IN : BUILT_IN); + } + + Namespaces(String prefix, String ns, Status status, BuiltIn builtIn) { + this.prefix = prefix; + this.ns = ns; + this.status = status; + this.builtIn = builtIn; + hashless = hashless(prefix); + } + + /** + * @param ns namespace + * @return this namespace without hash or slash at the end + */ + private static String hashless(String ns) { + int index = ns.length() - 1; + if (ns.charAt(index) == '/' || ns.charAt(index) == '#') { + return ns.substring(0, index); + } + return ns; + } + + /** + * @param i the iri to check + * @return true if the iri is for a namespace ignored by default + */ + public static boolean isDefaultIgnoredImport(IRI i) { + return defaultIgnoredImports.stream().anyMatch(n -> n.hashless.equals(i.toString())); + } + + /** + * @param i the string to check + * @return true if the string is for a namespace ignored by default + */ + public static boolean isDefaultIgnoredImport(String i) { + return defaultIgnoredImports.stream().anyMatch(n -> n.hashless.equals(i)); + } + + /** + * @return A short, human-readable, prefix name that matches, and expands to the full IRI. + */ + public String getPrefixName() { + return prefix; + } + + /** + * @return The prefix IRI which matches the prefix name. + */ + public String getPrefixIRI() { + return ns; + } + + /** + * @return {@code true} if this namespace is not obsolete and is currently in active use, + * otherwise {@code false}. + */ + public boolean isInUse() { + return status == IN_USE; + } + + /** + * @return {@code true} if this namespace is defined as a core part of the OWL-2 specification, + * otherwise {@code false}. + */ + public boolean isBuiltIn() { + return builtIn == BUILT_IN; + } + + @Override + public String toString() { + return ns; + } + + /** + * @param s string to check + * @return true if s equals this namespace + */ + public boolean inNamespace(String s) { + return ns.equals(s); + } + + /** + * @param i iri to check + * @return true if the namespace for i equals this namespace + */ + public boolean inNamespace(IRI i) { + return ns.equals(i.getNamespace()); + } + + /** + * Indicates that a prefix is builtin - i.e. that it is either {@code owl}, {@code rdf}, + * {@code rdfs}, or {@code xsd} + */ + public enum BuiltIn { + /** + * built in flag. + */ + BUILT_IN, + /** + * not built in flag. + */ + NOT_BUILT_IN + } + + /** + * Indicates whether a prefix is a legacy prefix or not. + */ + public enum Status { + /** + * legacy flag. + */ + LEGACY, + /** + * in use flag. + */ + IN_USE + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/vocab/OWL2Datatype.java b/api/src/main/java/org/semanticweb/owlapi/vocab/OWL2Datatype.java new file mode 100644 index 0000000000..ca37b424a4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/vocab/OWL2Datatype.java @@ -0,0 +1,444 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.vocab; + +import static org.semanticweb.owlapi.util.CollectionFactory.createSet; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asMap; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; +import static org.semanticweb.owlapi.vocab.Namespaces.OWL; +import static org.semanticweb.owlapi.vocab.Namespaces.RDF; +import static org.semanticweb.owlapi.vocab.Namespaces.RDFS; +import static org.semanticweb.owlapi.vocab.OWLFacet.LANG_RANGE; +import static org.semanticweb.owlapi.vocab.OWLFacet.LENGTH; +import static org.semanticweb.owlapi.vocab.OWLFacet.MAX_EXCLUSIVE; +import static org.semanticweb.owlapi.vocab.OWLFacet.MAX_INCLUSIVE; +import static org.semanticweb.owlapi.vocab.OWLFacet.MAX_LENGTH; +import static org.semanticweb.owlapi.vocab.OWLFacet.MIN_EXCLUSIVE; +import static org.semanticweb.owlapi.vocab.OWLFacet.MIN_INCLUSIVE; +import static org.semanticweb.owlapi.vocab.OWLFacet.MIN_LENGTH; +import static org.semanticweb.owlapi.vocab.OWLFacet.PATTERN; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.ANY_URI; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.BASE_64_BINARY; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.BOOLEAN; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.BYTE; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.DATE_TIME; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.DATE_TIME_STAMP; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.DECIMAL; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.DOUBLE; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.FLOAT; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.HEX_BINARY; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.INT; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.INTEGER; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.LANGUAGE; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.LONG; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.NAME; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.NCNAME; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.NEGATIVE_INTEGER; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.NMTOKEN; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.NON_NEGATIVE_INTEGER; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.NON_POSITIVE_INTEGER; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.NORMALIZED_STRING; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.POSITIVE_INTEGER; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.SHORT; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.STRING; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.TOKEN; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.UNSIGNED_BYTE; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.UNSIGNED_INT; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.UNSIGNED_LONG; +import static org.semanticweb.owlapi.vocab.XSDVocabulary.UNSIGNED_SHORT; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Pattern; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.HasPrefixedName; +import org.semanticweb.owlapi.model.HasShortForm; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.model.providers.DatatypeProvider; + +class DatatypeRegexp { + static final String ANY = ".*"; + static final String NUMBER = "(\\+|-)?([0-9]+)(\\s)*(/)(\\s)*([0-9]+)"; + static final String NO_LINES = "([^\\r\\n\\t])*"; + static final String INTNUMBER = "(\\+|-)?([0-9]+)"; + static final String INTNOSIGN = "(\\+)?([0-9]+)"; + static final String NEGINT = "-(0*[1-9][0-9]*)"; + static final String POSINT = "(\\+)?(0*[1-9][0-9]*)"; + static final String DECNUMBER = "(\\+|-)?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)"; + static final String NONNEG = "((\\+)?([0-9]+))|-(0+)"; + static final String NONPOS = "-([0-9]+)|(\\+?(0+))"; + static final String XSTRING = "([^\\s])(\\s([^\\s])|([^\\s]))*"; + static final String XLANG = "[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*"; + static final String NAME1 = + "[A-Z]|_|[a-z]|[\\u00C0-\\u00D6]|[\\u00D8-\\u00F6]|[\\u00F8-\\u02FF]|[\\u0370-\\u037D]|[\\u037F-\\u1FFF]|[\\u200C-\\u200D]|[\\u2070-\\u218F]|[\\u2C00-\\u2FEF]|[\\u3001-\\uD7FF]|[\\uF900-\\uFDCF]|[\\uFDF0-\\uFFFD]"; + static final String NAME2 = + "[A-Z]|_|[a-z]|[\\u00C0-\\u00D6]|[\\u00D8-\\u00F6]|[\\u00F8-\\u02FF]|[\\u0370-\\u037D]|[\\u037F-\\u1FFF]|[\\u200C-\\u200D]|[\\u2070-\\u218F]|[\\u2C00-\\u2FEF]|[\\u3001-\\uD7FF]|[\\uF900-\\uFDCF]|[\\uFDF0-\\uFFFD]|\"-\"|\".\"|[0-9]|\\u00B7|[\\u0300-\\u036F]|[\\u203F-\\u2040]"; + static final String XDOUBLE = + "(\\+|-)?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([Ee](\\+|-)?[0-9]+)?|(\\+|-)?INF|NaN"; + static final String TSTAMP = + "-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?|(24:00:00(\\.0+)?))(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))"; + static final String BOOL = "true|false|1|0"; + static final String HEX = "([0-9a-fA-F]{2})*"; + static final String B64 = + "((([A-Za-z0-9+/] ?){4})*(([A-Za-z0-9+/] ?){3}[A-Za-z0-9+/]|([A-Za-z0-9+/] ?){2}[AEIMQUYcgkosw048] ?=|[A-Za-z0-9+/] ?[AQgw] ?= ?=))?"; + + private DatatypeRegexp() {} +} + + +/** + * An enumeration of the datatypes in the OWL 2 specification. These are the datatypes in the OWL 2 + * datatype map. + * + * @author Matthew Horridge, The University Of Manchester, Information Management Group + * @since 2.2.0 + */ +public enum OWL2Datatype implements HasIRI, HasShortForm, HasPrefixedName { +//@formatter:off + /** RDF_XML_LITERAL. */ RDF_XML_LITERAL (RDF, "XMLLiteral", Category.CAT_STRING_WITHOUT_LANGUAGE_TAG, false, DatatypeRegexp.ANY), + /** RDFS_LITERAL. */ RDFS_LITERAL (RDFS, "Literal", Category.CAT_UNIVERSAL, false, DatatypeRegexp.ANY), + /** RDF_PLAIN_LITERAL. */ RDF_PLAIN_LITERAL (RDF, "PlainLiteral", Category.CAT_STRING_WITH_LANGUAGE_TAG, false, DatatypeRegexp.ANY), + /** RDF_LANG_STRING. */ RDF_LANG_STRING (RDF, "langString", Category.CAT_STRING_WITHOUT_LANGUAGE_TAG, false, DatatypeRegexp.ANY), + /** OWL_REAL. */ OWL_REAL (OWL, "real", Category.CAT_NUMBER, false, DatatypeRegexp.ANY), + /** OWL_RATIONAL. */ OWL_RATIONAL (OWL, "rational", Category.CAT_NUMBER, false, DatatypeRegexp.NUMBER), + /** XSD_STRING. */ XSD_STRING (STRING, Category.CAT_STRING_WITHOUT_LANGUAGE_TAG, false, DatatypeRegexp.ANY), + /** XSD_NORMALIZED_STRING. */ XSD_NORMALIZED_STRING (NORMALIZED_STRING, Category.CAT_STRING_WITHOUT_LANGUAGE_TAG, false, DatatypeRegexp.NO_LINES), + /** XSD_TOKEN. */ XSD_TOKEN (TOKEN, Category.CAT_STRING_WITHOUT_LANGUAGE_TAG, false, DatatypeRegexp.XSTRING), + /** XSD_LANGUAGE. */ XSD_LANGUAGE (LANGUAGE, Category.CAT_STRING_WITHOUT_LANGUAGE_TAG, true, DatatypeRegexp.XLANG), + /** XSD_NAME. */ XSD_NAME (NAME, Category.CAT_STRING_WITHOUT_LANGUAGE_TAG, false, ":|"+DatatypeRegexp.NAME1+"(:|"+DatatypeRegexp.NAME2+")*"), + /** XSD_NCNAME. */ XSD_NCNAME (NCNAME, Category.CAT_STRING_WITHOUT_LANGUAGE_TAG, false, DatatypeRegexp.NAME1+ "("+DatatypeRegexp.NAME2+")*"), + /** XSD_NMTOKEN. */ XSD_NMTOKEN (NMTOKEN, Category.CAT_STRING_WITHOUT_LANGUAGE_TAG, false, DatatypeRegexp.ANY), + /** XSD_DECIMAL. */ XSD_DECIMAL (DECIMAL, Category.CAT_NUMBER, false, DatatypeRegexp.DECNUMBER), + /** XSD_INTEGER. */ XSD_INTEGER (INTEGER, Category.CAT_NUMBER, false, DatatypeRegexp.INTNUMBER), + /** XSD_NON_NEGATIVE_INTEGER. */ XSD_NON_NEGATIVE_INTEGER (NON_NEGATIVE_INTEGER, Category.CAT_NUMBER, false, DatatypeRegexp.NONNEG), + /** XSD_NON_POSITIVE_INTEGER. */ XSD_NON_POSITIVE_INTEGER (NON_POSITIVE_INTEGER, Category.CAT_NUMBER, false, DatatypeRegexp.NONPOS), + /** XSD_POSITIVE_INTEGER. */ XSD_POSITIVE_INTEGER (POSITIVE_INTEGER, Category.CAT_NUMBER, false, DatatypeRegexp.POSINT), + /** XSD_NEGATIVE_INTEGER. */ XSD_NEGATIVE_INTEGER (NEGATIVE_INTEGER, Category.CAT_NUMBER, false, DatatypeRegexp.NEGINT), + /** XSD_LONG. */ XSD_LONG (LONG, Category.CAT_NUMBER, true, DatatypeRegexp.INTNUMBER), + /** XSD_INT. */ XSD_INT (INT, Category.CAT_NUMBER, true, DatatypeRegexp.INTNUMBER), + /** XSD_SHORT. */ XSD_SHORT (SHORT, Category.CAT_NUMBER, true, DatatypeRegexp.INTNUMBER), + /** XSD_BYTE. */ XSD_BYTE (BYTE, Category.CAT_NUMBER, true, DatatypeRegexp.INTNUMBER), + /** XSD_UNSIGNED_LONG. */ XSD_UNSIGNED_LONG (UNSIGNED_LONG, Category.CAT_NUMBER, true, DatatypeRegexp.INTNOSIGN), + /** XSD_UNSIGNED_INT. */ XSD_UNSIGNED_INT (UNSIGNED_INT, Category.CAT_NUMBER, true, DatatypeRegexp.INTNOSIGN), + /** XSD_UNSIGNED_SHORT. */ XSD_UNSIGNED_SHORT (UNSIGNED_SHORT, Category.CAT_NUMBER, true, DatatypeRegexp.INTNOSIGN), + /** XSD_UNSIGNED_BYTE. */ XSD_UNSIGNED_BYTE (UNSIGNED_BYTE, Category.CAT_NUMBER, true, DatatypeRegexp.INTNOSIGN), + /** XSD_DOUBLE. */ XSD_DOUBLE (DOUBLE, Category.CAT_NUMBER, true, DatatypeRegexp.XDOUBLE), + /** XSD_FLOAT. */ XSD_FLOAT (FLOAT, Category.CAT_NUMBER, true, DatatypeRegexp.XDOUBLE), + /** XSD_BOOLEAN. */ XSD_BOOLEAN (BOOLEAN, Category.CAT_BOOLEAN, true, DatatypeRegexp.BOOL), + /** XSD_HEX_BINARY. */ XSD_HEX_BINARY (HEX_BINARY, Category.CAT_BINARY, false, DatatypeRegexp.HEX), + /** XSD_BASE_. */ XSD_BASE_64_BINARY (BASE_64_BINARY, Category.CAT_BINARY, false, DatatypeRegexp.B64), + /** XSD_ANY_URI. */ XSD_ANY_URI (ANY_URI, Category.CAT_URI, false, DatatypeRegexp.ANY), + /** XSD_DATE_TIME. */ XSD_DATE_TIME (DATE_TIME, Category.CAT_TIME, false, DatatypeRegexp.TSTAMP+"?"), + /** XSD_DATE_TIME_STAMP. */ XSD_DATE_TIME_STAMP (DATE_TIME_STAMP, Category.CAT_TIME, false, DatatypeRegexp.TSTAMP); +//@formatter:on + + /** + * Datatypes allowed in the EL and QL profiles. + */ + public static final List EL_DATATYPES = + Arrays.asList(RDF_PLAIN_LITERAL, RDF_XML_LITERAL, RDFS_LITERAL, OWL_RATIONAL, OWL_REAL, + XSD_DECIMAL, XSD_INTEGER, XSD_NON_NEGATIVE_INTEGER, XSD_STRING, XSD_NORMALIZED_STRING, + XSD_TOKEN, XSD_NAME, XSD_NCNAME, XSD_NMTOKEN, XSD_HEX_BINARY, XSD_BASE_64_BINARY, + XSD_ANY_URI, XSD_DATE_TIME, XSD_DATE_TIME_STAMP); + /** + * Datatypes supported in the RL profile. + */ + public static final List RL_DATATYPES = + Arrays.asList(RDF_PLAIN_LITERAL, RDF_XML_LITERAL, RDFS_LITERAL, XSD_DECIMAL, XSD_INTEGER, + XSD_NON_NEGATIVE_INTEGER, XSD_NON_POSITIVE_INTEGER, XSD_POSITIVE_INTEGER, + XSD_NEGATIVE_INTEGER, XSD_LONG, XSD_INT, XSD_SHORT, XSD_BYTE, XSD_UNSIGNED_LONG, + XSD_UNSIGNED_BYTE, XSD_FLOAT, XSD_DOUBLE, XSD_STRING, XSD_NORMALIZED_STRING, XSD_TOKEN, + XSD_LANGUAGE, XSD_NAME, XSD_NCNAME, XSD_NMTOKEN, XSD_BOOLEAN, XSD_HEX_BINARY, + XSD_BASE_64_BINARY, XSD_ANY_URI, XSD_DATE_TIME, XSD_DATE_TIME_STAMP); + + private static final Map ALL_IRIS = asMap(stream(), HasIRI::getIRI); + private final String shortForm; + private final IRI iri; + private final Category category; + private final boolean finite; + private final Pattern pattern; + private final String regExpression; + private final String prefixedName; + + OWL2Datatype(Namespaces namespace, String shortForm, Category category, boolean finite, + String regEx) { + iri = IRI.create(namespace.toString(), shortForm); + this.shortForm = shortForm; + prefixedName = namespace.getPrefixName() + ':' + shortForm; + this.category = category; + this.finite = finite; + regExpression = regEx; + pattern = Pattern.compile(regEx, Pattern.DOTALL); + } + + OWL2Datatype(XSDVocabulary xsd, Category category, boolean finite, String regEx) { + iri = xsd.getIRI(); + shortForm = xsd.getShortForm(); + prefixedName = xsd.getPrefixedName(); + this.category = category; + this.finite = finite; + regExpression = regEx; + pattern = Pattern.compile(regEx, Pattern.DOTALL); + } + + private static Stream stream() { + return Stream.of(values()); + } + + /** + * Gets all of the built in datatype IRIs. + * + * @return A set of IRIs corresponding to the set of IRIs of all built in {@code OWL2Datatype}s. + */ + public static Set getDatatypeIRIs() { + return ALL_IRIS.keySet(); + } + + /** + * Determines if the specified IRI identifies a built in datatype. + * + * @param datatypeIRI The datatype IRI + * @return {@code true} if the IRI identifies a built in datatype, or {@code false} if the IRI + * does not identify a built in datatype. + */ + public static boolean isBuiltIn(IRI datatypeIRI) { + return ALL_IRIS.containsKey(datatypeIRI); + } + + /** + * Given an IRI that identifies an {@link OWLDatatype}, this method obtains the corresponding + * {@code OWL2Datatype}. + * + * @param datatype The datatype IRI. Not {@code null}. + * @return The {@code OWL2Datatype} that has the specified {@link IRI}. + * @throws OWLRuntimeException if the specified IRI is not a built in datatype IRI. + */ + public static OWL2Datatype getDatatype(IRI datatype) { + OWL2Datatype knownDatatype = ALL_IRIS.get(datatype); + if (knownDatatype == null) { + throw new OWLRuntimeException(datatype + " is not a built in datatype!"); + } + return knownDatatype; + } + + /** + * Given an IRI that identifies an {@link OWLDatatype}, this method obtains the corresponding + * {@code OWL2Datatype}. + * + * @param datatype The datatype IRI. Not {@code null}. + * @return The {@code OWL2Datatype} that has the specified {@link IRI}. + * @throws OWLRuntimeException if the specified IRI is not a built in datatype IRI. + */ + public static OWL2Datatype getDatatype(HasIRI datatype) { + return getDatatype(datatype.getIRI()); + } + + /** + * Gets the Pattern that specifies the regular expression for the allowed lexical values of a + * datatype. + * + * @return The Pattern, or {@code null} + */ + public Pattern getPattern() { + return pattern; + } + + /** + * Gets the Pattern string that specifies the regular expression for the allowed lexical values + * of a datatype. + * + * @return The Pattern string. Not null. + */ + public String getPatternString() { + return regExpression; + } + + @Override + public String getShortForm() { + return shortForm; + } + + @Override + public IRI getIRI() { + return iri; + } + + /** + * Gets the category for this datatype. + * + * @return The category + */ + public Category getCategory() { + return category; + } + + /** + * Determines if this datatype is a numeric datatype. + * + * @return {@code true} if this datatype is a numeric datatype + */ + public boolean isNumeric() { + return category.equals(Category.CAT_NUMBER); + } + + /** + * Determines whether or not this datatype is finite. + * + * @return {@code true} if this datatype is finite, or {@code false} if this datatype is + * infinite. + */ + public boolean isFinite() { + return finite; + } + + /** + * Gets the facets that are allowed for facet restrictions of this datatype. + * + * @return The allowed facets + */ + public Collection getFacets() { + return category.getFacets(); + } + + /** + * Gets the equivalent OWLDatatype from the given factory. + * + * @param factory the OWLDataFactory. + * @return An {@link OWLDatatype} that has the same IRI as this {@code OWL2Datatype}. + */ + public OWLDatatype getDatatype(DatatypeProvider factory) { + checkNotNull(factory, "factory cannot be null"); + return factory.getOWLDatatype(this); + } + + /** + * Determines if the specified string is the lexical space of this datatype. + * + * @param s The string to test + * @return {@code true} if the string is in the lexical space, otherwise {@code false} + */ + public boolean isInLexicalSpace(String s) { + return pattern.matcher(s).matches(); + } + + @Override + public String getPrefixedName() { + return prefixedName; + } + + /** + * @param e entity to check + * @return true if the entity and the enum value have the same IRI + */ + public boolean matches(OWLEntity e) { + return e.getIRI().equals(iri); + } + + /** + * Category enum. + */ + public enum Category { + //@formatter:off + /** NUMBER. */ CAT_NUMBER ("Number", MIN_INCLUSIVE, MAX_INCLUSIVE, MIN_EXCLUSIVE, MAX_EXCLUSIVE), + /** STRING_WITH_LANGUAGE_TAG. */ CAT_STRING_WITH_LANGUAGE_TAG ("String with a language tag", MIN_LENGTH, MAX_LENGTH, LENGTH, PATTERN, LANG_RANGE), + /** STRING_WITHOUT_LANGUAGE_TAG. */ CAT_STRING_WITHOUT_LANGUAGE_TAG("String without a language tag", MIN_LENGTH, MAX_LENGTH, LENGTH, PATTERN), + /** BINARY. */ CAT_BINARY ("Binary data", MIN_LENGTH, MAX_LENGTH, LENGTH), + /** URI. */ CAT_URI ("URI", MIN_LENGTH, MAX_LENGTH, PATTERN), + /** TIME. */ CAT_TIME ("Time instant", MIN_INCLUSIVE, MAX_INCLUSIVE, MIN_EXCLUSIVE, MAX_EXCLUSIVE), + /** BOOLEAN. */ CAT_BOOLEAN ("Boolean value"), + /** UNIVERSAL. */ CAT_UNIVERSAL ("Universal literal"); + //@formatter:on + private final String name; + private final Set facets; + + Category(String name, OWLFacet... facets) { + this.name = name; + this.facets = createSet(facets); + } + + /** + * @return name + */ + public String getName() { + return name; + } + + /** + * @return Facets. The set that is returned is a copy; modifications to the returned set + * will not be reflected in this object. + */ + public Set getFacets() { + return asSet(facets()); + } + + /** + * @return facets stream + */ + public Stream facets() { + return facets.stream(); + } + } + + /** + * Normalization enum. + */ + public enum WhiteSpaceNormalisation { + /** + * No normalization is done, the value is not changed (this is the behavior required by + * [XML] for element content). + */ + PRESERVE { + @Override + public String getNormalisedString(String s) { + return s; + } + }, + /** + * All occurrences of #x9 (tab), #xA (line feed) and #xD (carriage return) are replaced with + * #x20 (space). + */ + REPLACE { + @Override + public String getNormalisedString(String s) { + return s.replaceAll("\\t|\\n|\\r", " "); + } + }, + /** + * After the processing implied by replace, contiguous sequences of #x20's are collapsed to + * a single #x20, and any #x20 at the start or end of the string is then removed. + */ + COLLAPSE { + @Override + public String getNormalisedString(String s) { + return REPLACE.getNormalisedString(s).replaceAll("\\s+", " ").trim(); + } + }; + + /** + * Gets the normalised version of a string. + * + * @param s The string to normalise + * @return The normalised string + */ + public abstract String getNormalisedString(String s); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/vocab/OWLFacet.java b/api/src/main/java/org/semanticweb/owlapi/vocab/OWLFacet.java new file mode 100644 index 0000000000..c26edb1eba --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/vocab/OWLFacet.java @@ -0,0 +1,145 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.vocab; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asMap; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Map; +import java.util.Set; +import java.util.stream.Stream; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.HasPrefixedName; +import org.semanticweb.owlapi.model.HasShortForm; +import org.semanticweb.owlapi.model.IRI; + +/** + * Represents the facets that can be used for restricting a datatype. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @see org.semanticweb.owlapi.model.OWLFacetRestriction + * @see org.semanticweb.owlapi.model.OWLDatatypeRestriction + * @since 2.0.0 + */ +public enum OWLFacet implements HasShortForm, HasIRI, HasPrefixedName { +//@formatter:off + /** LENGTH. */ LENGTH (Namespaces.XSD, "length", "length"), + /** MIN_LENGTH. */ MIN_LENGTH (Namespaces.XSD, "minLength", "minLength"), + /** MAX_LENGTH. */ MAX_LENGTH (Namespaces.XSD, "maxLength", "maxLength"), + /** PATTERN. */ PATTERN (Namespaces.XSD, "pattern", "pattern"), + /** MIN_INCLUSIVE. */ MIN_INCLUSIVE (Namespaces.XSD, "minInclusive", ">="), + /** MIN_EXCLUSIVE. */ MIN_EXCLUSIVE (Namespaces.XSD, "minExclusive", ">"), + /** MAX_INCLUSIVE. */ MAX_INCLUSIVE (Namespaces.XSD, "maxInclusive", "<="), + /** MAX_EXCLUSIVE. */ MAX_EXCLUSIVE (Namespaces.XSD, "maxExclusive", "<"), + /** TOTAL_DIGITS. */ TOTAL_DIGITS (Namespaces.XSD, "totalDigits", "totalDigits"), + /** FRACTION_DIGITS. */ FRACTION_DIGITS (Namespaces.XSD, "fractionDigits", "fractionDigits"), + /** LANG_RANGE. */ LANG_RANGE (Namespaces.RDF, "langRange", "langRange"); +//@formatter:on + /** + * All facet iris. + */ + public static final Map FACET_IRIS = asMap(stream(), HasIRI::getIRI); + private final IRI iri; + private final String shortForm; + private final String symbolicForm; + private final String prefixedName; + + OWLFacet(Namespaces ns, String shortForm, String symbolicForm) { + iri = IRI.create(ns.toString(), shortForm); + this.shortForm = shortForm; + this.symbolicForm = symbolicForm; + prefixedName = ns.getPrefixName() + ':' + shortForm; + } + + private static Stream stream() { + return Stream.of(values()); + } + + /** + * @return all facet iris + */ + public static Set getFacetIRIs() { + return FACET_IRIS.keySet(); + } + + /** + * @param iri facet IRI + * @return facet for iri + */ + public static OWLFacet getFacet(IRI iri) { + checkNotNull(iri, "iri cannot be null"); + OWLFacet facet = FACET_IRIS.get(iri); + if (facet == null) { + throw new IllegalArgumentException("Unknown facet: " + iri); + } + return facet; + } + + /** + * Gets a facet by its short name. + * + * @param shortName The short name of the facet. + * @return The facet or {@code null} if not facet by the specified name exists. + */ + @Nullable + public static OWLFacet getFacetByShortName(String shortName) { + checkNotNull(shortName); + return stream().filter(v -> v.getShortForm().equals(shortName)).findAny().orElse(null); + } + + /** + * @param symbolicName symbolic name for facet + * @return facet for name + */ + @Nullable + public static OWLFacet getFacetBySymbolicName(String symbolicName) { + return stream().filter(v -> v.getSymbolicForm().equals(symbolicName)).findAny() + .orElse(null); + } + + /** + * @return all facets + */ + public static Set getFacets() { + return asSet(stream().map(v -> v.getSymbolicForm())); + } + + @Override + public String getShortForm() { + return shortForm; + } + + @Override + public IRI getIRI() { + return iri; + } + + /** + * @return symbolic form + */ + public String getSymbolicForm() { + return symbolicForm; + } + + @Override + public String toString() { + return getShortForm(); + } + + @Override + public String getPrefixedName() { + return prefixedName; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/vocab/OWLRDFVocabulary.java b/api/src/main/java/org/semanticweb/owlapi/vocab/OWLRDFVocabulary.java new file mode 100644 index 0000000000..160f59fe32 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/vocab/OWLRDFVocabulary.java @@ -0,0 +1,214 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.vocab; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.HasPrefixedName; +import org.semanticweb.owlapi.model.HasShortForm; +import org.semanticweb.owlapi.model.IRI; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public enum OWLRDFVocabulary implements HasShortForm, HasIRI, HasPrefixedName { +//@formatter:off + // OWL Vocab + /** http://www.w3.org/2002/07/owl#Thing. */ OWL_THING(Namespaces.OWL, "Thing"), + /** http://www.w3.org/2002/07/owl#Nothing. */ OWL_NOTHING(Namespaces.OWL, "Nothing"), + /** http://www.w3.org/2002/07/owl#Class. */ OWL_CLASS(Namespaces.OWL, "Class"), + /** http://www.w3.org/2002/07/owl#Ontology. */ OWL_ONTOLOGY(Namespaces.OWL, "Ontology"), + /** http://www.w3.org/2002/07/owl#imports. */ OWL_IMPORTS(Namespaces.OWL, "imports"), + /** http://www.w3.org/2002/07/owl#versionIRI. */ OWL_VERSION_IRI(Namespaces.OWL, "versionIRI"), + /** http://www.w3.org/2002/07/owl#versionInfo. */ OWL_VERSION_INFO(Namespaces.OWL, "versionInfo"), + /** http://www.w3.org/2002/07/owl#equivalentClass. */ OWL_EQUIVALENT_CLASS(Namespaces.OWL, "equivalentClass"), + /** http://www.w3.org/2002/07/owl#ObjectProperty. */ OWL_OBJECT_PROPERTY(Namespaces.OWL, "ObjectProperty"), + /** http://www.w3.org/2002/07/owl#DatatypeProperty. */ OWL_DATA_PROPERTY(Namespaces.OWL, "DatatypeProperty"), + /** http://www.w3.org/2002/07/owl#FunctionalProperty. */ OWL_FUNCTIONAL_PROPERTY(Namespaces.OWL, "FunctionalProperty"), + /** http://www.w3.org/2002/07/owl#AsymmetricProperty. */ OWL_ASYMMETRIC_PROPERTY(Namespaces.OWL, "AsymmetricProperty"), + /** http://www.w3.org/2002/07/owl#SymmetricProperty. */ OWL_SYMMETRIC_PROPERTY(Namespaces.OWL, "SymmetricProperty"), + /** http://www.w3.org/2002/07/owl#Restriction. */ OWL_RESTRICTION(Namespaces.OWL, "Restriction"), + /** http://www.w3.org/2002/07/owl#onProperty. */ OWL_ON_PROPERTY(Namespaces.OWL, "onProperty"), + /** http://www.w3.org/2002/07/owl#intersectionOf. */ OWL_INTERSECTION_OF(Namespaces.OWL, "intersectionOf"), + /** http://www.w3.org/2002/07/owl#unionOf. */ OWL_UNION_OF(Namespaces.OWL, "unionOf"), + /** http://www.w3.org/2002/07/owl#allValuesFrom. */ OWL_ALL_VALUES_FROM(Namespaces.OWL, "allValuesFrom"), + /** http://www.w3.org/2002/07/owl#someValuesFrom. */ OWL_SOME_VALUES_FROM(Namespaces.OWL, "someValuesFrom"), + /** http://www.w3.org/2002/07/owl#hasValue. */ OWL_HAS_VALUE(Namespaces.OWL, "hasValue"), + /** http://www.w3.org/2002/07/owl#disjointWith. */ OWL_DISJOINT_WITH(Namespaces.OWL, "disjointWith"), + /** http://www.w3.org/2002/07/owl#oneOf. */ OWL_ONE_OF(Namespaces.OWL, "oneOf"), + /** http://www.w3.org/2002/07/owl#hasSelf. */ OWL_HAS_SELF(Namespaces.OWL, "hasSelf"), + /** http://www.w3.org/2002/07/owl#disjointUnionOf. */ OWL_DISJOINT_UNION_OF(Namespaces.OWL, "disjointUnionOf"), + /** http://www.w3.org/2002/07/owl#minCardinality. */ OWL_MIN_CARDINALITY(Namespaces.OWL, "minCardinality"), + /** http://www.w3.org/2002/07/owl#cardinality. */ OWL_CARDINALITY(Namespaces.OWL, "cardinality"), + /** http://www.w3.org/2002/07/owl#qualifiedCardinality. */ OWL_QUALIFIED_CARDINALITY(Namespaces.OWL, "qualifiedCardinality"), + /** http://www.w3.org/2002/07/owl#AnnotationProperty. */ OWL_ANNOTATION_PROPERTY(Namespaces.OWL, "AnnotationProperty"), + /** http://www.w3.org/2002/07/owl#Annotation. */ OWL_ANNOTATION(Namespaces.OWL, "Annotation"), + /** http://www.w3.org/2002/07/owl#Individual. */ OWL_INDIVIDUAL(Namespaces.OWL, "Individual"), + /** http://www.w3.org/2002/07/owl#NamedIndividual. */ OWL_NAMED_INDIVIDUAL(Namespaces.OWL, "NamedIndividual"), + /** http://www.w3.org/2002/07/owl#Datatype. */ OWL_DATATYPE(Namespaces.OWL, "Datatype"), + /** http://www.w3.org/2000/01/rdf-schema#subClassOf. */ RDFS_SUBCLASS_OF(Namespaces.RDFS, "subClassOf"), + /** http://www.w3.org/2000/01/rdf-schema#subPropertyOf. */ RDFS_SUB_PROPERTY_OF(Namespaces.RDFS, "subPropertyOf"), + /** http://www.w3.org/1999/02/22-rdf-syntax-ns#type. */ RDF_TYPE(Namespaces.RDF, "type"), + /** http://www.w3.org/1999/02/22-rdf-syntax-ns#nil. */ RDF_NIL(Namespaces.RDF, "nil"), + /** http://www.w3.org/1999/02/22-rdf-syntax-ns#rest. */ RDF_REST(Namespaces.RDF, "rest"), + /** http://www.w3.org/1999/02/22-rdf-syntax-ns#first. */ RDF_FIRST(Namespaces.RDF, "first"), + /** http://www.w3.org/1999/02/22-rdf-syntax-ns#List. */ RDF_LIST(Namespaces.RDF, "List"), + /** http://www.w3.org/2002/07/owl#maxCardinality. */ OWL_MAX_CARDINALITY(Namespaces.OWL, "maxCardinality"), + /** http://www.w3.org/2000/01/rdf-schema#label. */ RDFS_LABEL(Namespaces.RDFS, "label"), + /** http://www.w3.org/2000/01/rdf-schema#comment. */ RDFS_COMMENT(Namespaces.RDFS, "comment"), + /** http://www.w3.org/2000/01/rdf-schema#seeAlso. */ RDFS_SEE_ALSO(Namespaces.RDFS, "seeAlso"), + /** http://www.w3.org/2000/01/rdf-schema#isDefinedBy. */ RDFS_IS_DEFINED_BY(Namespaces.RDFS, "isDefinedBy"), + /** http://www.w3.org/2000/01/rdf-schema#Resource. */ RDFS_RESOURCE(Namespaces.RDFS, "Resource"), + /** http://www.w3.org/2000/01/rdf-schema#Literal. */ RDFS_LITERAL(Namespaces.RDFS, "Literal"), + /** http://www.w3.org/2000/01/rdf-schema#subClassOf. */ RDFS_DATATYPE(Namespaces.RDFS, "Datatype"), + /** http://www.w3.org/2002/07/owl#TransitiveProperty. */ OWL_TRANSITIVE_PROPERTY(Namespaces.OWL, "TransitiveProperty"), + /** http://www.w3.org/2002/07/owl#ReflexiveProperty. */ OWL_REFLEXIVE_PROPERTY(Namespaces.OWL, "ReflexiveProperty"), + /** http://www.w3.org/2002/07/owl#IrreflexiveProperty. */ OWL_IRREFLEXIVE_PROPERTY(Namespaces.OWL, "IrreflexiveProperty"), + /** http://www.w3.org/2002/07/owl#inverseOf. */ OWL_INVERSE_OF(Namespaces.OWL, "inverseOf"), + /** http://www.w3.org/2002/07/owl#complementOf. */ OWL_COMPLEMENT_OF(Namespaces.OWL, "complementOf"), + /** http://www.w3.org/2002/07/owl#datatypeComplementOf. */ OWL_DATATYPE_COMPLEMENT_OF(Namespaces.OWL, "datatypeComplementOf"), + /** http://www.w3.org/2002/07/owl#AllDifferent. */ OWL_ALL_DIFFERENT(Namespaces.OWL, "AllDifferent"), + /** http://www.w3.org/2002/07/owl#distinctMembers. */ OWL_DISTINCT_MEMBERS(Namespaces.OWL, "distinctMembers"), + /** http://www.w3.org/2002/07/owl#sameAs. */ OWL_SAME_AS(Namespaces.OWL, "sameAs"), + /** http://www.w3.org/2002/07/owl#differentFrom. */ OWL_DIFFERENT_FROM(Namespaces.OWL, "differentFrom"), + /** http://www.w3.org/2002/07/owl#DeprecatedProperty. */ OWL_DEPRECATED_PROPERTY(Namespaces.OWL, "DeprecatedProperty"), + /** http://www.w3.org/2002/07/owl#equivalentProperty. */ OWL_EQUIVALENT_PROPERTY(Namespaces.OWL, "equivalentProperty"), + /** http://www.w3.org/2002/07/owl#DeprecatedClass. */ OWL_DEPRECATED_CLASS(Namespaces.OWL, "DeprecatedClass"), + /** http://www.w3.org/2002/07/owl#DataRange. */ OWL_DATA_RANGE(Namespaces.OWL, "DataRange"), + /** http://www.w3.org/2000/01/rdf-schema#domain. */ RDFS_DOMAIN(Namespaces.RDFS, "domain"), + /** http://www.w3.org/2000/01/rdf-schema#range. */ RDFS_RANGE(Namespaces.RDFS, "range"), + /** http://www.w3.org/2000/01/rdf-schema#Class. */ RDFS_CLASS(Namespaces.RDFS, "Class"), + /** http://www.w3.org/1999/02/22-rdf-syntax-ns#Property.*/ RDF_PROPERTY(Namespaces.RDF, "Property"), + /** http://www.w3.org/2002/07/owl#priorVersion. */ OWL_PRIOR_VERSION(Namespaces.OWL, "priorVersion"), + /** http://www.w3.org/2002/07/owl#deprecated. */ OWL_DEPRECATED(Namespaces.OWL, "deprecated"), + /** http://www.w3.org/2002/07/owl#incompatibleWith. */ OWL_INCOMPATIBLE_WITH(Namespaces.OWL, "incompatibleWith"), + /** http://www.w3.org/2002/07/owl#propertyDisjointWith. */ OWL_PROPERTY_DISJOINT_WITH(Namespaces.OWL, "propertyDisjointWith"), + /** http://www.w3.org/2002/07/owl#onClass. */ OWL_ON_CLASS(Namespaces.OWL, "onClass"), + /** http://www.w3.org/2002/07/owl#onDataRange. */ OWL_ON_DATA_RANGE(Namespaces.OWL, "onDataRange"), + /** http://www.w3.org/2002/07/owl#onDatatype. */ OWL_ON_DATA_TYPE(Namespaces.OWL, "onDatatype"), + /** http://www.w3.org/2002/07/owl#withRestrictions. */ OWL_WITH_RESTRICTIONS(Namespaces.OWL, "withRestrictions"), + /** http://www.w3.org/2002/07/owl#Axiom. */ OWL_AXIOM(Namespaces.OWL, "Axiom"), + /** http://www.w3.org/2002/07/owl#propertyChainAxiom. */ OWL_PROPERTY_CHAIN_AXIOM(Namespaces.OWL, "propertyChainAxiom"), + /** http://www.w3.org/2002/07/owl#AllDisjointClasses. */ OWL_ALL_DISJOINT_CLASSES(Namespaces.OWL, "AllDisjointClasses"), + /** http://www.w3.org/2002/07/owl#members. */ OWL_MEMBERS(Namespaces.OWL, "members"), + /** http://www.w3.org/2002/07/owl#AllDisjointProperties.*/ OWL_ALL_DISJOINT_PROPERTIES(Namespaces.OWL, "AllDisjointProperties"), + /** http://www.w3.org/2002/07/owl#topObjectProperty. */ OWL_TOP_OBJECT_PROPERTY(Namespaces.OWL, "topObjectProperty"), + /** http://www.w3.org/2002/07/owl#bottomObjectProperty. */ OWL_BOTTOM_OBJECT_PROPERTY(Namespaces.OWL, "bottomObjectProperty"), + /** http://www.w3.org/2002/07/owl#topDataProperty. */ OWL_TOP_DATA_PROPERTY(Namespaces.OWL, "topDataProperty"), + /** http://www.w3.org/2002/07/owl#bottomDataProperty. */ OWL_BOTTOM_DATA_PROPERTY(Namespaces.OWL, "bottomDataProperty"), + /** http://www.w3.org/2002/07/owl#hasKey. */ OWL_HAS_KEY(Namespaces.OWL, "hasKey"), + /** http://www.w3.org/2002/07/owl#annotatedSource. */ OWL_ANNOTATED_SOURCE(Namespaces.OWL, "annotatedSource"), + /** http://www.w3.org/2002/07/owl#annotatedProperty. */ OWL_ANNOTATED_PROPERTY(Namespaces.OWL, "annotatedProperty"), + /** http://www.w3.org/2002/07/owl#annotatedTarget. */ OWL_ANNOTATED_TARGET(Namespaces.OWL, "annotatedTarget"), + /** http://www.w3.org/2002/07/owl#sourceIndividual. */ OWL_SOURCE_INDIVIDUAL(Namespaces.OWL, "sourceIndividual"), + /** http://www.w3.org/2002/07/owl#assertionProperty. */ OWL_ASSERTION_PROPERTY(Namespaces.OWL, "assertionProperty"), + /** http://www.w3.org/2002/07/owl#targetIndividual. */ OWL_TARGET_INDIVIDUAL(Namespaces.OWL, "targetIndividual"), + /** http://www.w3.org/2002/07/owl#targetValue. */ OWL_TARGET_VALUE(Namespaces.OWL, "targetValue"), + + /** http://www.w3.org/2002/07/owl#InverseFunctionalProperty. */ OWL_INVERSE_FUNCTIONAL_PROPERTY(Namespaces.OWL, "InverseFunctionalProperty"), + /** http://www.w3.org/2002/07/owl#minQualifiedCardinality. */ OWL_MIN_QUALIFIED_CARDINALITY(Namespaces.OWL, "minQualifiedCardinality"), + /** http://www.w3.org/2002/07/owl#maxQualifiedCardinality. */ OWL_MAX_QUALIFIED_CARDINALITY(Namespaces.OWL, "maxQualifiedCardinality"), + /** http://www.w3.org/2002/07/owl#NegativePropertyAssertion. */ OWL_NEGATIVE_PROPERTY_ASSERTION(Namespaces.OWL, "NegativePropertyAssertion"), + /** http://www.w3.org/1999/02/22-rdf-syntax-ns#langString. */ RDF_LANG_STRING(Namespaces.RDF, "langString"), + /** http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral. */ RDF_PLAIN_LITERAL(Namespaces.RDF, "PlainLiteral"), + /** http://www.w3.org/1999/02/22-rdf-syntax-ns#Description. */ RDF_DESCRIPTION(Namespaces.RDF, "Description"), + /** http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral. */ RDF_XML_LITERAL(Namespaces.RDF, "XMLLiteral"), + /** http://www.w3.org/2002/07/owl#backwardCompatibleWith. */ OWL_BACKWARD_COMPATIBLE_WITH(Namespaces.OWL, "backwardCompatibleWith"), + /** http://www.w3.org/2002/07/owl#inverseObjectPropertyExpression. */ OWL_INVERSE_OBJECT_PROPERTY_EXPRESSION(Namespaces.OWL,"inverseObjectPropertyExpression"), + + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#OntologyProperty. */ OWL_ONTOLOGY_PROPERTY(Namespaces.OWL, "OntologyProperty"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#AntisymmetricProperty. */ OWL_ANTI_SYMMETRIC_PROPERTY(Namespaces.OWL, "AntisymmetricProperty"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#DataRestriction. */ OWL_DATA_RESTRICTION(Namespaces.OWL, "DataRestriction"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#ObjectRestriction. */ OWL_OBJECT_RESTRICTION(Namespaces.OWL, "ObjectRestriction"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#SelfRestriction. */ OWL_SELF_RESTRICTION(Namespaces.OWL, "SelfRestriction"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#declaredAs. */ OWL_DECLARED_AS(Namespaces.OWL, "declaredAs"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#NegativeObjectPropertyAssertion. */ OWL_NEGATIVE_OBJECT_PROPERTY_ASSERTION(Namespaces.OWL, "NegativeObjectPropertyAssertion"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#NegativeDataPropertyAssertion. */ OWL_NEGATIVE_DATA_PROPERTY_ASSERTION(Namespaces.OWL, "NegativeDataPropertyAssertion"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/1999/02/22-rdf-syntax-ns#subject. */ RDF_SUBJECT(Namespaces.RDF, "subject"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate. */ RDF_PREDICATE(Namespaces.RDF, "predicate"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/1999/02/22-rdf-syntax-ns#object. */ RDF_OBJECT(Namespaces.RDF, "object"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#subject. */ OWL_SUBJECT(Namespaces.OWL, "subject"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#predicate. */ OWL_PREDICATE(Namespaces.OWL, "predicate"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#object. */ OWL_OBJECT(Namespaces.OWL, "object"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#objectPropertyDomain. */ OWL_OBJECT_PROPERTY_DOMAIN(Namespaces.OWL, "objectPropertyDomain"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#dataPropertyDomain. */ OWL_DATA_PROPERTY_DOMAIN(Namespaces.OWL, "dataPropertyDomain"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#dataPropertyRange. */ OWL_DATA_PROPERTY_RANGE(Namespaces.OWL, "dataPropertyRange"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#objectPropertyRange. */ OWL_OBJECT_PROPERTY_RANGE(Namespaces.OWL, "objectPropertyRange"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#subObjectPropertyOf. */ OWL_SUB_OBJECT_PROPERTY_OF(Namespaces.OWL, "subObjectPropertyOf"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#subDataPropertyOf. */ OWL_SUB_DATA_PROPERTY_OF(Namespaces.OWL, "subDataPropertyOf"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#disjointDataProperties. */ OWL_DISJOINT_DATA_PROPERTIES(Namespaces.OWL, "disjointDataProperties"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#disjointObjectProperties. */ OWL_DISJOINT_OBJECT_PROPERTIES(Namespaces.OWL, "disjointObjectProperties"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#equivalentDataProperty. */ OWL_EQUIVALENT_DATA_PROPERTIES(Namespaces.OWL, "equivalentDataProperty"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#equivalentObjectProperty. */ OWL_EQUIVALENT_OBJECT_PROPERTIES(Namespaces.OWL, "equivalentObjectProperty"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#FunctionalDataProperty. */ OWL_FUNCTIONAL_DATA_PROPERTY(Namespaces.OWL, "FunctionalDataProperty"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#FunctionalObjectProperty. */ OWL_FUNCTIONAL_OBJECT_PROPERTY(Namespaces.OWL, "FunctionalObjectProperty"), + /** Deprecated vocabulary: here for backwards compatibility http://www.w3.org/2002/07/owl#propertyChain. */ OWL_PROPERTY_CHAIN(Namespaces.OWL, "propertyChain"); +//@formatter:on + + /** + * Set of all IRIs for this enum values. + */ + public static final Set BUILT_IN_VOCABULARY_IRIS = + asSet(Stream.of(values()).map(i -> i.getIRI())); + /** + * label , comment , versionInfo , backwardCompatibleWith , priorVersion , seeAlso , isDefinedBy + * , incompatibleWith , deprecated. + */ + public static final Set BUILT_IN_AP_IRIS = asSet(Stream.of(RDFS_LABEL, RDFS_COMMENT, + OWL_VERSION_INFO, OWL_BACKWARD_COMPATIBLE_WITH, OWL_PRIOR_VERSION, + RDFS_SEE_ALSO, RDFS_IS_DEFINED_BY, OWL_INCOMPATIBLE_WITH, OWL_DEPRECATED) + .map(HasIRI::getIRI)); + private final IRI iri; + private final Namespaces namespace; + private final String shortName; + private final String prefixedName; + + OWLRDFVocabulary(Namespaces namespace, String shortName) { + this.namespace = namespace; + this.shortName = shortName; + prefixedName = namespace.getPrefixName() + ':' + shortName; + iri = IRI.create(namespace.toString(), shortName); + } + + @Override + public IRI getIRI() { + return iri; + } + + /** + * @return the entry namespace + */ + public Namespaces getNamespace() { + return namespace; + } + + @Override + public String getPrefixedName() { + return prefixedName; + } + + @Override + public String getShortForm() { + return shortName; + } + + @Override + public String toString() { + return iri.toString(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/vocab/OWLXMLVocabulary.java b/api/src/main/java/org/semanticweb/owlapi/vocab/OWLXMLVocabulary.java new file mode 100644 index 0000000000..8a5cfbd81c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/vocab/OWLXMLVocabulary.java @@ -0,0 +1,160 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.vocab; + +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.HasPrefixedName; +import org.semanticweb.owlapi.model.HasShortForm; +import org.semanticweb.owlapi.model.IRI; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public enum OWLXMLVocabulary implements HasShortForm, HasIRI, HasPrefixedName { +//@formatter:off + /** CLASS. */ CLASS ("Class"), + /** DATA_PROPERTY. */ DATA_PROPERTY ("DataProperty"), + /** OBJECT_PROPERTY. */ OBJECT_PROPERTY ("ObjectProperty"), + /** NAMED_INDIVIDUAL. */ NAMED_INDIVIDUAL ("NamedIndividual"), + /** ENTITY_ANNOTATION. */ ENTITY_ANNOTATION ("EntityAnnotation"), + /** ANNOTATION_PROPERTY. */ ANNOTATION_PROPERTY ("AnnotationProperty"), + /** DATATYPE. */ DATATYPE ("Datatype"), + /** ANNOTATION. */ ANNOTATION ("Annotation"), + /** ANONYMOUS_INDIVIDUAL. */ ANONYMOUS_INDIVIDUAL ("AnonymousIndividual"), + /** NODE_ID. */ NODE_ID ("nodeID"), + /** ANNOTATION_URI. */ ANNOTATION_URI ("annotationURI"), + /** IMPORT. */ IMPORT ("Import"), + /** LABEL. */ LABEL ("Label"), + /** COMMENT. */ COMMENT ("Comment"), + /** DOCUMENTATION. */ DOCUMENTATION ("Documentation"), + /** ONTOLOGY. */ ONTOLOGY ("Ontology"), + /** LITERAL. */ LITERAL ("Literal"), + /** OBJECT_INVERSE_OF. */ OBJECT_INVERSE_OF ("ObjectInverseOf"), + /** DATA_COMPLEMENT_OF. */ DATA_COMPLEMENT_OF ("DataComplementOf"), + /** DATA_ONE_OF. */ DATA_ONE_OF ("DataOneOf"), + /** DATATYPE_RESTRICTION. */ DATATYPE_RESTRICTION ("DatatypeRestriction"), + /** FACET_RESTRICTION. */ FACET_RESTRICTION ("FacetRestriction"), + /** DATA_UNION_OF. */ DATA_UNION_OF ("DataUnionOf"), + /** DATA_INTERSECTION_OF. */ DATA_INTERSECTION_OF ("DataIntersectionOf"), + /** DATATYPE_FACET. */ DATATYPE_FACET ("facet"), + /** DATATYPE_IRI. */ DATATYPE_IRI ("datatypeIRI"), + /** DATA_RANGE. */ DATA_RANGE ("DataRange"), + /** OBJECT_INTERSECTION_OF. */ OBJECT_INTERSECTION_OF ("ObjectIntersectionOf"), + /** OBJECT_UNION_OF. */ OBJECT_UNION_OF ("ObjectUnionOf"), + /** OBJECT_COMPLEMENT_OF. */ OBJECT_COMPLEMENT_OF ("ObjectComplementOf"), + /** OBJECT_ONE_OF. */ OBJECT_ONE_OF ("ObjectOneOf"), + /** OBJECT_SOME_VALUES_FROM. */ OBJECT_SOME_VALUES_FROM ("ObjectSomeValuesFrom"), + /** OBJECT_ALL_VALUES_FROM. */ OBJECT_ALL_VALUES_FROM ("ObjectAllValuesFrom"), + /** OBJECT_HAS_SELF. */ OBJECT_HAS_SELF ("ObjectHasSelf"), + /** OBJECT_HAS_VALUE. */ OBJECT_HAS_VALUE ("ObjectHasValue"), + /** OBJECT_MIN_CARDINALITY. */ OBJECT_MIN_CARDINALITY ("ObjectMinCardinality"), + /** OBJECT_EXACT_CARDINALITY. */ OBJECT_EXACT_CARDINALITY ("ObjectExactCardinality"), + /** OBJECT_MAX_CARDINALITY. */ OBJECT_MAX_CARDINALITY ("ObjectMaxCardinality"), + /** DATA_SOME_VALUES_FROM. */ DATA_SOME_VALUES_FROM ("DataSomeValuesFrom"), + /** DATA_ALL_VALUES_FROM. */ DATA_ALL_VALUES_FROM ("DataAllValuesFrom"), + /** DATA_HAS_VALUE. */ DATA_HAS_VALUE ("DataHasValue"), + /** DATA_MIN_CARDINALITY. */ DATA_MIN_CARDINALITY ("DataMinCardinality"), + /** DATA_EXACT_CARDINALITY. */ DATA_EXACT_CARDINALITY ("DataExactCardinality"), + /** DATA_MAX_CARDINALITY. */ DATA_MAX_CARDINALITY ("DataMaxCardinality"), + /** SUB_CLASS_OF. */ SUB_CLASS_OF ("SubClassOf"), + /** EQUIVALENT_CLASSES. */ EQUIVALENT_CLASSES ("EquivalentClasses"), + /** DISJOINT_CLASSES. */ DISJOINT_CLASSES ("DisjointClasses"), + /** DISJOINT_UNION. */ DISJOINT_UNION ("DisjointUnion"), + /** UNION_OF. */ UNION_OF ("UnionOf"), + /** SUB_OBJECT_PROPERTY_OF. */ SUB_OBJECT_PROPERTY_OF ("SubObjectPropertyOf"), + /** OBJECT_PROPERTY_CHAIN. */ OBJECT_PROPERTY_CHAIN ("ObjectPropertyChain"), + /** EQUIVALENT_OBJECT_PROPERTIES. */ EQUIVALENT_OBJECT_PROPERTIES ("EquivalentObjectProperties"), + /** DISJOINT_OBJECT_PROPERTIES. */ DISJOINT_OBJECT_PROPERTIES ("DisjointObjectProperties"), + /** OBJECT_PROPERTY_DOMAIN. */ OBJECT_PROPERTY_DOMAIN ("ObjectPropertyDomain"), + /** OBJECT_PROPERTY_RANGE. */ OBJECT_PROPERTY_RANGE ("ObjectPropertyRange"), + /** INVERSE_OBJECT_PROPERTIES. */ INVERSE_OBJECT_PROPERTIES ("InverseObjectProperties"), + /** FUNCTIONAL_OBJECT_PROPERTY. */ FUNCTIONAL_OBJECT_PROPERTY ("FunctionalObjectProperty"), + /** INVERSE_FUNCTIONAL_OBJECT_PROPERTY. */ INVERSE_FUNCTIONAL_OBJECT_PROPERTY ("InverseFunctionalObjectProperty"), + /** SYMMETRIC_OBJECT_PROPERTY. */ SYMMETRIC_OBJECT_PROPERTY ("SymmetricObjectProperty"), + /** ASYMMETRIC_OBJECT_PROPERTY. */ ASYMMETRIC_OBJECT_PROPERTY ("AsymmetricObjectProperty"), + /** REFLEXIVE_OBJECT_PROPERTY. */ REFLEXIVE_OBJECT_PROPERTY ("ReflexiveObjectProperty"), + /** IRREFLEXIVE_OBJECT_PROPERTY. */ IRREFLEXIVE_OBJECT_PROPERTY ("IrreflexiveObjectProperty"), + /** TRANSITIVE_OBJECT_PROPERTY. */ TRANSITIVE_OBJECT_PROPERTY ("TransitiveObjectProperty"), + /** SUB_DATA_PROPERTY_OF. */ SUB_DATA_PROPERTY_OF ("SubDataPropertyOf"), + /** EQUIVALENT_DATA_PROPERTIES. */ EQUIVALENT_DATA_PROPERTIES ("EquivalentDataProperties"), + /** DISJOINT_DATA_PROPERTIES. */ DISJOINT_DATA_PROPERTIES ("DisjointDataProperties"), + /** DATA_PROPERTY_DOMAIN. */ DATA_PROPERTY_DOMAIN ("DataPropertyDomain"), + /** DATA_PROPERTY_RANGE. */ DATA_PROPERTY_RANGE ("DataPropertyRange"), + /** FUNCTIONAL_DATA_PROPERTY. */ FUNCTIONAL_DATA_PROPERTY ("FunctionalDataProperty"), + /** SAME_INDIVIDUAL. */ SAME_INDIVIDUAL ("SameIndividual"), + /** DIFFERENT_INDIVIDUALS. */ DIFFERENT_INDIVIDUALS ("DifferentIndividuals"), + /** CLASS_ASSERTION. */ CLASS_ASSERTION ("ClassAssertion"), + /** OBJECT_PROPERTY_ASSERTION. */ OBJECT_PROPERTY_ASSERTION ("ObjectPropertyAssertion"), + /** DATA_PROPERTY_ASSERTION. */ DATA_PROPERTY_ASSERTION ("DataPropertyAssertion"), + /** NEGATIVE_OBJECT_PROPERTY_ASSERTION. */ NEGATIVE_OBJECT_PROPERTY_ASSERTION ("NegativeObjectPropertyAssertion"), + /** NEGATIVE_DATA_PROPERTY_ASSERTION. */ NEGATIVE_DATA_PROPERTY_ASSERTION ("NegativeDataPropertyAssertion"), + /** HAS_KEY. */ HAS_KEY ("HasKey"), + /** DECLARATION. */ DECLARATION ("Declaration"), + /** ANNOTATION_ASSERTION. */ ANNOTATION_ASSERTION ("AnnotationAssertion"), + /** ANNOTATION_PROPERTY_DOMAIN. */ ANNOTATION_PROPERTY_DOMAIN ("AnnotationPropertyDomain"), + /** ANNOTATION_PROPERTY_RANGE. */ ANNOTATION_PROPERTY_RANGE ("AnnotationPropertyRange"), + /** SUB_ANNOTATION_PROPERTY_OF. */ SUB_ANNOTATION_PROPERTY_OF ("SubAnnotationPropertyOf"), + /** DATATYPE_DEFINITION. */ DATATYPE_DEFINITION ("DatatypeDefinition"), + /** PREFIX. */ PREFIX ("Prefix"), + /** NAME_ATTRIBUTE. */ NAME_ATTRIBUTE ("name"), + /** IRI_ATTRIBUTE. */ IRI_ATTRIBUTE ("IRI"), + /** ABBREVIATED_IRI_ATTRIBUTE. */ ABBREVIATED_IRI_ATTRIBUTE ("abbreviatedIRI"), + /** IRI_ELEMENT. */ IRI_ELEMENT ("IRI"), + /** ABBREVIATED_IRI_ELEMENT. */ ABBREVIATED_IRI_ELEMENT ("AbbreviatedIRI"), + /** CARDINALITY_ATTRIBUTE. */ CARDINALITY_ATTRIBUTE ("cardinality"), + + // Rules Extensions + /** DL_SAFE_RULE. */ DL_SAFE_RULE ("DLSafeRule"), + /** BODY. */ BODY ("Body"), + /** HEAD. */ HEAD ("Head"), + /** CLASS_ATOM. */ CLASS_ATOM ("ClassAtom"), + /** DATA_RANGE_ATOM. */ DATA_RANGE_ATOM ("DataRangeAtom"), + /** OBJECT_PROPERTY_ATOM. */ OBJECT_PROPERTY_ATOM ("ObjectPropertyAtom"), + /** DATA_PROPERTY_ATOM. */ DATA_PROPERTY_ATOM ("DataPropertyAtom"), + /** BUILT_IN_ATOM. */ BUILT_IN_ATOM ("BuiltInAtom"), + /** SAME_INDIVIDUAL_ATOM. */ SAME_INDIVIDUAL_ATOM ("SameIndividualAtom"), + /** DIFFERENT_INDIVIDUALS_ATOM. */ DIFFERENT_INDIVIDUALS_ATOM ("DifferentIndividualsAtom"), + /** VARIABLE. */ VARIABLE ("Variable"), + /** DESCRIPTION_GRAPH_RULE. */ DESCRIPTION_GRAPH_RULE ("DescriptionGraphRule"); + //@formatter:on + private final IRI iri; + private final String shortName; + private final String prefixedName; + + OWLXMLVocabulary(String name) { + iri = IRI.create(Namespaces.OWL.toString(), name); + shortName = name; + prefixedName = Namespaces.OWL.getPrefixName() + ':' + name; + } + + @Override + public IRI getIRI() { + return iri; + } + + @Override + public String toString() { + return iri.toString(); + } + + @Override + public String getShortForm() { + return shortName; + } + + @Override + public String getPrefixedName() { + return prefixedName; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/vocab/PROVVocabulary.java b/api/src/main/java/org/semanticweb/owlapi/vocab/PROVVocabulary.java new file mode 100644 index 0000000000..dda99705c3 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/vocab/PROVVocabulary.java @@ -0,0 +1,144 @@ +package org.semanticweb.owlapi.vocab; + +import static org.semanticweb.owlapi.model.EntityType.CLASS; +import static org.semanticweb.owlapi.model.EntityType.DATA_PROPERTY; +import static org.semanticweb.owlapi.model.EntityType.OBJECT_PROPERTY; +import static org.semanticweb.owlapi.vocab.Namespaces.PROV; + +import org.semanticweb.owlapi.model.EntityType; +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.HasPrefixedName; +import org.semanticweb.owlapi.model.HasShortForm; +import org.semanticweb.owlapi.model.IRI; + +/** + * @author Alex To, The University Of Sydney, Faculty of Engineering and Information Technologies + * @since 5.1.0 + */ +public enum PROVVocabulary implements HasShortForm, HasIRI, HasPrefixedName { + + // Prov Vocab http://www.w3.org/ns/prov# + //@formatter:off + /** http://www.w3.org/ns/prov#Activity. */ ACTIVITY_CLASS (PROV, "Activity", CLASS), + /** http://www.w3.org/ns/prov#Agent. */ AGENT_CLASS (PROV, "Agent", CLASS), + /** http://www.w3.org/ns/prov#Organization. */ ORGANIZATION (PROV, "Organization", CLASS), + /** http://www.w3.org/ns/prov#Person. */ PERSON (PROV, "Person", CLASS), + /** http://www.w3.org/ns/prov#SoftwareAgent. */ SOFTWARE_AGENT (PROV, "SoftwareAgent", CLASS), + /** http://www.w3.org/ns/prov#Entity. */ ENTITY_CLASS (PROV, "Entity", CLASS), + /** http://www.w3.org/ns/prov#Bundle. */ BUNDLE (PROV, "Bundle", CLASS), + /** http://www.w3.org/ns/prov#Collection. */ COLLECTION (PROV, "Collection", CLASS), + /** http://www.w3.org/ns/prov#EmptyCollection. */ EMPTY_COLLECTION (PROV, "EmptyCollection", CLASS), + /** http://www.w3.org/ns/prov#Plan. */ PLAN (PROV, "Plan", CLASS), + /** http://www.w3.org/ns/prov#Influence. */ INFLUENCE (PROV, "Influence", CLASS), + /** http://www.w3.org/ns/prov#ActivityInfluence. */ ACTIVITY_INFLUENCE (PROV, "ActivityInfluence", CLASS), + /** http://www.w3.org/ns/prov#Communication. */ COMMUNICATION (PROV, "Communication", CLASS), + /** http://www.w3.org/ns/prov#Generation. */ GENERATION (PROV, "Generation", CLASS), + /** http://www.w3.org/ns/prov#Invalidation. */ INVALIDATION (PROV, "Invalidation", CLASS), + /** http://www.w3.org/ns/prov#AgentInfluence. */ AGENT_INFLUENCE (PROV, "AgentInfluence", CLASS), + /** http://www.w3.org/ns/prov#Association. */ ASSOCIATION (PROV, "Association", CLASS), + /** http://www.w3.org/ns/prov#Attribution. */ ATTRIBUTION (PROV, "Attribution", CLASS), + /** http://www.w3.org/ns/prov#Delegation. */ DELEGATION (PROV, "Delegation", CLASS), + /** http://www.w3.org/ns/prov#EntityInfluence. */ ENTITY_INFLUENCE (PROV, "EntityInfluence", CLASS), + /** http://www.w3.org/ns/prov#Derivation. */ DERIVATION (PROV, "Derivation", CLASS), + /** http://www.w3.org/ns/prov#PrimarySource. */ PRIMARY_SOURCE (PROV, "PrimarySource", CLASS), + /** http://www.w3.org/ns/prov#Quotation. */ QUOTATION (PROV, "Quotation", CLASS), + /** http://www.w3.org/ns/prov#Revision. */ REVISION (PROV, "Revision", CLASS), + /** http://www.w3.org/ns/prov#End. */ END (PROV, "End", CLASS), + /** http://www.w3.org/ns/prov#Start. */ START (PROV, "Start", CLASS), + /** http://www.w3.org/ns/prov#Usage. */ USAGE (PROV, "Usage", CLASS), + /** http://www.w3.org/ns/prov#InstantaneousEvent. */ INSTANTANEOUS_EVENT (PROV, "InstantaneousEvent", CLASS), + /** http://www.w3.org/ns/prov#Location. */ LOCATION (PROV, "Location", CLASS), + /** http://www.w3.org/ns/prov#Role. */ ROLE (PROV, "Role", CLASS), + /** http://www.w3.org/ns/prov#alternateOf. */ ALTERNATE_OF (PROV, "alternateOf", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#atLocation. */ AT_LOCATION (PROV, "atLocation", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#hadActivity. */ HAD_ACTIVITY (PROV, "hadActivity", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#hadGeneration. */ HAD_GENERATION (PROV, "hadGeneration", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#hadPlan. */ HAD_PLAN (PROV, "hadPlan", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#hadRole. */ HAD_ROLE (PROV, "hadRole", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#hadUsage. */ HAD_USAGE (PROV, "hadUsage", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#influenced. */ INFLUENCED (PROV, "influenced", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#generated. */ GENERATED (PROV, "generated", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#invalidated. */ INVALIDATED (PROV, "invalidated", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#influencer. */ INFLUENCER (PROV, "influencer", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#activity. */ ACTIVITY_PROPERTY (PROV, "activity", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#agent. */ AGENT_PROPERTY (PROV, "agent", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#entity. */ ENTITY_PROPERTY (PROV, "entity", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#qualifiedInfluence. */ QUALIFIED_INFLUENCE (PROV, "qualifiedInfluence", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#qualifiedAssociation. */ QUALIFIED_ASSOCIATION (PROV, "qualifiedAssociation", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#qualifiedAttribution. */ QUALIFIED_ATTRIBUTION (PROV, "qualifiedAttribution", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#qualifiedCommunication. */ QUALIFIED_COMMUNICATION (PROV, "qualifiedCommunication", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#qualifiedDelegation. */ QUALIFIED_DELEGATION (PROV, "qualifiedDelegation", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#qualifiedDerivation. */ QUALIFIED_DERIVATION (PROV, "qualifiedDerivation", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#qualifiedEnd. */ QUALIFIED_END (PROV, "qualifiedEnd", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#qualifiedGeneration. */ QUALIFIED_GENERATION (PROV, "qualifiedGeneration", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#qualifiedInvalidation. */ QUALIFIED_INVALIDATION (PROV, "qualifiedInvalidation", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#qualifiedPrimarySource. */ QUALIFIED_PRIMARY_SOURCE (PROV, "qualifiedPrimarySource", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#qualifiedQuotation. */ QUALIFIED_QUOTATION (PROV, "qualifiedQuotation", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#qualifiedRevision. */ QUALIFIED_REVISION (PROV, "qualifiedRevision", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#qualifiedStart. */ QUALIFIED_START (PROV, "qualifiedStart", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#qualifiedUsage. */ QUALIFIED_USAGE (PROV, "qualifiedUsage", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#wasInfluencedBy. */ WAS_INFLUENCED_BY (PROV, "wasInfluencedBy", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#actedOnBehalfOf. */ ACTED_ON_BEHALF_OF (PROV, "actedOnBehalfOf", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#hadMember. */ HAD_MEMBER (PROV, "hadMember", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#used. */ USED (PROV, "used", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#wasAssociatedWith. */ WAS_ASSOCIATED_WITH (PROV, "wasAssociatedWith", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#wasAttributedTo. */ WAS_ATTRIBUTED_TO (PROV, "wasAttributedTo", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#wasDerivedFrom. */ WAS_DERIVED_FROM (PROV, "wasDerivedFrom", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#hadPrimarySource. */ HAD_PRIMARY_SOURCE (PROV, "hadPrimarySource", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#wasQuotedFrom. */ WAS_QUOTED_FROM (PROV, "wasQuotedFrom", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#wasRevisionOf. */ WAS_REVISION_OF (PROV, "wasRevisionOf", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#wasEndedBy. */ WAS_ENDED_BY (PROV, "wasEndedBy", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#wasGeneratedBy. */ WAS_GENERATED_BY (PROV, "wasGeneratedBy", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#wasInformedBy. */ WAS_INFORMED_BY (PROV, "wasInformedBy", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#wasInvalidatedBy. */ WAS_INVALIDATED_BY (PROV, "wasInvalidatedBy", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#wasStartedBy. */ WAS_STARTED_BY (PROV, "wasStartedBy", OBJECT_PROPERTY), + /** http://www.w3.org/ns/prov#atTime. */ AT_TIME (PROV, "atTime", DATA_PROPERTY), + /** http://www.w3.org/ns/prov#endedAtTime. */ ENDED_AT_TIME (PROV, "endedAtTime", DATA_PROPERTY), + /** http://www.w3.org/ns/prov#generatedAtTime. */ GENERATED_AT_TIME (PROV, "generatedAtTime", DATA_PROPERTY), + /** http://www.w3.org/ns/prov#invalidatedAtTime. */ INVALIDATED_AT_TIME (PROV, "invalidatedAtTime", DATA_PROPERTY), + /** http://www.w3.org/ns/prov#startedAtTime. */ STARTED_AT_TIME (PROV, "startedAtTime", DATA_PROPERTY), + /** http://www.w3.org/ns/prov#value. */ VALUE (PROV, "value", DATA_PROPERTY); + //@formatter:off + private final IRI iri; + private final Namespaces namespace; + private final String shortName; + private final String prefixedName; + private final EntityType entityType; + + PROVVocabulary(Namespaces namespace, String shortName, EntityType entityType) { + this.namespace = namespace; + this.shortName = shortName; + prefixedName = namespace.getPrefixName() + ':' + shortName; + iri = IRI.create(namespace.toString(), shortName); + this.entityType = entityType; + } + + @Override + public IRI getIRI() { + return iri; + } + + @Override + public String getPrefixedName() { + return prefixedName; + } + + @Override + public String getShortForm() { + return shortName; + } + + /** + * @return namespace + */ + public Namespaces getNamespace() { + return namespace; + } + + /** + * @return entity type + */ + public EntityType getEntityType() { + return entityType; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/vocab/SKOSVocabulary.java b/api/src/main/java/org/semanticweb/owlapi/vocab/SKOSVocabulary.java new file mode 100644 index 0000000000..efa5e767e7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/vocab/SKOSVocabulary.java @@ -0,0 +1,176 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.vocab; + +import static org.semanticweb.owlapi.model.EntityType.ANNOTATION_PROPERTY; +import static org.semanticweb.owlapi.model.EntityType.CLASS; +import static org.semanticweb.owlapi.model.EntityType.DATA_PROPERTY; +import static org.semanticweb.owlapi.model.EntityType.OBJECT_PROPERTY; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; +import java.util.stream.Stream; +import org.semanticweb.owlapi.model.EntityType; +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.HasPrefixedName; +import org.semanticweb.owlapi.model.HasShortForm; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.providers.AnnotationPropertyProvider; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public enum SKOSVocabulary implements HasShortForm, HasIRI, HasPrefixedName { +//@formatter:off + /** BROADMATCH. */ BROADMATCH ("broadMatch", OBJECT_PROPERTY), + /** BROADER. */ BROADER ("broader", OBJECT_PROPERTY), + /** BROADERTRANSITIVE.*/ BROADERTRANSITIVE ("broaderTransitive", OBJECT_PROPERTY), + /** CLOSEMATCH. */ CLOSEMATCH ("closeMatch", OBJECT_PROPERTY), + /** EXACTMATCH. */ EXACTMATCH ("exactMatch", OBJECT_PROPERTY), + /** HASTOPCONCEPT. */ HASTOPCONCEPT ("hasTopConcept", OBJECT_PROPERTY), + /** INSCHEME. */ INSCHEME ("inScheme", OBJECT_PROPERTY), + /** MAPPINGRELATION. */ MAPPINGRELATION ("mappingRelation", OBJECT_PROPERTY), + /** MEMBER. */ MEMBER ("member", OBJECT_PROPERTY), + /** MEMBERLIST. */ MEMBERLIST ("memberList", OBJECT_PROPERTY), + /** NARROWMATCH. */ NARROWMATCH ("narrowMatch", OBJECT_PROPERTY), + /** NARROWER. */ NARROWER ("narrower", OBJECT_PROPERTY), + /** NARROWTRANSITIVE. */ NARROWTRANSITIVE ("narrowTransitive", OBJECT_PROPERTY), + /** RELATED. */ RELATED ("related", OBJECT_PROPERTY), + /** RELATEDMATCH. */ RELATEDMATCH ("relatedMatch", OBJECT_PROPERTY), + /** SEMANTICRELATION. */ SEMANTICRELATION ("semanticRelation", OBJECT_PROPERTY), + /** TOPCONCEPTOF. */ TOPCONCEPTOF ("topConceptOf", OBJECT_PROPERTY), + /** COLLECTION. */ COLLECTION ("Collection", CLASS), + /** CONCEPT. */ CONCEPT ("Concept", CLASS), + /** CONCEPTSCHEME. */ CONCEPTSCHEME ("ConceptScheme", CLASS), + /** ORDEREDCOLLECTION.*/ ORDEREDCOLLECTION ("OrderedCollection", CLASS), + /** TOPCONCEPT. */ TOPCONCEPT ("TopConcept", CLASS), + /** ALTLABEL. */ ALTLABEL ("altLabel", ANNOTATION_PROPERTY), + /** CHANGENOTE. */ CHANGENOTE ("changeNote", ANNOTATION_PROPERTY), + /** DEFINITION. */ DEFINITION ("definition", ANNOTATION_PROPERTY), + /** EDITORIALNOTE. */ EDITORIALNOTE ("editorialNote", ANNOTATION_PROPERTY), + /** EXAMPLE. */ EXAMPLE ("example", ANNOTATION_PROPERTY), + /** HIDDENLABEL. */ HIDDENLABEL ("hiddenLabel", ANNOTATION_PROPERTY), + /** HISTORYNOTE. */ HISTORYNOTE ("historyNote", ANNOTATION_PROPERTY), + /** NOTE. */ NOTE ("note", ANNOTATION_PROPERTY), + /** PREFLABEL. */ PREFLABEL ("prefLabel", ANNOTATION_PROPERTY), + /** SCOPENOTE. */ SCOPENOTE ("scopeNote", ANNOTATION_PROPERTY), + /** @deprecated No longer used */ + @Deprecated + DOCUMENT("Document", CLASS), + /** @deprecated No longer used */ + @Deprecated + IMAGE("Image", CLASS), + /** @deprecated No longer used */ + @Deprecated + COLLECTABLEPROPERTY("CollectableProperty", ANNOTATION_PROPERTY), + /** @deprecated No longer used */ + @Deprecated + RESOURCE("Resource", CLASS), + /** @deprecated No longer used */ + @Deprecated + COMMENT("comment", ANNOTATION_PROPERTY); +//@formatter:on + /** + * All IRIs. + */ + public static final Set ALL_IRIS = asSet(stream().map(v -> v.getIRI())); + private final String localName; + private final IRI iri; + private final EntityType entityType; + private final String prefixedName; + + SKOSVocabulary(String localname, EntityType entityType) { + localName = localname; + prefixedName = Namespaces.SKOS.getPrefixName() + ':' + localname; + this.entityType = entityType; + iri = IRI.create(Namespaces.SKOS.toString(), localname); + } + + private static Stream stream() { + return Stream.of(values()); + } + + /** + * @param dataFactory data factory to use + * @return set of SKOS annotation properties + */ + public static Set getAnnotationProperties( + AnnotationPropertyProvider dataFactory) { + return asSet( + stream().filter(v -> v.entityType.equals(ANNOTATION_PROPERTY)).map(v -> dataFactory + .getOWLAnnotationProperty(v.iri))); + } + + /** + * @param dataFactory data factory to use + * @return set of SKOS object properties + */ + public static Set getObjectProperties(OWLDataFactory dataFactory) { + return asSet(stream().filter(v -> v.entityType.equals(OBJECT_PROPERTY)).map(v -> dataFactory + .getOWLObjectProperty(v.iri))); + } + + /** + * @param dataFactory data factory to use + * @return set of SKOS data properties + */ + public static Set getDataProperties(OWLDataFactory dataFactory) { + return asSet(stream().filter(v -> v.entityType.equals(DATA_PROPERTY)) + .map(v -> dataFactory.getOWLDataProperty( + v.iri))); + } + + /** + * @param dataFactory data factory to use + * @return set of SKOS classes + */ + public static Set getClasses(OWLDataFactory dataFactory) { + return asSet(stream().filter(v -> v.entityType.equals(CLASS)) + .map(v -> dataFactory.getOWLClass(v.iri))); + } + + /** + * @return entity type + */ + public EntityType getEntityType() { + return entityType; + } + + /** + * @return local name + */ + public String getLocalName() { + return localName; + } + + @Override + public IRI getIRI() { + return iri; + } + + @Override + public String getShortForm() { + return localName; + } + + @Override + public String getPrefixedName() { + return prefixedName; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/vocab/SWRLBuiltInsVocabulary.java b/api/src/main/java/org/semanticweb/owlapi/vocab/SWRLBuiltInsVocabulary.java new file mode 100644 index 0000000000..f8e9308abd --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/vocab/SWRLBuiltInsVocabulary.java @@ -0,0 +1,162 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.vocab; + +import java.util.stream.Stream; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.HasPrefixedName; +import org.semanticweb.owlapi.model.HasShortForm; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.SWRLPredicate; + +/** + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public enum SWRLBuiltInsVocabulary implements SWRLPredicate, HasShortForm, HasIRI, HasPrefixedName { +//@formatter:off + /** EQUAL. */ EQUAL("equal", 2), + /** NOT_EQUAL. */ NOT_EQUAL("notEqual", 2), + /** LESS_THAN. */ LESS_THAN("lessThan", 2), + /** LESS_THAN_OR_EQUAL. */ LESS_THAN_OR_EQUAL("lessThanOrEqual", 2), + /** GREATER_THAN. */ GREATER_THAN("greaterThan", 2), + /** GREATER_THAN_OR_EQUAL. */ GREATER_THAN_OR_EQUAL("greaterThanOrEqual", 2), + /** ADD. */ ADD("add", -1), + /** SUBTRACT. */ SUBTRACT("subtract", 3), + /** MULTIPLY. */ MULTIPLY("multiply", -1), + /** DIVIDE. */ DIVIDE("divide", 3), + /** INTEGER_DIVIDE. */ INTEGER_DIVIDE("integerDivide", 3), + /** MOD. */ MOD("mod", 3), + /** POW. */ POW("pow", 3), + /** UNARY_MINUS. */ UNARY_MINUS("unaryMinus", 2), + /** UNARY_PLUS. */ UNARY_PLUS("unaryPlus", 2), + /** ABS. */ ABS("abs", 2), + /** CEILING. */ CEILING("ceiling", 2), + /** FLOOR. */ FLOOR("floor", 2), + /** ROUND. */ ROUND("round", 2), + /** ROUND_HALF_TO_EVEN. */ ROUND_HALF_TO_EVEN("roundHalfToEven", 2, 3), + /** SIN. */ SIN("sin", 2), + /** COS. */ COS("cos", 2), + /** TAN. */ TAN("tan", 2), + /** BOOLEAN_NOT. */ BOOLEAN_NOT("booleanNot", 2), + /** STRING_EQUALS_IGNORE_CASE. */STRING_EQUALS_IGNORE_CASE("stringEqualIgnoreCase", 2), + /** STRING_CONCAT. */ STRING_CONCAT("stringConcat", -1), + /** SUBSTRING. */ SUBSTRING("substring", 3), + /** STRING_LENGTH. */ STRING_LENGTH("stringLength", 2), + /** NORMALIZE_SPACE. */ NORMALIZE_SPACE("normalizeSpace", 2), + /** UPPER_CASE. */ UPPER_CASE("upperCase", 2), + /** LOWER_CASE. */ LOWER_CASE("lowerCase", 2), + /** TRANSLATE. */ TRANSLATE("translate", 4), + /** CONTAINS. */ CONTAINS("contains", 2), + /** CONTAINS_IGNORE_CASE. */ CONTAINS_IGNORE_CASE("containsIgnoreCase", 2), + /** STARTS_WITH. */ STARTS_WITH("startsWith", 2), + /** ENDS_WITH. */ ENDS_WITH("endsWith", 2), + /** SUBSTRING_BEFORE. */ SUBSTRING_BEFORE("substringBefore", 3), + /** SUBSTRING_AFTER. */ SUBSTRING_AFTER("substringAfter", 3), + /** MATCHES. */ MATCHES("matchesLax", 2), + /** REPLACE. */ REPLACE("replace", 4), + /** TOKENIZE. */ TOKENIZE("tokenize", 3), + /** YEAR_MONTH_DURATION. */ YEAR_MONTH_DURATION("yearMonthDuration", 5), + /** DAY_TIME_DURATION. */ DAY_TIME_DURATION("dayTimeDuration", 5), + /** DATE_TIME. */ DATE_TIME("dateTime", 5), + /** DATE. */ DATE("date", 5), + /** TIME. */ TIME("time", 5), + /** SUBTRACT_DATES. */ SUBTRACT_DATES("subtractDates", 3), + /** SUBTRACT_TIMES. */ SUBTRACT_TIMES("subtractTimes", 3), + /** RESOLVE_URI. */ RESOLVE_URI("resolveURI", 3), + /** ANY_URI. */ ANY_URI("anyURI", 7), + /** ADD_YEAR_MONTH_DURATIONS. */ ADD_YEAR_MONTH_DURATIONS("addYearMonthDurations", -1), + /** SUBTRACT_YEAR_MONTH_DURATIONS. */ SUBTRACT_YEAR_MONTH_DURATIONS("subtractYearMonthDurations", 3), + /** MULTIPLY_YEAR_MONTH_DURATIONS. */ MULTIPLY_YEAR_MONTH_DURATIONS("multiplyYearMonthDurations", 3), + /** DIVIDE_YEAR_MONTH_DURATIONS. */ DIVIDE_YEAR_MONTH_DURATIONS("divideYearMonthDurations", 3), + /** ADD_DAY_TIME_DURATIONS. */ ADD_DAY_TIME_DURATIONS("addDayTimeDurations", -1), + /** SUBTRACT_DAY_TIME_DURATIONS. */ SUBTRACT_DAY_TIME_DURATIONS("subtractDayTimeDurations", 3), + /** MULTIPLY_DAY_TIME_DURATIONS. */ MULTIPLY_DAY_TIME_DURATIONS("multiplyDayTimeDurations", 3), + /** DIVIDE_DAY_TIME_DURATIONS. */ DIVIDE_DAY_TIME_DURATIONS("divideDayTimeDurations", 3), + /** ADD_DAY_TIME_DURATION_TO_DATE_TIME. */ ADD_DAY_TIME_DURATION_TO_DATE_TIME("addDayTimeDurationToDateTime", 3), + /** SUBTRACT_YEAR_MONTH_DURATION_FROM_DATE_TIME. */ SUBTRACT_YEAR_MONTH_DURATION_FROM_DATE_TIME("subtractYearMonthDurationFromDateTime", 3), + /** SUBTRACT_DAY_TIME_DURATION_FROM_DATE_TIME. */ SUBTRACT_DAY_TIME_DURATION_FROM_DATE_TIME("subtractDayTimeDurationFromDateTime", 3), + /** ADD_YEAR_MONTH_DURATION_TO_DATE. */ ADD_YEAR_MONTH_DURATION_TO_DATE("addYearMonthDurationToDate", 3), + /** ADD_DAY_TIME_DURATION_TO_DATE. */ ADD_DAY_TIME_DURATION_TO_DATE("addDayTimeDurationToDate", 3), + /** SUBTRACT_YEAR_MONTH_DURATION_FROM_DATE. */ SUBTRACT_YEAR_MONTH_DURATION_FROM_DATE("subtractYearMonthDurationFromDate", 3), + /** SUBTRACT_DAY_TIME_DURATION_FROM_DATE. */ SUBTRACT_DAY_TIME_DURATION_FROM_DATE("subtractDayTimeDurationFromDate", 3), + /** ADD_DAY_TIME_DURATION_FROM_TIME. */ ADD_DAY_TIME_DURATION_FROM_TIME("addDayTimeDurationToTime", 3), + /** SUBTRACT_DAY_TIME_DURATION_FROM_TIME. */ SUBTRACT_DAY_TIME_DURATION_FROM_TIME("subtractDayTimeDurationFromTime", 3), + /** SUBTRACT_DATE_TIMES_YIELDING_YEAR_MONTH_DURATION. */ SUBTRACT_DATE_TIMES_YIELDING_YEAR_MONTH_DURATION("subtractDateTimesYieldingYearMonthDuration", 3), + /** SUBTRACT_DATE_TIMES_YIELDING_DAY_TIME_DURATION. */ SUBTRACT_DATE_TIMES_YIELDING_DAY_TIME_DURATION("subtractDateTimesYieldingDayTimeDuration", 3); + //@formatter:on + private final String shortName; + private final String prefixedName; + private final IRI iri; + // Arity of the predicate (-1 if infinite) + private final int minArity; + private final int maxArity; + + SWRLBuiltInsVocabulary(String name, int arity) { + this(name, arity, arity); + } + + SWRLBuiltInsVocabulary(String name, int minArity, int maxArity) { + shortName = name; + prefixedName = Namespaces.SWRLB.getPrefixName() + ':' + name; + iri = IRI.create(Namespaces.SWRLB.toString(), name); + this.minArity = minArity; + this.maxArity = maxArity; + } + + /** + * Gets a builtin vocabulary value for a given IRI. + * + * @param iri The IRI + * @return The builtin vocabulary having the specified IRI, or {@code null} if there is no + * builtin vocabulary with the specified IRI + */ + @Nullable + public static SWRLBuiltInsVocabulary getBuiltIn(IRI iri) { + return Stream.of(values()).filter(v -> v.iri.equals(iri)).findAny().orElse(null); + } + + @Override + public String getShortForm() { + return shortName; + } + + @Override + public IRI getIRI() { + return iri; + } + + /** + * Gets the minimum arity of this built in. + * + * @return The minimum arity of this built in + */ + public int getMinArity() { + return minArity; + } + + /** + * Gets the maximum arity of this built in. + * + * @return The maximum arity of the built in or -1 if the arity is infinite + */ + public int getMaxArity() { + return maxArity; + } + + @Override + public String getPrefixedName() { + return prefixedName; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/vocab/SWRLVocabulary.java b/api/src/main/java/org/semanticweb/owlapi/vocab/SWRLVocabulary.java new file mode 100644 index 0000000000..858cd563bd --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/vocab/SWRLVocabulary.java @@ -0,0 +1,71 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.vocab; + +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.HasPrefixedName; +import org.semanticweb.owlapi.model.HasShortForm; +import org.semanticweb.owlapi.model.IRI; + +/** + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + */ +public enum SWRLVocabulary implements HasShortForm, HasIRI, HasPrefixedName { +//@formatter:off + /** IMP. */ IMP ("Imp"), + /** INDIVIDUAL_PROPERTY_ATOM. */ INDIVIDUAL_PROPERTY_ATOM("IndividualPropertyAtom"), + /** DATAVALUED_PROPERTY_ATOM. */ DATAVALUED_PROPERTY_ATOM("DatavaluedPropertyAtom"), + /** CLASS_ATOM. */ CLASS_ATOM ("ClassAtom"), + /** DATA_RANGE_ATOM. */ DATA_RANGE_ATOM ("DataRangeAtom"), + /** VARIABLE. */ VARIABLE ("Variable"), + /** ATOM_LIST. */ ATOM_LIST ("AtomList"), + /** SAME_INDIVIDUAL_ATOM. */ SAME_INDIVIDUAL_ATOM ("SameIndividualAtom"), + /** DIFFERENT_INDIVIDUALS_ATOM. */ DIFFERENT_INDIVIDUALS_ATOM("DifferentIndividualsAtom"), + /** BUILT_IN_ATOM. */ BUILT_IN_ATOM ("BuiltinAtom"), + /** HEAD. */ HEAD ("head"), + /** BODY. */ BODY ("body"), + /** CLASS_PREDICATE. */ CLASS_PREDICATE ("classPredicate"), + /** DATA_RANGE. */ DATA_RANGE ("dataRange"), + /** PROPERTY_PREDICATE. */ PROPERTY_PREDICATE ("propertyPredicate"), + /** BUILT_IN. */ BUILT_IN ("builtin"), + /** BUILT_IN_CLASS. */ BUILT_IN_CLASS ("Builtin"), + /** ARGUMENTS. */ ARGUMENTS ("arguments"), + /** ARGUMENT_1. */ ARGUMENT_1 ("argument1"), + /** ARGUMENT_2. */ ARGUMENT_2 ("argument2"); + //@formatter:on + private final String shortName; + private final IRI iri; + private final String prefixedName; + + SWRLVocabulary(String name) { + shortName = name; + prefixedName = Namespaces.SWRL.getPrefixName() + ':' + name; + iri = IRI.create(Namespaces.SWRL.toString(), name); + } + + @Override + public IRI getIRI() { + return iri; + } + + @Override + public String getShortForm() { + return shortName; + } + + @Override + public String getPrefixedName() { + return prefixedName; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/vocab/TIMEVocabulary.java b/api/src/main/java/org/semanticweb/owlapi/vocab/TIMEVocabulary.java new file mode 100644 index 0000000000..e161cf8645 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/vocab/TIMEVocabulary.java @@ -0,0 +1,157 @@ +package org.semanticweb.owlapi.vocab; + +import static org.semanticweb.owlapi.model.EntityType.CLASS; +import static org.semanticweb.owlapi.model.EntityType.DATA_PROPERTY; +import static org.semanticweb.owlapi.model.EntityType.NAMED_INDIVIDUAL; +import static org.semanticweb.owlapi.model.EntityType.OBJECT_PROPERTY; +import static org.semanticweb.owlapi.vocab.Namespaces.TIME; + +import org.semanticweb.owlapi.model.EntityType; +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.HasPrefixedName; +import org.semanticweb.owlapi.model.HasShortForm; +import org.semanticweb.owlapi.model.IRI; + +/** + * @author Alex To, The University Of Sydney, Faculty of Engineering and Information Technologies + * @since 5.1.0 + */ +public enum TIMEVocabulary implements HasShortForm, HasIRI, HasPrefixedName { + + // Time Vocab http://www.w3.org/2006/time# + //@formatter:off + /** http://www.w3.org/2006/time#DayOfWeek. */DAY_OF_WEEK_CLASS (TIME, "DayOfWeek", CLASS), + /** http://www.w3.org/2006/time#generalYear. */GENERAL_YEAR (TIME, "generalYear", CLASS), + /** http://www.w3.org/2006/time#TemporalDuration. */TEMPORAL_DURATION (TIME, "TemporalDuration", CLASS), + /** http://www.w3.org/2006/time#GeneralDurationDescription. */GENERAL_DURATION_DESCRIPTION (TIME, "GeneralDurationDescription", CLASS), + /** http://www.w3.org/2006/time#DurationDescription. */DURATION_DESCRIPTION (TIME, "DurationDescription", CLASS), + /** http://www.w3.org/2006/time#Year. */YEAR_CLASS (TIME, "Year", CLASS), + /** http://www.w3.org/2006/time#TemporalUnit. */TEMPORAL_UNIT (TIME, "TemporalUnit", CLASS), + /** http://www.w3.org/2006/time#Duration. */DURATION (TIME, "Duration", CLASS), + /** http://www.w3.org/2006/time#TemporalEntity. */TEMPORAL_ENTITY (TIME, "TemporalEntity", CLASS), + /** http://www.w3.org/2006/time#Instant. */INSTANT (TIME, "Instant", CLASS), + /** http://www.w3.org/2006/time#Interval. */INTERVAL (TIME, "Interval", CLASS), + /** http://www.w3.org/2006/time#ProperInterval. */PROPER_INTERVAL (TIME, "ProperInterval", CLASS), + /** http://www.w3.org/2006/time#DateTimeInterval. */DATE_TIME_INTERVAL (TIME, "DateTimeInterval", CLASS), + /** http://www.w3.org/2006/time#TemporalPosition. */TEMPORAL_POSITION (TIME, "TemporalPosition", CLASS), + /** http://www.w3.org/2006/time#GeneralDateTimeDescription. */GENERAL_DATE_TIME_DESCRIPTION (TIME, "GeneralDateTimeDescription", CLASS), + /** http://www.w3.org/2006/time#DateTimeDescription. */DATE_TIME_DESCRIPTION (TIME, "DateTimeDescription", CLASS), + /** http://www.w3.org/2006/time#MonthOfYear. */MONTH_OF_YEAR_CLASS (TIME, "MonthOfYear", CLASS), + /** http://www.w3.org/2006/time#January. */JANUARY (TIME, "January", CLASS), + /** http://www.w3.org/2006/time#TimePosition. */TIME_POSITION (TIME, "TimePosition", CLASS), + /** http://www.w3.org/2006/time#TRS. */TEMPORAL_REFERENCE_SYSTEM (TIME, "TRS", CLASS), + /** http://www.w3.org/2006/time#TimeZone. */TIME_ZONE_CLASS (TIME, "TimeZone", CLASS), + /** http://www.w3.org/2006/time#after. */AFTER (TIME, "after", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#intervalAfter. */INTERVAL_AFTER (TIME, "intervalAfter", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#intervalBefore. */BEFORE (TIME, "intervalBefore", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#dayOfWeek. */DAY_OF_WEEK_PROPERTY (TIME, "dayOfWeek", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#hasDateTimeDescription. */HAS_DATE_TIME_DESCRIPTION (TIME, "hasDateTimeDescription", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#hasTemporalDuration. */HAS_TEMPORAL_DURATION (TIME, "hasTemporalDuration", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#hasDuration. */HAS_DURATION (TIME, "hasDuration", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#hasDurationDescription. */HAS_DURATION_DESCRIPTION (TIME, "hasDurationDescription", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#hasTime. */HAS_TIME (TIME, "hasTime", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#hasBeginning. */HAS_BEGINNING (TIME, "hasBeginning", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#hasEnd. */HAS_END (TIME, "hasEnd", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#inside. */INSIDE (TIME, "inside", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#timeZone. */TIME_ZONE_PROPERTY (TIME, "timeZone", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#intervalContains. */INTERVAL_CONTAINS (TIME, "intervalContains", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#intervalDisjoint. */INTERVAL_DISJOINT (TIME, "intervalDisjoint", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#intervalEquals. */INTERVAL_EQUALS (TIME, "intervalEquals", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#intervalFinishedBy. */INTERVAL_FINISHED_BY (TIME, "intervalFinishedBy", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#intervalIn. */INTERVAL_IN (TIME, "intervalIn", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#intervalDuring. */INTERVAL_DURING (TIME, "intervalDuring", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#intervalFinishes. */INTERVAL_FINISHES (TIME, "intervalFinishes", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#intervalStarts. */INTERVAL_STARTS (TIME, "intervalStarts", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#intervalMeets. */INTERVAL_MEETS (TIME, "intervalMeets", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#intervalMetBy. */INTERVAL_MET_BY (TIME, "intervalMetBy", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#intervalOverlappedBy. */INTERVAL_OVERLAPPED_BY (TIME, "intervalOverlappedBy", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#intervalOverlaps. */INTERVAL_OVERLAP (TIME, "intervalOverlaps", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#intervalStartedBy. */INTERVAL_STARTED_BY (TIME, "intervalStartedBy", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#monthOfYear. */MONTH_OF_YEAR_PROPERTY (TIME, "monthOfYear", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#inTemporalPosition. */IN_TEMPORAL_POSITION (TIME, "inTemporalPosition", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#inDateTime. */IN_DATE_TIME (TIME, "inDateTime", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#inTimePosition. */IN_TIME_POSITION (TIME, "inTimePosition", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#hasTRS. */HAS_TRS (TIME, "hasTRS", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#unitType. */UNIT_TYPE (TIME, "unitType", OBJECT_PROPERTY), + /** http://www.w3.org/2006/time#day. */DAY (TIME, "day", DATA_PROPERTY), + /** http://www.w3.org/2006/time#dayOfYear. */DAY_OF_YEAR (TIME, "dayOfYear", DATA_PROPERTY), + /** http://www.w3.org/2006/time#days. */DAYS (TIME, "days", DATA_PROPERTY), + /** http://www.w3.org/2006/time#hasXSDDuration. */HAS_XSD_DURATION (TIME, "hasXSDDuration", DATA_PROPERTY), + /** http://www.w3.org/2006/time#hour. */HOUR (TIME, "hour", DATA_PROPERTY), + /** http://www.w3.org/2006/time#hours. */HOURS (TIME, "hours", DATA_PROPERTY), + /** http://www.w3.org/2006/time#inXSDDateTimeStamp. */IN_XSD_DATE_TIME_STAMP (TIME, "inXSDDateTimeStamp", DATA_PROPERTY), + /** http://www.w3.org/2006/time#inXSDgYear. */IN_XSD_G_YEAR (TIME, "inXSDgYear", DATA_PROPERTY), + /** http://www.w3.org/2006/time#inXSDgYearMonth. */IN_XSD_G_YEAR_MONTH (TIME, "inXSDgYearMonth", DATA_PROPERTY), + /** http://www.w3.org/2006/time#minute. */MINUTE (TIME, "minute", DATA_PROPERTY), + /** http://www.w3.org/2006/time#minutes. */MINUTES (TIME, "minutes", DATA_PROPERTY), + /** http://www.w3.org/2006/time#month. */MONTH (TIME, "month", DATA_PROPERTY), + /** http://www.w3.org/2006/time#months. */MONTHS (TIME, "months", DATA_PROPERTY), + /** http://www.w3.org/2006/time#nominalPosition. */NOMINAL_POSITION (TIME, "nominalPosition", DATA_PROPERTY), + /** http://www.w3.org/2006/time#numericDuration. */NUMERIC_DURATION (TIME, "numericDuration", DATA_PROPERTY), + /** http://www.w3.org/2006/time#numericPosition. */NUMERIC_POSITION (TIME, "numericPosition", DATA_PROPERTY), + /** http://www.w3.org/2006/time#second. */SECOND (TIME, "second", DATA_PROPERTY), + /** http://www.w3.org/2006/time#seconds. */SECONDS (TIME, "seconds", DATA_PROPERTY), + /** http://www.w3.org/2006/time#week. */WEEK (TIME, "week", DATA_PROPERTY), + /** http://www.w3.org/2006/time#weeks. */WEEKS (TIME, "weeks", DATA_PROPERTY), + /** http://www.w3.org/2006/time#year. */YEAR_PROPERTY (TIME, "year", DATA_PROPERTY), + /** http://www.w3.org/2006/time#years. */YEARS (TIME, "years", DATA_PROPERTY), + /** http://www.w3.org/2006/time#xsdDateTime. */XSD_DATE_TIME (TIME, "xsdDateTime", DATA_PROPERTY), + /** http://www.w3.org/2006/time#inXSDDateTime. */IN_XSD_DATE_TIME (TIME, "inXSDDateTime", DATA_PROPERTY), + /** http://www.w3.org/2006/time#unitDay. */UNIT_DAY (TIME, "unitDay", NAMED_INDIVIDUAL), + /** http://www.w3.org/2006/time#Friday. */FRIDAY (TIME, "Friday", NAMED_INDIVIDUAL), + /** http://www.w3.org/2006/time#unitHour. */UNIT_HOUR (TIME, "unitHour", NAMED_INDIVIDUAL), + /** http://www.w3.org/2006/time#unitMinute. */UNIT_MINUTE (TIME, "unitMinute", NAMED_INDIVIDUAL), + /** http://www.w3.org/2006/time#Monday. */MONDAY (TIME, "Monday", NAMED_INDIVIDUAL), + /** http://www.w3.org/2006/time#unitMonth. */UNIT_MONTH (TIME, "unitMonth", NAMED_INDIVIDUAL), + /** http://www.w3.org/2006/time#Saturday. */SATURDAY (TIME, "Saturday", NAMED_INDIVIDUAL), + /** http://www.w3.org/2006/time#unitSecond. */UNIT_SECOND (TIME, "unitSecond", NAMED_INDIVIDUAL), + /** http://www.w3.org/2006/time#Sunday. */SUNDAY (TIME, "Sunday", NAMED_INDIVIDUAL), + /** http://www.w3.org/2006/time#Thursday. */THURSDAY (TIME, "Thursday", NAMED_INDIVIDUAL), + /** http://www.w3.org/2006/time#Tuesday. */TUESDAY (TIME, "Tuesday", NAMED_INDIVIDUAL), + /** http://www.w3.org/2006/time#Wednesday. */WEDNESDAY (TIME, "Wednesday", NAMED_INDIVIDUAL), + /** http://www.w3.org/2006/time#unitWeek. */UNIT_WEEK (TIME, "unitWeek", NAMED_INDIVIDUAL), + /** http://www.w3.org/2006/time#unitYear. */UNIT_YEAR (TIME, "unitYear", NAMED_INDIVIDUAL); +//@formatter:on + private final IRI iri; + private final Namespaces namespace; + private final String shortName; + private final String prefixedName; + private final EntityType entityType; + + TIMEVocabulary(Namespaces namespace, String shortName, EntityType entityType) { + this.namespace = namespace; + this.shortName = shortName; + prefixedName = namespace.getPrefixName() + ':' + shortName; + iri = IRI.create(namespace.toString(), shortName); + this.entityType = entityType; + } + + @Override + public IRI getIRI() { + return iri; + } + + @Override + public String getPrefixedName() { + return prefixedName; + } + + @Override + public String getShortForm() { + return shortName; + } + + /** + * @return namespace + */ + public Namespaces getNamespace() { + return namespace; + } + + /** + * @return entity type + */ + public EntityType getEntityType() { + return entityType; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/vocab/XSDVocabulary.java b/api/src/main/java/org/semanticweb/owlapi/vocab/XSDVocabulary.java new file mode 100644 index 0000000000..0d525043de --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/vocab/XSDVocabulary.java @@ -0,0 +1,130 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.vocab; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.HasPrefixedName; +import org.semanticweb.owlapi.model.HasShortForm; +import org.semanticweb.owlapi.model.IRI; + +/** + * A vocabulary for XML Schema Data Types (XSD). + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public enum XSDVocabulary implements HasShortForm, HasIRI, HasPrefixedName { + // @formatter:off + /** ANY_TYPE. */ ANY_TYPE ("anyType"), + /** ANY_SIMPLE_TYPE. */ ANY_SIMPLE_TYPE ("anySimpleType"), + /** STRING. */ STRING ("string"), + /** INTEGER. */ INTEGER ("integer"), + /** LONG. */ LONG ("long"), + /** INT. */ INT ("int"), + /** SHORT. */ SHORT ("short"), + /** BYTE. */ BYTE ("byte"), + /** DECIMAL. */ DECIMAL ("decimal"), + /** FLOAT. */ FLOAT ("float"), + /** BOOLEAN. */ BOOLEAN ("boolean"), + /** DOUBLE. */ DOUBLE ("double"), + /** NON_POSITIVE_INTEGER. */ NON_POSITIVE_INTEGER("nonPositiveInteger"), + /** NEGATIVE_INTEGER. */ NEGATIVE_INTEGER ("negativeInteger"), + /** NON_NEGATIVE_INTEGER. */ NON_NEGATIVE_INTEGER("nonNegativeInteger"), + /** UNSIGNED_LONG. */ UNSIGNED_LONG ("unsignedLong"), + /** UNSIGNED_INT. */ UNSIGNED_INT ("unsignedInt"), + /** POSITIVE_INTEGER. */ POSITIVE_INTEGER ("positiveInteger"), + /** BASE_64_BINARY. */ BASE_64_BINARY ("base64Binary"), + /** NORMALIZED_STRING. */ NORMALIZED_STRING ("normalizedString"), + /** HEX_BINARY. */ HEX_BINARY ("hexBinary"), + /** ANY_URI. */ ANY_URI ("anyURI"), + /** Q_NAME. */ Q_NAME ("QName"), + /** NOTATION. */ NOTATION ("NOTATION"), + /** TOKEN. */ TOKEN ("token"), + /** LANGUAGE. */ LANGUAGE ("language"), + /** NAME. */ NAME ("Name"), + /** NCNAME. */ NCNAME ("NCName"), + /** NMTOKEN. */ NMTOKEN ("NMTOKEN"), + /** NMTOKENS. */ NMTOKENS ("NMTOKENS"), + /** ID. */ ID ("ID"), + /** IDREF. */ IDREF ("IDREF"), + /** IDREFS. */ IDREFS ("IDREFS"), + /** ENTITY. */ ENTITY ("ENTITY"), + /** ENTITIES. */ ENTITIES ("ENTITIES"), + /** DURATION. */ DURATION ("duration"), + /** DATE_TIME. */ DATE_TIME ("dateTime"), + /** DATE_TIME_STAMP. */ DATE_TIME_STAMP ("dateTimeStamp"), + /** TIME. */ TIME ("time"), + /** DATE. */ DATE ("date"), + /** G_YEAR_MONTH. */ G_YEAR_MONTH ("gYearMonth"), + /** G_YEAR. */ G_YEAR ("gYear"), + /** G_MONTH_DAY. */ G_MONTH_DAY ("gMonthYear"), + /** G_DAY. */ G_DAY ("gDay"), + /** G_MONTH. */ G_MONTH ("gMonth"), + /** UNSIGNED_SHORT. */ UNSIGNED_SHORT ("unsignedShort"), + /** UNSIGNED_BYTE. */ UNSIGNED_BYTE ("unsignedByte"); + // @formatter:on + private final String shortName; + private final IRI iri; + private final String prefixedName; + + XSDVocabulary(String name) { + shortName = name; + prefixedName = Namespaces.XSD.getPrefixName() + ':' + name; + iri = IRI.create(Namespaces.XSD.toString(), name); + } + + /** + * Easy parse of short names of the kind "xsd:typename". Note that the match + * must be exact - uppercase or lowercase variants are not accepted. An + * IllegalArgumentException will be thrown for non matching input. + * + * @param s string of the form {@code xsd:typename} + * @return the XSDVocabulary item matching xsd:typename, e.g., {@code STRING} for {@code + * "xsd:string"} + */ + public static XSDVocabulary parseShortName(String s) { + checkNotNull(s, "the input string cannot be null"); + if (s.startsWith("xsd:")) { + String name = s.substring(4); + for (XSDVocabulary v : values()) { + if (v.shortName.equals(name)) { + return v; + } + } + } + throw new IllegalArgumentException( + "the input value does not match any of the known xsd types: " + s); + } + + @Override + public String getShortForm() { + return shortName; + } + + @Override + public IRI getIRI() { + return iri; + } + + @Override + public String toString() { + return iri.toString(); + } + + @Override + public String getPrefixedName() { + return prefixedName; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapi/vocab/package-info.java b/api/src/main/java/org/semanticweb/owlapi/vocab/package-info.java new file mode 100644 index 0000000000..22f2747987 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/vocab/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Vocabulary package. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.vocab; diff --git a/api/src/main/java/org/semanticweb/owlapi/vocab/packageinfo b/api/src/main/java/org/semanticweb/owlapi/vocab/packageinfo new file mode 100644 index 0000000000..992045e711 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapi/vocab/packageinfo @@ -0,0 +1 @@ +version 6.0.0 diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BaseAnnotationPropertyBuilder.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseAnnotationPropertyBuilder.java new file mode 100644 index 0000000000..6b0506f36b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseAnnotationPropertyBuilder.java @@ -0,0 +1,66 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObject; + +/** + * Builder class for OWLDataAllValuesFrom. + * + * @param type built + * @param builder type + */ +public abstract class BaseAnnotationPropertyBuilder extends + BaseBuilder implements + SettableProperty { + + @Nullable + private OWLAnnotationProperty property = null; + + /** + * @param df data factory + */ + @Inject + public BaseAnnotationPropertyBuilder(OWLDataFactory df) { + super(df); + } + + @Override + @SuppressWarnings("unchecked") + public B withProperty(OWLAnnotationProperty arg) { + property = arg; + return (B) this; + } + + /** + * @param arg property + * @return builder + */ + @SuppressWarnings("unchecked") + public B withProperty(IRI arg) { + property = df.getOWLAnnotationProperty(arg); + return (B) this; + } + + @Override + public OWLAnnotationProperty getProperty() { + return verifyNotNull(property); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BaseBuilder.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseBuilder.java new file mode 100644 index 0000000000..a2a2d7e4b7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseBuilder.java @@ -0,0 +1,119 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.add; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.stream.Stream; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.profiles.OWLProfileReport; +import org.semanticweb.owlapi.profiles.Profiles; + +/** + * Base builder class, providing annotations storage. + * + * @param built type + * @param builder type + * @author ignazio + */ +public abstract class BaseBuilder implements Builder { + + protected final OWLDataFactory df; + protected final List annotations = new ArrayList<>(); + + /** + * @param df data factory + */ + @Inject + protected BaseBuilder(OWLDataFactory df) { + this.df = checkNotNull(df); + } + + /** + * @param arg annotation + * @return builder + */ + @SuppressWarnings("unchecked") + public B withAnnotation(OWLAnnotation arg) { + annotations.add(arg); + return (B) this; + } + + /** + * @param arg annotations + * @return builder + */ + @SuppressWarnings("unchecked") + public B withAnnotations(Collection arg) { + annotations.addAll(arg); + return (B) this; + } + + /** + * @param arg annotations + * @return builder + */ + @SuppressWarnings("unchecked") + public B withAnnotations(Stream arg) { + add(annotations, arg); + return (B) this; + } + + /** + * Clear annotations. + * + * @return builder + */ + @SuppressWarnings("unchecked") + public B clearAnnotations() { + annotations.clear(); + return (B) this; + } + + @Override + public abstract T buildObject(); + + @Override + public List applyChanges(OWLOntology o) { + T object = buildObject(); + if (!(object instanceof OWLAxiom)) { + return Collections.emptyList(); + } + // create and apply the new change + AddAxiom change = new AddAxiom(o, (OWLAxiom) object); + o.applyChange(change); + // check conformity to the profile + OWLProfileReport report = Profiles.OWL2_DL.checkOntology(o); + // collect all changes to fix the ontology + List changes = asList( + report.getViolations().stream().flatMap(v -> v.repair().stream())); + // fix the ontology + o.getOWLOntologyManager().applyChanges(changes); + // return all applied changes for reference + changes.add(change); + return changes; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BaseDataBuilder.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseDataBuilder.java new file mode 100644 index 0000000000..341574ae07 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseDataBuilder.java @@ -0,0 +1,71 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; + +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * Builder class for OWLDataAllValuesFrom. + * + * @param type built + * @param builder type + */ +public abstract class BaseDataBuilder extends BaseDataPropertyBuilder + implements SettableRange { + + @Nullable + private OWLDataRange dataRange = null; + + /** + * @param df data factory + */ + @Inject + public BaseDataBuilder(OWLDataFactory df) { + super(df); + } + + /** + * @param arg range + * @return builder + */ + public B withRange(OWL2Datatype arg) { + return withRange(arg.getDatatype(df)); + } + + @Override + @SuppressWarnings("unchecked") + public B withRange(OWLDataRange arg) { + dataRange = arg; + return (B) this; + } + + /** + * @return the data range + */ + public OWLDataRange getDataRange() { + return verifyNotNull(dataRange); + } + + @Override + public OWLDataRange getRange() { + return getDataRange(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BaseDataPropertyBuilder.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseDataPropertyBuilder.java new file mode 100644 index 0000000000..5d70ccaf24 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseDataPropertyBuilder.java @@ -0,0 +1,55 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLObject; + +/** + * Builder class for OWLDataAllValuesFrom. + * + * @param type built + * @param builder type + */ +public abstract class BaseDataPropertyBuilder extends + BaseBuilder implements + SettableProperty { + + @Nullable + private OWLDataPropertyExpression property = null; + + /** + * @param df data factory + */ + @Inject + public BaseDataPropertyBuilder(OWLDataFactory df) { + super(df); + } + + @Override + @SuppressWarnings("unchecked") + public B withProperty(OWLDataPropertyExpression arg) { + property = arg; + return (B) this; + } + + @Override + public OWLDataPropertyExpression getProperty() { + return verifyNotNull(property); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BaseDomainBuilder.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseDomainBuilder.java new file mode 100644 index 0000000000..677e74d0ad --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseDomainBuilder.java @@ -0,0 +1,78 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObject; + +/** + * Builder class for OWLDataPropertyDomainAxiom. + * + * @param type built + * @param builder type + * @param

contained items type + */ +public abstract class BaseDomainBuilder extends BaseBuilder { + + @Nullable + private P property = null; + @Nullable + private OWLClassExpression domain = null; + + /** + * @param df data factory + */ + @Inject + public BaseDomainBuilder(OWLDataFactory df) { + super(df); + } + + /** + * @param arg domain + * @return builder + */ + @SuppressWarnings("unchecked") + public B withDomain(OWLClassExpression arg) { + domain = arg; + return (B) this; + } + + /** + * @param arg property + * @return builder + */ + @SuppressWarnings("unchecked") + public B withProperty(P arg) { + property = arg; + return (B) this; + } + + /** + * @return the property + */ + public P getProperty() { + return verifyNotNull(property); + } + + /** + * @return the domain + */ + public OWLClassExpression getDomain() { + return verifyNotNull(domain); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BaseEntityBuilder.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseEntityBuilder.java new file mode 100644 index 0000000000..6653c25798 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseEntityBuilder.java @@ -0,0 +1,98 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.PrefixManager; + +/** + * Abstract builder for entities. + * + * @param OWL type + * @param builder type + * @author ignazio + */ +public abstract class BaseEntityBuilder extends BaseBuilder { + + @Nullable + protected String string = null; + @Nullable + protected PrefixManager pm = null; + @Nullable + private IRI iri = null; + + /** + * @param df data factory + */ + @Inject + public BaseEntityBuilder(OWLDataFactory df) { + super(df); + } + + /** + * @param arg property iri + * @return builder + */ + @SuppressWarnings("unchecked") + public B withIRI(IRI arg) { + iri = arg; + return (B) this; + } + + /** + * @param arg prefix manager + * @return builder + */ + @SuppressWarnings("unchecked") + public B withPrefixManager(PrefixManager arg) { + pm = arg; + return (B) this; + } + + /** + * @param arg prefixed iri + * @return builder + */ + @SuppressWarnings("unchecked") + public B withPrefixedIRI(String arg) { + string = arg; + return (B) this; + } + + /** + * @return iri + */ + public IRI getIRI() { + return verifyNotNull(iri); + } + + /** + * @return string + */ + public String getString() { + return verifyNotNull(string); + } + + /** + * @return prefix manager + */ + public PrefixManager getPM() { + return verifyNotNull(pm); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BaseObjectBuilder.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseObjectBuilder.java new file mode 100644 index 0000000000..2a5b4be893 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseObjectBuilder.java @@ -0,0 +1,55 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObject; + +/** + * Builder class for OWLDataAllValuesFrom. + * + * @param type built + * @param builder type + */ +public abstract class BaseObjectBuilder extends + BaseObjectPropertyBuilder implements + SettableRange { + + @Nullable + private OWLClassExpression range = null; + + /** + * @param df data factory + */ + @Inject + public BaseObjectBuilder(OWLDataFactory df) { + super(df); + } + + @Override + @SuppressWarnings("unchecked") + public B withRange(OWLClassExpression arg) { + range = arg; + return (B) this; + } + + @Override + public OWLClassExpression getRange() { + return verifyNotNull(range); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BaseObjectPropertyBuilder.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseObjectPropertyBuilder.java new file mode 100644 index 0000000000..31e49f0c8a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseObjectPropertyBuilder.java @@ -0,0 +1,54 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.annotation.Nullable; +import javax.inject.Inject; + +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; + +/** + * Builder class for OWLDataAllValuesFrom. + * + * @param type built + * @param builder type + */ +public abstract class BaseObjectPropertyBuilder extends BaseBuilder + implements SettableProperty { + + @Nullable + private OWLObjectPropertyExpression property = null; + + /** + * @param df data factory + */ + @Inject + public BaseObjectPropertyBuilder(OWLDataFactory df) { + super(df); + } + + @Override + @SuppressWarnings("unchecked") + public B withProperty(OWLObjectPropertyExpression arg) { + property = arg; + return (B) this; + } + + @Override + @Nullable + public OWLObjectPropertyExpression getProperty() { + return property; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BaseSetBuilder.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseSetBuilder.java new file mode 100644 index 0000000000..cc1af68f17 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseSetBuilder.java @@ -0,0 +1,87 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.add; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Stream; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObject; + +/** + * Abstract builder for entities. + * + * @param type built + * @param builder type + * @param contained items type + * @author ignazio + */ +public abstract class BaseSetBuilder extends BaseBuilder { + + protected final Set items = new HashSet<>(); + + /** + * @param df data factory + */ + @Inject + public BaseSetBuilder(OWLDataFactory df) { + super(df); + } + + /** + * @param arg item to add + * @return builder + */ + @SuppressWarnings("unchecked") + public B withItem(I arg) { + items.add(arg); + return (B) this; + } + + /** + * @param arg items to add + * @return builder + */ + @SuppressWarnings("unchecked") + public B withItems(Collection arg) { + items.addAll(arg); + return (B) this; + } + + /** + * @param arg items to add + * @return builder + */ + @SuppressWarnings({"unchecked"}) + public B withItems(Stream arg) { + add(items, arg); + return (B) this; + } + + /** + * @param arg items to add + * @return builder + */ + @SafeVarargs + @SuppressWarnings("unchecked") + public final B withItems(I... arg) { + for (I i : arg) { + items.add(i); + } + return (B) this; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BaseSubBuilder.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseSubBuilder.java new file mode 100644 index 0000000000..2a16c0e228 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BaseSubBuilder.java @@ -0,0 +1,77 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObject; + +/** + * Builder class for OWLSubAnnotationPropertyOfAxiom. + * + * @param type built + * @param builder type + * @param contained items type + */ +public abstract class BaseSubBuilder extends BaseBuilder { + + @Nullable + private I sub = null; + @Nullable + private I sup = null; + + /** + * @param df data factory + */ + @Inject + public BaseSubBuilder(OWLDataFactory df) { + super(df); + } + + /** + * @param arg sub item + * @return builder + */ + @SuppressWarnings("unchecked") + public B withSub(I arg) { + sub = arg; + return (B) this; + } + + /** + * @param arg sup item + * @return builder + */ + @SuppressWarnings("unchecked") + public B withSup(I arg) { + sup = arg; + return (B) this; + } + + /** + * @return the sub + */ + @Nullable + public I getSub() { + return sub; + } + + /** + * @return the sup + */ + @Nullable + public I getSup() { + return sup; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/Builder.java b/api/src/main/java/org/semanticweb/owlapitools/builders/Builder.java new file mode 100644 index 0000000000..d2ecfe100c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/Builder.java @@ -0,0 +1,42 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import java.util.List; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; + +/** + * A builder interface for building owl objects. + * + * @param builder type + * @author ignazio + */ +public interface Builder { + + /** + * @return freshly built object + */ + T buildObject(); + + /** + * If the builder is constructing an axiom, this method will add the axiom + * and all needed changes to make the ontology fit in the expected profile; + * the changes will be returned but there is no need to apply them, as they + * have already been applied. + * + * @param o ontology + * @return changes the ontology to which the changes should be applied + */ + List applyChanges(OWLOntology o); +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAnnotation.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAnnotation.java new file mode 100644 index 0000000000..41b6ec8958 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAnnotation.java @@ -0,0 +1,71 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationValue; +import org.semanticweb.owlapi.model.OWLDataFactory; + +/** + * Builder class for OWLAnnotation. + */ +public class BuilderAnnotation extends + BaseAnnotationPropertyBuilder { + + @Nullable + private OWLAnnotationValue value = null; + + /** + * @param df data factory + */ + @Inject + public BuilderAnnotation(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderAnnotation(OWLAnnotation expected, OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withValue(expected.getValue()); + } + + /** + * @param arg the annotation value + * @return builder + */ + public BuilderAnnotation withValue(OWLAnnotationValue arg) { + value = arg; + return this; + } + + @Override + public OWLAnnotation buildObject() { + return df.getOWLAnnotation(getProperty(), getValue(), annotations); + } + + /** + * @return value + */ + public OWLAnnotationValue getValue() { + return verifyNotNull(value); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAnnotationAssertion.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAnnotationAssertion.java new file mode 100644 index 0000000000..c362f3de24 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAnnotationAssertion.java @@ -0,0 +1,107 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationSubject; +import org.semanticweb.owlapi.model.OWLAnnotationValue; +import org.semanticweb.owlapi.model.OWLDataFactory; + +/** + * Builder class for OWLAnnotationAssertionAxiom. + */ +public class BuilderAnnotationAssertion extends + BaseAnnotationPropertyBuilder implements + Builder { + + @Nullable + private OWLAnnotationSubject subject = null; + @Nullable + private OWLAnnotationValue value; + + /** + * @param df data factory + */ + @Inject + public BuilderAnnotationAssertion(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderAnnotationAssertion(OWLAnnotationAssertionAxiom expected, OWLDataFactory df) { + this(df); + withAnnotations(expected.annotations()).withSubject(expected.getSubject()) + .withProperty(expected.getProperty()) + .withValue(expected.getValue()); + } + + /** + * @param arg subject + * @return builder + */ + public BuilderAnnotationAssertion withSubject(OWLAnnotationSubject arg) { + subject = arg; + return this; + } + + /** + * @param arg subject + * @return builder + */ + public BuilderAnnotationAssertion withSubject(HasIRI arg) { + subject = arg.getIRI(); + return this; + } + + /** + * @param arg value + * @return builder + */ + public BuilderAnnotationAssertion withValue(OWLAnnotationValue arg) { + value = arg; + return this; + } + + @Override + public OWLAnnotationAssertionAxiom buildObject() { + return df.getOWLAnnotationAssertionAxiom(getProperty(), verifyNotNull(subject), + verifyNotNull(value), + annotations); + } + + /** + * @return value + */ + @Nullable + public OWLAnnotationValue getValue() { + return value; + } + + /** + * @return value + */ + @Nullable + public OWLAnnotationSubject getSubject() { + return subject; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAnnotationProperty.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAnnotationProperty.java new file mode 100644 index 0000000000..a725b0701c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAnnotationProperty.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLDataFactory; + +/** + * Builder class for OWLAnnotationProperty. + */ +public class BuilderAnnotationProperty extends + BaseEntityBuilder { + + /** + * @param df data factory + */ + @Inject + public BuilderAnnotationProperty(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderAnnotationProperty(OWLAnnotationProperty expected, OWLDataFactory df) { + this(df); + withIRI(expected.getIRI()); + } + + @Override + public OWLAnnotationProperty buildObject() { + if (pm != null && string != null) { + return df.getOWLAnnotationProperty(getString(), getPM()); + } + return df.getOWLAnnotationProperty(getIRI()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAnnotationPropertyDomain.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAnnotationPropertyDomain.java new file mode 100644 index 0000000000..091e648cfa --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAnnotationPropertyDomain.java @@ -0,0 +1,74 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataFactory; + +/** + * Builder class for OWLAnnotationPropertyDomainAxiom. + */ +public class BuilderAnnotationPropertyDomain + extends + BaseAnnotationPropertyBuilder { + + @Nullable + private IRI domain = null; + + /** + * @param df data factory + */ + @Inject + public BuilderAnnotationPropertyDomain(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderAnnotationPropertyDomain(OWLAnnotationPropertyDomainAxiom expected, + OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withDomain(expected.getDomain()) + .withAnnotations(expected.annotations()); + } + + /** + * @param arg domain + * @return builder + */ + public BuilderAnnotationPropertyDomain withDomain(IRI arg) { + domain = arg; + return this; + } + + @Override + public OWLAnnotationPropertyDomainAxiom buildObject() { + return df.getOWLAnnotationPropertyDomainAxiom(getProperty(), getDomain(), annotations); + } + + /** + * @return domain + */ + public IRI getDomain() { + return verifyNotNull(domain); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAnnotationPropertyRange.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAnnotationPropertyRange.java new file mode 100644 index 0000000000..35a4dfcc42 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAnnotationPropertyRange.java @@ -0,0 +1,74 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDataFactory; + +/** + * Builder class for OWLAnnotationPropertyRangeAxiom. + */ +public class BuilderAnnotationPropertyRange + extends + BaseAnnotationPropertyBuilder { + + @Nullable + private IRI iri = null; + + /** + * @param df data factory + */ + @Inject + public BuilderAnnotationPropertyRange(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderAnnotationPropertyRange(OWLAnnotationPropertyRangeAxiom expected, + OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withRange(expected.getRange()) + .withAnnotations(expected.annotations()); + } + + /** + * @param arg range + * @return builder + */ + public BuilderAnnotationPropertyRange withRange(IRI arg) { + iri = arg; + return this; + } + + @Override + public OWLAnnotationPropertyRangeAxiom buildObject() { + return df.getOWLAnnotationPropertyRangeAxiom(getProperty(), getRange(), annotations); + } + + /** + * @return range + */ + public IRI getRange() { + return verifyNotNull(iri); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAnonymousIndividual.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAnonymousIndividual.java new file mode 100644 index 0000000000..eeec6dd8bf --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAnonymousIndividual.java @@ -0,0 +1,73 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLDataFactory; + +/** + * Builder class for OWLAnonymousIndividual. + */ +public class BuilderAnonymousIndividual extends + BaseBuilder { + + @Nullable + private String id = null; + + /** + * @param df data factory + */ + @Inject + public BuilderAnonymousIndividual(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderAnonymousIndividual(OWLAnonymousIndividual expected, OWLDataFactory df) { + this(df); + withId(expected.getID().getID()); + } + + /** + * @param arg blank node id + * @return builder + */ + public BuilderAnonymousIndividual withId(String arg) { + id = arg; + return this; + } + + @Override + public OWLAnonymousIndividual buildObject() { + if (id == null) { + return df.getOWLAnonymousIndividual(); + } + return df.getOWLAnonymousIndividual(getId()); + } + + /** + * @return id + */ + public String getId() { + return verifyNotNull(id); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAsymmetricObjectProperty.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAsymmetricObjectProperty.java new file mode 100644 index 0000000000..b5a7b5c805 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderAsymmetricObjectProperty.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLDataFactory; + +/** + * Builder class for OWLAsymmetricObjectPropertyAxiom. + */ +public class BuilderAsymmetricObjectProperty extends + BaseObjectPropertyBuilder { + + /** + * @param df data factory + */ + @Inject + public BuilderAsymmetricObjectProperty(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderAsymmetricObjectProperty(OWLAsymmetricObjectPropertyAxiom expected, + OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withAnnotations(expected.annotations()); + } + + @Override + public OWLAsymmetricObjectPropertyAxiom buildObject() { + return df.getOWLAsymmetricObjectPropertyAxiom(verifyNotNull(getProperty()), annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderClass.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderClass.java new file mode 100644 index 0000000000..05d69ad652 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderClass.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataFactory; + +/** + * Builder class for OWLClass. + */ +public class BuilderClass extends BaseEntityBuilder { + + /** + * @param df data factory + */ + @Inject + public BuilderClass(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderClass(OWLClass expected, OWLDataFactory df) { + this(df); + withIRI(expected.getIRI()); + } + + @Override + public OWLClass buildObject() { + if (pm != null && string != null) { + return df.getOWLClass(getString(), getPM()); + } + return df.getOWLClass(getIRI()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderClassAssertion.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderClassAssertion.java new file mode 100644 index 0000000000..d833e9543f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderClassAssertion.java @@ -0,0 +1,91 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLIndividual; + +/** + * Builder class for OWLClassAssertionAxiom. + */ +public class BuilderClassAssertion extends + BaseBuilder { + + @Nullable + private OWLIndividual i = null; + @Nullable + private OWLClassExpression ce = null; + + /** + * @param df data factory + */ + @Inject + public BuilderClassAssertion(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderClassAssertion(OWLClassAssertionAxiom expected, OWLDataFactory df) { + this(df); + withClass(expected.getClassExpression()).withIndividual(expected.getIndividual()) + .withAnnotations(expected.annotations()); + } + + /** + * @param arg individual + * @return builder + */ + public BuilderClassAssertion withIndividual(OWLIndividual arg) { + i = arg; + return this; + } + + /** + * @param arg argument + * @return builder + */ + public BuilderClassAssertion withClass(OWLClassExpression arg) { + ce = arg; + return this; + } + + @Override + public OWLClassAssertionAxiom buildObject() { + return df.getOWLClassAssertionAxiom(getClassExpression(), getIndividual(), annotations); + } + + /** + * @return class expression + */ + public OWLClassExpression getClassExpression() { + return verifyNotNull(ce); + } + + /** + * @return individual + */ + public OWLIndividual getIndividual() { + return verifyNotNull(i); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderComplementOf.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderComplementOf.java new file mode 100644 index 0000000000..3437e3d2e0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderComplementOf.java @@ -0,0 +1,70 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; + +/** + * Builder class for OWLObjectComplementOf. + */ +public class BuilderComplementOf extends BaseBuilder { + + @Nullable + private OWLClassExpression c = null; + + /** + * @param df data factory + */ + @Inject + public BuilderComplementOf(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderComplementOf(OWLObjectComplementOf expected, OWLDataFactory df) { + this(df); + withClass(expected.getOperand()); + } + + /** + * @param arg class expression + * @return builder + */ + public BuilderComplementOf withClass(OWLClassExpression arg) { + c = arg; + return this; + } + + @Override + public OWLObjectComplementOf buildObject() { + return df.getOWLObjectComplementOf(getClassExpression()); + } + + /** + * @return class expression + */ + public OWLClassExpression getClassExpression() { + return verifyNotNull(c); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataAllValuesFrom.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataAllValuesFrom.java new file mode 100644 index 0000000000..8ad0612636 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataAllValuesFrom.java @@ -0,0 +1,48 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataFactory; + +/** + * Builder class for OWLDataAllValuesFrom. + */ +public class BuilderDataAllValuesFrom extends + BaseDataBuilder { + + /** + * @param df data factory + */ + @Inject + public BuilderDataAllValuesFrom(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDataAllValuesFrom(OWLDataAllValuesFrom expected, OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withRange(expected.getFiller()); + } + + @Override + public OWLDataAllValuesFrom buildObject() { + return df.getOWLDataAllValuesFrom(getProperty(), getDataRange()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataComplementOf.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataComplementOf.java new file mode 100644 index 0000000000..dde3cc318d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataComplementOf.java @@ -0,0 +1,80 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataComplementOf; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * Builder class for OWLDataComplementOf. + */ +public class BuilderDataComplementOf extends + BaseBuilder { + + @Nullable + private OWLDataRange dataRange = null; + + /** + * @param df data factory + */ + @Inject + public BuilderDataComplementOf(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDataComplementOf(OWLDataComplementOf expected, OWLDataFactory df) { + this(df); + withRange(expected.getDataRange()); + } + + /** + * @param arg range + * @return builder + */ + public BuilderDataComplementOf withRange(OWL2Datatype arg) { + return withRange(arg.getDatatype(df)); + } + + /** + * @param arg range + * @return builder + */ + public BuilderDataComplementOf withRange(OWLDataRange arg) { + dataRange = arg; + return this; + } + + @Override + public OWLDataComplementOf buildObject() { + return df.getOWLDataComplementOf(getRange()); + } + + /** + * @return range + */ + public OWLDataRange getRange() { + return verifyNotNull(dataRange); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataExactCardinality.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataExactCardinality.java new file mode 100644 index 0000000000..459f076418 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataExactCardinality.java @@ -0,0 +1,63 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataFactory; + +/** + * Builder class for OWLDataExactCardinality. + */ +public class BuilderDataExactCardinality extends + BaseDataBuilder + implements SettableCardinality { + + private int cardinality = -1; + + /** + * @param df data factory + */ + @Inject + public BuilderDataExactCardinality(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDataExactCardinality(OWLDataExactCardinality expected, OWLDataFactory df) { + this(df); + withCardinality(expected.getCardinality()).withProperty(expected.getProperty()) + .withRange(expected.getFiller()); + } + + @Override + public BuilderDataExactCardinality withCardinality(int arg) { + cardinality = arg; + return this; + } + + @Override + public int getCardinality() { + return cardinality; + } + + @Override + public OWLDataExactCardinality buildObject() { + return df.getOWLDataExactCardinality(cardinality, getProperty(), getDataRange()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataHasValue.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataHasValue.java new file mode 100644 index 0000000000..65f34bc6ed --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataHasValue.java @@ -0,0 +1,84 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLLiteral; + +/** + * Builder class for OWLDataHasValue. + */ +public class BuilderDataHasValue extends + BaseDataPropertyBuilder implements + SettableRange, + SettableProperty { + + @Nullable + private OWLLiteral literal = null; + + /** + * @param df data factory + */ + @Inject + public BuilderDataHasValue(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDataHasValue(OWLDataHasValue expected, OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withLiteral(expected.getFiller()); + } + + /** + * @param arg literal + * @return builder + */ + public BuilderDataHasValue withLiteral(OWLLiteral arg) { + literal = arg; + return this; + } + + @Override + public OWLDataHasValue buildObject() { + return df.getOWLDataHasValue(getProperty(), getLiteral()); + } + + /** + * @return literal + */ + public OWLLiteral getLiteral() { + return verifyNotNull(literal); + } + + @Override + public OWLLiteral getRange() { + return getLiteral(); + } + + @Override + public BuilderDataHasValue withRange(OWLLiteral range) { + return withLiteral(range); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataIntersectionOf.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataIntersectionOf.java new file mode 100644 index 0000000000..060b4e5937 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataIntersectionOf.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataIntersectionOf; +import org.semanticweb.owlapi.model.OWLDataRange; + +/** + * Builder class for OWLDataIntersectionOf. + */ +public class BuilderDataIntersectionOf + extends BaseSetBuilder { + + /** + * @param df data factory + */ + @Inject + public BuilderDataIntersectionOf(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDataIntersectionOf(OWLDataIntersectionOf expected, OWLDataFactory df) { + this(df); + withItems(expected.operands()); + } + + @Override + public OWLDataIntersectionOf buildObject() { + return df.getOWLDataIntersectionOf(items); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataMaxCardinality.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataMaxCardinality.java new file mode 100644 index 0000000000..73657de1e0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataMaxCardinality.java @@ -0,0 +1,63 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; + +/** + * Builder class for OWLDataMaxCardinality. + */ +public class BuilderDataMaxCardinality extends + BaseDataBuilder + implements SettableCardinality { + + private int cardinality = -1; + + /** + * @param df data factory + */ + @Inject + public BuilderDataMaxCardinality(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDataMaxCardinality(OWLDataMaxCardinality expected, OWLDataFactory df) { + this(df); + withCardinality(expected.getCardinality()).withProperty(expected.getProperty()) + .withRange(expected.getFiller()); + } + + @Override + public BuilderDataMaxCardinality withCardinality(int arg) { + cardinality = arg; + return this; + } + + @Override + public int getCardinality() { + return cardinality; + } + + @Override + public OWLDataMaxCardinality buildObject() { + return df.getOWLDataMaxCardinality(cardinality, getProperty(), getDataRange()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataMinCardinality.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataMinCardinality.java new file mode 100644 index 0000000000..d27b1f8db8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataMinCardinality.java @@ -0,0 +1,63 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; + +/** + * Builder class for OWLDataMinCardinality. + */ +public class BuilderDataMinCardinality extends + BaseDataBuilder + implements SettableCardinality { + + private int cardinality = -1; + + /** + * @param df data factory + */ + @Inject + public BuilderDataMinCardinality(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDataMinCardinality(OWLDataMinCardinality expected, OWLDataFactory df) { + this(df); + withCardinality(expected.getCardinality()).withProperty(expected.getProperty()) + .withRange(expected.getFiller()); + } + + @Override + public BuilderDataMinCardinality withCardinality(int arg) { + cardinality = arg; + return this; + } + + @Override + public int getCardinality() { + return cardinality; + } + + @Override + public OWLDataMinCardinality buildObject() { + return df.getOWLDataMinCardinality(cardinality, getProperty(), getDataRange()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataOneOf.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataOneOf.java new file mode 100644 index 0000000000..f3e118399d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataOneOf.java @@ -0,0 +1,48 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLLiteral; + +/** + * Builder class for OWLDataOneOf. + */ +public class BuilderDataOneOf extends BaseSetBuilder { + + /** + * @param df data factory + */ + @Inject + public BuilderDataOneOf(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDataOneOf(OWLDataOneOf expected, OWLDataFactory df) { + this(df); + withItems(expected.values()); + } + + @Override + public OWLDataOneOf buildObject() { + return df.getOWLDataOneOf(items); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataProperty.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataProperty.java new file mode 100644 index 0000000000..360ff18a1a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataProperty.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataProperty; + +/** + * Builder class for OWLDataProperty. + */ +public class BuilderDataProperty extends BaseEntityBuilder { + + /** + * @param df data factory + */ + @Inject + public BuilderDataProperty(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDataProperty(OWLDataProperty expected, OWLDataFactory df) { + this(df); + withIRI(expected.getIRI()); + } + + @Override + public OWLDataProperty buildObject() { + if (pm != null && string != null) { + return df.getOWLDataProperty(getString(), getPM()); + } + return df.getOWLDataProperty(getIRI()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataPropertyAssertion.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataPropertyAssertion.java new file mode 100644 index 0000000000..cd625f5b9b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataPropertyAssertion.java @@ -0,0 +1,93 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; + +/** + * Builder class for OWLDataPropertyAssertionAxiom. + */ +public class BuilderDataPropertyAssertion + extends BaseDataPropertyBuilder { + + @Nullable + private OWLIndividual subject = null; + @Nullable + private OWLLiteral object = null; + + /** + * @param df data factory + */ + @Inject + public BuilderDataPropertyAssertion(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDataPropertyAssertion(OWLDataPropertyAssertionAxiom expected, OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withSubject(expected.getSubject()) + .withValue(expected.getObject()) + .withAnnotations(expected.annotations()); + } + + /** + * @param arg value + * @return builder + */ + public BuilderDataPropertyAssertion withValue(OWLLiteral arg) { + object = arg; + return this; + } + + /** + * @param arg individual + * @return builder + */ + public BuilderDataPropertyAssertion withSubject(OWLIndividual arg) { + subject = arg; + return this; + } + + @Override + public OWLDataPropertyAssertionAxiom buildObject() { + return df.getOWLDataPropertyAssertionAxiom(getProperty(), getSubject(), getLiteral(), + annotations); + } + + /** + * @return individual + */ + public OWLIndividual getSubject() { + return verifyNotNull(subject); + } + + /** + * @return literal + */ + public OWLLiteral getLiteral() { + return verifyNotNull(object); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataPropertyDomain.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataPropertyDomain.java new file mode 100644 index 0000000000..6c9eb6573a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataPropertyDomain.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; + +/** + * Builder class for OWLDataPropertyDomainAxiom. + */ +public class BuilderDataPropertyDomain extends + BaseDomainBuilder implements + SettableProperty { + + /** + * @param df data factory + */ + @Inject + public BuilderDataPropertyDomain(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDataPropertyDomain(OWLDataPropertyDomainAxiom expected, OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withDomain(expected.getDomain()) + .withAnnotations(expected.annotations()); + } + + @Override + public OWLDataPropertyDomainAxiom buildObject() { + return df.getOWLDataPropertyDomainAxiom(getProperty(), getDomain(), annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataPropertyRange.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataPropertyRange.java new file mode 100644 index 0000000000..02bc1eaddd --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataPropertyRange.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; + +/** + * Builder class for OWLDataPropertyRangeAxiom. + */ +public class BuilderDataPropertyRange extends + BaseDataBuilder { + + /** + * @param df data factory + */ + @Inject + public BuilderDataPropertyRange(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDataPropertyRange(OWLDataPropertyRangeAxiom expected, OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withRange(expected.getRange()) + .withAnnotations(expected.annotations()); + } + + @Override + public OWLDataPropertyRangeAxiom buildObject() { + return df.getOWLDataPropertyRangeAxiom(getProperty(), getDataRange(), annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataSomeValuesFrom.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataSomeValuesFrom.java new file mode 100644 index 0000000000..022315caaa --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataSomeValuesFrom.java @@ -0,0 +1,48 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; + +/** + * Builder class for OWLDataSomeValuesFrom. + */ +public class BuilderDataSomeValuesFrom extends + BaseDataBuilder { + + /** + * @param df data factory + */ + @Inject + public BuilderDataSomeValuesFrom(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDataSomeValuesFrom(OWLDataSomeValuesFrom expected, OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withRange(expected.getFiller()); + } + + @Override + public OWLDataSomeValuesFrom buildObject() { + return df.getOWLDataSomeValuesFrom(getProperty(), getDataRange()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataUnionOf.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataUnionOf.java new file mode 100644 index 0000000000..8734ac7a85 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDataUnionOf.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLDataUnionOf; + +/** + * Builder class for OWLDataUnionOf. + */ +public class BuilderDataUnionOf extends + BaseSetBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDataUnionOf(OWLDataUnionOf expected, OWLDataFactory df) { + this(df); + withItems(expected.operands()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderDataUnionOf(OWLDataFactory df) { + super(df); + } + + @Override + public OWLDataUnionOf buildObject() { + return df.getOWLDataUnionOf(items); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDatatype.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDatatype.java new file mode 100644 index 0000000000..d8236afefe --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDatatype.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDatatype; + +/** + * Builder class for OWLDatatype. + */ +public class BuilderDatatype extends BaseEntityBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDatatype(OWLDatatype expected, OWLDataFactory df) { + this(df); + withIRI(expected.getIRI()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderDatatype(OWLDataFactory df) { + super(df); + } + + @Override + public OWLDatatype buildObject() { + if (pm != null && string != null) { + return df.getOWLDatatype(getString(), getPM()); + } + return df.getOWLDatatype(getIRI()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDatatypeDefinition.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDatatypeDefinition.java new file mode 100644 index 0000000000..a40ff34d6f --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDatatypeDefinition.java @@ -0,0 +1,101 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * Builder class for OWLDatatypeDefinitionAxiom. + */ +public class BuilderDatatypeDefinition extends + BaseBuilder { + + @Nullable + private OWLDataRange range = null; + @Nullable + private OWLDatatype type = null; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDatatypeDefinition(OWLDatatypeDefinitionAxiom expected, OWLDataFactory df) { + this(df); + with(expected.getDatatype()).withType(expected.getDataRange()) + .withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderDatatypeDefinition(OWLDataFactory df) { + super(df); + } + + /** + * @param arg range + * @return builder + */ + public BuilderDatatypeDefinition withType(OWL2Datatype arg) { + return withType(arg.getDatatype(df)); + } + + /** + * @param arg range + * @return builder + */ + public BuilderDatatypeDefinition withType(OWLDataRange arg) { + range = arg; + return this; + } + + /** + * @param arg type + * @return builder + */ + public BuilderDatatypeDefinition with(OWLDatatype arg) { + type = arg; + return this; + } + + @Override + public OWLDatatypeDefinitionAxiom buildObject() { + return df.getOWLDatatypeDefinitionAxiom(verifyNotNull(type), getRange(), annotations); + } + + /** + * @return range + */ + public OWLDataRange getRange() { + return verifyNotNull(range); + } + + /** + * @return type + */ + @Nullable + public OWLDatatype getType() { + return type; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDatatypeRestriction.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDatatypeRestriction.java new file mode 100644 index 0000000000..e27c334890 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDatatypeRestriction.java @@ -0,0 +1,73 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLFacetRestriction; + +/** + * Builder class for OWLDatatypeRestriction. + */ +public class BuilderDatatypeRestriction + extends + BaseSetBuilder { + + @Nullable + private OWLDatatype type = null; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDatatypeRestriction(OWLDatatypeRestriction expected, OWLDataFactory df) { + this(df); + withDatatype(expected.getDatatype()).withItems(expected.facetRestrictions()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderDatatypeRestriction(OWLDataFactory df) { + super(df); + } + + /** + * @param arg range + * @return builder + */ + public BuilderDatatypeRestriction withDatatype(OWLDatatype arg) { + type = arg; + return this; + } + + @Override + public OWLDatatypeRestriction buildObject() { + return df.getOWLDatatypeRestriction(getType(), items); + } + + /** + * @return type + */ + public OWLDatatype getType() { + return verifyNotNull(type); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDeclaration.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDeclaration.java new file mode 100644 index 0000000000..65ccb7a966 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDeclaration.java @@ -0,0 +1,71 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLEntity; + +/** + * Builder class for OWLDeclarationAxiom. + */ +public class BuilderDeclaration extends BaseBuilder { + + @Nullable + private OWLEntity entity = null; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDeclaration(OWLDeclarationAxiom expected, OWLDataFactory df) { + this(df); + withEntity(expected.getEntity()).withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderDeclaration(OWLDataFactory df) { + super(df); + } + + /** + * @param arg entity + * @return builder + */ + public BuilderDeclaration withEntity(OWLEntity arg) { + entity = arg; + return this; + } + + @Override + public OWLDeclarationAxiom buildObject() { + return df.getOWLDeclarationAxiom(verifyNotNull(entity), annotations); + } + + /** + * @return entity + */ + @Nullable + public OWLEntity getEntity() { + return entity; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDifferentIndividuals.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDifferentIndividuals.java new file mode 100644 index 0000000000..e0e574f5a1 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDifferentIndividuals.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLIndividual; + +/** + * Builder class for OWLDifferentIndividualsAxiom. + */ +public class BuilderDifferentIndividuals + extends + BaseSetBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDifferentIndividuals(OWLDifferentIndividualsAxiom expected, OWLDataFactory df) { + this(df); + withItems(expected.individuals()).withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderDifferentIndividuals(OWLDataFactory df) { + super(df); + } + + @Override + public OWLDifferentIndividualsAxiom buildObject() { + return df.getOWLDifferentIndividualsAxiom(items, annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDisjointClasses.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDisjointClasses.java new file mode 100644 index 0000000000..2b968f4988 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDisjointClasses.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; + +/** + * Builder class for OWLDisjointClassesAxiom. + */ +public class BuilderDisjointClasses + extends BaseSetBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDisjointClasses(OWLDisjointClassesAxiom expected, OWLDataFactory df) { + this(df); + withItems(expected.classExpressions()).withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderDisjointClasses(OWLDataFactory df) { + super(df); + } + + @Override + public OWLDisjointClassesAxiom buildObject() { + return df.getOWLDisjointClassesAxiom(items, annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDisjointDataProperties.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDisjointDataProperties.java new file mode 100644 index 0000000000..2c3f1aabaf --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDisjointDataProperties.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; + +/** + * Builder class for OWLDisjointDataPropertiesAxiom. + */ +public class BuilderDisjointDataProperties extends + BaseSetBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDisjointDataProperties(OWLDisjointDataPropertiesAxiom expected, + OWLDataFactory df) { + this(df); + withItems(expected.properties()).withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderDisjointDataProperties(OWLDataFactory df) { + super(df); + } + + @Override + public OWLDisjointDataPropertiesAxiom buildObject() { + return df.getOWLDisjointDataPropertiesAxiom(items, annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDisjointObjectProperties.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDisjointObjectProperties.java new file mode 100644 index 0000000000..7f71d03fad --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDisjointObjectProperties.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; + +/** + * Builder class for OWLDisjointObjectPropertiesAxiom. + */ +public class BuilderDisjointObjectProperties extends + BaseSetBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDisjointObjectProperties(OWLDisjointObjectPropertiesAxiom expected, + OWLDataFactory df) { + this(df); + withItems(expected.properties()).withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderDisjointObjectProperties(OWLDataFactory df) { + super(df); + } + + @Override + public OWLDisjointObjectPropertiesAxiom buildObject() { + return df.getOWLDisjointObjectPropertiesAxiom(items, annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDisjointUnion.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDisjointUnion.java new file mode 100644 index 0000000000..8d87b043a8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderDisjointUnion.java @@ -0,0 +1,75 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; + +/** + * Builder class for OWLDisjointUnionAxiom. + */ +public class BuilderDisjointUnion extends + BaseSetBuilder { + + @Nullable + private OWLClass ce = null; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderDisjointUnion(OWLDisjointUnionAxiom expected, OWLDataFactory df) { + this(df); + withClass(expected.getOWLClass()).withItems(expected.classExpressions()) + .withAnnotations(expected + .annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderDisjointUnion(OWLDataFactory df) { + super(df); + } + + /** + * @param arg right hand entity + * @return builder + */ + public BuilderDisjointUnion withClass(OWLClass arg) { + ce = arg; + return this; + } + + @Override + public OWLDisjointUnionAxiom buildObject() { + return df.getOWLDisjointUnionAxiom(verifyNotNull(ce), items, annotations); + } + + /** + * @return class expression + */ + @Nullable + public OWLClass getClassExpression() { + return ce; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderEntity.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderEntity.java new file mode 100644 index 0000000000..df916bebc7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderEntity.java @@ -0,0 +1,73 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.EntityType; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLEntity; + +/** + * Builder class for OWLEntity. + */ +public class BuilderEntity extends BaseEntityBuilder { + + @Nullable + private EntityType entityType = null; + + /** + * @param df data factory + */ + @Inject + public BuilderEntity(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderEntity(OWLEntity expected, OWLDataFactory df) { + this(df); + withType(expected.getEntityType()).withIRI(expected.getIRI()); + } + + /** + * @param arg entity type + * @return builder + */ + public BuilderEntity withType(EntityType arg) { + entityType = arg; + return this; + } + + /** + * @return entity type + */ + public EntityType getEntityType() { + return verifyNotNull(entityType); + } + + @Override + public OWLEntity buildObject() { + if (pm != null && string != null) { + return df.getOWLEntity(getEntityType(), getPM().getIRI(getString())); + } + return df.getOWLEntity(getEntityType(), getIRI()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderEquivalentClasses.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderEquivalentClasses.java new file mode 100644 index 0000000000..fae62da70d --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderEquivalentClasses.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; + +/** + * Builder class for OWLEquivalentClassesAxiom. + */ +public class BuilderEquivalentClasses + extends + BaseSetBuilder { + + /** + * @param df data factory + */ + @Inject + public BuilderEquivalentClasses(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderEquivalentClasses(OWLEquivalentClassesAxiom expected, OWLDataFactory df) { + this(df); + withItems(expected.classExpressions()).withAnnotations(expected.annotations()); + } + + @Override + public OWLEquivalentClassesAxiom buildObject() { + return df.getOWLEquivalentClassesAxiom(items, annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderEquivalentDataProperties.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderEquivalentDataProperties.java new file mode 100644 index 0000000000..aad905b268 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderEquivalentDataProperties.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; + +/** + * Builder class for OWLEquivalentDataPropertiesAxiom. + */ +public class BuilderEquivalentDataProperties extends + BaseSetBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderEquivalentDataProperties(OWLEquivalentDataPropertiesAxiom expected, + OWLDataFactory df) { + this(df); + withItems(expected.properties()).withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderEquivalentDataProperties(OWLDataFactory df) { + super(df); + } + + @Override + public OWLEquivalentDataPropertiesAxiom buildObject() { + return df.getOWLEquivalentDataPropertiesAxiom(items, annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderEquivalentObjectProperties.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderEquivalentObjectProperties.java new file mode 100644 index 0000000000..052e9ce18b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderEquivalentObjectProperties.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; + +/** + * Builder class for OWLEquivalentObjectPropertiesAxiom. + */ +public class BuilderEquivalentObjectProperties extends + BaseSetBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderEquivalentObjectProperties(OWLEquivalentObjectPropertiesAxiom expected, + OWLDataFactory df) { + this(df); + withItems(expected.properties()).withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderEquivalentObjectProperties(OWLDataFactory df) { + super(df); + } + + @Override + public OWLEquivalentObjectPropertiesAxiom buildObject() { + return df.getOWLEquivalentObjectPropertiesAxiom(items, annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderFacetRestriction.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderFacetRestriction.java new file mode 100644 index 0000000000..08373b15c4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderFacetRestriction.java @@ -0,0 +1,117 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.vocab.OWLFacet; + +/** + * Builder class for OWLFacetRestriction. + */ +public class BuilderFacetRestriction extends + BaseBuilder { + + @Nullable + private OWLLiteral literal = null; + @Nullable + private OWLFacet facet = null; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderFacetRestriction(OWLFacetRestriction expected, OWLDataFactory df) { + this(df); + withFacet(expected.getFacet()).withLiteral(expected.getFacetValue()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderFacetRestriction(OWLDataFactory df) { + super(df); + } + + /** + * @param arg int value + * @return builder + */ + public BuilderFacetRestriction withLiteral(int arg) { + literal = df.getOWLLiteral(arg); + return this; + } + + /** + * @param arg literal value + * @return builder + */ + public BuilderFacetRestriction withLiteral(OWLLiteral arg) { + literal = arg; + return this; + } + + /** + * @param arg double value + * @return builder + */ + public BuilderFacetRestriction withLiteral(double arg) { + literal = df.getOWLLiteral(arg); + return this; + } + + /** + * @param arg float value + * @return builder + */ + public BuilderFacetRestriction withLiteral(float arg) { + literal = df.getOWLLiteral(arg); + return this; + } + + /** + * @param arg facet + * @return builder + */ + public BuilderFacetRestriction withFacet(OWLFacet arg) { + facet = arg; + return this; + } + + @Override + public OWLFacetRestriction buildObject() { + return df.getOWLFacetRestriction(getFacet(), getLiteral()); + } + + /** + * @return facet + */ + public OWLFacet getFacet() { + return verifyNotNull(facet); + } + + /** + * @return literal + */ + public OWLLiteral getLiteral() { + return verifyNotNull(literal); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderFunctionalDataProperty.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderFunctionalDataProperty.java new file mode 100644 index 0000000000..daf894b016 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderFunctionalDataProperty.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; + +/** + * Builder class for OWLFunctionalDataPropertyAxiom. + */ +public class BuilderFunctionalDataProperty + extends BaseDataPropertyBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderFunctionalDataProperty(OWLFunctionalDataPropertyAxiom expected, + OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderFunctionalDataProperty(OWLDataFactory df) { + super(df); + } + + @Override + public OWLFunctionalDataPropertyAxiom buildObject() { + return df.getOWLFunctionalDataPropertyAxiom(getProperty(), annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderFunctionalObjectProperty.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderFunctionalObjectProperty.java new file mode 100644 index 0000000000..3636f3bd26 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderFunctionalObjectProperty.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; + +/** + * Builder class for OWLFunctionalObjectPropertyAxiom. + */ +public class BuilderFunctionalObjectProperty extends + BaseObjectPropertyBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderFunctionalObjectProperty(OWLFunctionalObjectPropertyAxiom expected, + OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderFunctionalObjectProperty(OWLDataFactory df) { + super(df); + } + + @Override + public OWLFunctionalObjectPropertyAxiom buildObject() { + return df.getOWLFunctionalObjectPropertyAxiom(verifyNotNull(getProperty()), annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderHasKey.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderHasKey.java new file mode 100644 index 0000000000..1fb9633787 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderHasKey.java @@ -0,0 +1,74 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLHasKeyAxiom; +import org.semanticweb.owlapi.model.OWLPropertyExpression; + +/** + * Builder class for OWLHasKeyAxiom. + */ +public class BuilderHasKey extends + BaseSetBuilder { + + @Nullable + private OWLClassExpression ce; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderHasKey(OWLHasKeyAxiom expected, OWLDataFactory df) { + this(df); + withClass(expected.getClassExpression()).withAnnotations(expected.annotations()) + .withItems(expected + .dataPropertyExpressions()).withItems(expected.objectPropertyExpressions()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderHasKey(OWLDataFactory df) { + super(df); + } + + /** + * @param arg class expression + * @return builder + */ + public BuilderHasKey withClass(OWLClassExpression arg) { + ce = arg; + return this; + } + + @Override + public OWLHasKeyAxiom buildObject() { + return df.getOWLHasKeyAxiom(getClassExpression(), items, annotations); + } + + /** + * @return class expression + */ + public OWLClassExpression getClassExpression() { + return verifyNotNull(ce); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderImportsDeclaration.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderImportsDeclaration.java new file mode 100644 index 0000000000..8434d721e8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderImportsDeclaration.java @@ -0,0 +1,86 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.AddImport; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLImportsDeclaration; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; + +/** + * Builder class for OWLImportsDeclaration. + */ +public class BuilderImportsDeclaration implements Builder { + + protected final OWLDataFactory df; + @Nullable + private IRI iri; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderImportsDeclaration(OWLImportsDeclaration expected, OWLDataFactory df) { + this(df); + withImportedOntology(expected.getIRI()); + } + + /** + * Default constructor. + * + * @param df data factory + */ + @Inject + public BuilderImportsDeclaration(OWLDataFactory df) { + this.df = checkNotNull(df); + } + + /** + * @param arg IRI of imported ontology + * @return builder + */ + public BuilderImportsDeclaration withImportedOntology(IRI arg) { + iri = arg; + return this; + } + + @Override + public OWLImportsDeclaration buildObject() { + return df.getOWLImportsDeclaration(getIRI()); + } + + /** + * @return iri + */ + public IRI getIRI() { + return verifyNotNull(iri); + } + + @Override + public List applyChanges(OWLOntology o) { + List list = new ArrayList<>(); + list.add(new AddImport(o, buildObject())); + return list; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderInverseFunctionalObjectProperty.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderInverseFunctionalObjectProperty.java new file mode 100644 index 0000000000..f9e663d6d3 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderInverseFunctionalObjectProperty.java @@ -0,0 +1,52 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; + +/** + * Builder class for OWLInverseFunctionalObjectPropertyAxiom. + */ +public class BuilderInverseFunctionalObjectProperty extends + BaseObjectPropertyBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderInverseFunctionalObjectProperty(OWLInverseFunctionalObjectPropertyAxiom expected, + OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderInverseFunctionalObjectProperty(OWLDataFactory df) { + super(df); + } + + @Override + public OWLInverseFunctionalObjectPropertyAxiom buildObject() { + return df + .getOWLInverseFunctionalObjectPropertyAxiom(verifyNotNull(getProperty()), annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderInverseObjectProperties.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderInverseObjectProperties.java new file mode 100644 index 0000000000..2ca7987512 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderInverseObjectProperties.java @@ -0,0 +1,75 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; + +/** + * Builder class for OWLInverseObjectPropertiesAxiom. + */ +public class BuilderInverseObjectProperties extends + BaseObjectPropertyBuilder { + + @Nullable + private OWLObjectPropertyExpression inverseProperty = null; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderInverseObjectProperties(OWLInverseObjectPropertiesAxiom expected, + OWLDataFactory df) { + this(df); + withProperty(expected.getFirstProperty()).withInverseProperty(expected.getSecondProperty()) + .withAnnotations( + expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderInverseObjectProperties(OWLDataFactory df) { + super(df); + } + + /** + * @param arg inverse property + * @return builder + */ + public BuilderInverseObjectProperties withInverseProperty(OWLObjectPropertyExpression arg) { + inverseProperty = arg; + return this; + } + + @Override + public OWLInverseObjectPropertiesAxiom buildObject() { + return df.getOWLInverseObjectPropertiesAxiom(verifyNotNull(getProperty()), getInverse(), + annotations); + } + + /** + * @return inverse + */ + public OWLObjectPropertyExpression getInverse() { + return verifyNotNull(inverseProperty); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderIrreflexiveObjectProperty.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderIrreflexiveObjectProperty.java new file mode 100644 index 0000000000..a1fcd5cb09 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderIrreflexiveObjectProperty.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; + +/** + * Builder class for OWLIrreflexiveObjectPropertyAxiom. + */ +public class BuilderIrreflexiveObjectProperty extends + BaseObjectPropertyBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderIrreflexiveObjectProperty(OWLIrreflexiveObjectPropertyAxiom expected, + OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderIrreflexiveObjectProperty(OWLDataFactory df) { + super(df); + } + + @Override + public OWLIrreflexiveObjectPropertyAxiom buildObject() { + return df.getOWLIrreflexiveObjectPropertyAxiom(verifyNotNull(getProperty()), annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderLiteral.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderLiteral.java new file mode 100644 index 0000000000..ccf0cbed34 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderLiteral.java @@ -0,0 +1,196 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * Builder class for OWLLiteral. + */ +public class BuilderLiteral extends BaseBuilder { + + @Nullable + private String lang = null; + @Nullable + private String literalForm = null; + @Nullable + private Integer intValue = null; + @Nullable + private Double doubleValue = null; + @Nullable + private Float floatValue = null; + @Nullable + private Boolean booleanValue = null; + @Nullable + private OWLDatatype datatype; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderLiteral(OWLLiteral expected, OWLDataFactory df) { + this(df); + if (expected.hasLang()) { + withLanguage(expected.getLang()); + } else { + withDatatype(expected.getDatatype()); + } + if (expected.isBoolean()) { + withValue(expected.parseBoolean()); + } else if (expected.isDouble()) { + withValue(expected.parseDouble()); + } else if (expected.isFloat()) { + withValue(expected.parseFloat()); + } else if (expected.isInteger()) { + withValue(expected.parseInteger()); + } else { + withLiteralForm(expected.getLiteral()); + } + } + + /** + * @param df data factory + */ + @Inject + public BuilderLiteral(OWLDataFactory df) { + super(df); + } + + protected void clear() { + literalForm = null; + intValue = null; + doubleValue = null; + floatValue = null; + booleanValue = null; + } + + /** + * @param arg int value + * @return builder + */ + public BuilderLiteral withValue(int arg) { + clear(); + intValue = Integer.valueOf(arg); + return this; + } + + /** + * @param arg datatype + * @return builder + */ + public BuilderLiteral withDatatype(OWL2Datatype arg) { + return withDatatype(df.getOWLDatatype(arg.getIRI())); + } + + /** + * @param arg datatype + * @return builder + */ + public BuilderLiteral withDatatype(OWLDatatype arg) { + lang = null; + datatype = arg; + return this; + } + + /** + * @param arg datatype + * @return builder + */ + public BuilderLiteral withDatatype(IRI arg) { + lang = null; + datatype = df.getOWLDatatype(arg); + return this; + } + + /** + * @param arg boolean value + * @return builder + */ + public BuilderLiteral withValue(boolean arg) { + clear(); + booleanValue = Boolean.valueOf(arg); + return this; + } + + /** + * @param arg double value + * @return builder + */ + public BuilderLiteral withValue(double arg) { + clear(); + doubleValue = Double.valueOf(arg); + return this; + } + + /** + * @param arg float value + * @return builder + */ + public BuilderLiteral withValue(float arg) { + clear(); + floatValue = Float.valueOf(arg); + return this; + } + + /** + * @param arg literal form + * @return builder + */ + public BuilderLiteral withLiteralForm(String arg) { + clear(); + literalForm = arg; + return this; + } + + /** + * @param arg language + * @return builder + */ + public BuilderLiteral withLanguage(String arg) { + datatype = null; + lang = arg; + return this; + } + + @SuppressWarnings("null") + @Override + public OWLLiteral buildObject() { + if (intValue != null) { + return df.getOWLLiteral(intValue.intValue()); + } + if (doubleValue != null) { + return df.getOWLLiteral(doubleValue.doubleValue()); + } + if (floatValue != null) { + return df.getOWLLiteral(floatValue.floatValue()); + } + if (booleanValue != null) { + return df.getOWLLiteral(booleanValue.booleanValue()); + } + if (lang != null) { + return df.getOWLLiteral(literalForm, lang); + } + if (datatype == null) { + return df.getOWLLiteral(literalForm); + } + return df.getOWLLiteral(literalForm, datatype); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderNamedIndividual.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderNamedIndividual.java new file mode 100644 index 0000000000..84ad2ccc9e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderNamedIndividual.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLNamedIndividual; + +/** + * Builder class for OWLNamedIndividual. + */ +public class BuilderNamedIndividual extends + BaseEntityBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderNamedIndividual(OWLNamedIndividual expected, OWLDataFactory df) { + this(df); + withIRI(expected.getIRI()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderNamedIndividual(OWLDataFactory df) { + super(df); + } + + @Override + public OWLNamedIndividual buildObject() { + if (pm != null && string != null) { + return df.getOWLNamedIndividual(getString(), getPM()); + } + return df.getOWLNamedIndividual(getIRI()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderNegativeDataPropertyAssertion.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderNegativeDataPropertyAssertion.java new file mode 100644 index 0000000000..b5529672af --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderNegativeDataPropertyAssertion.java @@ -0,0 +1,96 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; + +/** + * Builder class for OWLNegativeDataPropertyAssertionAxiom. + */ +public class BuilderNegativeDataPropertyAssertion + extends + BaseDataPropertyBuilder { + + @Nullable + private OWLIndividual subject = null; + @Nullable + private OWLLiteral value = null; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderNegativeDataPropertyAssertion(OWLNegativeDataPropertyAssertionAxiom expected, + OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withSubject(expected.getSubject()) + .withValue(expected.getObject()) + .withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderNegativeDataPropertyAssertion(OWLDataFactory df) { + super(df); + } + + /** + * @param arg value + * @return builder + */ + public BuilderNegativeDataPropertyAssertion withValue(OWLLiteral arg) { + value = arg; + return this; + } + + /** + * @param arg subject + * @return builder + */ + public BuilderNegativeDataPropertyAssertion withSubject(OWLIndividual arg) { + subject = arg; + return this; + } + + @Override + public OWLNegativeDataPropertyAssertionAxiom buildObject() { + return df + .getOWLNegativeDataPropertyAssertionAxiom(getProperty(), getSubject(), getLiteral(), + annotations); + } + + /** + * @return individual + */ + public OWLIndividual getSubject() { + return verifyNotNull(subject); + } + + /** + * @return literal + */ + public OWLLiteral getLiteral() { + return verifyNotNull(value); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderNegativeObjectPropertyAssertion.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderNegativeObjectPropertyAssertion.java new file mode 100644 index 0000000000..5fed90d6f9 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderNegativeObjectPropertyAssertion.java @@ -0,0 +1,96 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; + +/** + * Builder class for OWLNegativeObjectPropertyAssertionAxiom. + */ +public class BuilderNegativeObjectPropertyAssertion extends + BaseObjectPropertyBuilder { + + @Nullable + private OWLIndividual subject = null; + @Nullable + private OWLIndividual value = null; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderNegativeObjectPropertyAssertion(OWLNegativeObjectPropertyAssertionAxiom expected, + OWLDataFactory df) { + this(df); + withSubject(expected.getSubject()).withProperty(expected.getProperty()) + .withValue(expected.getObject()) + .withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderNegativeObjectPropertyAssertion(OWLDataFactory df) { + super(df); + } + + /** + * @param arg value + * @return builder + */ + public BuilderNegativeObjectPropertyAssertion withValue(OWLIndividual arg) { + value = arg; + return this; + } + + /** + * @param arg subject + * @return builder + */ + public BuilderNegativeObjectPropertyAssertion withSubject(OWLIndividual arg) { + subject = arg; + return this; + } + + @Override + public OWLNegativeObjectPropertyAssertionAxiom buildObject() { + return df.getOWLNegativeObjectPropertyAssertionAxiom(verifyNotNull(getProperty()), + verifyNotNull(subject), + verifyNotNull(value), annotations); + } + + /** + * @return individual + */ + @Nullable + public OWLIndividual getSubject() { + return subject; + } + + /** + * @return individual + */ + @Nullable + public OWLIndividual getValue() { + return value; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectAllValuesFrom.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectAllValuesFrom.java new file mode 100644 index 0000000000..bf63a2dde5 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectAllValuesFrom.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; + +/** + * Builder class for OWLObjectAllValuesFrom. + */ +public class BuilderObjectAllValuesFrom extends + BaseObjectBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderObjectAllValuesFrom(OWLObjectAllValuesFrom expected, OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withRange(expected.getFiller()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderObjectAllValuesFrom(OWLDataFactory df) { + super(df); + } + + @Override + public OWLObjectAllValuesFrom buildObject() { + return df.getOWLObjectAllValuesFrom(verifyNotNull(getProperty()), getRange()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectExactCardinality.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectExactCardinality.java new file mode 100644 index 0000000000..9f70f0f116 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectExactCardinality.java @@ -0,0 +1,66 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; + +/** + * Builder class for OWLObjectExactCardinality. + */ +public class BuilderObjectExactCardinality extends + BaseObjectBuilder implements + SettableCardinality { + + private int cardinality = -1; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderObjectExactCardinality(OWLObjectExactCardinality expected, OWLDataFactory df) { + this(df); + withCardinality(expected.getCardinality()).withProperty(expected.getProperty()) + .withRange(expected.getFiller()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderObjectExactCardinality(OWLDataFactory df) { + super(df); + } + + @Override + public BuilderObjectExactCardinality withCardinality(int arg) { + cardinality = arg; + return this; + } + + @Override + public int getCardinality() { + return cardinality; + } + + @Override + public OWLObjectExactCardinality buildObject() { + return df + .getOWLObjectExactCardinality(cardinality, verifyNotNull(getProperty()), getRange()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectHasSelf.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectHasSelf.java new file mode 100644 index 0000000000..f30a945ee2 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectHasSelf.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; + +/** + * Builder class for OWLObjectHasSelf. + */ +public class BuilderObjectHasSelf extends + BaseObjectPropertyBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderObjectHasSelf(OWLObjectHasSelf expected, OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderObjectHasSelf(OWLDataFactory df) { + super(df); + } + + @Override + public OWLObjectHasSelf buildObject() { + return df.getOWLObjectHasSelf(verifyNotNull(getProperty())); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectHasValue.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectHasValue.java new file mode 100644 index 0000000000..403ac06da8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectHasValue.java @@ -0,0 +1,71 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLObjectHasValue; + +/** + * Builder class for OWLObjectHasValue. + */ +public class BuilderObjectHasValue extends + BaseObjectPropertyBuilder { + + @Nullable + private OWLIndividual value = null; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderObjectHasValue(OWLObjectHasValue expected, OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withValue(expected.getFiller()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderObjectHasValue(OWLDataFactory df) { + super(df); + } + + /** + * @param arg argument + * @return builder + */ + public BuilderObjectHasValue withValue(OWLIndividual arg) { + value = arg; + return this; + } + + @Override + public OWLObjectHasValue buildObject() { + return df.getOWLObjectHasValue(verifyNotNull(getProperty()), getValue()); + } + + /** + * @return value + */ + public OWLIndividual getValue() { + return verifyNotNull(value); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectIntersectionOf.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectIntersectionOf.java new file mode 100644 index 0000000000..0843f65bff --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectIntersectionOf.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; + +/** + * Builder class for OWLObjectIntersectionOf. + */ +public class BuilderObjectIntersectionOf + extends + BaseSetBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderObjectIntersectionOf(OWLObjectIntersectionOf expected, OWLDataFactory df) { + this(df); + withItems(expected.operands()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderObjectIntersectionOf(OWLDataFactory df) { + super(df); + } + + @Override + public OWLObjectIntersectionOf buildObject() { + return df.getOWLObjectIntersectionOf(items); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectInverseOf.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectInverseOf.java new file mode 100644 index 0000000000..50f7c9a6c0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectInverseOf.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectInverseOf; + +/** + * Builder class for OWLObjectInverseOf. + */ +public class BuilderObjectInverseOf extends + BaseObjectPropertyBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderObjectInverseOf(OWLObjectInverseOf expected, OWLDataFactory df) { + this(df); + withProperty(expected.getInverse()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderObjectInverseOf(OWLDataFactory df) { + super(df); + } + + @Override + public OWLObjectInverseOf buildObject() { + return df.getOWLObjectInverseOf(verifyNotNull(getProperty()).asOWLObjectProperty()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectMaxCardinality.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectMaxCardinality.java new file mode 100644 index 0000000000..cfac2bc697 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectMaxCardinality.java @@ -0,0 +1,65 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; + +/** + * Builder class for OWLObjectMaxCardinality. + */ +public class BuilderObjectMaxCardinality extends + BaseObjectBuilder + implements SettableCardinality { + + private int cardinality = -1; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderObjectMaxCardinality(OWLObjectMaxCardinality expected, OWLDataFactory df) { + this(df); + withCardinality(expected.getCardinality()).withProperty(expected.getProperty()) + .withRange(expected.getFiller()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderObjectMaxCardinality(OWLDataFactory df) { + super(df); + } + + @Override + public BuilderObjectMaxCardinality withCardinality(int arg) { + cardinality = arg; + return this; + } + + @Override + public int getCardinality() { + return cardinality; + } + + @Override + public OWLObjectMaxCardinality buildObject() { + return df.getOWLObjectMaxCardinality(cardinality, verifyNotNull(getProperty()), getRange()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectMinCardinality.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectMinCardinality.java new file mode 100644 index 0000000000..e42324945b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectMinCardinality.java @@ -0,0 +1,65 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; + +/** + * Builder class for OWLObjectMinCardinality. + */ +public class BuilderObjectMinCardinality extends + BaseObjectBuilder + implements SettableCardinality { + + private int cardinality = -1; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderObjectMinCardinality(OWLObjectMinCardinality expected, OWLDataFactory df) { + this(df); + withCardinality(expected.getCardinality()).withProperty(expected.getProperty()) + .withRange(expected.getFiller()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderObjectMinCardinality(OWLDataFactory df) { + super(df); + } + + @Override + public BuilderObjectMinCardinality withCardinality(int arg) { + cardinality = arg; + return this; + } + + @Override + public int getCardinality() { + return cardinality; + } + + @Override + public OWLObjectMinCardinality buildObject() { + return df.getOWLObjectMinCardinality(cardinality, verifyNotNull(getProperty()), getRange()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectProperty.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectProperty.java new file mode 100644 index 0000000000..ebf7626c00 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectProperty.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectProperty; + +/** + * Builder class for OWLObjectProperty. + */ +public class BuilderObjectProperty extends + BaseEntityBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderObjectProperty(OWLObjectProperty expected, OWLDataFactory df) { + this(df); + withIRI(expected.getIRI()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderObjectProperty(OWLDataFactory df) { + super(df); + } + + @Override + public OWLObjectProperty buildObject() { + if (pm != null && string != null) { + return df.getOWLObjectProperty(getString(), getPM()); + } + return df.getOWLObjectProperty(getIRI()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectPropertyAssertion.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectPropertyAssertion.java new file mode 100644 index 0000000000..f963b87388 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectPropertyAssertion.java @@ -0,0 +1,96 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; + +/** + * Builder class for OWLObjectPropertyAssertionAxiom. + */ +public class BuilderObjectPropertyAssertion extends + BaseObjectPropertyBuilder { + + @Nullable + private OWLIndividual subject = null; + @Nullable + private OWLIndividual value = null; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderObjectPropertyAssertion(OWLObjectPropertyAssertionAxiom expected, + OWLDataFactory df) { + this(df); + withSubject(expected.getSubject()).withProperty(expected.getProperty()) + .withValue(expected.getObject()) + .withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderObjectPropertyAssertion(OWLDataFactory df) { + super(df); + } + + /** + * @param arg subject + * @return builder + */ + public BuilderObjectPropertyAssertion withSubject(OWLIndividual arg) { + subject = arg; + return this; + } + + /** + * @param arg value + * @return builder + */ + public BuilderObjectPropertyAssertion withValue(OWLIndividual arg) { + value = arg; + return this; + } + + @Override + public OWLObjectPropertyAssertionAxiom buildObject() { + return df.getOWLObjectPropertyAssertionAxiom(verifyNotNull(getProperty()), + verifyNotNull(subject), + verifyNotNull(value), annotations); + } + + /** + * @return individual + */ + @Nullable + public OWLIndividual getValue() { + return value; + } + + /** + * @return individual + */ + @Nullable + public OWLIndividual getSubject() { + return subject; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectPropertyDomain.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectPropertyDomain.java new file mode 100644 index 0000000000..5ef8b09999 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectPropertyDomain.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; + +/** + * Builder class for OWLObjectPropertyDomainAxiom. + */ +public class BuilderObjectPropertyDomain extends + BaseDomainBuilder implements + SettableProperty { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderObjectPropertyDomain(OWLObjectPropertyDomainAxiom expected, OWLDataFactory df) { + this(df); + withDomain(expected.getDomain()).withProperty(expected.getProperty()) + .withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderObjectPropertyDomain(OWLDataFactory df) { + super(df); + } + + @Override + public OWLObjectPropertyDomainAxiom buildObject() { + return df.getOWLObjectPropertyDomainAxiom(getProperty(), getDomain(), annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectPropertyRange.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectPropertyRange.java new file mode 100644 index 0000000000..6c9d5e332a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectPropertyRange.java @@ -0,0 +1,52 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; + +/** + * Builder class for OWLObjectPropertyRangeAxiom. + */ +public class BuilderObjectPropertyRange extends + BaseObjectBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderObjectPropertyRange(OWLObjectPropertyRangeAxiom expected, OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withRange(expected.getRange()) + .withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderObjectPropertyRange(OWLDataFactory df) { + super(df); + } + + @Override + public OWLObjectPropertyRangeAxiom buildObject() { + return df + .getOWLObjectPropertyRangeAxiom(verifyNotNull(getProperty()), getRange(), annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectSomeValuesFrom.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectSomeValuesFrom.java new file mode 100644 index 0000000000..d0ec8a97c0 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderObjectSomeValuesFrom.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; + +/** + * Builder class for OWLObjectSomeValuesFrom. + */ +public class BuilderObjectSomeValuesFrom extends + BaseObjectBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderObjectSomeValuesFrom(OWLObjectSomeValuesFrom expected, OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withRange(expected.getFiller()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderObjectSomeValuesFrom(OWLDataFactory df) { + super(df); + } + + @Override + public OWLObjectSomeValuesFrom buildObject() { + return df.getOWLObjectSomeValuesFrom(verifyNotNull(getProperty()), getRange()); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderOneOf.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderOneOf.java new file mode 100644 index 0000000000..94b7ddb912 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderOneOf.java @@ -0,0 +1,48 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLObjectOneOf; + +/** + * Builder class for OWLObjectOneOf. + */ +public class BuilderOneOf extends BaseSetBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderOneOf(OWLObjectOneOf expected, OWLDataFactory df) { + this(df); + withItems(expected.individuals()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderOneOf(OWLDataFactory df) { + super(df); + } + + @Override + public OWLObjectOneOf buildObject() { + return df.getOWLObjectOneOf(items); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderPropertyChain.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderPropertyChain.java new file mode 100644 index 0000000000..466f5104f8 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderPropertyChain.java @@ -0,0 +1,83 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; + +/** + * Builder class for OWLSubPropertyChainOfAxiom. + */ +public class BuilderPropertyChain extends + BaseObjectPropertyBuilder { + + private final List chain = new ArrayList<>(); + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderPropertyChain(OWLSubPropertyChainOfAxiom expected, OWLDataFactory df) { + this(df); + withPropertiesInChain(expected.getPropertyChain()).withProperty(expected.getSuperProperty()) + .withAnnotations( + expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderPropertyChain(OWLDataFactory df) { + super(df); + } + + /** + * @param arg property + * @return builder + */ + public BuilderPropertyChain withPropertyInChain(OWLObjectPropertyExpression arg) { + chain.add(arg); + return this; + } + + /** + * @param arg properties + * @return builder + */ + public BuilderPropertyChain withPropertiesInChain(Collection arg) { + chain.addAll(arg); + return this; + } + + /** + * @return size of the chain + */ + public int chainSize() { + return chain.size(); + } + + @Override + public OWLSubPropertyChainOfAxiom buildObject() { + return df.getOWLSubPropertyChainOfAxiom(chain, verifyNotNull(getProperty()), annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderReflexiveObjectProperty.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderReflexiveObjectProperty.java new file mode 100644 index 0000000000..5baeb10c94 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderReflexiveObjectProperty.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; + +/** + * Builder class for OWLReflexiveObjectPropertyAxiom. + */ +public class BuilderReflexiveObjectProperty extends + BaseObjectPropertyBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderReflexiveObjectProperty(OWLReflexiveObjectPropertyAxiom expected, + OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderReflexiveObjectProperty(OWLDataFactory df) { + super(df); + } + + @Override + public OWLReflexiveObjectPropertyAxiom buildObject() { + return df.getOWLReflexiveObjectPropertyAxiom(verifyNotNull(getProperty()), annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLBuiltInAtom.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLBuiltInAtom.java new file mode 100644 index 0000000000..8bffb1c990 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLBuiltInAtom.java @@ -0,0 +1,93 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.SWRLBuiltInAtom; +import org.semanticweb.owlapi.model.SWRLDArgument; + +/** + * Builder class for SWRLBuiltInAtom. + */ +public class BuilderSWRLBuiltInAtom extends BaseBuilder { + + private final List args = new ArrayList<>(); + @Nullable + private IRI iri = null; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderSWRLBuiltInAtom(SWRLBuiltInAtom expected, OWLDataFactory df) { + this(df); + with(expected.getPredicate()).with(expected.getArguments()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderSWRLBuiltInAtom(OWLDataFactory df) { + super(df); + } + + /** + * @param arg iri + * @return builder + */ + public BuilderSWRLBuiltInAtom with(IRI arg) { + iri = arg; + return this; + } + + /** + * @param arg argument + * @return builder + */ + public BuilderSWRLBuiltInAtom with(SWRLDArgument arg) { + args.add(arg); + return this; + } + + /** + * @param arg arguments + * @return builder + */ + public BuilderSWRLBuiltInAtom with(Collection arg) { + args.addAll(arg); + return this; + } + + @Override + public SWRLBuiltInAtom buildObject() { + return df.getSWRLBuiltInAtom(getIRI(), args); + } + + /** + * @return iri + */ + public IRI getIRI() { + return verifyNotNull(iri); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLClassAtom.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLClassAtom.java new file mode 100644 index 0000000000..fbb8fc7dbc --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLClassAtom.java @@ -0,0 +1,89 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.SWRLClassAtom; +import org.semanticweb.owlapi.model.SWRLIArgument; + +/** + * Builder class for SWRLClassAtom. + */ +public class BuilderSWRLClassAtom extends BaseBuilder { + + @Nullable + private SWRLIArgument argument = null; + @Nullable + private OWLClassExpression predicate = null; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderSWRLClassAtom(SWRLClassAtom expected, OWLDataFactory df) { + this(df); + with(expected.getPredicate()).with(expected.getArgument()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderSWRLClassAtom(OWLDataFactory df) { + super(df); + } + + /** + * @param arg argument + * @return builder + */ + public BuilderSWRLClassAtom with(SWRLIArgument arg) { + argument = arg; + return this; + } + + /** + * @param arg class + * @return builder + */ + public BuilderSWRLClassAtom with(OWLClassExpression arg) { + predicate = arg; + return this; + } + + @Override + public SWRLClassAtom buildObject() { + return df.getSWRLClassAtom(getPredicate(), getArgument()); + } + + /** + * @return predicate + */ + public OWLClassExpression getPredicate() { + return verifyNotNull(predicate); + } + + /** + * @return predicate + */ + public SWRLIArgument getArgument() { + return verifyNotNull(argument); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLDataPropertyAtom.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLDataPropertyAtom.java new file mode 100644 index 0000000000..4500fa1699 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLDataPropertyAtom.java @@ -0,0 +1,93 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.SWRLDArgument; +import org.semanticweb.owlapi.model.SWRLDataPropertyAtom; +import org.semanticweb.owlapi.model.SWRLIArgument; + +/** + * Builder class for SWRLDataPropertyAtom. + */ +public class BuilderSWRLDataPropertyAtom extends + BaseDataPropertyBuilder { + + @Nullable + private SWRLDArgument arg1; + @Nullable + private SWRLIArgument arg0; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderSWRLDataPropertyAtom(SWRLDataPropertyAtom expected, OWLDataFactory df) { + this(df); + withProperty(expected.getPredicate()).with(expected.getSecondArgument()) + .with(expected.getFirstArgument()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderSWRLDataPropertyAtom(OWLDataFactory df) { + super(df); + } + + /** + * @param arg data argument + * @return builder + */ + public BuilderSWRLDataPropertyAtom with(SWRLDArgument arg) { + arg1 = arg; + return this; + } + + /** + * @param arg individual + * @return builder + */ + public BuilderSWRLDataPropertyAtom with(SWRLIArgument arg) { + arg0 = arg; + return this; + } + + @Override + public SWRLDataPropertyAtom buildObject() { + return df.getSWRLDataPropertyAtom(getProperty(), verifyNotNull(arg0), verifyNotNull(arg1)); + } + + /** + * @return arg 1 + */ + @Nullable + public SWRLDArgument getArg1() { + return arg1; + } + + /** + * @return arg 0 + */ + @Nullable + public SWRLIArgument getArg0() { + return arg0; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLDataRangeAtom.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLDataRangeAtom.java new file mode 100644 index 0000000000..97f4e2f2d4 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLDataRangeAtom.java @@ -0,0 +1,99 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.SWRLDArgument; +import org.semanticweb.owlapi.model.SWRLDataRangeAtom; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * Builder class for SWRLDataRangeAtom. + */ +public class BuilderSWRLDataRangeAtom extends + BaseBuilder { + + @Nullable + private SWRLDArgument argument; + @Nullable + private OWLDataRange predicate; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderSWRLDataRangeAtom(SWRLDataRangeAtom expected, OWLDataFactory df) { + this(df); + with(expected.getArgument()).with(expected.getPredicate()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderSWRLDataRangeAtom(OWLDataFactory df) { + super(df); + } + + /** + * @param arg argument + * @return builder + */ + public BuilderSWRLDataRangeAtom with(SWRLDArgument arg) { + argument = arg; + return this; + } + + /** + * @param arg predicate + * @return builder + */ + public BuilderSWRLDataRangeAtom with(OWL2Datatype arg) { + return with(arg.getDatatype(df)); + } + + /** + * @param arg predicate + * @return builder + */ + public BuilderSWRLDataRangeAtom with(OWLDataRange arg) { + predicate = arg; + return this; + } + + @Override + public SWRLDataRangeAtom buildObject() { + return df.getSWRLDataRangeAtom(getPredicate(), getArgument()); + } + + /** + * @return the argument + */ + public SWRLDArgument getArgument() { + return verifyNotNull(argument); + } + + /** + * @return the predicate + */ + public OWLDataRange getPredicate() { + return verifyNotNull(predicate); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLDifferentIndividualsAtom.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLDifferentIndividualsAtom.java new file mode 100644 index 0000000000..06be0fdcc2 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLDifferentIndividualsAtom.java @@ -0,0 +1,52 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.SWRLDifferentIndividualsAtom; + +/** + * Builder class for SWRLDifferentIndividualsAtom. + */ +public class BuilderSWRLDifferentIndividualsAtom extends + BuilderSWRLIndividualsAtom { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderSWRLDifferentIndividualsAtom(SWRLDifferentIndividualsAtom expected, + OWLDataFactory df) { + this(df); + withArg0(expected.getFirstArgument()).withArg1(expected.getSecondArgument()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderSWRLDifferentIndividualsAtom(OWLDataFactory df) { + super(df); + } + + @Override + public SWRLDifferentIndividualsAtom buildObject() { + return df + .getSWRLDifferentIndividualsAtom(verifyNotNull(getArg0()), verifyNotNull(getArg1())); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLIndividualArgument.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLIndividualArgument.java new file mode 100644 index 0000000000..bf1bc560b3 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLIndividualArgument.java @@ -0,0 +1,71 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.SWRLIndividualArgument; + +/** + * Builder class for SWRLIndividualArgument. + */ +public class BuilderSWRLIndividualArgument extends + BaseBuilder { + + @Nullable + private OWLIndividual individual; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderSWRLIndividualArgument(SWRLIndividualArgument expected, OWLDataFactory df) { + this(df); + with(expected.getIndividual()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderSWRLIndividualArgument(OWLDataFactory df) { + super(df); + } + + /** + * @param arg individual + * @return builder + */ + public BuilderSWRLIndividualArgument with(OWLIndividual arg) { + individual = arg; + return this; + } + + @Override + public SWRLIndividualArgument buildObject() { + return df.getSWRLIndividualArgument(getIndividual()); + } + + /** + * @return individual + */ + public OWLIndividual getIndividual() { + return verifyNotNull(individual); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLIndividualsAtom.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLIndividualsAtom.java new file mode 100644 index 0000000000..db74eb8864 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLIndividualsAtom.java @@ -0,0 +1,78 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.SWRLBinaryAtom; +import org.semanticweb.owlapi.model.SWRLIArgument; + +/** + * Builder class for SWRL Individuals Atom. + * + * @param type to build + * @param builder + */ +abstract public class BuilderSWRLIndividualsAtom, B extends Builder> + extends BaseBuilder { + + @Nullable + private SWRLIArgument arg0; + @Nullable + private SWRLIArgument arg1; + + /** + * @param df data factory + */ + @Inject + public BuilderSWRLIndividualsAtom(OWLDataFactory df) { + super(df); + } + + /** + * @param arg arg0 + * @return builder + */ + @SuppressWarnings("unchecked") + public B withArg0(SWRLIArgument arg) { + arg0 = arg; + return (B) this; + } + + /** + * @param arg arg0 + * @return builder + */ + @SuppressWarnings("unchecked") + public B withArg1(SWRLIArgument arg) { + arg1 = arg; + return (B) this; + } + + /** + * @return arg 1 + */ + @Nullable + public SWRLIArgument getArg1() { + return arg1; + } + + /** + * @return arg 0 + */ + @Nullable + public SWRLIArgument getArg0() { + return arg0; + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLLiteralArgument.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLLiteralArgument.java new file mode 100644 index 0000000000..cae7b7d254 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLLiteralArgument.java @@ -0,0 +1,71 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.SWRLLiteralArgument; + +/** + * Builder class for SWRLLiteralArgument. + */ +public class BuilderSWRLLiteralArgument extends + BaseBuilder { + + @Nullable + private OWLLiteral literal; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderSWRLLiteralArgument(SWRLLiteralArgument expected, OWLDataFactory df) { + this(df); + with(expected.getLiteral()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderSWRLLiteralArgument(OWLDataFactory df) { + super(df); + } + + /** + * @param arg literal + * @return builder + */ + public BuilderSWRLLiteralArgument with(OWLLiteral arg) { + literal = arg; + return this; + } + + @Override + public SWRLLiteralArgument buildObject() { + return df.getSWRLLiteralArgument(getLiteral()); + } + + /** + * @return literal + */ + public OWLLiteral getLiteral() { + return verifyNotNull(literal); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLObjectPropertyAtom.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLObjectPropertyAtom.java new file mode 100644 index 0000000000..6e7cf82505 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLObjectPropertyAtom.java @@ -0,0 +1,76 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.SWRLObjectPropertyAtom; + +/** + * Builder class for SWRLObjectPropertyAtom. + */ +public class BuilderSWRLObjectPropertyAtom extends + BuilderSWRLIndividualsAtom { + + @Nullable + private OWLObjectPropertyExpression property = null; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderSWRLObjectPropertyAtom(SWRLObjectPropertyAtom expected, OWLDataFactory df) { + this(df); + withArg0(expected.getFirstArgument()).withArg1(expected.getSecondArgument()) + .withProperty(expected + .getPredicate()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderSWRLObjectPropertyAtom(OWLDataFactory df) { + super(df); + } + + /** + * @param arg property + * @return this builder + */ + public BuilderSWRLObjectPropertyAtom withProperty(OWLObjectPropertyExpression arg) { + property = arg; + return this; + } + + /** + * @return property + */ + @Nullable + public OWLObjectPropertyExpression getProperty() { + return property; + } + + @Override + public SWRLObjectPropertyAtom buildObject() { + return df.getSWRLObjectPropertyAtom(verifyNotNull(getProperty()), verifyNotNull(getArg0()), + verifyNotNull( + getArg1())); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLRule.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLRule.java new file mode 100644 index 0000000000..acb9b0326b --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLRule.java @@ -0,0 +1,125 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.add; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.stream.Stream; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.SWRLAtom; +import org.semanticweb.owlapi.model.SWRLRule; + +/** + * Builder class for SWRLRule. + */ +public class BuilderSWRLRule extends BaseBuilder { + + private final List body = new ArrayList<>(); + private final List head = new ArrayList<>(); + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderSWRLRule(SWRLRule expected, OWLDataFactory df) { + this(df); + withBody(expected.body()).withHead(expected.head()).withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderSWRLRule(OWLDataFactory df) { + super(df); + } + + /** + * @param arg body atom + * @return builder + */ + public BuilderSWRLRule withBody(SWRLAtom arg) { + body.add(arg); + return this; + } + + /** + * @param arg head atom + * @return builder + */ + public BuilderSWRLRule withHead(SWRLAtom arg) { + head.add(arg); + return this; + } + + /** + * @param arg body atom + * @return builder + */ + public BuilderSWRLRule withBody(Collection arg) { + body.addAll(arg); + return this; + } + + /** + * @param arg body atom + * @return builder + */ + public BuilderSWRLRule withBody(Stream arg) { + add(body, arg); + return this; + } + + /** + * @param arg head atom + * @return builder + */ + public BuilderSWRLRule withHead(Collection arg) { + head.addAll(arg); + return this; + } + + /** + * @param arg head atom + * @return builder + */ + public BuilderSWRLRule withHead(Stream arg) { + add(head, arg); + return this; + } + + @Override + public SWRLRule buildObject() { + return df.getSWRLRule(body, head, annotations); + } + + /** + * @return size of body + */ + public int bodySize() { + return body.size(); + } + + /** + * @return size of head + */ + public int headSize() { + return head.size(); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLSameIndividualAtom.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLSameIndividualAtom.java new file mode 100644 index 0000000000..b8b46ca7bf --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLSameIndividualAtom.java @@ -0,0 +1,50 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.SWRLSameIndividualAtom; + +/** + * Builder class for SWRLSameIndividualAtom. + */ +public class BuilderSWRLSameIndividualAtom extends + BuilderSWRLIndividualsAtom { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderSWRLSameIndividualAtom(SWRLSameIndividualAtom expected, OWLDataFactory df) { + this(df); + withArg0(expected.getFirstArgument()).withArg1(expected.getSecondArgument()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderSWRLSameIndividualAtom(OWLDataFactory df) { + super(df); + } + + @Override + public SWRLSameIndividualAtom buildObject() { + return df.getSWRLSameIndividualAtom(verifyNotNull(getArg0()), verifyNotNull(getArg1())); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLVariable.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLVariable.java new file mode 100644 index 0000000000..86b41cf660 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSWRLVariable.java @@ -0,0 +1,70 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.SWRLVariable; + +/** + * Builder class for SWRLVariable. + */ +public class BuilderSWRLVariable extends BaseBuilder { + + @Nullable + private IRI iri; + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderSWRLVariable(SWRLVariable expected, OWLDataFactory df) { + this(df); + with(expected.getIRI()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderSWRLVariable(OWLDataFactory df) { + super(df); + } + + /** + * @param arg iri + * @return builder + */ + public BuilderSWRLVariable with(IRI arg) { + iri = arg; + return this; + } + + @Override + public SWRLVariable buildObject() { + return df.getSWRLVariable(getIRI()); + } + + /** + * @return iri + */ + public IRI getIRI() { + return verifyNotNull(iri); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSameIndividual.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSameIndividual.java new file mode 100644 index 0000000000..badc9a4cfe --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSameIndividual.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; + +/** + * Builder class for OWLSameIndividualAxiom. + */ +public class BuilderSameIndividual + extends BaseSetBuilder { + + /** + * builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderSameIndividual(OWLSameIndividualAxiom expected, OWLDataFactory df) { + this(df); + withItems(expected.individuals()).withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderSameIndividual(OWLDataFactory df) { + super(df); + } + + @Override + public OWLSameIndividualAxiom buildObject() { + return df.getOWLSameIndividualAxiom(items, annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSubAnnotationPropertyOf.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSubAnnotationPropertyOf.java new file mode 100644 index 0000000000..4aa9781af3 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSubAnnotationPropertyOf.java @@ -0,0 +1,55 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom; + +/** + * Builder class for OWLSubAnnotationPropertyOfAxiom. + */ +public class BuilderSubAnnotationPropertyOf extends + BaseSubBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderSubAnnotationPropertyOf(OWLSubAnnotationPropertyOfAxiom expected, + OWLDataFactory df) { + this(df); + withSub(expected.getSubProperty()).withSup(expected.getSuperProperty()) + .withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderSubAnnotationPropertyOf(OWLDataFactory df) { + super(df); + } + + @Override + public OWLSubAnnotationPropertyOfAxiom buildObject() { + return df + .getOWLSubAnnotationPropertyOfAxiom(verifyNotNull(getSub()), verifyNotNull(getSup()), + annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSubClass.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSubClass.java new file mode 100644 index 0000000000..2c4baca274 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSubClass.java @@ -0,0 +1,53 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; + +/** + * Builder class for OWLSubClassOfAxiom. + */ +public class BuilderSubClass extends + BaseSubBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderSubClass(OWLSubClassOfAxiom expected, OWLDataFactory df) { + this(df); + withSub(expected.getSubClass()).withSup(expected.getSuperClass()) + .withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderSubClass(OWLDataFactory df) { + super(df); + } + + @Override + public OWLSubClassOfAxiom buildObject() { + return df + .getOWLSubClassOfAxiom(verifyNotNull(getSub()), verifyNotNull(getSup()), annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSubDataProperty.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSubDataProperty.java new file mode 100644 index 0000000000..71315a0b4a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSubDataProperty.java @@ -0,0 +1,53 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; + +/** + * Builder class for OWLSubDataPropertyOfAxiom. + */ +public class BuilderSubDataProperty extends + BaseSubBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderSubDataProperty(OWLSubDataPropertyOfAxiom expected, OWLDataFactory df) { + this(df); + withSub(expected.getSubProperty()).withSup(expected.getSuperProperty()) + .withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderSubDataProperty(OWLDataFactory df) { + super(df); + } + + @Override + public OWLSubDataPropertyOfAxiom buildObject() { + return df.getOWLSubDataPropertyOfAxiom(verifyNotNull(getSub()), verifyNotNull(getSup()), + annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSubObjectProperty.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSubObjectProperty.java new file mode 100644 index 0000000000..9779c53f86 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSubObjectProperty.java @@ -0,0 +1,53 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; + +/** + * Builder class for OWLSubObjectPropertyOfAxiom. + */ +public class BuilderSubObjectProperty extends + BaseSubBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderSubObjectProperty(OWLSubObjectPropertyOfAxiom expected, OWLDataFactory df) { + this(df); + withSub(expected.getSubProperty()).withSup(expected.getSuperProperty()) + .withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderSubObjectProperty(OWLDataFactory df) { + super(df); + } + + @Override + public OWLSubObjectPropertyOfAxiom buildObject() { + return df.getOWLSubObjectPropertyOfAxiom(verifyNotNull(getSub()), verifyNotNull(getSup()), + annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSymmetricObjectProperty.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSymmetricObjectProperty.java new file mode 100644 index 0000000000..a8a31960b7 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderSymmetricObjectProperty.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; + +/** + * Builder class for OWLSymmetricObjectPropertyAxiom. + */ +public class BuilderSymmetricObjectProperty extends + BaseObjectPropertyBuilder { + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderSymmetricObjectProperty(OWLSymmetricObjectPropertyAxiom expected, + OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withAnnotations(expected.annotations()); + } + + /** + * @param df data factory + */ + @Inject + public BuilderSymmetricObjectProperty(OWLDataFactory df) { + super(df); + } + + @Override + public OWLSymmetricObjectPropertyAxiom buildObject() { + return df.getOWLSymmetricObjectPropertyAxiom(verifyNotNull(getProperty()), annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderTransitiveObjectProperty.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderTransitiveObjectProperty.java new file mode 100644 index 0000000000..a33291dbbf --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderTransitiveObjectProperty.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; + +/** + * Builder class for OWLTransitiveObjectPropertyAxiom. + */ +public class BuilderTransitiveObjectProperty extends + BaseObjectPropertyBuilder { + + /** + * @param df data factory + */ + @Inject + public BuilderTransitiveObjectProperty(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderTransitiveObjectProperty(OWLTransitiveObjectPropertyAxiom expected, + OWLDataFactory df) { + this(df); + withProperty(expected.getProperty()).withAnnotations(expected.annotations()); + } + + @Override + public OWLTransitiveObjectPropertyAxiom buildObject() { + return df.getOWLTransitiveObjectPropertyAxiom(verifyNotNull(getProperty()), annotations); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderUnionOf.java b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderUnionOf.java new file mode 100644 index 0000000000..733065697e --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/BuilderUnionOf.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapitools.builders; + +import javax.inject.Inject; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; + +/** + * Builder class for OWLObjectUnionOf. + */ +public class BuilderUnionOf extends + BaseSetBuilder { + + /** + * @param df data factory + */ + @Inject + public BuilderUnionOf(OWLDataFactory df) { + super(df); + } + + /** + * Builder initialized from an existing object. + * + * @param expected the existing object + * @param df data factory + */ + public BuilderUnionOf(OWLObjectUnionOf expected, OWLDataFactory df) { + this(df); + withItems(expected.operands()); + } + + @Override + public OWLObjectUnionOf buildObject() { + return df.getOWLObjectUnionOf(items); + } +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/SettableCardinality.java b/api/src/main/java/org/semanticweb/owlapitools/builders/SettableCardinality.java new file mode 100644 index 0000000000..069d47f210 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/SettableCardinality.java @@ -0,0 +1,18 @@ +package org.semanticweb.owlapitools.builders; + +import org.semanticweb.owlapi.model.HasCardinality; + +/** + * An object with a settable cardinality attribute. + * + * @param returned type for builders + * @author ignazio + */ +public interface SettableCardinality extends HasCardinality { + + /** + * @param cardinality cardinality to set + * @return builder + */ + B withCardinality(int cardinality); +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/SettableProperty.java b/api/src/main/java/org/semanticweb/owlapitools/builders/SettableProperty.java new file mode 100644 index 0000000000..555cd48a00 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/SettableProperty.java @@ -0,0 +1,20 @@ +package org.semanticweb.owlapitools.builders; + +import org.semanticweb.owlapi.model.HasProperty; +import org.semanticweb.owlapi.model.OWLObject; + +/** + * An object with a settable property attribute. + * + * @param

type of property + * @param type of builder + * @author ignazio + */ +public interface SettableProperty

extends HasProperty

{ + + /** + * @param p property to set + * @return builder + */ + B withProperty(P p); +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/SettableRange.java b/api/src/main/java/org/semanticweb/owlapitools/builders/SettableRange.java new file mode 100644 index 0000000000..7aa2935d3a --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/SettableRange.java @@ -0,0 +1,20 @@ +package org.semanticweb.owlapitools.builders; + +import org.semanticweb.owlapi.model.HasRange; +import org.semanticweb.owlapi.model.OWLObject; + +/** + * An interface for objects which have a settable range attribute. + * + * @param type of builder + * @param type of range + * @author ignazio + */ +public interface SettableRange extends HasRange { + + /** + * @param range range to set + * @return builder + */ + B withRange(R range); +} diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/package-info.java b/api/src/main/java/org/semanticweb/owlapitools/builders/package-info.java new file mode 100644 index 0000000000..288c81a58c --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Builders package. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapitools.builders; diff --git a/api/src/main/java/org/semanticweb/owlapitools/builders/packageinfo b/api/src/main/java/org/semanticweb/owlapitools/builders/packageinfo new file mode 100644 index 0000000000..11725e3c92 --- /dev/null +++ b/api/src/main/java/org/semanticweb/owlapitools/builders/packageinfo @@ -0,0 +1 @@ +version 6.0.1 diff --git a/api/src/main/javadoc/doc-files/hierarchy.png b/api/src/main/javadoc/doc-files/hierarchy.png new file mode 100644 index 0000000000..19161f0a37 Binary files /dev/null and b/api/src/main/javadoc/doc-files/hierarchy.png differ diff --git a/api/src/test/java/org/semanticweb/owlapi/change/OWLOntologyChangeRecordTest.java b/api/src/test/java/org/semanticweb/owlapi/change/OWLOntologyChangeRecordTest.java new file mode 100644 index 0000000000..0a75534ef8 --- /dev/null +++ b/api/src/test/java/org/semanticweb/owlapi/change/OWLOntologyChangeRecordTest.java @@ -0,0 +1,36 @@ +package org.semanticweb.owlapi.change; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntologyID; + +class OWLOntologyChangeRecordTest { + + private static final String URN_TEST = "urn:test#"; + + @Test + public void testSerializeChangeRecord() throws Exception { + OWLOntologyID id1 = new OWLOntologyID(optional(IRI.create(URN_TEST, "a")), + optional(IRI.create(URN_TEST, "v1"))); + OWLOntologyID id2 = new OWLOntologyID(optional(IRI.create(URN_TEST, "a")), + optional(IRI.create(URN_TEST, "v2"))); + OWLOntologyChangeRecord idChangeRecord = + new OWLOntologyChangeRecord(id1, new SetOntologyIDData(id2)); + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + try (ObjectOutputStream out = new ObjectOutputStream(byteArrayOutputStream)) { + out.writeObject(idChangeRecord); + out.close(); + } + ObjectInputStream in = + new ObjectInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray())); + OWLOntologyChangeRecord recordIn = (OWLOntologyChangeRecord) in.readObject(); + assertEquals(idChangeRecord, recordIn); + } +} diff --git a/api/src/test/java/org/semanticweb/owlapi/io/CommonsRDFTermTest.java b/api/src/test/java/org/semanticweb/owlapi/io/CommonsRDFTermTest.java new file mode 100644 index 0000000000..2d063b3733 --- /dev/null +++ b/api/src/test/java/org/semanticweb/owlapi/io/CommonsRDFTermTest.java @@ -0,0 +1,214 @@ +package org.semanticweb.owlapi.io; + +import static org.junit.jupiter.api.Assumptions.assumeTrue; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import java.util.concurrent.atomic.AtomicInteger; + +import javax.annotation.Nullable; + +import org.apache.commons.rdf.api.AbstractRDFTest; +import org.apache.commons.rdf.api.BlankNode; +import org.apache.commons.rdf.api.BlankNodeOrIRI; +import org.apache.commons.rdf.api.Dataset; +import org.apache.commons.rdf.api.Graph; +import org.apache.commons.rdf.api.IRI; +import org.apache.commons.rdf.api.Literal; +import org.apache.commons.rdf.api.Quad; +import org.apache.commons.rdf.api.RDF; +import org.apache.commons.rdf.api.RDFTerm; +import org.apache.commons.rdf.api.Triple; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.model.NodeID; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +// NOTE: Always fully qualified IRI to avoid confusion between +//import org.apache.commons.rdf.api.IRI; +//import org.semanticweb.owlapi.model.IRI; + +@SuppressWarnings({"javadoc", "null"}) +public class CommonsRDFTermTest extends AbstractRDFTest { + + @Disabled + @Override + public void hashCodeBlankNode() { + // TODO Auto-generated method stub + // super.hashCodeBlankNode(); + } + + @Disabled + @Override + public void hashCodeLiteral() { + // TODO Auto-generated method stub + // super.hashCodeLiteral(); + } + + @Disabled + @Override + public void testCreateGraph() { + // TODO Auto-generated method stub + // super.testCreateGraph(); + } + + @Disabled + @Override + public void testCreateBlankNodeIdentifierTwiceDifferentFactories() { + // TODO Auto-generated method stub + // super.testCreateBlankNodeIdentifierTwiceDifferentFactories(); + } + + @Disabled + @Override + public void hashCodeTriple() { + // TODO Auto-generated method stub + // super.hashCodeTriple(); + } + + @Override + public RDF createFactory() { + return new OWLAPIRDFTermFactory(); + } + + @Override + @Disabled + @Test + public void testPossiblyInvalidBlankNode() throws Exception { + // FIXME: Should BlankNode identifiers be validated? At least + // ntriplesString() output should be checked - but could + // this also affect load/save issues? + assumeTrue(false, "BlankNode identifiers are not validated"); + super.testPossiblyInvalidBlankNode(); + } + + @Disabled + @Override + public void testInvalidLiteralLang() throws Exception { + // FIXME: RDFLiteral should not allow spaces in lang + assumeTrue(false, "RDFLiteral does not validate lang"); + super.testInvalidLiteralLang(); + } + + @Disabled + @Override + public void testInvalidIRI() throws Exception { + assumeTrue(false, "IRI string is not validated"); + super.testInvalidIRI(); + } + + private final class OWLAPIRDFTermFactory implements RDF { + + private final AtomicInteger bnodeCounter = new AtomicInteger(); + + public OWLAPIRDFTermFactory() {} + + @Override + public RDFResourceBlankNode createBlankNode() { + return new RDFResourceBlankNode(Integer.valueOf(bnodeCounter.incrementAndGet()), false, + false, false); + } + + @Override + public RDFResourceBlankNode createBlankNode(@Nullable String name) { + org.semanticweb.owlapi.model.IRI iri = + createIRI(NodeID.getIRIFromNodeID(verifyNotNull(name))); + return new RDFResourceBlankNode(iri, false, false, false); + } + + @Override + public RDFLiteral createLiteral(@Nullable String lexicalForm) { + return new RDFLiteral(verifyNotNull(lexicalForm), null, + OWL2Datatype.XSD_STRING.getIRI()); + } + + @Override + public RDFLiteral createLiteral(@Nullable String lexicalForm, @Nullable IRI dataType) { + return new RDFLiteral(verifyNotNull(lexicalForm), null, + createIRI(verifyNotNull(dataType).getIRIString())); + } + + @Override + public RDFLiteral createLiteral(@Nullable String lexicalForm, + @Nullable String languageTag) { + return new RDFLiteral(verifyNotNull(lexicalForm), languageTag, null); + } + + @Override + public org.semanticweb.owlapi.model.IRI createIRI(@Nullable String iriStr) { + return org.semanticweb.owlapi.model.IRI.create(verifyNotNull(iriStr)); + // TODO: What about RDFResourceIRI? + // return new RDFResourceIRI(innerIri); + } + + @Override + public Triple createTriple(@Nullable BlankNodeOrIRI subject, @Nullable IRI predicate, + @Nullable RDFTerm object) { + RDFResource subject2 = (RDFResource) convert(subject); + RDFResourceIRI predicate2 = (RDFResourceIRI) convert(predicate); + RDFNode object2 = convert(object); + return new RDFTriple(subject2, predicate2, object2); + } + + private RDFNode convert(@Nullable RDFTerm term) { + verifyNotNull(term); + if (term instanceof RDFNode) { + // NOTE: Naively assuming it can then be further casted to + // RDFResourceIRI etc + return (RDFNode) term; + } + if (term instanceof IRI) { + IRI iri = (IRI) term; + return new RDFResourceIRI(createIRI(iri.getIRIString())); + } + if (term instanceof BlankNode) { + BlankNode blankNode = (BlankNode) term; + String ntriples = blankNode.ntriplesString(); + org.semanticweb.owlapi.model.IRI iriLike; + if (ntriples.startsWith("<") && ntriples.endsWith(">")) { + // strange.. a BlankNode with IRI? Well, we can handle + // those. + iriLike = createIRI(ntriples.substring(1, ntriples.length() - 1)); + } else if (ntriples.startsWith("_:")) { + // org.semanticweb.owlapi.model.IRI supports these directly + // even though they are not relly IRIs + iriLike = createIRI(ntriples); + } else { + // How can this be valid N-Triples? + throw new IllegalArgumentException( + "Unsupported ntriplesString on BlankNode: " + ntriples); + } + return new RDFResourceBlankNode(iriLike, false, false, false); + } + if (term instanceof Literal) { + Literal literal = (Literal) term; + org.semanticweb.owlapi.model.IRI dataType = null; + if (!literal.getLanguageTag().isPresent()) { + dataType = createIRI(literal.getDatatype().getIRIString()); + } + return new RDFLiteral(literal.getLexicalForm(), + literal.getLanguageTag().orElse(null), dataType); + } + throw new IllegalArgumentException( + "Unsupported type: " + verifyNotNull(term).getClass()); + } + + @Override + public Graph createGraph() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Dataset createDataset() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Quad createQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, + RDFTerm object) { + // TODO Auto-generated method stub + return null; + } + } +} diff --git a/api/src/test/java/org/semanticweb/owlapi/io/StreamDocumentSourceBaseTestCase.java b/api/src/test/java/org/semanticweb/owlapi/io/StreamDocumentSourceBaseTestCase.java new file mode 100644 index 0000000000..db21438d46 --- /dev/null +++ b/api/src/test/java/org/semanticweb/owlapi/io/StreamDocumentSourceBaseTestCase.java @@ -0,0 +1,44 @@ +package org.semanticweb.owlapi.io; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringWriter; +import java.nio.charset.StandardCharsets; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.model.IRI; + +@SuppressWarnings("resource") +class StreamDocumentSourceBaseTestCase { + + @Test + void shouldCreateRewindableReaderWithKnownContent() throws IOException { + String input = + "\n" + + "\n" + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + " \n" + + " \n" + + ""; + StreamDocumentSourceBase source = new StreamDocumentSourceBase( + new InputStreamReader(new ByteArrayInputStream(input.getBytes()), + StandardCharsets.UTF_8), + IRI.create("urn:test#", "test"), null, null) {}; + Reader r = source.getReader().get(); + StringWriter w = new StringWriter(); + int i = r.read(); + while (i > -1) { + w.write(i); + i = r.read(); + } + w.flush(); + String result = w.toString(); + assertEquals(input, result); + } +} diff --git a/api/src/test/java/org/semanticweb/owlapi/io/XZStreamDocumentSourceTestCase.java b/api/src/test/java/org/semanticweb/owlapi/io/XZStreamDocumentSourceTestCase.java new file mode 100644 index 0000000000..075241628d --- /dev/null +++ b/api/src/test/java/org/semanticweb/owlapi/io/XZStreamDocumentSourceTestCase.java @@ -0,0 +1,39 @@ +package org.semanticweb.owlapi.io; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.Reader; +import java.util.Optional; + +import org.junit.jupiter.api.Test; + +/** + * Created by ses on 3/12/15. + */ +class XZStreamDocumentSourceTestCase { + + @Test + void testReadKoalaDoc() throws IOException { + XZStreamDocumentSource source = + new XZStreamDocumentSource(getClass().getResourceAsStream("/koala.owl.xz")); + Optional reader = source.getReader(); + assertTrue(source.getInputStream().isPresent()); + assertTrue(reader.isPresent()); + try (BufferedReader in = new BufferedReader(reader.get())) { + int lineCount = 0; + int koalaCount = 0; + String line = null; + while ((line = in.readLine()) != null) { + lineCount++; + if (line.contains("Koala")) { + koalaCount++; + } + } + assertEquals(3, koalaCount); + assertEquals(250, lineCount); + } + } +} diff --git a/api/src/test/java/org/semanticweb/owlapi/model/NodeIDTestCase.java b/api/src/test/java/org/semanticweb/owlapi/model/NodeIDTestCase.java new file mode 100644 index 0000000000..e37fa241ac --- /dev/null +++ b/api/src/test/java/org/semanticweb/owlapi/model/NodeIDTestCase.java @@ -0,0 +1,69 @@ +package org.semanticweb.owlapi.model; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +/** + * @author ignazio + */ +class NodeIDTestCase { + + private static final String SOMESTRING = "somestring"; + + @Test + void shouldCreateNodeString() { + assertEquals("_:genid30", NodeID.nodeString(30)); + } + + @Test + void shouldCreateIRIFromNodeString() { + assertEquals("_:genid-nodeid-somestring_", NodeID.getIRIFromNodeID("somestring_genid")); + } + + @Test + void shouldCreateNextIRI() { + assertTrue(NodeID.nextAnonymousIRI().matches("_:genid[0-9]+")); + } + + @Test + void shouldFindAnonymousNode() { + assertTrue(NodeID.isAnonymousNodeIRI("_:sometest_genid_something")); + assertTrue(NodeID.isAnonymousNodeIRI("_:genid_something")); + assertFalse(NodeID.isAnonymousNodeIRI("http://sometest_genid_something")); + assertFalse(NodeID.isAnonymousNodeIRI((String) null)); + } + + @Test + void shouldFindAnonymousNodeIRI() { + assertTrue(NodeID.isAnonymousNodeIRI(IRI.create("_:sometest_genid_something"))); + assertTrue(NodeID.isAnonymousNodeIRI(IRI.create("_:genid_something"))); + assertFalse(NodeID.isAnonymousNodeIRI(IRI.create("http://sometest_genid#", "something"))); + assertFalse(NodeID.isAnonymousNodeIRI((IRI) null)); + } + + @Test + void shouldFindsharedNodeIRI() { + assertFalse(NodeID.isAnonymousNodeID("_:sometest_genid-nodeid-_something")); + assertTrue(NodeID.isAnonymousNodeID("_:genid-nodeid-_something")); + assertFalse(NodeID.isAnonymousNodeID("http://sometest_genid-nodeid-_something")); + assertFalse(NodeID.isAnonymousNodeID(null)); + } + + @Test + void shouldbuildNode() { + assertTrue( + NodeID.isAnonymousNodeIRI(NodeID.getNodeID("_:sometest_genid_something").getID())); + assertTrue( + NodeID.isAnonymousNodeIRI(NodeID.getNodeID("http://sometest_genid_something").getID())); + assertTrue(NodeID.isAnonymousNodeIRI(NodeID.getNodeID(null).getID())); + NodeID id = NodeID.getNodeID(null); + assertEquals(id.getID(), id.toString()); + assertEquals(NodeID.getNodeID(SOMESTRING), NodeID.getNodeID(SOMESTRING)); + assertEquals(NodeID.getNodeID(SOMESTRING).compareTo(NodeID.getNodeID("someotherstring")), + SOMESTRING.compareTo("someotherstring")); + assertEquals(id.hashCode(), id.toString().hashCode()); + } +} diff --git a/api/src/test/java/org/semanticweb/owlapi/model/VocabularyEnumTestCase.java b/api/src/test/java/org/semanticweb/owlapi/model/VocabularyEnumTestCase.java new file mode 100644 index 0000000000..4c8bad5c21 --- /dev/null +++ b/api/src/test/java/org/semanticweb/owlapi/model/VocabularyEnumTestCase.java @@ -0,0 +1,76 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import static java.util.Arrays.stream; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.startsWith; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; +import static org.semanticweb.owlapi.vocab.Namespaces.DC; +import static org.semanticweb.owlapi.vocab.Namespaces.OWL; +import static org.semanticweb.owlapi.vocab.Namespaces.SKOS; +import static org.semanticweb.owlapi.vocab.Namespaces.SWRL; +import static org.semanticweb.owlapi.vocab.Namespaces.SWRLB; +import static org.semanticweb.owlapi.vocab.Namespaces.XSD; + +import java.util.Collection; +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.vocab.DublinCoreVocabulary; +import org.semanticweb.owlapi.vocab.Namespaces; +import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; +import org.semanticweb.owlapi.vocab.OWLXMLVocabulary; +import org.semanticweb.owlapi.vocab.SKOSVocabulary; +import org.semanticweb.owlapi.vocab.SWRLBuiltInsVocabulary; +import org.semanticweb.owlapi.vocab.SWRLVocabulary; +import org.semanticweb.owlapi.vocab.XSDVocabulary; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5.0 + */ +class VocabularyEnumTestCase { + + static Collection getData() { + return asList( + concat(stream(DublinCoreVocabulary.values()).map(input -> new Object[] {input, DC}), + stream(OWLRDFVocabulary.values()) + .map(input -> new Object[] {input, input.getNamespace()}), + stream(OWLXMLVocabulary.values()).map(input -> new Object[] {input, OWL}), + stream(SKOSVocabulary.values()).map(input -> new Object[] {input, SKOS}), + stream(SWRLBuiltInsVocabulary.values()).map(input -> new Object[] {input, SWRLB}), + stream(SWRLVocabulary.values()).map(input -> new Object[] {input, SWRL}), + stream(XSDVocabulary.values()).map(input -> new Object[] {input, XSD}))); + } + + @SafeVarargs + private static Stream concat(Stream... values) { + Stream toReturn = values[0]; + for (int i = 1; i < values.length; i++) { + toReturn = Stream.concat(toReturn, values[i]); + } + return toReturn; + } + + @ParameterizedTest + @MethodSource("getData") + void shouldGetDublinCorePrefixName(Object in, Namespaces expected) { + HasIRI iri = (HasIRI) in; + HasPrefixedName name = (HasPrefixedName) in; + assertThat(name.getPrefixedName(), startsWith(expected.getPrefixName())); + assertThat(iri.getIRI().getNamespace(), equalTo(expected.getPrefixIRI())); + } +} diff --git a/api/src/test/java/org/semanticweb/owlapi/util/OWLOntologyIRIShortFormProviderTestCase.java b/api/src/test/java/org/semanticweb/owlapi/util/OWLOntologyIRIShortFormProviderTestCase.java new file mode 100644 index 0000000000..d2e5bb1d32 --- /dev/null +++ b/api/src/test/java/org/semanticweb/owlapi/util/OWLOntologyIRIShortFormProviderTestCase.java @@ -0,0 +1,93 @@ +package org.semanticweb.owlapi.util; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; + +import org.hamcrest.CoreMatchers; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.model.IRI; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.5 + */ +class OWLOntologyIRIShortFormProviderTestCase { + + static final String ONT = "ont"; + static final String ONTOLOGIES = "/ontologies/"; + static final String SCHEME_DOMAIN = "http://www.semanticweb.org"; + final OntologyIRIShortFormProvider sfp = new OntologyIRIShortFormProvider(); + + @Test + void shouldFindLastPathElement() { + String shortForm = sfp.getShortForm(IRI.create(SCHEME_DOMAIN + ONTOLOGIES, ONT)); + assertThat(shortForm, is(equalTo(ONT))); + } + + /* + * A test to see if a meaningful short form is returned when the ontology IRI encodes version + * information at the end. For example, the dublin core IRIs do this. + */ + @Test + void shouldReturnLastNonNumericPathElement() { + String shortForm = + sfp.getShortForm(IRI.create(SCHEME_DOMAIN + "/ontologies/ont/1.1.11", "")); + assertThat(shortForm, is(equalTo(ONT))); + } + + @Test + void shouldReturnLastNonVersionPathElement() { + String shortForm = + sfp.getShortForm(IRI.create(SCHEME_DOMAIN + "/ontologies/ont/", "v1.1.11")); + assertThat(shortForm, is(equalTo(ONT))); + } + + @Test + void shouldReturnFullIRIForNoPath() { + String shortForm = sfp.getShortForm(IRI.create(SCHEME_DOMAIN, "")); + assertThat(shortForm, is(equalTo(SCHEME_DOMAIN))); + } + + @Test + void shouldStripAwayOWLExtension() { + String shortForm = sfp.getShortForm(IRI.create(SCHEME_DOMAIN + ONTOLOGIES, "ont.owl")); + assertThat(shortForm, is(equalTo(ONT))); + } + + @Test + void shouldStripAwayRDFExtension() { + String shortForm = sfp.getShortForm(IRI.create(SCHEME_DOMAIN + ONTOLOGIES, "ont.rdf")); + assertThat(shortForm, is(equalTo(ONT))); + } + + @Test + void shouldStripAwayXMLExtension() { + String shortForm = sfp.getShortForm(IRI.create(SCHEME_DOMAIN + ONTOLOGIES, "ont.xml")); + assertThat(shortForm, is(equalTo(ONT))); + } + + @Test + void shouldStripAwayOBOExtension() { + String shortForm = sfp.getShortForm(IRI.create(SCHEME_DOMAIN + ONTOLOGIES, "ont.obo")); + assertThat(shortForm, is(equalTo(ONT))); + } + + @Test + void shouldReturnSkosForSKOSNamespace() { + String shortForm = sfp.getShortForm(IRI.create("http://www.w3.org/2004/02/skos/", "core")); + assertThat(shortForm, is(CoreMatchers.equalTo("skos"))); + } + + @Test + void shouldReturnDcForDublinCoreNamespace() { + String shortForm = sfp.getShortForm(IRI.create("http://purl.org/dc/elements/1.1", "")); + assertThat(shortForm, is(CoreMatchers.equalTo("dc"))); + } + + @Test + void shouldReturnDcForDublinCoreNamespaceEndingWithSlash() { + String shortForm = sfp.getShortForm(IRI.create("http://purl.org/dc/elements/1.1/", "")); + assertThat(shortForm, is(CoreMatchers.equalTo("dc"))); + } +} diff --git a/api/src/test/resources/koala.owl.xz b/api/src/test/resources/koala.owl.xz new file mode 100644 index 0000000000..0d9afa365c Binary files /dev/null and b/api/src/test/resources/koala.owl.xz differ diff --git a/apibinding/pom.xml b/apibinding/pom.xml new file mode 100644 index 0000000000..0e84b80e72 --- /dev/null +++ b/apibinding/pom.xml @@ -0,0 +1,52 @@ + + 4.0.0 + owlapi-apibinding + OWLAPI :: Binding and Config + + net.sourceforge.owlapi + owlapi-parent + 5.1.18 + + + + ${project.groupId} + owlapi-api + ${project.version} + + + ${project.groupId} + owlapi-impl + ${project.version} + + + ${project.groupId} + owlapi-parsers + ${project.version} + + + ${project.groupId} + owlapi-oboformat + ${project.version} + + + ${project.groupId} + owlapi-tools + ${project.version} + + + ${project.groupId} + owlapi-rio + ${project.version} + + + + diff --git a/apibinding/src/main/java/org/semanticweb/owlapi/apibinding/OWLFunctionalSyntaxFactory.java b/apibinding/src/main/java/org/semanticweb/owlapi/apibinding/OWLFunctionalSyntaxFactory.java new file mode 100644 index 0000000000..52f72baa92 --- /dev/null +++ b/apibinding/src/main/java/org/semanticweb/owlapi/apibinding/OWLFunctionalSyntaxFactory.java @@ -0,0 +1,830 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.apibinding; + +import static org.semanticweb.owlapi.model.IRI.getNextDocumentIRI; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationSubject; +import org.semanticweb.owlapi.model.OWLAnnotationValue; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataComplementOf; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataIntersectionOf; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDataUnionOf; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLHasKeyAxiom; +import org.semanticweb.owlapi.model.OWLImportsDeclaration; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectInverseOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLPropertyExpression; +import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; +import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.PrefixManager; +import org.semanticweb.owlapi.vocab.OWL2Datatype; +import org.semanticweb.owlapi.vocab.OWLFacet; + +/** + * A utility class whose methods may be statically imported so that OWL API objects can be + * constructed by writing code that looks like the OWL 2 Functional Syntax.
+ * Note that this class is primarily intended for developers who need to write test cases. Normal + * client code should probably use an {@link org.semanticweb.owlapi.model.OWLDataFactory} for + * creating objects. + * + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +@SuppressWarnings("javadoc") +public final class OWLFunctionalSyntaxFactory { + + private static final String URNTESTS_URI = "urn:tests#uri"; + private static final OWLDataFactory DF = OWLManager.getOWLDataFactory(); + + private OWLFunctionalSyntaxFactory() {} + + public static OWLImportsDeclaration ImportsDeclaration(IRI i) { + return DF.getOWLImportsDeclaration(i); + } + + // Entities + public static OWLClass Class(IRI iri) { + return DF.getOWLClass(iri); + } + + public static OWLClass createClass() { + return Class(getNextDocumentIRI(URNTESTS_URI)); + } + + public static OWLObjectProperty createObjectProperty() { + return ObjectProperty(getNextDocumentIRI(URNTESTS_URI)); + } + + public static OWLDataProperty createDataProperty() { + return DataProperty(getNextDocumentIRI(URNTESTS_URI)); + } + + public static OWLNamedIndividual createIndividual() { + return NamedIndividual(getNextDocumentIRI(URNTESTS_URI)); + } + + public static OWLAnnotationProperty createAnnotationProperty() { + return AnnotationProperty(getNextDocumentIRI(URNTESTS_URI)); + } + + public static OWLLiteral createOWLLiteral() { + return Literal("Test" + System.currentTimeMillis(), + Datatype(getNextDocumentIRI(URNTESTS_URI))); + } + + public static OWLClass Class(String abbreviatedIRI, PrefixManager pm) { + return DF.getOWLClass(abbreviatedIRI, pm); + } + + public static OWLAnnotationProperty RDFSComment() { + return DF.getRDFSComment(); + } + + public static OWLAnnotationProperty RDFSLabel() { + return DF.getRDFSLabel(); + } + + public static OWLDatatype TopDatatype() { + return DF.getTopDatatype(); + } + + public static OWLClass OWLThing() { + return DF.getOWLThing(); + } + + public static OWLDatatype Integer() { + return DF.getIntegerOWLDatatype(); + } + + public static OWLDatatype Double() { + return DF.getDoubleOWLDatatype(); + } + + public static OWLDatatype Float() { + return DF.getFloatOWLDatatype(); + } + + public static OWLDatatype Boolean() { + return DF.getBooleanOWLDatatype(); + } + + public static OWLClass OWLNothing() { + return DF.getOWLNothing(); + } + + public static OWLObjectProperty ObjectProperty(IRI iri) { + return DF.getOWLObjectProperty(iri); + } + + public static OWLObjectProperty ObjectProperty(String abbreviatedIRI, PrefixManager pm) { + return DF.getOWLObjectProperty(abbreviatedIRI, pm); + } + + public static OWLObjectInverseOf ObjectInverseOf(OWLObjectProperty pe) { + return DF.getOWLObjectInverseOf(pe); + } + + public static OWLDataProperty DataProperty(IRI iri) { + return DF.getOWLDataProperty(iri); + } + + public static OWLDataProperty DataProperty(String abbreviatedIRI, PrefixManager pm) { + return DF.getOWLDataProperty(abbreviatedIRI, pm); + } + + public static OWLAnnotationProperty AnnotationProperty(IRI iri) { + return DF.getOWLAnnotationProperty(iri); + } + + public static OWLAnnotationProperty AnnotationProperty(String abbreviatedIRI, + PrefixManager pm) { + return DF.getOWLAnnotationProperty(abbreviatedIRI, pm); + } + + public static OWLNamedIndividual NamedIndividual(IRI iri) { + return DF.getOWLNamedIndividual(iri); + } + + public static OWLAnonymousIndividual AnonymousIndividual() { + return DF.getOWLAnonymousIndividual(); + } + + public static OWLAnonymousIndividual AnonymousIndividual(String id) { + return DF.getOWLAnonymousIndividual(id); + } + + public static OWLNamedIndividual NamedIndividual(String abbreviatedIRI, PrefixManager pm) { + return DF.getOWLNamedIndividual(abbreviatedIRI, pm); + } + + public static OWLDatatype Datatype(IRI iri) { + return DF.getOWLDatatype(iri); + } + + public static OWLDeclarationAxiom Declaration(OWLEntity entity) { + return DF.getOWLDeclarationAxiom(entity); + } + + public static OWLDeclarationAxiom Declaration(OWLEntity entity, Collection a) { + return DF.getOWLDeclarationAxiom(entity, a); + } + + public static OWLDeclarationAxiom Declaration(OWLEntity entity, OWLAnnotation... a) { + return DF.getOWLDeclarationAxiom(entity, new HashSet<>(Arrays.asList(a))); + } + + // Class Expressions + public static OWLObjectIntersectionOf ObjectIntersectionOf( + OWLClassExpression... classExpressions) { + return DF.getOWLObjectIntersectionOf(classExpressions); + } + + public static OWLObjectUnionOf ObjectUnionOf(OWLClassExpression... classExpressions) { + return DF.getOWLObjectUnionOf(classExpressions); + } + + public static OWLObjectComplementOf ObjectComplementOf(OWLClassExpression classExpression) { + return DF.getOWLObjectComplementOf(classExpression); + } + + public static OWLObjectSomeValuesFrom ObjectSomeValuesFrom(OWLObjectPropertyExpression pe, + OWLClassExpression ce) { + return DF.getOWLObjectSomeValuesFrom(pe, ce); + } + + public static OWLObjectAllValuesFrom ObjectAllValuesFrom(OWLObjectPropertyExpression pe, + OWLClassExpression ce) { + return DF.getOWLObjectAllValuesFrom(pe, ce); + } + + public static OWLObjectHasValue ObjectHasValue(OWLObjectPropertyExpression pe, + OWLIndividual individual) { + return DF.getOWLObjectHasValue(pe, individual); + } + + public static OWLObjectMinCardinality ObjectMinCardinality(int cardinality, + OWLObjectPropertyExpression pe, OWLClassExpression ce) { + return DF.getOWLObjectMinCardinality(cardinality, pe, ce); + } + + public static OWLObjectMaxCardinality ObjectMaxCardinality(int cardinality, + OWLObjectPropertyExpression pe, OWLClassExpression ce) { + return DF.getOWLObjectMaxCardinality(cardinality, pe, ce); + } + + public static OWLObjectExactCardinality ObjectExactCardinality(int cardinality, + OWLObjectPropertyExpression pe, OWLClassExpression ce) { + return DF.getOWLObjectExactCardinality(cardinality, pe, ce); + } + + public static OWLObjectHasSelf ObjectHasSelf(OWLObjectPropertyExpression pe) { + return DF.getOWLObjectHasSelf(pe); + } + + public static OWLObjectOneOf ObjectOneOf(OWLIndividual... individuals) { + return DF.getOWLObjectOneOf(individuals); + } + + public static OWLDataSomeValuesFrom DataSomeValuesFrom(OWLDataPropertyExpression pe, + OWLDataRange dr) { + return DF.getOWLDataSomeValuesFrom(pe, dr); + } + + public static OWLDataAllValuesFrom DataAllValuesFrom(OWLDataPropertyExpression pe, + OWLDataRange dr) { + return DF.getOWLDataAllValuesFrom(pe, dr); + } + + public static OWLDataHasValue DataHasValue(OWLDataPropertyExpression pe, OWLLiteral literal) { + return DF.getOWLDataHasValue(pe, literal); + } + + public static OWLDataMinCardinality DataMinCardinality(int cardinality, + OWLDataPropertyExpression pe, OWLDataRange dr) { + return DF.getOWLDataMinCardinality(cardinality, pe, dr); + } + + public static OWLDataMaxCardinality DataMaxCardinality(int cardinality, + OWLDataPropertyExpression pe, OWLDataRange dr) { + return DF.getOWLDataMaxCardinality(cardinality, pe, dr); + } + + public static OWLDataExactCardinality DataExactCardinality(int cardinality, + OWLDataPropertyExpression pe, OWLDataRange dr) { + return DF.getOWLDataExactCardinality(cardinality, pe, dr); + } + + // Data Ranges other than datatype + public static OWLDataIntersectionOf DataIntersectionOf(OWLDataRange... dataRanges) { + return DF.getOWLDataIntersectionOf(dataRanges); + } + + public static OWLDataUnionOf DataUnionOf(OWLDataRange... dataRanges) { + return DF.getOWLDataUnionOf(dataRanges); + } + + public static OWLDataComplementOf DataComplementOf(OWLDataRange dataRange) { + return DF.getOWLDataComplementOf(dataRange); + } + + public static OWLDataOneOf DataOneOf(OWLLiteral... literals) { + return DF.getOWLDataOneOf(literals); + } + + public static OWLDatatypeRestriction DatatypeRestriction(OWLDatatype datatype, + OWLFacetRestriction... facetRestrictions) { + return DF.getOWLDatatypeRestriction(datatype, facetRestrictions); + } + + public static OWLFacetRestriction FacetRestriction(OWLFacet facet, OWLLiteral facetValue) { + return DF.getOWLFacetRestriction(facet, facetValue); + } + + // Axioms + public static OWLSubClassOfAxiom SubClassOf(OWLClassExpression subClass, + OWLClassExpression superClass) { + return DF.getOWLSubClassOfAxiom(subClass, superClass); + } + + public static OWLSubClassOfAxiom SubClassOf(OWLClassExpression subClass, + OWLClassExpression superClass, Collection a) { + return DF.getOWLSubClassOfAxiom(subClass, superClass, a); + } + + public static OWLEquivalentClassesAxiom EquivalentClasses( + OWLClassExpression... classExpressions) { + return DF.getOWLEquivalentClassesAxiom(classExpressions); + } + + public static OWLEquivalentClassesAxiom EquivalentClasses(Collection a, + OWLClassExpression... classExpressions) { + return DF.getOWLEquivalentClassesAxiom(Arrays.asList(classExpressions), a); + } + + public static OWLDisjointClassesAxiom DisjointClasses(OWLClassExpression... classExpressions) { + return DF.getOWLDisjointClassesAxiom(classExpressions); + } + + public static OWLDisjointClassesAxiom DisjointClasses( + Collection classExpressions) { + return DF.getOWLDisjointClassesAxiom(classExpressions); + } + + public static OWLDisjointClassesAxiom DisjointClasses( + Collection classExpressions, Collection a) { + return DF.getOWLDisjointClassesAxiom(classExpressions, a); + } + + public static OWLDisjointUnionAxiom DisjointUnion(OWLClass cls, + OWLClassExpression... classExpressions) { + return DF.getOWLDisjointUnionAxiom(cls, Arrays.asList(classExpressions)); + } + + public static OWLDisjointClassesAxiom DisjointClasses(Collection a, + OWLClassExpression... classExpressions) { + return DF.getOWLDisjointClassesAxiom(Arrays.asList(classExpressions), a); + } + + public static OWLSubObjectPropertyOfAxiom SubObjectPropertyOf( + OWLObjectPropertyExpression subProperty, OWLObjectPropertyExpression superProperty) { + return DF.getOWLSubObjectPropertyOfAxiom(subProperty, superProperty); + } + + public static OWLSubPropertyChainOfAxiom SubPropertyChainOf( + List chain, + OWLObjectPropertyExpression superProperty) { + return DF.getOWLSubPropertyChainOfAxiom(chain, superProperty); + } + + public static OWLSubPropertyChainOfAxiom SubPropertyChainOf( + List chain, + OWLObjectPropertyExpression superProperty, Collection a) { + return DF.getOWLSubPropertyChainOfAxiom(chain, superProperty, a); + } + + public static OWLSubObjectPropertyOfAxiom SubObjectPropertyOf( + OWLObjectPropertyExpression subProperty, OWLObjectPropertyExpression superProperty, + Collection a) { + return DF.getOWLSubObjectPropertyOfAxiom(subProperty, superProperty, a); + } + + public static OWLEquivalentObjectPropertiesAxiom EquivalentObjectProperties( + OWLObjectPropertyExpression... properties) { + return DF.getOWLEquivalentObjectPropertiesAxiom(properties); + } + + public static OWLEquivalentObjectPropertiesAxiom EquivalentObjectProperties( + Collection a, OWLObjectPropertyExpression... properties) { + return DF.getOWLEquivalentObjectPropertiesAxiom(Arrays.asList(properties), a); + } + + public static OWLDisjointObjectPropertiesAxiom DisjointObjectProperties( + OWLObjectPropertyExpression... properties) { + return DF.getOWLDisjointObjectPropertiesAxiom(properties); + } + + public static OWLDisjointObjectPropertiesAxiom DisjointObjectProperties( + Collection a, OWLObjectPropertyExpression... properties) { + return DF.getOWLDisjointObjectPropertiesAxiom(Arrays.asList(properties), a); + } + + public static OWLInverseObjectPropertiesAxiom InverseObjectProperties( + OWLObjectPropertyExpression peA, OWLObjectPropertyExpression peB) { + return DF.getOWLInverseObjectPropertiesAxiom(peA, peB); + } + + public static OWLObjectPropertyDomainAxiom ObjectPropertyDomain( + OWLObjectPropertyExpression property, OWLClassExpression domain) { + return DF.getOWLObjectPropertyDomainAxiom(property, domain); + } + + public static OWLObjectPropertyDomainAxiom ObjectPropertyDomain( + OWLObjectPropertyExpression property, OWLClassExpression domain, + Collection a) { + return DF.getOWLObjectPropertyDomainAxiom(property, domain, a); + } + + public static OWLObjectPropertyRangeAxiom ObjectPropertyRange( + OWLObjectPropertyExpression property, OWLClassExpression range) { + return DF.getOWLObjectPropertyRangeAxiom(property, range); + } + + public static OWLObjectPropertyRangeAxiom ObjectPropertyRange( + OWLObjectPropertyExpression property, OWLClassExpression range, + Collection a) { + return DF.getOWLObjectPropertyRangeAxiom(property, range, a); + } + + public static OWLFunctionalObjectPropertyAxiom FunctionalObjectProperty( + OWLObjectPropertyExpression property) { + return DF.getOWLFunctionalObjectPropertyAxiom(property); + } + + public static OWLFunctionalObjectPropertyAxiom FunctionalObjectProperty( + OWLObjectPropertyExpression property, Collection a) { + return DF.getOWLFunctionalObjectPropertyAxiom(property, a); + } + + public static OWLInverseFunctionalObjectPropertyAxiom InverseFunctionalObjectProperty( + OWLObjectPropertyExpression property) { + return DF.getOWLInverseFunctionalObjectPropertyAxiom(property); + } + + public static OWLInverseFunctionalObjectPropertyAxiom InverseFunctionalObjectProperty( + OWLObjectPropertyExpression property, Collection a) { + return DF.getOWLInverseFunctionalObjectPropertyAxiom(property, a); + } + + public static OWLReflexiveObjectPropertyAxiom ReflexiveObjectProperty( + OWLObjectPropertyExpression property) { + return DF.getOWLReflexiveObjectPropertyAxiom(property); + } + + public static OWLReflexiveObjectPropertyAxiom ReflexiveObjectProperty( + OWLObjectPropertyExpression property, Collection a) { + return DF.getOWLReflexiveObjectPropertyAxiom(property, a); + } + + public static OWLIrreflexiveObjectPropertyAxiom IrreflexiveObjectProperty( + OWLObjectPropertyExpression property) { + return DF.getOWLIrreflexiveObjectPropertyAxiom(property); + } + + public static OWLIrreflexiveObjectPropertyAxiom IrreflexiveObjectProperty( + OWLObjectPropertyExpression property, Collection a) { + return DF.getOWLIrreflexiveObjectPropertyAxiom(property, a); + } + + public static OWLSymmetricObjectPropertyAxiom SymmetricObjectProperty( + OWLObjectPropertyExpression property) { + return DF.getOWLSymmetricObjectPropertyAxiom(property); + } + + public static OWLSymmetricObjectPropertyAxiom SymmetricObjectProperty( + OWLObjectPropertyExpression property, Collection a) { + return DF.getOWLSymmetricObjectPropertyAxiom(property, a); + } + + public static OWLAsymmetricObjectPropertyAxiom AsymmetricObjectProperty( + OWLObjectPropertyExpression property) { + return DF.getOWLAsymmetricObjectPropertyAxiom(property); + } + + public static OWLAsymmetricObjectPropertyAxiom AsymmetricObjectProperty( + OWLObjectPropertyExpression property, Collection a) { + return DF.getOWLAsymmetricObjectPropertyAxiom(property, a); + } + + public static OWLTransitiveObjectPropertyAxiom TransitiveObjectProperty( + OWLObjectPropertyExpression property) { + return DF.getOWLTransitiveObjectPropertyAxiom(property); + } + + public static OWLTransitiveObjectPropertyAxiom TransitiveObjectProperty( + OWLObjectPropertyExpression property, Collection a) { + return DF.getOWLTransitiveObjectPropertyAxiom(property, a); + } + + public static OWLSubDataPropertyOfAxiom SubDataPropertyOf(OWLDataPropertyExpression subProperty, + OWLDataPropertyExpression superProperty) { + return DF.getOWLSubDataPropertyOfAxiom(subProperty, superProperty); + } + + public static OWLSubDataPropertyOfAxiom SubDataPropertyOf(OWLDataPropertyExpression subProperty, + OWLDataPropertyExpression superProperty, Collection a) { + return DF.getOWLSubDataPropertyOfAxiom(subProperty, superProperty, a); + } + + public static OWLEquivalentDataPropertiesAxiom EquivalentDataProperties( + OWLDataPropertyExpression... properties) { + return DF.getOWLEquivalentDataPropertiesAxiom(properties); + } + + public static OWLEquivalentDataPropertiesAxiom EquivalentDataProperties( + Collection a, OWLDataPropertyExpression... properties) { + return DF.getOWLEquivalentDataPropertiesAxiom(Arrays.asList(properties), a); + } + + public static OWLDisjointDataPropertiesAxiom DisjointDataProperties( + OWLDataPropertyExpression... properties) { + return DF.getOWLDisjointDataPropertiesAxiom(properties); + } + + public static OWLDisjointDataPropertiesAxiom DisjointDataProperties(Collection a, + OWLDataPropertyExpression... properties) { + return DF.getOWLDisjointDataPropertiesAxiom(Arrays.asList(properties), a); + } + + public static OWLDataPropertyDomainAxiom DataPropertyDomain(OWLDataPropertyExpression property, + OWLClassExpression domain) { + return DF.getOWLDataPropertyDomainAxiom(property, domain); + } + + public static OWLDataPropertyDomainAxiom DataPropertyDomain(OWLDataPropertyExpression property, + OWLClassExpression domain, Collection a) { + return DF.getOWLDataPropertyDomainAxiom(property, domain, a); + } + + public static OWLDataPropertyRangeAxiom DataPropertyRange(OWLDataPropertyExpression property, + OWLDataRange range) { + return DF.getOWLDataPropertyRangeAxiom(property, range); + } + + public static OWLDataPropertyRangeAxiom DataPropertyRange(OWLDataPropertyExpression property, + OWLDataRange range, Collection a) { + return DF.getOWLDataPropertyRangeAxiom(property, range, a); + } + + public static OWLFunctionalDataPropertyAxiom FunctionalDataProperty( + OWLDataPropertyExpression property) { + return DF.getOWLFunctionalDataPropertyAxiom(property); + } + + public static OWLFunctionalDataPropertyAxiom FunctionalDataProperty( + OWLDataPropertyExpression property, Collection a) { + return DF.getOWLFunctionalDataPropertyAxiom(property, a); + } + + public static OWLDatatypeDefinitionAxiom DatatypeDefinition(OWLDatatype datatype, + OWLDataRange dataRange) { + return DF.getOWLDatatypeDefinitionAxiom(datatype, dataRange); + } + + public static OWLHasKeyAxiom HasKey(OWLClassExpression classExpression, + OWLPropertyExpression... propertyExpressions) { + return DF.getOWLHasKeyAxiom(classExpression, propertyExpressions); + } + + public static OWLHasKeyAxiom HasKey(Collection a, + OWLClassExpression classExpression, OWLPropertyExpression... propertyExpressions) { + return DF.getOWLHasKeyAxiom(classExpression, Arrays.asList(propertyExpressions), a); + } + + public static OWLSameIndividualAxiom SameIndividual(OWLIndividual... individuals) { + return DF.getOWLSameIndividualAxiom(individuals); + } + + public static OWLDifferentIndividualsAxiom DifferentIndividuals(OWLIndividual... individuals) { + return DF.getOWLDifferentIndividualsAxiom(individuals); + } + + public static OWLDifferentIndividualsAxiom DifferentIndividuals( + Collection individuals, Collection a) { + return DF.getOWLDifferentIndividualsAxiom(individuals, a); + } + + public static OWLSameIndividualAxiom SameIndividual( + Collection individuals) { + return DF.getOWLSameIndividualAxiom(individuals); + } + + public static OWLDifferentIndividualsAxiom DifferentIndividuals( + Collection individuals) { + return DF.getOWLDifferentIndividualsAxiom(individuals); + } + + public static OWLClassAssertionAxiom ClassAssertion(OWLClassExpression ce, OWLIndividual ind, + Collection a) { + return DF.getOWLClassAssertionAxiom(ce, ind, a); + } + + public static OWLClassAssertionAxiom ClassAssertion(OWLClassExpression ce, OWLIndividual ind) { + return DF.getOWLClassAssertionAxiom(ce, ind); + } + + public static OWLObjectPropertyAssertionAxiom ObjectPropertyAssertion( + OWLObjectPropertyExpression property, OWLIndividual source, OWLIndividual target) { + return DF.getOWLObjectPropertyAssertionAxiom(property, source, target); + } + + public static OWLObjectPropertyAssertionAxiom ObjectPropertyAssertion( + OWLObjectPropertyExpression property, OWLIndividual source, OWLIndividual target, + Collection a) { + return DF.getOWLObjectPropertyAssertionAxiom(property, source, target, a); + } + + public static OWLNegativeObjectPropertyAssertionAxiom NegativeObjectPropertyAssertion( + OWLObjectPropertyExpression property, OWLIndividual source, OWLIndividual target) { + return DF.getOWLNegativeObjectPropertyAssertionAxiom(property, source, target); + } + + public static OWLNegativeObjectPropertyAssertionAxiom NegativeObjectPropertyAssertion( + OWLObjectPropertyExpression property, OWLIndividual source, OWLIndividual target, + Collection a) { + return DF.getOWLNegativeObjectPropertyAssertionAxiom(property, source, target, a); + } + + public static OWLDataPropertyAssertionAxiom DataPropertyAssertion( + OWLDataPropertyExpression property, OWLIndividual source, OWLLiteral target) { + return DF.getOWLDataPropertyAssertionAxiom(property, source, target); + } + + public static OWLDataPropertyAssertionAxiom DataPropertyAssertion( + OWLDataPropertyExpression property, OWLIndividual source, OWLLiteral target, + Collection a) { + return DF.getOWLDataPropertyAssertionAxiom(property, source, target, a); + } + + public static OWLNegativeDataPropertyAssertionAxiom NegativeDataPropertyAssertion( + OWLDataPropertyExpression property, OWLIndividual source, OWLLiteral target) { + return DF.getOWLNegativeDataPropertyAssertionAxiom(property, source, target); + } + + public static OWLNegativeDataPropertyAssertionAxiom NegativeDataPropertyAssertion( + OWLDataPropertyExpression property, OWLIndividual source, OWLLiteral target, + Collection a) { + return DF.getOWLNegativeDataPropertyAssertionAxiom(property, source, target, a); + } + + public static OWLAnnotationAssertionAxiom AnnotationAssertion(OWLAnnotationProperty property, + OWLAnnotationSubject subject, OWLAnnotationValue value) { + return DF.getOWLAnnotationAssertionAxiom(property, subject, value); + } + + public static OWLAnnotationAssertionAxiom AnnotationAssertion(OWLAnnotationProperty property, + OWLAnnotationSubject subject, OWLAnnotationValue value, Collection set) { + return DF.getOWLAnnotationAssertionAxiom(property, subject, value, set); + } + + public static OWLAnnotationAssertionAxiom AnnotationAssertion(OWLAnnotationProperty property, + OWLAnnotationSubject subject, OWLAnnotationValue value, OWLAnnotation... set) { + return DF.getOWLAnnotationAssertionAxiom(property, subject, value, + new HashSet<>(Arrays.asList(set))); + } + + public static OWLAnnotation Annotation(OWLAnnotationProperty property, + OWLAnnotationValue value) { + return DF.getOWLAnnotation(property, value); + } + + public static OWLAnnotation Annotation(OWLAnnotationProperty property, OWLAnnotationValue value, + Collection anns) { + if (anns.isEmpty()) { + return DF.getOWLAnnotation(property, value); + } + return DF.getOWLAnnotation(property, value, anns.stream()); + } + + public static OWLAnnotation Annotation(OWLAnnotationProperty property, OWLAnnotationValue value, + OWLAnnotation... anns) { + if (anns.length == 0) { + return DF.getOWLAnnotation(property, value); + } + return DF.getOWLAnnotation(property, value, Stream.of(anns)); + } + + public static OWLSubAnnotationPropertyOfAxiom SubAnnotationPropertyOf( + OWLAnnotationProperty subProperty, OWLAnnotationProperty superProperty) { + return DF.getOWLSubAnnotationPropertyOfAxiom(subProperty, superProperty); + } + + public static OWLAnnotationPropertyDomainAxiom AnnotationPropertyDomain( + OWLAnnotationProperty property, IRI iri) { + return DF.getOWLAnnotationPropertyDomainAxiom(property, iri); + } + + public static OWLAnnotationPropertyRangeAxiom AnnotationPropertyRange( + OWLAnnotationProperty property, IRI iri) { + return DF.getOWLAnnotationPropertyRangeAxiom(property, iri); + } + + public static OWLAnnotationPropertyDomainAxiom AnnotationPropertyDomain( + OWLAnnotationProperty property, String iri) { + return DF.getOWLAnnotationPropertyDomainAxiom(property, IRI(iri)); + } + + public static OWLAnnotationPropertyRangeAxiom AnnotationPropertyRange( + OWLAnnotationProperty property, String iri) { + return DF.getOWLAnnotationPropertyRangeAxiom(property, IRI(iri)); + } + + public static IRI IRI(String iri) { + return IRI.create(iri); + } + + public static IRI IRI(String ns, String fragment) { + return IRI.create(ns, fragment); + } + + public static OWLLiteral PlainLiteral(String literal) { + return DF.getOWLLiteral(literal, ""); + } + + public static OWLDatatype PlainLiteral() { + return DF.getRDFPlainLiteral(); + } + + public static OWLLiteral Literal(String literal, @Nullable String lang) { + return DF.getOWLLiteral(literal, lang); + } + + public static OWLLiteral Literal(String literal, OWLDatatype type) { + return DF.getOWLLiteral(literal, type); + } + + public static OWLLiteral Literal(String literal, OWL2Datatype type) { + return DF.getOWLLiteral(literal, type); + } + + public static OWLLiteral Literal(String literal) { + return DF.getOWLLiteral(literal); + } + + public static OWLLiteral Literal(boolean literal) { + return DF.getOWLLiteral(literal); + } + + public static OWLLiteral Literal(int literal) { + return DF.getOWLLiteral(literal); + } + + public static OWLLiteral Literal(double literal) { + return DF.getOWLLiteral(literal); + } + + public static OWLLiteral Literal(float literal) { + return DF.getOWLLiteral(literal); + } + + public static OWLOntology Ontology(OWLOntologyManager man, OWLAxiom... axioms) { + try { + return man.createOntology(Arrays.asList(axioms)); + } catch (OWLOntologyCreationException e) { + throw new OWLRuntimeException(e); + } + } +} diff --git a/apibinding/src/main/java/org/semanticweb/owlapi/apibinding/OWLManager.java b/apibinding/src/main/java/org/semanticweb/owlapi/apibinding/OWLManager.java new file mode 100644 index 0000000000..4d3d640202 --- /dev/null +++ b/apibinding/src/main/java/org/semanticweb/owlapi/apibinding/OWLManager.java @@ -0,0 +1,166 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.apibinding; + +import java.lang.annotation.Annotation; +import java.util.Arrays; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.function.Supplier; + +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLOntologyBuilder; +import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLOntologyManagerFactory; +import org.semanticweb.owlapi.model.OntologyConfigurator; +import org.semanticweb.owlapi.util.mansyntax.ManchesterOWLSyntaxParser; +import org.semanticweb.owlapi.utilities.Injector; + +import uk.ac.manchester.cs.owl.owlapi.CompressionEnabled; +import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl; +import uk.ac.manchester.cs.owl.owlapi.concurrent.ConcurrentOWLOntologyBuilder; +import uk.ac.manchester.cs.owl.owlapi.concurrent.NoOpReadWriteLock; +import uk.ac.manchester.cs.owl.owlapi.concurrent.NonConcurrentDelegate; +import uk.ac.manchester.cs.owl.owlapi.concurrent.NonConcurrentOWLOntologyBuilder; + +/** + * Provides a point of convenience for creating an {@code OWLOntologyManager} with commonly required + * features (such as an RDF parser for example). + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +public class OWLManager implements OWLOntologyManagerFactory { + enum InjectorConstants { + @CompressionEnabled + COMPRESSION_ENABLED(Boolean.class, () -> Boolean.FALSE), + // + CONCURRENTBUILDER(OWLOntologyBuilder.class, ConcurrentOWLOntologyBuilder.class), + // + @NonConcurrentDelegate + NONCONCURRENTBUILDER(OWLOntologyBuilder.class, NonConcurrentOWLOntologyBuilder.class), + // + CONFIG(OntologyConfigurator.class, OntologyConfigurator::new), + // XXX ontology manager and ontology builder have independent locks in their constructors, + // but they should actually share the one lock. Ontologies moving managers should rely on + // the manager for locks. Now they rely on the fact that the locks are injector level + // singletons. + REENTRANT(ReadWriteLock.class, () -> new ReentrantReadWriteLock()), + // + NOOP(ReadWriteLock.class, new NoOpReadWriteLock()); + + private Class c; + private Supplier s; + private Class type; + private Object instance; + + InjectorConstants(Class c, Supplier s) { + this.c = c; + this.s = s; + } + + InjectorConstants(Class c, Object s) { + this.c = c; + instance = s; + } + + InjectorConstants(Class c, Class t) { + this.c = c; + type = t; + } + + Annotation[] anns() { + try { + return InjectorConstants.class.getField(name()).getAnnotations(); + } catch (NoSuchFieldException | SecurityException e) { + throw new RuntimeException(e); + } + } + + Injector init(Injector i) { + if (instance != null) { + i.bindToOne(instance, c, anns()); + } else if (s != null) { + i.bindToOne(s, c, anns()); + } else { + i.bind(type, c, anns()); + } + return i; + } + } + + private static final Injector concurrentInjector = + InjectorConstants.REENTRANT.init(configure(new Injector())); + private static final Injector normalInjector = + InjectorConstants.NOOP.init(configure(new Injector())); + + private static Injector configure(Injector i) { + Arrays.stream(InjectorConstants.values()).forEach(f -> f.init(i)); + return i; + } + + /** + * Creates an OWL ontology manager that is configured with standard parsers, storers etc. + * + * @return The new manager. + */ + public static OWLOntologyManager createOWLOntologyManager() { + return normalInjector.inject(normalInjector.getImplementation(OWLOntologyManager.class)); + } + + /** + * Creates an OWL ontology manager that is configured with the standard parsers and storers and + * provides locking for concurrent access. + * + * @return The new manager. + */ + public static OWLOntologyManager createConcurrentOWLOntologyManager() { + return concurrentInjector + .inject(concurrentInjector.getImplementation(OWLOntologyManager.class)); + } + + /** + * Gets a global data factory that can be used to create OWL API objects. + * + * @param config configuration object allowing a data factory behaviour to be tweaked. Currently + * this only affects the creation of OWL constructs where collections are not allowed to + * have duplicates. + * + * @return An OWLDataFactory that can be used for creating OWL API objects. + */ + public static OWLDataFactory getOWLDataFactory(OWLOntologyLoaderConfiguration config) { + return new OWLDataFactoryImpl(config); + } + + /** + * Gets a global data factory that can be used to create OWL API objects. + * + * @return An OWLDataFactory that can be used for creating OWL API objects. + */ + public static OWLDataFactory getOWLDataFactory() { + return getOWLDataFactory(new OWLOntologyLoaderConfiguration()); + } + + /** + * @return an initialized manchester syntax parser for parsing strings + */ + public static ManchesterOWLSyntaxParser createManchesterParser() { + return normalInjector.getImplementation(ManchesterOWLSyntaxParser.class); + } + + @Override + public OWLOntologyManager get() { + return createOWLOntologyManager(); + } +} diff --git a/apibinding/src/main/java/org/semanticweb/owlapi/apibinding/package-info.java b/apibinding/src/main/java/org/semanticweb/owlapi/apibinding/package-info.java new file mode 100644 index 0000000000..58351a3cd8 --- /dev/null +++ b/apibinding/src/main/java/org/semanticweb/owlapi/apibinding/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Binding package. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.apibinding; diff --git a/apibinding/src/main/java/org/semanticweb/owlapi/apibinding/packageinfo b/apibinding/src/main/java/org/semanticweb/owlapi/apibinding/packageinfo new file mode 100644 index 0000000000..7c7a9efd9c --- /dev/null +++ b/apibinding/src/main/java/org/semanticweb/owlapi/apibinding/packageinfo @@ -0,0 +1 @@ +version 5.1.0 diff --git a/apibinding/src/main/resources/META-INF/services/org.semanticweb.owlapi.model.OWLOntologyManagerFactory b/apibinding/src/main/resources/META-INF/services/org.semanticweb.owlapi.model.OWLOntologyManagerFactory new file mode 100644 index 0000000000..ea9e179678 --- /dev/null +++ b/apibinding/src/main/resources/META-INF/services/org.semanticweb.owlapi.model.OWLOntologyManagerFactory @@ -0,0 +1 @@ +org.semanticweb.owlapi.apibinding.OWLManager \ No newline at end of file diff --git a/benchmarks/pom.xml b/benchmarks/pom.xml new file mode 100644 index 0000000000..cc4e8abac5 --- /dev/null +++ b/benchmarks/pom.xml @@ -0,0 +1,114 @@ + + + + 4.0.0 + + net.sourceforge.owlapi + owlapi-parent + 5.0.5 + + owlapi-benchmarks + + Auto-generated JMH benchmark + + + 3.0 + + + + + ${project.groupId} + owlapi-distribution + ${project.version} + + + net.sourceforge.owlapi + owlapi-ncbitaxon + 4.0.1 + + + org.openjdk.jmh + jmh-core + ${jmh.version} + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh.version} + provided + + + + + 1.3.1 + benchmarks + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.0 + + + package_only + package + + + + + org.apache.maven.plugins + maven-shade-plugin + 2.4.3 + + + package + + shade + + + ${uberjar.name} + + + org.openjdk.jmh.Main + + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + + + + + diff --git a/benchmarks/src/main/java/org/semanticweb/owlapi/benchmarks/FullGalenMemoryBenchmark.java b/benchmarks/src/main/java/org/semanticweb/owlapi/benchmarks/FullGalenMemoryBenchmark.java new file mode 100644 index 0000000000..76b7054ec7 --- /dev/null +++ b/benchmarks/src/main/java/org/semanticweb/owlapi/benchmarks/FullGalenMemoryBenchmark.java @@ -0,0 +1,13 @@ +package org.semanticweb.owlapi.benchmarks; + +import java.nio.file.FileSystems; + +@SuppressWarnings("javadoc") +public class FullGalenMemoryBenchmark { + + public static void main(String[] args) throws Exception { + MemoryBenchmark.memoryProfile(FileSystems.getDefault().getPath( + "/Users/ignazio/full-galen.owl"), FileSystems.getDefault().getPath( + "fullgalen.hprof")); + } +} diff --git a/benchmarks/src/main/java/org/semanticweb/owlapi/benchmarks/GazetteerMemoryBenchmark.java b/benchmarks/src/main/java/org/semanticweb/owlapi/benchmarks/GazetteerMemoryBenchmark.java new file mode 100644 index 0000000000..2613cccc3c --- /dev/null +++ b/benchmarks/src/main/java/org/semanticweb/owlapi/benchmarks/GazetteerMemoryBenchmark.java @@ -0,0 +1,23 @@ +package org.semanticweb.owlapi.benchmarks; + +import java.io.IOException; +import java.nio.file.FileSystems; +import java.nio.file.Path; +import java.util.Date; +import org.obolibrary.oboformat.parser.OBOFormatParser; + +@SuppressWarnings("javadoc") +public class GazetteerMemoryBenchmark { + + public static void main(String[] args) throws Exception { + memoryProfile(FileSystems.getDefault().getPath("/Users/ignazio/gaz-fixed.obo"), + FileSystems.getDefault() + .getPath("gazetteer" + new Date() + ".hprof")); + } + + public static void memoryProfile(Path ontologyPath, Path hprofPath) throws IOException { + OBOFormatParser parser = new OBOFormatParser(); + parser.parse(ontologyPath.toFile()); + MemoryBenchmark.getDiagnostics().dumpHeap(hprofPath.toString(), true); + } +} diff --git a/benchmarks/src/main/java/org/semanticweb/owlapi/benchmarks/MemoryBenchmark.java b/benchmarks/src/main/java/org/semanticweb/owlapi/benchmarks/MemoryBenchmark.java new file mode 100644 index 0000000000..621c5658c7 --- /dev/null +++ b/benchmarks/src/main/java/org/semanticweb/owlapi/benchmarks/MemoryBenchmark.java @@ -0,0 +1,113 @@ +package org.semanticweb.owlapi.benchmarks; + +import static java.lang.management.ManagementFactory.*; + +import com.sun.management.HotSpotDiagnosticMXBean; +import com.sun.management.VMOption; +import java.io.File; +import java.io.IOException; +import java.lang.management.RuntimeMXBean; +import java.nio.file.FileSystems; +import java.nio.file.Path; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.io.FileDocumentSource; +import org.semanticweb.owlapi.io.GZipFileDocumentSource; +import org.semanticweb.owlapi.io.OWLOntologyDocumentSource; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.util.AutoIRIMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Created by ses on 3/19/14. + */ +public class MemoryBenchmark { + + private static Logger logger = LoggerFactory.getLogger(MemoryBenchmark.class); + + @SuppressWarnings("javadoc") + public static void main(String[] args) throws Exception { + if (args.length > 2) { + System.err.println("usage: " + MemoryBenchmark.class.getCanonicalName() + + " "); + } + String filename = "/Users/ses/ontologies/GO/go.ofn"; + if (args.length > 0) { + filename = args[0]; + } + Path ontologyPath = FileSystems.getDefault().getPath(filename); + Path hprofPath = getHprofPath(args, ontologyPath); + memoryProfile(ontologyPath, hprofPath); + System.exit(0); + } + + /** + * Run memory profiling for an input ontology and output the dump file to + * the hprof path provided + * + * @param ontologyPath input ontology + * @param hprofPath dump file path for output + * @throws OWLOntologyCreationException if the ontology cannot be created or loaded + * @throws IOException if the dump file cannot be created + */ + public static void memoryProfile(Path ontologyPath, Path hprofPath) + throws OWLOntologyCreationException, + IOException { + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + File file = ontologyPath.toFile(); + manager.getIRIMappers().add(new AutoIRIMapper(file.getParentFile(), false)); + OWLOntologyDocumentSource ds = null; + if (file.getName().endsWith(".gz")) { + ds = new GZipFileDocumentSource(file); + } else { + ds = new FileDocumentSource(file); + } + OWLOntologyLoaderConfiguration config = new OWLOntologyLoaderConfiguration() + .setStrict(false); + long start = System.currentTimeMillis(); + OWLOntology ontology = manager.loadOntologyFromOntologyDocument(ds, config); + System.out.println( + "MemoryBenchmark.memoryProfile() elapsed: " + (System.currentTimeMillis() - start)); + getDiagnostics().dumpHeap(hprofPath.toString(), true); + manager.removeOntology(ontology); + } + + protected static HotSpotDiagnosticMXBean getDiagnostics() throws IOException { + HotSpotDiagnosticMXBean hotSpotDiagnosticMXBean = newPlatformMXBeanProxy( + getPlatformMBeanServer(), + "com.sun.management:type=HotSpotDiagnostic", HotSpotDiagnosticMXBean.class); + for (VMOption vmOption : hotSpotDiagnosticMXBean.getDiagnosticOptions()) { + logger.info("vmOption = {}", vmOption); + } + return hotSpotDiagnosticMXBean; + } + + protected static Path getHprofPath(String[] args, Path ontologyPath) { + Path hprofPath = null; + if (args.length > 1) { + hprofPath = FileSystems.getDefault().getPath(args[1]); + } else { + try { + String name = newPlatformMXBeanProxy(getPlatformMBeanServer(), RUNTIME_MXBEAN_NAME, + RuntimeMXBean.class) + .getName(); + String profileFileName = "ontology-hprof-" + name + ".hprof"; + hprofPath = ontologyPath.resolveSibling(profileFileName); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + System.out.println("hprofPath = " + hprofPath); + try { + if (hprofPath.toFile().exists()) { + hprofPath.toFile().delete(); + } + } catch (Exception e) { + logger.debug(e.getMessage(), e); + } + return hprofPath; + } +} diff --git a/benchmarks/src/main/java/org/semanticweb/owlapi/benchmarks/MyBenchmark.java b/benchmarks/src/main/java/org/semanticweb/owlapi/benchmarks/MyBenchmark.java new file mode 100644 index 0000000000..347a49fd18 --- /dev/null +++ b/benchmarks/src/main/java/org/semanticweb/owlapi/benchmarks/MyBenchmark.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.semanticweb.owlapi.benchmarks; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.zip.GZIPInputStream; +import org.openjdk.jmh.annotations.*; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.io.FileDocumentSource; +import org.semanticweb.owlapi.io.OWLOntologyDocumentSource; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import uk.ac.manchester.cs.owl.owlapi.OWLOntologyImpl; + +@SuppressWarnings("javadoc") +@State(Scope.Thread) +public class MyBenchmark { + + private File uncompressedTaxonFile; + + @Setup(Level.Trial) + public void setUp() throws IOException { + uncompressedTaxonFile = File.createTempFile("taxons", "ofn"); + InputStream resourceAsStream = getClass().getResourceAsStream( + "/ncbitaxon.rdf.ofn.gz"); + try (GZIPInputStream in = new GZIPInputStream(resourceAsStream); + FileOutputStream out = new FileOutputStream(uncompressedTaxonFile)) { + int n; + byte[] buf = new byte[8192]; + while ((n = in.read(buf)) >= 0) { + out.write(buf, 0, n); + } + out.flush(); + } + } + + @TearDown(Level.Trial) + public void tearDown() { + uncompressedTaxonFile.delete(); + } + + @BenchmarkMode(Mode.AverageTime) + @Benchmark + public void testLoadTaxonFSS() throws OWLOntologyCreationException { + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + OWLOntologyDocumentSource ds = new FileDocumentSource( + uncompressedTaxonFile); + OWLOntologyLoaderConfiguration config = new OWLOntologyLoaderConfiguration() + .setStrict(false); + OWLOntologyImpl ontology = (OWLOntologyImpl) manager + .loadOntologyFromOntologyDocument(ds, config); + manager.removeOntology(ontology); + } +} diff --git a/benchmarks/src/main/java/org/semanticweb/owlapi/benchmarks/NCBITaxonMemoryBenchmark.java b/benchmarks/src/main/java/org/semanticweb/owlapi/benchmarks/NCBITaxonMemoryBenchmark.java new file mode 100644 index 0000000000..791ecec5d8 --- /dev/null +++ b/benchmarks/src/main/java/org/semanticweb/owlapi/benchmarks/NCBITaxonMemoryBenchmark.java @@ -0,0 +1,17 @@ +package org.semanticweb.owlapi.benchmarks; + +import java.nio.file.FileSystems; + +/** + * Convenience for NCBI memory benchmark + */ +@SuppressWarnings("javadoc") +public class NCBITaxonMemoryBenchmark { + + public static void main(String[] args) throws Exception { + MemoryBenchmark.memoryProfile( + FileSystems.getDefault().getPath( + "/Users/ignazio/workspace/benchmarks/ncbitaxon/src/main/resources/ncbitaxon.rdf.ofn.gz"), + FileSystems.getDefault().getPath("ncbitaxon.hprof")); + } +} diff --git a/benchmarks/src/main/java/org/semanticweb/owlapi/benchmarks/packageinfo b/benchmarks/src/main/java/org/semanticweb/owlapi/benchmarks/packageinfo new file mode 100644 index 0000000000..ca54300068 --- /dev/null +++ b/benchmarks/src/main/java/org/semanticweb/owlapi/benchmarks/packageinfo @@ -0,0 +1 @@ +version 5 diff --git a/compatibility/pom.xml b/compatibility/pom.xml new file mode 100644 index 0000000000..fbcff4a02b --- /dev/null +++ b/compatibility/pom.xml @@ -0,0 +1,28 @@ + + 4.0.0 + owlapi-compatibility + OWLAPI :: Compatibility + + net.sourceforge.owlapi + owlapi-parent + 5.1.18 + + + + ${project.groupId} + owlapi-apibinding + ${project.version} + + + + diff --git a/compatibility/src/main/java/de/uulm/ecs/ai/owlapi/krssparser/KRSS2OntologyFormat.java b/compatibility/src/main/java/de/uulm/ecs/ai/owlapi/krssparser/KRSS2OntologyFormat.java new file mode 100644 index 0000000000..d767305cf1 --- /dev/null +++ b/compatibility/src/main/java/de/uulm/ecs/ai/owlapi/krssparser/KRSS2OntologyFormat.java @@ -0,0 +1,43 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package de.uulm.ecs.ai.owlapi.krssparser; + +import org.semanticweb.owlapi.model.OWLOntologyFormat; + +/** + * @author Olaf Noppens, Ulm University, Institute of Artificial Intelligence + * @deprecated use {@link org.semanticweb.owlapi.formats.KRSS2DocumentFormat} + */ +@Deprecated +public class KRSS2OntologyFormat extends org.semanticweb.owlapi.formats.KRSS2DocumentFormat + implements OWLOntologyFormat { + + /** + * ignore ontology iri parameter + */ + public static final String IGNORE_ONTOLOGYURI = "ignoreOntologyURI"; + + /** + * @return true if ontology iri is ignored + */ + public boolean isIgnoreOntologyURI() { + return getParameter(IGNORE_ONTOLOGYURI, Boolean.FALSE).booleanValue(); + } + + /** + * @param ignore ignore ontology iri + */ + public void setIgnoreOntologyURI(boolean ignore) { + setParameter(IGNORE_ONTOLOGYURI, Boolean.valueOf(ignore)); + } +} diff --git a/compatibility/src/main/java/de/uulm/ecs/ai/owlapi/krssparser/packageinfo b/compatibility/src/main/java/de/uulm/ecs/ai/owlapi/krssparser/packageinfo new file mode 100644 index 0000000000..8ce0371286 --- /dev/null +++ b/compatibility/src/main/java/de/uulm/ecs/ai/owlapi/krssparser/packageinfo @@ -0,0 +1 @@ +version 5.0.0 diff --git a/compatibility/src/main/java/org/coode/owl/krssparser/KRSSOntologyFormat.java b/compatibility/src/main/java/org/coode/owl/krssparser/KRSSOntologyFormat.java new file mode 100644 index 0000000000..6d6f5f76c1 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owl/krssparser/KRSSOntologyFormat.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.coode.owl.krssparser; + +import org.semanticweb.owlapi.model.OWLOntologyFormat; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group, Date: + * 02-Jan-2007 + * @deprecated use {@link org.semanticweb.owlapi.formats.KRSSDocumentFormat} + */ +@Deprecated +public class KRSSOntologyFormat extends + org.semanticweb.owlapi.formats.KRSSDocumentFormat implements + OWLOntologyFormat { + +} diff --git a/compatibility/src/main/java/org/coode/owl/krssparser/packageinfo b/compatibility/src/main/java/org/coode/owl/krssparser/packageinfo new file mode 100644 index 0000000000..8ce0371286 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owl/krssparser/packageinfo @@ -0,0 +1 @@ +version 5.0.0 diff --git a/compatibility/src/main/java/org/coode/owlapi/latex/LatexAxiomsListOntologyFormat.java b/compatibility/src/main/java/org/coode/owlapi/latex/LatexAxiomsListOntologyFormat.java new file mode 100644 index 0000000000..dac33af770 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/latex/LatexAxiomsListOntologyFormat.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.coode.owlapi.latex; + +import org.semanticweb.owlapi.model.OWLOntologyFormat; + +/** + * @author Matthew Horridge, The University Of Manchester, Information Management Group, Date: + * 03-Aug-2008 + * @deprecated use {@link org.semanticweb.owlapi.formats.LatexAxiomsListDocumentFormat} + */ +@Deprecated +public class LatexAxiomsListOntologyFormat extends + org.semanticweb.owlapi.formats.LatexAxiomsListDocumentFormat implements + OWLOntologyFormat { + +} diff --git a/compatibility/src/main/java/org/coode/owlapi/latex/LatexOntologyFormat.java b/compatibility/src/main/java/org/coode/owlapi/latex/LatexOntologyFormat.java new file mode 100644 index 0000000000..0539945668 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/latex/LatexOntologyFormat.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.coode.owlapi.latex; + +import org.semanticweb.owlapi.model.OWLOntologyFormat; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group, Date: + * 26-Jan-2008 + * @deprecated use {@link org.semanticweb.owlapi.formats.LatexDocumentFormat} + */ +@Deprecated +public class LatexOntologyFormat extends + org.semanticweb.owlapi.formats.LatexDocumentFormat implements + OWLOntologyFormat { + +} diff --git a/compatibility/src/main/java/org/coode/owlapi/latex/package-info.java b/compatibility/src/main/java/org/coode/owlapi/latex/package-info.java new file mode 100644 index 0000000000..6d7d5844c9 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/latex/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Latex compatibility package. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.coode.owlapi.latex; diff --git a/compatibility/src/main/java/org/coode/owlapi/latex/packageinfo b/compatibility/src/main/java/org/coode/owlapi/latex/packageinfo new file mode 100644 index 0000000000..8ce0371286 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/latex/packageinfo @@ -0,0 +1 @@ +version 5.0.0 diff --git a/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntax.java b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntax.java new file mode 100644 index 0000000000..6686e076db --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntax.java @@ -0,0 +1,207 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.coode.owlapi.manchesterowlsyntax; + +import javax.annotation.Nullable; + +/** + * The vocabulary that the Manchester OWL Syntax uses. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group, Date: + * 25-Apr-2007 + * @deprecated use {@link org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax} + */ +@Deprecated +public enum ManchesterOWLSyntax { + //@formatter:off + /** VALUE_PARTITION */ VALUE_PARTITION (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.VALUE_PARTITION ), + /** DASH */ DASH (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.DASH ), + /** OPEN */ OPEN (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.OPEN ), + /** CLOSE */ CLOSE (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.CLOSE ), + /** OPENBRACE */ OPENBRACE (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.OPENBRACE ), + /** CLOSEBRACE */ CLOSEBRACE (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.CLOSEBRACE ), + /** OPENBRACKET */ OPENBRACKET (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.OPENBRACKET ), + /** CLOSEBRACKET */ CLOSEBRACKET (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.CLOSEBRACKET ), + /** ONTOLOGY */ ONTOLOGY (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.ONTOLOGY ), + /** IMPORT */ IMPORT (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.IMPORT ), + /** PREFIX */ PREFIX (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.PREFIX ), + /** CLASS */ CLASS (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.CLASS ), + /** OBJECT_PROPERTY */ OBJECT_PROPERTY (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.OBJECT_PROPERTY ), + /** CHAIN_IMPLY */ CHAIN_IMPLY (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.CHAIN_IMPLY ), + /** CHAIN_CONNECT */ CHAIN_CONNECT (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.CHAIN_CONNECT ), + /** DATA_PROPERTY */ DATA_PROPERTY (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.DATA_PROPERTY ), + /** INDIVIDUAL */ INDIVIDUAL (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.INDIVIDUAL ), + /** DATATYPE */ DATATYPE (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.DATATYPE ), + /** ANNOTATION_PROPERTY */ ANNOTATION_PROPERTY (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.ANNOTATION_PROPERTY ), + /** SOME */ SOME (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.SOME ), + /** ONLY */ ONLY (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.ONLY ), + /** ONLYSOME */ ONLYSOME (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.ONLYSOME ), + /** MIN */ MIN (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.MIN ), + /** MAX */ MAX (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.MAX ), + /** EXACTLY */ EXACTLY (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.EXACTLY ), + /** VALUE */ VALUE (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.VALUE ), + /** AND */ AND (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.AND ), + /** OR */ OR (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.OR ), + /** NOT */ NOT (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.NOT ), + /** INVERSE */ INVERSE (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.INVERSE ), + /** INV */ INV (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.INV ), + /** SELF */ SELF (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.SELF ), + /** THAT */ THAT (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.THAT ), + /** FACET_RESTRICTION_SEPARATOR */ FACET_RESTRICTION_SEPARATOR (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.FACET_RESTRICTION_SEPARATOR ), + /** SUBCLASS_OF */ SUBCLASS_OF (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.SUBCLASS_OF ), + /** SUPERCLASS_OF */ SUPERCLASS_OF (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.SUPERCLASS_OF ), + /** EQUIVALENT_TO */ EQUIVALENT_TO (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.EQUIVALENT_TO ), + /** EQUIVALENT_CLASSES */ EQUIVALENT_CLASSES (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.EQUIVALENT_CLASSES ), + /** EQUIVALENT_PROPERTIES */ EQUIVALENT_PROPERTIES (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.EQUIVALENT_PROPERTIES), + /** DISJOINT_WITH */ DISJOINT_WITH (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.DISJOINT_WITH ), + /** INDIVIDUALS */ INDIVIDUALS (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.INDIVIDUALS ), + /** DISJOINT_CLASSES */ DISJOINT_CLASSES (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.DISJOINT_CLASSES ), + /** DISJOINT_PROPERTIES */ DISJOINT_PROPERTIES (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.DISJOINT_PROPERTIES ), + /** DISJOINT_UNION_OF */ DISJOINT_UNION_OF (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.DISJOINT_UNION_OF ), + /** FACTS */ FACTS (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.FACTS ), + /** SAME_AS */ SAME_AS (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.SAME_AS ), + /** SAME_INDIVIDUAL */ SAME_INDIVIDUAL (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.SAME_INDIVIDUAL ), + /** DIFFERENT_FROM */ DIFFERENT_FROM (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.DIFFERENT_FROM ), + /** DIFFERENT_INDIVIDUALS */ DIFFERENT_INDIVIDUALS (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.DIFFERENT_INDIVIDUALS), + /** MIN_INCLUSIVE_FACET */ MIN_INCLUSIVE_FACET (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.MIN_INCLUSIVE_FACET ), + /** MAX_INCLUSIVE_FACET */ MAX_INCLUSIVE_FACET (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.MAX_INCLUSIVE_FACET ), + /** MIN_EXCLUSIVE_FACET */ MIN_EXCLUSIVE_FACET (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.MIN_EXCLUSIVE_FACET ), + /** MAX_EXCLUSIVE_FACET */ MAX_EXCLUSIVE_FACET (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.MAX_EXCLUSIVE_FACET ), + /** ONE_OF_DELIMETER */ ONE_OF_DELIMETER (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.ONE_OF_DELIMETER ), + /** TYPES */ TYPES (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.TYPES ), + /** TYPE */ TYPE (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.TYPE ), + /** ANNOTATIONS */ ANNOTATIONS (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.ANNOTATIONS ), + /** COMMA */ COMMA (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.COMMA ), + /** DOMAIN */ DOMAIN (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.DOMAIN ), + /** RANGE */ RANGE (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.RANGE ), + /** CHARACTERISTICS */ CHARACTERISTICS (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.CHARACTERISTICS ), + /** FUNCTIONAL */ FUNCTIONAL (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.FUNCTIONAL ), + /** INVERSE_FUNCTIONAL */ INVERSE_FUNCTIONAL (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.INVERSE_FUNCTIONAL ), + /** SYMMETRIC */ SYMMETRIC (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.SYMMETRIC ), + /** TRANSITIVE */ TRANSITIVE (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.TRANSITIVE ), + /** REFLEXIVE */ REFLEXIVE (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.REFLEXIVE ), + /** IRREFLEXIVE */ IRREFLEXIVE (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.IRREFLEXIVE ), + /** LITERAL_TRUE */ LITERAL_TRUE (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.LITERAL_TRUE ), + /** LITERAL_FALSE */ LITERAL_FALSE (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.LITERAL_FALSE ), + /** LITERAL_INTEGER */ LITERAL_INTEGER (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.LITERAL_INTEGER ), + /** LITERAL_FLOAT */ LITERAL_FLOAT (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.LITERAL_FLOAT ), + /** LITERAL_DOUBLE */ LITERAL_DOUBLE (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.LITERAL_DOUBLE ), + /** LITERAL_LITERAL */ LITERAL_LITERAL (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.LITERAL_LITERAL ), + /** LITERAL_LIT_DATATYPE */ LITERAL_LIT_DATATYPE (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.LITERAL_LIT_DATATYPE ), + /** LITERAL_LIT_LANG */ LITERAL_LIT_LANG (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.LITERAL_LIT_LANG ), + /** For legacy reasons. */ + /**ANTI_SYMMETRIC */ ANTI_SYMMETRIC (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.ANTI_SYMMETRIC ), + /**ASYMMETRIC */ ASYMMETRIC (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.ASYMMETRIC ), + /**INVERSE_OF */ INVERSE_OF (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.INVERSE_OF ), + /**INVERSES */ INVERSES (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.INVERSES ), + /**SUB_PROPERTY_OF */ SUB_PROPERTY_OF (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.SUB_PROPERTY_OF ), + /**SUPER_PROPERTY_OF */ SUPER_PROPERTY_OF (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.SUPER_PROPERTY_OF ), + /**SUB_PROPERTY_CHAIN */ SUB_PROPERTY_CHAIN (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.SUB_PROPERTY_CHAIN ), + /**HAS_KEY */ HAS_KEY (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.HAS_KEY ), + /**RULE */ RULE (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax.RULE ); + + //@formatter:on + org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax legacy; + + private ManchesterOWLSyntax( + org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax legacy) { + this.legacy = legacy; + } + + /** + * @param rendering rendering + * @return manchester owl syntax object + */ + public static @Nullable ManchesterOWLSyntax parse(String rendering) { + for (ManchesterOWLSyntax m : values()) { + if (m.matches(rendering)) { + return m; + } + } + return null; + } + + /** + * @return frame keyword + */ + public boolean isFrameKeyword() { + return legacy.isFrameKeyword(); + } + + /** + * @return section keyword + */ + public boolean isSectionKeyword() { + return legacy.isSectionKeyword(); + } + + /** + * @return axiom keyword + */ + public boolean isAxiomKeyword() { + return legacy.isAxiomKeyword(); + } + + /** + * @return true if it is a class connective + */ + public boolean isClassExpressionConnectiveKeyword() { + return legacy.isClassExpressionConnectiveKeyword(); + } + + /** + * @return class quantifier + */ + public boolean isClassExpressionQuantiferKeyword() { + return legacy.isClassExpressionQuantiferKeyword(); + } + + @Override + public String toString() { + return legacy.toString(); + } + + /** + * @return keyword + */ + public String keyword() { + return legacy.keyword(); + } + + /** + * @param s s + * @return true if matches keyword + */ + public boolean matches(String s) { + return legacy.matches(s); + } + + /** + * @param s s + * @return true if either form matches + */ + public boolean matchesEitherForm(String s) { + return legacy.matchesEitherForm(s); + } + + /** + * for keywords which match two tokens. + * + * @param s s + * @param v v + * @return true if matches + */ + public boolean matches(String s, String v) { + return legacy.matches(s, v); + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxClassExpressionParser.java b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxClassExpressionParser.java new file mode 100644 index 0000000000..1433aa5293 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxClassExpressionParser.java @@ -0,0 +1,39 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.coode.owlapi.manchesterowlsyntax; + +import org.semanticweb.owlapi.expression.OWLEntityChecker; +import org.semanticweb.owlapi.model.OWLDataFactory; + +/** + * An expression parser that parses class expressions written in the Manchester + * OWL Syntax. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group, Date: + * 13-Sep-2007 + * @deprecated use {@link org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxClassExpressionParser} + */ +@Deprecated +public class ManchesterOWLSyntaxClassExpressionParser + extends + org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxClassExpressionParser { + + /** + * @param dataFactory dataFactory + * @param checker checker + */ + public ManchesterOWLSyntaxClassExpressionParser(OWLDataFactory dataFactory, + OWLEntityChecker checker) { + super(dataFactory, checker); + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxClassFrameParser.java b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxClassFrameParser.java new file mode 100644 index 0000000000..5369c1fc2c --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxClassFrameParser.java @@ -0,0 +1,38 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.coode.owlapi.manchesterowlsyntax; + +import org.semanticweb.owlapi.expression.OWLEntityChecker; +import org.semanticweb.owlapi.model.OWLDataFactory; + +/** + * An expression parser that parses a Manchester OWL Syntax Class Frame to + * produce a set of axioms that represent the class frame. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group, Date: + * 13-Sep-2007 + * @deprecated use {@link org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxClassFrameParser} + */ +@Deprecated +public class ManchesterOWLSyntaxClassFrameParser + extends org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxClassFrameParser { + + /** + * @param dataFactory dataFactory + * @param checker checker + */ + public ManchesterOWLSyntaxClassFrameParser(OWLDataFactory dataFactory, + OWLEntityChecker checker) { + super(dataFactory, checker); + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxEditorParser.java b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxEditorParser.java new file mode 100644 index 0000000000..76fa4dd3ae --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxEditorParser.java @@ -0,0 +1,66 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.coode.owlapi.manchesterowlsyntax; + +import java.util.Set; + +import org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxParserImpl; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OntologyConfigurator; + +/** + * A parser for the Manchester OWL Syntax. All properties must be defined before they are used. For + * example, consider the restriction hasPart some Leg. The parser must know in advance whether or + * not hasPart is an object property or a data property so that Leg gets parsed correctly. In a + * tool, such as an editor, it is expected that hasPart will already exists as either a data + * property or an object property. If a complete ontology is being parsed, it is expected that + * hasPart will have been defined at the top of the file before it is used in any class expressions + * or property assertions (e.g. ObjectProperty: hasPart) + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group, Date: + * 10-Sep-2007 + * @deprecated use {@link org.semanticweb.owlapi.apibinding.OWLManager#createManchesterParser()} + */ +@Deprecated +public class ManchesterOWLSyntaxEditorParser extends ManchesterOWLSyntaxParserImpl { + + /** + * @param dataFactory dataFactory + * @param s s + */ + public ManchesterOWLSyntaxEditorParser(OWLDataFactory dataFactory, String s) { + this(new OntologyConfigurator(), dataFactory, s); + } + + /** + * @param configuration configuration + * @param dataFactory dataFactory + * @param s s + */ + public ManchesterOWLSyntaxEditorParser(OntologyConfigurator configuration, + OWLDataFactory dataFactory, String s) { + super(configuration, dataFactory); + setStringToParse(s); + } + + /** + * @param b unused + * @return set of class expressions + * @deprecated use {@link #parseClassExpressionList()} + */ + @Deprecated + public Set parseClassExpressionList(@SuppressWarnings("unused") boolean b) { + return parseClassExpressionList(); + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxFramesParser.java b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxFramesParser.java new file mode 100644 index 0000000000..c2d20c3b6a --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxFramesParser.java @@ -0,0 +1,34 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.coode.owlapi.manchesterowlsyntax; + +import org.semanticweb.owlapi.expression.OWLEntityChecker; +import org.semanticweb.owlapi.model.OWLDataFactory; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group, Date: + * 05-Feb-2009 + * @deprecated use {@link org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxFramesParser} + */ +@Deprecated +public class ManchesterOWLSyntaxFramesParser + extends org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxFramesParser { + + /** + * @param dataFactory the data factory + * @param checker the entity checker + */ + public ManchesterOWLSyntaxFramesParser(OWLDataFactory dataFactory, OWLEntityChecker checker) { + super(dataFactory, checker); + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxInlineAxiomParser.java b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxInlineAxiomParser.java new file mode 100644 index 0000000000..fa9edccc69 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxInlineAxiomParser.java @@ -0,0 +1,35 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.coode.owlapi.manchesterowlsyntax; + +import org.semanticweb.owlapi.expression.OWLEntityChecker; +import org.semanticweb.owlapi.model.OWLDataFactory; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group, Date: + * 13-May-2009 + * @deprecated use {@link org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxInlineAxiomParser} + */ +@Deprecated +public class ManchesterOWLSyntaxInlineAxiomParser + extends org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxInlineAxiomParser { + + /** + * @param dataFactory dataFactory + * @param checker checker + */ + public ManchesterOWLSyntaxInlineAxiomParser(OWLDataFactory dataFactory, + OWLEntityChecker checker) { + super(dataFactory, checker); + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxOntologyFormat.java b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxOntologyFormat.java new file mode 100644 index 0000000000..f015b4ef2d --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxOntologyFormat.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.coode.owlapi.manchesterowlsyntax; + +import org.semanticweb.owlapi.vocab.PrefixOWLOntologyFormat; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group, Date: + * 10-May-2007 + * @deprecated use {@link org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat} + */ +@Deprecated +public class ManchesterOWLSyntaxOntologyFormat extends + org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat implements + PrefixOWLOntologyFormat { + +} diff --git a/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxOntologyParser.java b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxOntologyParser.java new file mode 100644 index 0000000000..780c8c5dd3 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/ManchesterOWLSyntaxOntologyParser.java @@ -0,0 +1,25 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.coode.owlapi.manchesterowlsyntax; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group, Date: + * 13-Aug-2007 + * @deprecated use {@link org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxOntologyParser} + */ +@Deprecated +public class ManchesterOWLSyntaxOntologyParser + extends + org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxOntologyParser { + +} diff --git a/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/package-info.java b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/package-info.java new file mode 100644 index 0000000000..a809b983ec --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Manchester syntax compatibility package. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.coode.owlapi.manchesterowlsyntax; diff --git a/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/packageinfo b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/packageinfo new file mode 100644 index 0000000000..131c449ad4 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/manchesterowlsyntax/packageinfo @@ -0,0 +1 @@ +version 7.0.1 diff --git a/compatibility/src/main/java/org/coode/owlapi/obo/parser/OBOOntologyFormat.java b/compatibility/src/main/java/org/coode/owlapi/obo/parser/OBOOntologyFormat.java new file mode 100644 index 0000000000..3509a38421 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo/parser/OBOOntologyFormat.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.coode.owlapi.obo.parser; + +import org.semanticweb.owlapi.model.OWLOntologyFormat; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group, Date: + * 10-Jan-2007 + * @deprecated use {@link org.semanticweb.owlapi.formats.OBODocumentFormat} + */ +@Deprecated +public class OBOOntologyFormat extends + org.semanticweb.owlapi.formats.OBODocumentFormat implements + OWLOntologyFormat { + +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo/parser/packageinfo b/compatibility/src/main/java/org/coode/owlapi/obo/parser/packageinfo new file mode 100644 index 0000000000..8ce0371286 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo/parser/packageinfo @@ -0,0 +1 @@ +version 5.0.0 diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/AbstractTagValueHandler.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/AbstractTagValueHandler.java new file mode 100644 index 0000000000..b868b85445 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/AbstractTagValueHandler.java @@ -0,0 +1,956 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.coode.owlapi.obo12.parser; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.StringTokenizer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.AddOntologyAnnotation; +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.util.CollectionFactory; + +/** + * Author: Matthew Horridge
+ * The University Of Manchester
+ * Bio-Health Informatics Group
+ * Date: 10-Jan-2007
+ *
+ *

+ * Concrete implementations of this interface allow specific behaviour for + * processing specific tag value pairs in an OBO file to be specified. + *

+ *

Tag-Value Pairs (From the OBO 1.4 Guide)

+ *

+ * Tag-value pairs consist of a tag name, an unescaped colon, the tag value, and + * a newline: + *

+ * <tag>: <value> {<trailing modifiers>} ! <comment> The + * tag name is always a string. The value is always a string, but the value + * string may require special parsing depending on the tag with which it is + * associated. + *

+ * In general, tag-value pairs occur on a single line. Multi-line values are + * possible using escape characters (see escape characters). + *

+ * In general, each stanza type expects a particular set of pre-defined tags. + * However, a stanza may contain any tag. If a parser does not recognize a tag + * name for a particular stanza, no error will be generated. This allows new + * experimental tags to be added without breaking existing parsers. See handling + * unrecognized tags for specifics. + *

+ *

Trailing Modifiers

+ *

+ * Any tag-value pair may be followed by a trailing modifier. Trailing modifiers + * have been introduced into the OBO 1.2 Specification to allow the graceful + * addition of new features to existing tags. + *

+ * A trailing modifier has the following structure: + *

+ * {<name>=<value>, <name=value>, <name=value>} That is, + * trailing modifiers are lists of name-value pairs. + *

+ * Parser implementations may choose to decode and/or round-trip these trailing + * modifiers. However, this is not required. A parser may choose to ignore or + * strip away trailing modifiers. + *

+ * For this reason, trailing modifiers should only include information that is + * optional or experimental. + *

+ * Trailing modifiers may also occur within dbxref definitions (see dbxref + * formatting). + *

+ *

+ */ +interface TagValueHandler { + + /** + * Gets the name of the tag handled by this tag value handler + * + * @return The name of the tag + */ + String getTagName(); + + /** + * Handles a tag. This is called by the OBOConsumer during parsing to handle + * tags that match the value returned by the {@link #getTagName()} method. + * + * @param currentId The id of the current frame. + * @param value The value of the tag + * @param qualifierBlock qualifier block + * @param comment The hidden comment. This is made up of any characters between ! and the end of + * line. + */ + void handle(String currentId, String value, String qualifierBlock, String comment); +} + +abstract class AbstractTagValueHandler implements TagValueHandler { + + private final String tag; + private final OBOConsumer consumer; + + public AbstractTagValueHandler(String tag, OBOConsumer consumer) { + this.tag = tag; + this.consumer = consumer; + } + + @Override + public String getTagName() { + return tag; + } + + public OWLOntologyManager getOWLOntologyManager() { + return consumer.getOWLOntologyManager(); + } + + public OWLOntology getOntology() { + return consumer.getOntology(); + } + + public void applyChange(OWLOntologyChange change) { + consumer.getOWLOntologyManager().applyChange(change); + } + + public OBOConsumer getConsumer() { + return consumer; + } + + public OWLDataFactory getDataFactory() { + return consumer.getOWLOntologyManager().getOWLDataFactory(); + } + + public IRI getTagIRI(OBOVocabulary vocabulary) { + return consumer.getIRIFromTagName(vocabulary.getName()); + } + + /** + * Gets an IRI for a tag name. This is a helper method, which ultimately + * calls {@link OBOConsumer#getIRIFromTagName(String)}. + * + * @param tagName The tag name. + * @return The IRI corresponding to the tag name. + */ + public IRI getTagIRI(String tagName) { + return consumer.getIRIFromTagName(tagName); + } + + public IRI getIRIFromOBOId(String id) { + return consumer.getIRIFromOBOId(id); + } + + /** + * Gets an {@link OWLAnnotation} for a tag value pair. + * + * @param tagName The tag name. + * @param value The tag value. Note that the tag value is un-escaped and stripped of double + * quotes if they exist. + * @return An {@link OWLAnnotation} that is formed by converting the tagName to an IRI and then + * to an {@link OWLAnnotationProperty} and the value to an {@link OWLLiteral}. + */ + public OWLAnnotation getAnnotationForTagValuePair(String tagName, String value) { + IRI tagIRI = getTagIRI(tagName); + OWLDataFactory df = getDataFactory(); + OWLAnnotationProperty annotationProperty = df.getOWLAnnotationProperty(tagIRI); + String unescapedString = getUnquotedString(value); + OWLLiteral annotationValue = df.getOWLLiteral(unescapedString); + return df.getOWLAnnotation(annotationProperty, annotationValue); + } + + public OWLClass getClassFromId(String s) { + return getDataFactory().getOWLClass(getIRIFromOBOId(s)); + } + + public OWLClass getCurrentClass() { + return getDataFactory().getOWLClass(getIRIFromOBOId(consumer.getCurrentId())); + } + + protected OWLClass getOWLClass(String id) { + return getDataFactory().getOWLClass(getIRIFromOBOId(id)); + } + + protected OWLObjectProperty getOWLObjectProperty(String id) { + return getDataFactory().getOWLObjectProperty(getIRIFromOBOId(id)); + } + + protected String getUnquotedString(String value) { + String unquotedString; + if (value.startsWith("\"") && value.endsWith("\"")) { + unquotedString = value.substring(1, value.length() - 1); + } else { + unquotedString = value; + } + return unquotedString; + } + + protected OWLClassExpression getOWLClassOrRestriction(String termList) { + String[] strings = termList.split(" "); + if (strings.length == 1) { + return getDataFactory().getOWLClass(getIRIFromOBOId(strings[0])); + } + String id0 = strings[0]; + String id1 = strings[1]; + IRI propertyIRI = getConsumer().getRelationIRIFromSymbolicIdOrOBOId(id0); + OWLObjectProperty prop = getDataFactory().getOWLObjectProperty(propertyIRI); + OWLClass filler = getDataFactory().getOWLClass(getIRIFromOBOId(id1)); + return getDataFactory().getOWLObjectSomeValuesFrom(prop, filler); + } + + protected OWLLiteral getBooleanConstant(boolean b) { + return getDataFactory().getOWLLiteral(b); + } + + protected void addAnnotation(String id, String uriID, OWLLiteral value) { + IRI subject = getIRIFromOBOId(id); + OWLAnnotationProperty annotationProperty = getDataFactory() + .getOWLAnnotationProperty(getIRIFromOBOId(uriID)); + OWLAxiom ax = getDataFactory() + .getOWLAnnotationAssertionAxiom(annotationProperty, subject, value); + applyChange(new AddAxiom(getOntology(), ax)); + } +} + +class AltIdTagValueHandler extends AbstractTagValueHandler { + + public AltIdTagValueHandler(OBOConsumer consumer) { + super(OBOVocabulary.ALT_ID.getName(), consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + HasIRI subject = getConsumer().getCurrentEntity(); + OWLAnnotationProperty property = getDataFactory() + .getOWLAnnotationProperty(OBOVocabulary.ALT_ID); + IRI object = getIRIFromOBOId(value); + OWLAnnotationAssertionAxiom ax = getDataFactory() + .getOWLAnnotationAssertionAxiom(property, subject.getIRI(), + object); + applyChange(new AddAxiom(getOntology(), ax)); + } +} + +class AsymmetricHandler extends AbstractTagValueHandler { + + public AsymmetricHandler(OBOConsumer consumer) { + super(OBOVocabulary.IS_ASYMMETRIC.getName(), consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + if (Boolean.parseBoolean(value)) { + OWLObjectProperty prop = getOWLObjectProperty(currentId); + OWLAxiom ax = getDataFactory().getOWLAsymmetricObjectPropertyAxiom(prop); + applyChange(new AddAxiom(getOntology(), ax)); + } else { + addAnnotation(currentId, OBOVocabulary.IS_ASYMMETRIC.getName(), + getBooleanConstant(false)); + } + } +} + +class DataVersionTagValueHandler extends AbstractTagValueHandler { + + public DataVersionTagValueHandler(OBOConsumer consumer) { + super(OBOVocabulary.DATA_VERSION.getName(), consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + getConsumer().setDataVersionTagValue(value); + } +} + +/** + * Author: Matthew Horridge
+ * The University Of Manchester
+ * Information Management Group
+ * Date: 01-Sep-2008
+ *
+ *

+ * OBO Namespaces are NOT like XML Namespaces. They are NOT used to form + * abbreviations for IRIs. The description below, taken from the OBOEdit manual, + * explains their provenance. + *

+ *

OBO Namespaces and Ontology Name (OBO Syntax and Semantics Document: + * Section 4.3)

+ *

+ * Note that OBO namespaces are not the same as OWL namespaces - the analog of + * OWL namespaces are OBO ID spaces. OBO namespaces are semantics-free + * properties of a frame that allow partitioning of an ontology into + * sub-ontologies. For example, the GO is partitioned into 3 ontologies (3 OBO + * namespaces, 1 OWL namespace). + *

+ * Every frame must have exactly one namespace. However, these do not need to be + * explicitly assigned. After parsing an OBO Document, any frame without a + * namespace is assigned the default-namespace, from the OBO Document header. If + * this is not specified, the Parser assigns a namespace arbitrarily. It is + * recommended this is equivalent to the URL or file path from which the + * document was retrieved. + *

+ * Every OBODoc should have an "ontology" tag specified in the header. If this + * is not specified, then the parser should supply a default value. This value + * should be derived from the URL of the source of the ontology (typically using + * http or file schemes). + *

+ *

+ *

+ *

+ *

OBO Namespaces (From the OBOEdit Manual)

+ *

+ * Namespaces + *

+ * OBO files are designed to be easily merged and separated. Most tools that use + * OBO files can load many OBO files at once. If several ontologies have been + * loaded together and saved into a single file, it would be impossible to know + * which terms came from which file unless the origin of each term is indicated + * somehow. Namespaces are used to solve this problem by indicating a "logical + * ontology" to which every term, relation, instance OR relationship belongs, + * i.e., each entity is tagged with a Namespace that indicates which ontology it + * is part of. + *

+ * Namespaces are user-definable. Every ontology object belongs to a single + * namespace. When terms from many ontologies have been loaded together, + * namespaces are used to break the merged ontology back into separate files. + */ +class DefaultNamespaceTagValueHandler extends AbstractTagValueHandler { + + public DefaultNamespaceTagValueHandler(OBOConsumer consumer) { + super(OBOVocabulary.DEFAULT_NAMESPACE.getName(), consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + // Just register the namespace with the consumer and add it as an + // annotation to the ontology + getConsumer().setDefaultNamespaceTagValue(value); + // Add an annotation to the ontology + OWLAnnotation annotation = getAnnotationForTagValuePair( + OBOVocabulary.DEFAULT_NAMESPACE.getName(), value); + applyChange(new AddOntologyAnnotation(getOntology(), annotation)); + } +} + +class DefTagValueHandler extends AbstractTagValueHandler { + + private static final Pattern PATTERN = Pattern + .compile("\"([^\"]*)\"\\s*(\\[([^\\]]*)\\])?\\s*"); + private static final int QUOTED_STRING_CONTENT_GROUP = 1; + private static final int XREF_GROUP = 3; + + public DefTagValueHandler(OBOConsumer consumer) { + super(OBOVocabulary.DEF.getName(), consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + Matcher matcher = PATTERN.matcher(value); + OWLDataFactory df = getDataFactory(); + String annotationValue; + Set xrefAnnotations = Collections.emptySet(); + if (matcher.matches()) { + annotationValue = matcher.group(QUOTED_STRING_CONTENT_GROUP); + xrefAnnotations = getXRefAnnotations(matcher); + } else { + annotationValue = getUnquotedString(value); + } + IRI propertyIRI = getTagIRI(getTagName()); + OWLAnnotationProperty property = df.getOWLAnnotationProperty(propertyIRI); + OWLEntity currentEntity = getConsumer().getCurrentEntity(); + OWLLiteral literal = df.getOWLLiteral(annotationValue); + OWLAnnotationAssertionAxiom ax = df + .getOWLAnnotationAssertionAxiom(property, currentEntity.getIRI(), literal, + xrefAnnotations); + applyChange(new AddAxiom(getOntology(), ax)); + } + + private Set getXRefAnnotations(Matcher matcher) { + Set annotations = new HashSet<>(); + String xrefs = matcher.group(XREF_GROUP); + if (xrefs != null) { + for (String xrefValue : xrefs.split(",")) { + annotations.add(getConsumer().parseXRef(xrefValue)); + } + } + return annotations; + } +} + +class DisjointFromHandler extends AbstractTagValueHandler { + + public DisjointFromHandler(OBOConsumer consumer) { + super("disjoint_from", consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + OWLAxiom ax = getDataFactory() + .getOWLDisjointClassesAxiom(CollectionFactory.createSet(getCurrentClass(), + getOWLClass(value))); + applyChange(new AddAxiom(getOntology(), ax)); + } +} + +class DomainHandler extends AbstractTagValueHandler { + + public DomainHandler(OBOConsumer consumer) { + super(OBOVocabulary.DOMAIN.getName(), consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + OWLObjectProperty prop = getOWLObjectProperty(getConsumer().getCurrentId()); + OWLClass cls = getOWLClass(value); + applyChange(new AddAxiom(getOntology(), + getDataFactory().getOWLObjectPropertyDomainAxiom(prop, cls))); + } +} + +class IDSpaceTagValueHandler extends AbstractTagValueHandler { + + private static final Pattern PATTERN = Pattern.compile("([^\\s]*)\\s+([^\\s]*)"); + private static final int ID_PREFIX_GROUP = 1; + private static final int IRI_PREFIX_GROUP = 2; + + public IDSpaceTagValueHandler(OBOConsumer consumer) { + super(OBOVocabulary.ID_SPACE.getName(), consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + Matcher matcher = PATTERN.matcher(value); + if (matcher.matches()) { + String idPrefix = matcher.group(ID_PREFIX_GROUP); + String iriPrefix = matcher.group(IRI_PREFIX_GROUP); + getConsumer().registerIdSpace(idPrefix, iriPrefix); + } + } +} + +class IDTagValueHandler extends AbstractTagValueHandler { + + public IDTagValueHandler(OBOConsumer consumer) { + super(OBOVocabulary.ID.getName(), consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + getConsumer().setCurrentId(value); + OWLEntity entity = getConsumer().getCurrentEntity(); + applyChange(new AddAxiom(getOntology(), getDataFactory().getOWLDeclarationAxiom(entity))); + } +} + +class IntersectionOfHandler extends AbstractTagValueHandler { + + public IntersectionOfHandler(OBOConsumer consumer) { + super("intersection_of", consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + getConsumer().addIntersectionOfOperand(getOWLClassOrRestriction(value)); + } +} + +class InverseHandler extends AbstractTagValueHandler { + + public InverseHandler(OBOConsumer consumer) { + super(OBOVocabulary.INVERSE.getName(), consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + OWLAxiom ax = getDataFactory() + .getOWLInverseObjectPropertiesAxiom(getOWLObjectProperty(currentId), + getOWLObjectProperty(value)); + applyChange(new AddAxiom(getOntology(), ax)); + } +} + +class IsATagValueHandler extends AbstractTagValueHandler { + + public IsATagValueHandler(OBOConsumer consumer) { + super(OBOVocabulary.IS_A.getName(), consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + if (getConsumer().isTerm()) { + // We simply add a subclass axiom + applyChange(new AddAxiom(getOntology(), + getDataFactory().getOWLSubClassOfAxiom(getClassFromId(currentId), + getClassFromId(value)))); + } else if (getConsumer().isTypedef()) { + // We simply add a sub property axiom + applyChange(new AddAxiom(getOntology(), getDataFactory().getOWLSubObjectPropertyOfAxiom( + getOWLObjectProperty(currentId), getOWLObjectProperty(value)))); + } + } +} + +class IsObsoleteTagValueHandler extends AbstractTagValueHandler { + + public IsObsoleteTagValueHandler(OBOConsumer consumer) { + super(OBOVocabulary.IS_OBSOLETE.getName(), consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + OWLDataFactory df = getDataFactory(); + OWLAnnotationProperty deprecatedProperty = df.getOWLDeprecated(); + OWLLiteral annotationValue = df.getOWLLiteral(true); + IRI subject = getIRIFromOBOId(currentId); + OWLAnnotationAssertionAxiom ax = df + .getOWLAnnotationAssertionAxiom(deprecatedProperty, subject, + annotationValue); + applyChange(new AddAxiom(getOntology(), ax)); + } +} + +class NameTagValueHandler extends AbstractTagValueHandler { + + public NameTagValueHandler(OBOConsumer consumer) { + super(OBOVocabulary.NAME.getName(), consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + // This is an annotation - but add as a label + OWLEntity ent; + if (getConsumer().isTerm()) { + ent = getDataFactory().getOWLClass(getIRIFromOBOId(currentId)); + } else if (getConsumer().isTypedef()) { + ent = getDataFactory().getOWLObjectProperty(getIRIFromOBOId(currentId)); + } else { + ent = getDataFactory().getOWLNamedIndividual(getIRIFromOBOId(currentId)); + } + OWLAxiom ax = getDataFactory() + .getOWLAnnotationAssertionAxiom(ent.getIRI(), getDataFactory().getRDFSLabel( + value)); + applyChange(new AddAxiom(getOntology(), ax)); + } +} + +class OntologyTagValueHandler extends AbstractTagValueHandler { + + public OntologyTagValueHandler(OBOConsumer consumer) { + super(OBOVocabulary.ONTOLOGY.getName(), consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + getConsumer().setOntologyTagValue(value); + } +} + +class PartOfTagValueHandler extends AbstractTagValueHandler { + + public PartOfTagValueHandler(OBOConsumer consumer) { + super(OBOVocabulary.RELATIONSHIP.getName(), consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + int index = value.indexOf(' '); + String propLocalName = value.substring(0, index); + String val = value.substring(index + 1, value.length()); + OWLDataFactory df = getDataFactory(); + OWLObjectProperty prop = df.getOWLObjectProperty(getIRIFromOBOId(propLocalName)); + OWLClass filler = getClassFromId(val); + OWLClassExpression desc = df.getOWLObjectSomeValuesFrom(prop, filler); + OWLAxiom ax = df.getOWLSubClassOfAxiom(getCurrentClass(), desc); + applyChange(new AddAxiom(getOntology(), ax)); + } +} + +class RawFrameHandler implements OBOParserHandler { + + private final List currentTagValuePairs = new ArrayList<>(); + private final List typeDefFrames = new ArrayList<>(); + private final List nonTypeDefFrames = new ArrayList<>(); + @Nullable + private String currentFrameType = ""; + @Nullable + private OBOFrame headerFrame; + + @Override + public void startHeader() { + currentTagValuePairs.clear(); + } + + @Override + public void endHeader() { + headerFrame = new OBOFrame(currentTagValuePairs); + } + + @Override + public void startFrame(@Nullable String frameType) { + currentFrameType = frameType; + currentTagValuePairs.clear(); + } + + @Override + public void endFrame() { + storeCurrentFrame(); + } + + private OBOFrame storeCurrentFrame() { + OBOFrame frame = new OBOFrame(currentFrameType, currentTagValuePairs); + if (frame.isTypeDefFrame()) { + typeDefFrames.add(frame); + } else { + nonTypeDefFrames.add(frame); + } + return frame; + } + + @Override + public void handleTagValue(String tag, String value, String qualifierBlock, String comment) { + OBOTagValuePair tvp = new OBOTagValuePair(tag, value, qualifierBlock, comment); + currentTagValuePairs.add(tvp); + } + + /** + * @return the header frame + */ + @Nullable + public OBOFrame getHeaderFrame() { + return headerFrame; + } + + /** + * @return the typedef frames + */ + public List getTypeDefFrames() { + return typeDefFrames; + } + + /** + * @return the non typedef frames + */ + public List getNonTypeDefFrames() { + return nonTypeDefFrames; + } +} + +class ReflexiveHandler extends AbstractTagValueHandler { + + public ReflexiveHandler(OBOConsumer consumer) { + super(OBOVocabulary.IS_REFLEXIVE.getName(), consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + if (Boolean.parseBoolean(value)) { + OWLObjectProperty prop = getOWLObjectProperty(currentId); + OWLAxiom ax = getDataFactory().getOWLReflexiveObjectPropertyAxiom(prop); + applyChange(new AddAxiom(getOntology(), ax)); + } else { + addAnnotation(currentId, OBOVocabulary.IS_REFLEXIVE.getName(), + getBooleanConstant(false)); + } + } +} + +class RelationshipTagValueHandler extends AbstractTagValueHandler { + + private final Pattern tagValuePattern = Pattern + .compile("([^\\s]*)\\s*([^\\s]*)\\s*(\\{([^\\}]*)\\})?"); + + public RelationshipTagValueHandler(OBOConsumer consumer) { + super(OBOVocabulary.RELATIONSHIP.getName(), consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + Matcher matcher = tagValuePattern.matcher(value); + if (matcher.matches()) { + IRI propIRI = getConsumer().getRelationIRIFromSymbolicIdOrOBOId(matcher.group(1)); + IRI fillerIRI = getIRIFromOBOId(matcher.group(2)); + OWLObjectProperty prop = getDataFactory().getOWLObjectProperty(propIRI); + OWLClass filler = getDataFactory().getOWLClass(fillerIRI); + OWLClassExpression restriction = getDataFactory() + .getOWLObjectSomeValuesFrom(prop, filler); + OWLClass subCls = getDataFactory().getOWLClass(getIRIFromOBOId(currentId)); + applyChange(new AddAxiom(getOntology(), + getDataFactory().getOWLSubClassOfAxiom(subCls, restriction))); + applyChange(new AddAxiom(getOntology(), getDataFactory().getOWLDeclarationAxiom(prop))); + } + } +} + +class SymmetricTagValueHandler extends AbstractTagValueHandler { + + public SymmetricTagValueHandler(OBOConsumer consumer) { + super(OBOVocabulary.IS_SYMMETRIC.getName(), consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + if (Boolean.parseBoolean(value)) { + OWLObjectProperty prop = getOWLObjectProperty(currentId); + OWLAxiom ax = getDataFactory().getOWLSymmetricObjectPropertyAxiom(prop); + applyChange(new AddAxiom(getOntology(), ax)); + } else { + addAnnotation(currentId, OBOVocabulary.IS_SYMMETRIC.getName(), + getBooleanConstant(false)); + } + } +} + +class SynonymTagValueHandler extends AbstractTagValueHandler { + + public static final IRI SYNONYM_TYPE_IRI = OBOVocabulary.SYNONYM_TYPE.getIRI(); + public static final IRI XREF_IRI = OBOVocabulary.XREF.getIRI(); + private static final String TAG_NAME = OBOVocabulary.SYNONYM.toString(); + // synonym: "synonym" (EXACT|BROAD|NARROW|RELATED) TYPE? XRefList + private static final Pattern VALUEPATTERN = Pattern.compile( + "\"([^\"]*)\"\\s*([^\\s]*)\\s*([^\\[\\s]+)?\\s*\\[([^\\]]*)\\]"); + private static final int VALUE_GROUP = 1; + private static final int SCOPE_GROUP = 2; + private static final int SYNONYM_TYPE_GROUP = 3; + private static final int XREF_GROUP = 4; + + public SynonymTagValueHandler(OBOConsumer consumer) { + super(TAG_NAME, consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + Matcher matcher = VALUEPATTERN.matcher(value); + if (matcher.matches()) { + OWLDataFactory df = getDataFactory(); + OWLAnnotationProperty property = getSynonymAnnotationProperty(matcher); + Set annotations = new HashSet<>(); + annotations.addAll(getSynonymTypeAnnotations(matcher)); + annotations.addAll(getXRefAnnotations(matcher)); + OWLEntity subject = getConsumer().getCurrentEntity(); + String synonym = matcher.group(VALUE_GROUP); + OWLLiteral synonymLiteral = df.getOWLLiteral(synonym); + OWLAnnotationAssertionAxiom annoAssertion = df + .getOWLAnnotationAssertionAxiom(property, subject.getIRI(), + synonymLiteral, annotations); + applyChange(new AddAxiom(getOntology(), annoAssertion)); + } + } + + private Set getSynonymTypeAnnotations(Matcher matcher) { + if (matcher.group(SYNONYM_TYPE_GROUP) != null) { + OWLAnnotation typeAnnotation = getSynonymTypeAnnotation(matcher); + return Collections.singleton(typeAnnotation); + } else { + return Collections.emptySet(); + } + } + + private Set getXRefAnnotations(Matcher matcher) { + Set annotations = new HashSet<>(); + String xrefs = matcher.group(XREF_GROUP); + if (xrefs != null) { + StringTokenizer tokenizer = new StringTokenizer(xrefs, ","); + while (tokenizer.hasMoreTokens()) { + String xref = tokenizer.nextToken(); + OWLAnnotation xrefAnnotation = getConsumer().parseXRef(xref); + annotations.add(xrefAnnotation); + } + } + return annotations; + } + + private OWLAnnotationProperty getSynonymAnnotationProperty(Matcher matcher) { + String synonymScope = matcher.group(SCOPE_GROUP); + IRI annotationPropertyIRI; + if (SynonymScope.BROAD.name().equals(synonymScope)) { + annotationPropertyIRI = getTagIRI(OBOVocabulary.BROAD_SYNONYM); + } else if (SynonymScope.EXACT.name().equals(synonymScope)) { + annotationPropertyIRI = getTagIRI(OBOVocabulary.EXACT_SYNONYM); + } else if (SynonymScope.NARROW.name().equals(synonymScope)) { + annotationPropertyIRI = getTagIRI(OBOVocabulary.NARROW_SYNONYM); + } else if (SynonymScope.RELATED.name().equals(synonymScope)) { + annotationPropertyIRI = getTagIRI(OBOVocabulary.RELATED_SYNONYM); + } else { + annotationPropertyIRI = getTagIRI(OBOVocabulary.SYNONYM); + } + return getDataFactory().getOWLAnnotationProperty(annotationPropertyIRI); + } + + private OWLAnnotation getSynonymTypeAnnotation(Matcher matcher) { + OWLDataFactory df = getDataFactory(); + String synonymType = matcher.group(SYNONYM_TYPE_GROUP); + return df.getOWLAnnotation(df.getOWLAnnotationProperty(SYNONYM_TYPE_IRI), + df.getOWLLiteral(synonymType)); + } +} + +class SynonymTypeDefTagHandler extends AbstractTagValueHandler { + + private static final Pattern PATTERN = Pattern + .compile("([^\\s]*)\\s+\"([^\"]*)\"(\\s*([^\\s]*)\\s*)?"); + private static final int ID_GROUP = 1; + private static final int NAME_GROUP = 2; + + public SynonymTypeDefTagHandler(OBOConsumer consumer) { + super(OBOVocabulary.SYNONYM_TYPE_DEF.getName(), consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + Matcher matcher = PATTERN.matcher(value); + if (matcher.matches()) { + String id = matcher.group(ID_GROUP); + IRI annotationPropertyIRI = getIRIFromOBOId(id); + String name = matcher.group(NAME_GROUP); + OWLDataFactory df = getDataFactory(); + OWLAnnotationProperty annotationProperty = df + .getOWLAnnotationProperty(annotationPropertyIRI); + applyChange(new AddAxiom(getOntology(), df.getOWLDeclarationAxiom(annotationProperty))); + IRI subsetdefIRI = getTagIRI(OBOVocabulary.SUBSETDEF.getName()); + OWLAnnotationProperty subsetdefAnnotationProperty = df + .getOWLAnnotationProperty(subsetdefIRI); + applyChange(new AddAxiom(getOntology(), + df.getOWLSubAnnotationPropertyOfAxiom(annotationProperty, + subsetdefAnnotationProperty))); + applyChange(new AddAxiom(getOntology(), + df.getOWLAnnotationAssertionAxiom(annotationPropertyIRI, df + .getRDFSLabel(name)))); + } else { + OWLAnnotation annotation = getAnnotationForTagValuePair( + OBOVocabulary.SYNONYM_TYPE_DEF.getName(), value); + applyChange(new AddOntologyAnnotation(getOntology(), annotation)); + } + // ID QuotedString [Scope] + // 18th April 2012 + // AnnotationProperty(T(ID)) + // SubAnnotationPropertyOf(T(ID) T(subsetdef)) + // AnnotationAssertion(T(name) T(ID) ID) + // AnnotationAssertion(T(hasScope) T(ID) Scope) + } +} + +class TransitiveOverHandler extends AbstractTagValueHandler { + + public TransitiveOverHandler(OBOConsumer consumer) { + super("is_transitive_over", consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + OWLObjectProperty first = getOWLObjectProperty(currentId); + OWLObjectProperty second = getOWLObjectProperty(value); + List chain = new ArrayList<>(); + chain.add(first); + chain.add(second); + OWLAxiom ax = getDataFactory().getOWLSubPropertyChainOfAxiom(chain, first); + applyChange(new AddAxiom(getOntology(), ax)); + } +} + +class TransitiveTagValueHandler extends AbstractTagValueHandler { + + public TransitiveTagValueHandler(OBOConsumer consumer) { + super(OBOVocabulary.IS_TRANSITIVE.getName(), consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + if (Boolean.parseBoolean(value)) { + OWLObjectProperty prop = getDataFactory() + .getOWLObjectProperty(getIRIFromOBOId(currentId)); + OWLAxiom ax = getDataFactory().getOWLTransitiveObjectPropertyAxiom(prop); + applyChange(new AddAxiom(getOntology(), ax)); + } + } +} + +class UnionOfHandler extends AbstractTagValueHandler { + + public UnionOfHandler(OBOConsumer consumer) { + super("union_of", consumer); + } + + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + getConsumer().addUnionOfOperand(getOWLClassOrRestriction(value)); + } +} + +class XRefTagHandler extends AbstractTagValueHandler { + + public XRefTagHandler(OBOConsumer consumer) { + super(OBOVocabulary.XREF.getName(), consumer); + } + + @SuppressWarnings({"null", "unused"}) + @Override + public void handle(String currentId, String value, String qualifierBlock, String comment) { + if (currentId == null) { + return; + } + OWLAnnotation xrefAnnotation = getConsumer().parseXRef(value); + IRI subject = getIRIFromOBOId(currentId); + OWLAnnotationAssertionAxiom ax = getDataFactory() + .getOWLAnnotationAssertionAxiom(xrefAnnotation.getProperty(), + subject, xrefAnnotation.getValue()); + applyChange(new AddAxiom(getOntology(), ax)); + if (getConsumer().isTypedef() && xrefAnnotation.getValue().isIRI()) { + IRI xrefIRI = (IRI) xrefAnnotation.getValue(); + String typedefId = getConsumer().getCurrentId(); + getConsumer().addSymbolicIdMapping(typedefId, xrefIRI); + } + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/IDSpaceManager.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/IDSpaceManager.java new file mode 100644 index 0000000000..5bd14f2280 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/IDSpaceManager.java @@ -0,0 +1,125 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, The University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.coode.owlapi.obo12.parser; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.HashMap; +import java.util.Map; + +/** + * Author: Matthew Horridge
+ * Stanford University
+ * Bio-Medical Informatics Research Group
+ * Date: 18/04/2012 + *

+ * Maps between id prefixes and IRI prefixes. By default an IRI prefix is the + * value defined by {@link OBOPrefix#getPrefix()}, but this can be overridden + * using an idspace tag in the ontology header. + *

+ *

+ * Note that the terminology used here, i.e. "id prefix" and "IRI prefix" is OBO + * terminology and is not related to the OWL notion of prefix name and prefix. + * "id prefix" is the substring before the colon in an OBO id. IRI prefix is the + * prefix of an IRI that is the result of translating an OBO id to an IRI. + *

+ */ +class IDSpaceManager { + + private final Map idPrefix2IRIPrefixMap = new HashMap<>(); + + /** + * + */ + public IDSpaceManager() { + } + + /** + * Creates an IDSpaceManager and copying the id prefix to IRI prefix + * mappings contained in some other IDSpaceManager. + * + * @param idSpaceManager The other IDSpaceManager from where id prefix to IRI prefix mappings + * will be copied. Not null. + * @throws NullPointerException if idSpaceManager is null. + */ + public IDSpaceManager(IDSpaceManager idSpaceManager) { + checkNotNull(idSpaceManager, "idSpaceManager must not be null"); + idPrefix2IRIPrefixMap.putAll(idSpaceManager.idPrefix2IRIPrefixMap); + } + + /** + * Gets the default IRI prefix (which is returned by the + * {@link #getIRIPrefix(String)} for unregistered id prefixes. + * + * @return The default prefix. This is actually defined by {@link OBOPrefix#OBO}. + */ + public String getDefaultIRIPrefix() { + return OBOPrefix.OBO.getPrefix(); + } + + /** + * Gets an IRI prefix from an id prefix. + * + * @param idPrefix The id prefix. May be null. + * @return The IRI prefix for the given id prefix. Not null. If the specified id prefix is not + * registered/set with this manager, or it is null, then the default prefix will be returned, + * which is defined by {@link OBOPrefix#OBO}. + */ + public String getIRIPrefix(String idPrefix) { + String iriPrefix = idPrefix2IRIPrefixMap.get(idPrefix); + if (iriPrefix != null) { + return iriPrefix; + } else { + return getDefaultIRIPrefix(); + } + } + + /** + * Sets the IRI prefix for a given id prefix. This clears any previously set + * IRI prefix for the given id prefix. + * + * @param idPrefix The id prefix to set. + * @param iriPrefix The IRI prefix that the id prefix maps to. + */ + public void setIRIPrefix(String idPrefix, String iriPrefix) { + checkNotNull(idPrefix, "idPrefix must not be null"); + checkNotNull(iriPrefix, "iriPrefix must not be null"); + idPrefix2IRIPrefixMap.put(idPrefix, iriPrefix); + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/JavaCharStream.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/JavaCharStream.java new file mode 100644 index 0000000000..74ba273a45 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/JavaCharStream.java @@ -0,0 +1,546 @@ +/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 7.0 */ +/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=false */ +package org.coode.owlapi.obo12.parser; + +/** + * An implementation of interface CharStream, where the stream is assumed to + * contain only ASCII characters (with java-like unicode escape processing). + */ +@SuppressWarnings("all") + class JavaCharStream +{ + /** Whether parser is static. */ + public static final boolean staticFlag = false; + + + static final int hexval(char c) throws java.io.IOException { + switch(c) + { + case '0' : + return 0; + case '1' : + return 1; + case '2' : + return 2; + case '3' : + return 3; + case '4' : + return 4; + case '5' : + return 5; + case '6' : + return 6; + case '7' : + return 7; + case '8' : + return 8; + case '9' : + return 9; + + case 'a' : + case 'A' : + return 10; + case 'b' : + case 'B' : + return 11; + case 'c' : + case 'C' : + return 12; + case 'd' : + case 'D' : + return 13; + case 'e' : + case 'E' : + return 14; + case 'f' : + case 'F' : + return 15; + } + + throw new java.io.IOException(); // Should never come here + } + +/** Position in buffer. */ + public int bufpos = -1; + int bufsize; + int available; + int tokenBegin; + protected int bufline[]; + protected int bufcolumn[]; + + protected int column = 0; + protected int line = 1; + + protected boolean prevCharIsCR = false; + protected boolean prevCharIsLF = false; + + protected Provider inputStream; + + protected char[] nextCharBuf; + protected char[] buffer; + protected int maxNextCharInd = 0; + protected int nextCharInd = -1; + protected int inBuf = 0; + protected int tabSize = 1; + protected boolean trackLineColumn = true; + + public void setTabSize(int i) { tabSize = i; } + public int getTabSize(int i) { return tabSize; } + + protected void ExpandBuff(boolean wrapAround) + { + char[] newbuffer = new char[bufsize + 2048]; + int newbufline[] = new int[bufsize + 2048]; + int newbufcolumn[] = new int[bufsize + 2048]; + + try + { + if (wrapAround) + { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); + bufcolumn = newbufcolumn; + + bufpos += (bufsize - tokenBegin); + } + else + { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + bufcolumn = newbufcolumn; + + bufpos -= tokenBegin; + } + } + catch (Exception t) + { + throw new RuntimeException(t.getMessage()); + } + + available = (bufsize += 2048); + tokenBegin = 0; + } + + protected void FillBuff() throws java.io.IOException + { + int i; + if (maxNextCharInd == 4096) + maxNextCharInd = nextCharInd = 0; + + try { + if ((i = inputStream.read(nextCharBuf, maxNextCharInd, + 4096 - maxNextCharInd)) == -1) + { + inputStream.close(); + throw new java.io.IOException(); + } + else + maxNextCharInd += i; + return; + } + catch(java.io.IOException e) { + if (bufpos != 0) + { + --bufpos; + backup(0); + } + else + { + bufline[bufpos] = line; + bufcolumn[bufpos] = column; + } + throw e; + } + } + + protected char ReadByte() throws java.io.IOException + { + if (++nextCharInd >= maxNextCharInd) + FillBuff(); + + return nextCharBuf[nextCharInd]; + } + +/** @return starting character for token. */ + public char BeginToken() throws java.io.IOException + { + if (inBuf > 0) + { + --inBuf; + + if (++bufpos == bufsize) + bufpos = 0; + + tokenBegin = bufpos; + return buffer[bufpos]; + } + + tokenBegin = 0; + bufpos = -1; + + return readChar(); + } + + protected void AdjustBuffSize() + { + if (available == bufsize) + { + if (tokenBegin > 2048) + { + bufpos = 0; + available = tokenBegin; + } + else + ExpandBuff(false); + } + else if (available > tokenBegin) + available = bufsize; + else if ((tokenBegin - available) < 2048) + ExpandBuff(true); + else + available = tokenBegin; + } + + protected void UpdateLineColumn(char c) + { + column++; + + if (prevCharIsLF) + { + prevCharIsLF = false; + line += (column = 1); + } + else if (prevCharIsCR) + { + prevCharIsCR = false; + if (c == '\n') + { + prevCharIsLF = true; + } + else + line += (column = 1); + } + + switch (c) + { + case '\r' : + prevCharIsCR = true; + break; + case '\n' : + prevCharIsLF = true; + break; + case '\t' : + column--; + column += (tabSize - (column % tabSize)); + break; + default : + break; + } + + bufline[bufpos] = line; + bufcolumn[bufpos] = column; + } + +/** Read a character. */ + public char readChar() throws java.io.IOException + { + if (inBuf > 0) + { + --inBuf; + + if (++bufpos == bufsize) + bufpos = 0; + + return buffer[bufpos]; + } + + char c; + + if (++bufpos == available) + AdjustBuffSize(); + + if ((buffer[bufpos] = c = ReadByte()) == '\\') + { + UpdateLineColumn(c); + + int backSlashCnt = 1; + + for (;;) // Read all the backslashes + { + if (++bufpos == available) + AdjustBuffSize(); + + try + { + if ((buffer[bufpos] = c = ReadByte()) != '\\') + { + UpdateLineColumn(c); + // found a non-backslash char. + if ((c == 'u') && ((backSlashCnt & 1) == 1)) + { + if (--bufpos < 0) + bufpos = bufsize - 1; + + break; + } + + backup(backSlashCnt); + return '\\'; + } + } + catch(java.io.IOException e) + { + // We are returning one backslash so we should only backup (count-1) + if (backSlashCnt > 1) + backup(backSlashCnt-1); + + return '\\'; + } + + UpdateLineColumn(c); + backSlashCnt++; + } + + // Here, we have seen an odd number of backslash's followed by a 'u' + try + { + while ((c = ReadByte()) == 'u') + ++column; + + buffer[bufpos] = c = (char)(hexval(c) << 12 | + hexval(ReadByte()) << 8 | + hexval(ReadByte()) << 4 | + hexval(ReadByte())); + + column += 4; + } + catch(java.io.IOException e) + { + throw new RuntimeException("Invalid escape character at line " + line + + " column " + column + "."); + } + + if (backSlashCnt == 1) + return c; + else + { + backup(backSlashCnt - 1); + return '\\'; + } + } + else + { + UpdateLineColumn(c); + return c; + } + } + + @Deprecated + /** + * @deprecated + * @see #getEndColumn + */ + public int getColumn() { + return bufcolumn[bufpos]; + } + + @Deprecated + /** + * @deprecated + * @see #getEndLine + */ + public int getLine() { + return bufline[bufpos]; + } + +/** Get end column. */ + public int getEndColumn() { + return bufcolumn[bufpos]; + } + +/** Get end line. */ + public int getEndLine() { + return bufline[bufpos]; + } + +/** @return column of token start */ + public int getBeginColumn() { + return bufcolumn[tokenBegin]; + } + +/** @return line number of token start */ + public int getBeginLine() { + return bufline[tokenBegin]; + } + +/** Retreat. */ + public void backup(int amount) { + + inBuf += amount; + if ((bufpos -= amount) < 0) + bufpos += bufsize; + } + +/** Constructor. */ + public JavaCharStream(Provider dstream, + int startline, int startcolumn, int buffersize) + { + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; + nextCharBuf = new char[4096]; + } + +/** Constructor. */ + public JavaCharStream(Provider dstream, + int startline, int startcolumn) + { + this(dstream, startline, startcolumn, 4096); + } + +/** Constructor. */ + public JavaCharStream(Provider dstream) + { + this(dstream, 1, 1, 4096); + } +/** Reinitialise. */ + public void ReInit(Provider dstream, + int startline, int startcolumn, int buffersize) + { + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + if (buffer == null || buffersize != buffer.length) + { + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; + nextCharBuf = new char[4096]; + } + prevCharIsLF = prevCharIsCR = false; + tokenBegin = inBuf = maxNextCharInd = 0; + nextCharInd = bufpos = -1; + } + +/** Reinitialise. */ + public void ReInit(Provider dstream, + int startline, int startcolumn) + { + ReInit(dstream, startline, startcolumn, 4096); + } + +/** Reinitialise. */ + public void ReInit(Provider dstream) + { + ReInit(dstream, 1, 1, 4096); + } + + + + /** @return token image as String */ + public String GetImage() + { + if (bufpos >= tokenBegin) + return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); + else + return new String(buffer, tokenBegin, bufsize - tokenBegin) + + new String(buffer, 0, bufpos + 1); + } + + /** @return suffix */ + public char[] GetSuffix(int len) + { + char[] ret = new char[len]; + + if ((bufpos + 1) >= len) + System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); + else + { + System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, + len - bufpos - 1); + System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); + } + + return ret; + } + + /** Set buffers back to null when finished. */ + public void Done() + { + nextCharBuf = null; + buffer = null; + bufline = null; + bufcolumn = null; + } + + /** + * Method to adjust line and column numbers for the start of a token. + */ + public void adjustBeginLineColumn(int newLine, int newCol) + { + int start = tokenBegin; + int len; + + if (bufpos >= tokenBegin) + { + len = bufpos - tokenBegin + inBuf + 1; + } + else + { + len = bufsize - tokenBegin + bufpos + 1 + inBuf; + } + + int i = 0, j = 0, k = 0; + int nextColDiff = 0, columnDiff = 0; + + while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) + { + bufline[j] = newLine; + nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; + bufcolumn[j] = newCol + columnDiff; + columnDiff = nextColDiff; + i++; + } + + if (i < len) + { + bufline[j] = newLine++; + bufcolumn[j] = newCol + columnDiff; + + while (i++ < len) + { + if (bufline[j = start % bufsize] != bufline[++start % bufsize]) + bufline[j] = newLine++; + else + bufline[j] = newLine; + } + } + + line = bufline[j]; + column = bufcolumn[j]; + } + boolean getTrackLineColumn() { return trackLineColumn; } + void setTrackLineColumn(boolean tlc) { trackLineColumn = tlc; } + +} +/* JavaCC - OriginalChecksum=5d304ec5a223e239ec5822cefffda3d1 (do not edit this line) */ diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/Modifiers.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/Modifiers.java new file mode 100644 index 0000000000..f13a95cc07 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/Modifiers.java @@ -0,0 +1,110 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.coode.owlapi.obo12.parser; + +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +/** + * Author: Matthew Horridge
+ * The University of Manchester
+ * Bio-Health Informatics Group
+ * Date: 03/02/2011 + */ +class Modifiers { + + private final Map> modifierNameValuesMap = new LinkedHashMap<>(); + + public Modifiers() { + } + + /** + * Parses a list of modifiers. + * + * @param modifiersList The string representation of a list of modifiers. The representation may + * or may not include the surrounding braces (braces will be ignored). + * @return A list of modifiers + */ + public static Modifiers parseModifiers(String modifiersList) { + Modifiers modifiers = new Modifiers(); + for (String s : modifiersList.split(",")) { + String nameValuePair = s.trim(); + String[] split = nameValuePair.split("="); + if (split.length == 2) { + modifiers.addModifier(split[0], split[1]); + } + } + return modifiers; + } + + /** + * Adds a modifier + * + * @param name The modifier name + * @param value The modifier value + */ + public void addModifier(String name, String value) { + Set values = modifierNameValuesMap.get(name); + if (values == null) { + values = new HashSet<>(); + modifierNameValuesMap.put(name, values); + } + values.add(value); + } + + /** + * Returns the names of modifiers stored in this modifier object + * + * @return The names of modifiers (may be empty) + */ + public Set getModifierNames() { + return modifierNameValuesMap.keySet(); + } + + public Set getModifierValues(String modifierName) { + Set valuesToReturn = new HashSet<>(); + Set values = modifierNameValuesMap.get(modifierName); + if (values != null) { + valuesToReturn.addAll(values); + } + return valuesToReturn; + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBO12DocumentFormat.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBO12DocumentFormat.java new file mode 100644 index 0000000000..7aa3fc5253 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBO12DocumentFormat.java @@ -0,0 +1,84 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.coode.owlapi.obo12.parser; + +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLDocumentFormatImpl; + +/** + * Author: Matthew Horridge
+ * The University Of Manchester
+ * Bio-Health Informatics Group
+ * Date: 10-Jan-2007
+ *
+ */ +public class OBO12DocumentFormat extends OWLDocumentFormatImpl implements + OWLDocumentFormat { + + private IDSpaceManager idSpaceManager = new IDSpaceManager(); + + @Override + public String toString() { + return getKey(); + } + + /** + * @param m An {@link IDSpaceManager} which specifies mappings between id prefixes and IRI + * prefixes. + */ + public void setIDSpaceManager(IDSpaceManager m) { + idSpaceManager = m; + } + + /** + * Gets the OBO id-space manager. This is NOT the same as a prefix manager. + * + * @return The {@link IDSpaceManager} for this format. For ontologies parsed from an OBO file + * this will contain any id prefix to IRI prefix mappings that were parsed out of the file (from + * id-space tags). Not null. + */ + public IDSpaceManager getIdSpaceManager() { + return idSpaceManager; + } + + @Override + public String getKey() { + return "OBO 1.2 Format"; + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBO12DocumentFormatFactory.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBO12DocumentFormatFactory.java new file mode 100644 index 0000000000..7db8585b12 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBO12DocumentFormatFactory.java @@ -0,0 +1,23 @@ +package org.coode.owlapi.obo12.parser; + +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.util.OWLDocumentFormatFactoryImpl; + +@SuppressWarnings("javadoc") +public class OBO12DocumentFormatFactory extends OWLDocumentFormatFactoryImpl { + + @Override + public OWLDocumentFormat get() { + return createFormat(); + } + + @Override + public String getKey() { + return "OBO 1.2 Format"; + } + + @Override + public OWLDocumentFormat createFormat() { + return new OBO12DocumentFormat(); + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBO12ParserFactory.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBO12ParserFactory.java new file mode 100644 index 0000000000..dbba7f06b8 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBO12ParserFactory.java @@ -0,0 +1,75 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.coode.owlapi.obo12.parser; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.io.OWLParser; +import org.semanticweb.owlapi.io.OWLParserFactory; +import org.semanticweb.owlapi.model.OWLDocumentFormatFactory; + +/** + * Author: Matthew Horridge
+ * The University Of Manchester
+ * Bio-Health Informatics Group
+ * Date: 10-Jan-2007
+ *
+ */ +public class OBO12ParserFactory implements OWLParserFactory { + + @Override + public OWLParser get() { + return createParser(); + } + + @Override + public @Nullable String getDefaultMIMEType() { + return new OBO12DocumentFormatFactory().getDefaultMIMEType(); + } + + @Override + public OWLParser createParser() { + return new OWLOBO12Parser(); + } + + @Override + public OWLDocumentFormatFactory getSupportedFormat() { + return new OBO12DocumentFormatFactory(); + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOConsumer.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOConsumer.java new file mode 100644 index 0000000000..94334b576c --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOConsumer.java @@ -0,0 +1,555 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.coode.owlapi.obo12.parser; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import java.net.URI; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.AddImport; +import org.semanticweb.owlapi.model.AddOntologyAnnotation; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationValue; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLImportsDeclaration; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.model.SetOntologyID; +import org.semanticweb.owlapi.model.UnloadableImportException; +import org.semanticweb.owlapi.util.CollectionFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Author: Matthew Horridge
+ * The University Of Manchester
+ * Bio-Health Informatics Group
+ * Date: 10-Jan-2007
+ *
+ */ +class OBOConsumer implements OBOParserHandler { + + private static final Logger LOGGER = LoggerFactory.getLogger(OBOConsumer.class.getName()); + private static final String IMPORT_TAG_NAME = "import"; + private static final Pattern XREF_PATTERN = Pattern + .compile("([^\"]*)\\s*(\"((\\\"|[^\"])*)\")?"); + private static final int XREF_ID_GROUP = 1; + private static final int XREF_QUOTED_STRING_GROUP = 3; + private final OWLOntologyLoaderConfiguration configuration; + private final OWLOntologyManager owlOntologyManager; + private final OWLOntology ontology; + private final Map handlerMap = new HashMap<>(); + private final Set intersectionOfOperands; + private final Set unionOfOperands = new HashSet<>(); + private final Map symbolicIdCache = new HashMap<>(); + private final Map tagIRICache = new HashMap<>(); + private final IDSpaceManager idSpaceManager = new IDSpaceManager(); + private boolean inHeader; + @Nullable + private String currentId; + // private String defaultNamespace; + @Nullable + private String defaultNamespaceTagValue = OBOVocabulary.OBO_IRI_BASE; + @Nullable + private String stanzaType; + private boolean termType; + private boolean typedefType; + private boolean instanceType; + private Map uriCache = new HashMap<>(); + private String ontologyTagValue = ""; + private String dataVersionTagValue = ""; + + public OBOConsumer(OWLOntology ontology, OWLOntologyLoaderConfiguration configuration, + IRI baseIRI) { + this.configuration = configuration; + owlOntologyManager = ontology.getOWLOntologyManager(); + this.ontology = ontology; + intersectionOfOperands = new HashSet<>(); + uriCache = new HashMap<>(); + for (OBOVocabulary v : OBOVocabulary.values()) { + tagIRICache.put(v.getName(), v.getIRI()); + } + ontologyTagValue = getDefaultOntologyTagValue(baseIRI); + loadBuiltinURIs(); + setupTagHandlers(); + } + + private static String getDefaultOntologyTagValue(IRI baseIRI) { + URI baseURI = baseIRI.toURI(); + String baseURIPath = baseURI.getPath(); + if (baseURIPath == null) { + return baseIRI.toString(); + } + int lastSlashIndex = baseURIPath.lastIndexOf("/"); + if (lastSlashIndex == -1 || lastSlashIndex + 1 == baseURIPath.length()) { + return baseURIPath; + } + return baseURIPath.substring(lastSlashIndex + 1); + } + + public OWLOntologyManager getOWLOntologyManager() { + return owlOntologyManager; + } + + public OWLOntology getOntology() { + return ontology; + } + + public String getCurrentId() { + return verifyNotNull(currentId); + } + + public void setCurrentId(String currentId) { + this.currentId = currentId; + } + + public void addSymbolicIdMapping(String symbolicName, IRI fullIRI) { + symbolicIdCache.put(symbolicName, fullIRI); + } + + /** + * Gets the default-namespace tag value for the current ontology. If not + * default-namespace tag value has been set explicitly then this method + * returns the default value which is equal to + * {@link OBOVocabulary#OBO_IRI_BASE}. + * + * @return The default-namespace tag value. Not null. + */ + @Nullable + public String getDefaultNamespaceTagValue() { + return defaultNamespaceTagValue; + } + + /** + * Sets the value of the default-namespace tag for the current ontology + * being parsed. + * + * @param defaultNamespaceTagValue The value of the default-namespace tag. + */ + public void setDefaultNamespaceTagValue(String defaultNamespaceTagValue) { + this.defaultNamespaceTagValue = defaultNamespaceTagValue; + } + + /** + * Sets the value of the ontology tag for the current ontology that is being + * parsed. This is used to construct an + * {@link org.semanticweb.owlapi.model.OWLOntologyID} for the current + * ontology once the ontology header has been parsed in its entirety. + * + * @param ontologyTagValue The ontology tag value. Ultimately, this will be translated to an + * IRI. + */ + public void setOntologyTagValue(String ontologyTagValue) { + this.ontologyTagValue = ontologyTagValue; + } + + /** + * Sets the value of the data-version tag for the current ontology that is + * being parsed. This is used to construct an + * {@link org.semanticweb.owlapi.model.OWLOntologyID} for the current + * ontology once the ontology header has been parsed in its entirety. + * + * @param dataVersionTagValue The data-version tag value. Ultimately, this will be translated to + * an IRI. + */ + public void setDataVersionTagValue(String dataVersionTagValue) { + this.dataVersionTagValue = dataVersionTagValue; + } + + public void registerIdSpace(String idSpacePrefix, String iriPrefix) { + idSpaceManager.setIRIPrefix(idSpacePrefix, iriPrefix); + } + + /** + * Gets a COPY of the {@link IDSpaceManager} held by this OBOConsumer. + * + * @return A copy of the IDSpaceManager held by this consumer. + */ + public IDSpaceManager getIdSpaceManager() { + return idSpaceManager; + } + + public void addUnionOfOperand(OWLClassExpression classExpression) { + unionOfOperands.add(classExpression); + } + + public void addIntersectionOfOperand(OWLClassExpression classExpression) { + intersectionOfOperands.add(classExpression); + } + + @Nullable + public String getStanzaType() { + return stanzaType; + } + + public boolean isTerm() { + return termType; + } + + public boolean isTypedef() { + return typedefType; + } + + public boolean isInstanceType() { + return instanceType; + } + + private void loadBuiltinURIs() { + for (OBOVocabulary v : OBOVocabulary.values()) { + uriCache.put(v.getName(), v.getIRI()); + } + } + + private void setupTagHandlers() { + addTagHandler(new OntologyTagValueHandler(this)); + addTagHandler(new IDTagValueHandler(this)); + addTagHandler(new NameTagValueHandler(this)); + addTagHandler(new IsATagValueHandler(this)); + addTagHandler(new PartOfTagValueHandler(this)); + addTagHandler(new TransitiveTagValueHandler(this)); + addTagHandler(new SymmetricTagValueHandler(this)); + addTagHandler(new RelationshipTagValueHandler(this)); + addTagHandler(new UnionOfHandler(this)); + addTagHandler(new IntersectionOfHandler(this)); + addTagHandler(new DisjointFromHandler(this)); + addTagHandler(new AsymmetricHandler(this)); + addTagHandler(new InverseHandler(this)); + addTagHandler(new ReflexiveHandler(this)); + addTagHandler(new TransitiveOverHandler(this)); + addTagHandler(new DefaultNamespaceTagValueHandler(this)); + addTagHandler(new SynonymTagValueHandler(this)); + addTagHandler(new XRefTagHandler(this)); + addTagHandler(new DefTagValueHandler(this)); + addTagHandler(new IsObsoleteTagValueHandler(this)); + addTagHandler(new IDSpaceTagValueHandler(this)); + addTagHandler(new DataVersionTagValueHandler(this)); + addTagHandler(new SynonymTypeDefTagHandler(this)); + addTagHandler(new AltIdTagValueHandler(this)); + } + + private void addTagHandler(TagValueHandler handler) { + handlerMap.put(handler.getTagName(), handler); + } + + @Override + public void startHeader() { + inHeader = true; + } + + @Override + public void endHeader() { + inHeader = false; + setOntologyId(); + } + + /** + * Sets the {@link org.semanticweb.owlapi.model.OWLOntologyID} of the + * ontology being parsed from the tag values held by the + * {@link #ontologyTagValue} and {@link #dataVersionTagValue} field. IRIs + * for each field are generated and used to construct the + * {@link org.semanticweb.owlapi.model.OWLOntologyID}. + */ + private void setOntologyId() { + IRI ontologyIRI = IRI + .create(idSpaceManager.getIRIPrefix(ontologyTagValue), ontologyTagValue); + IRI versionIRI = null; + if (dataVersionTagValue.length() > 0) { + versionIRI = IRI.create(ontologyIRI + "/", dataVersionTagValue); + } + OWLOntologyID ontologyID = new OWLOntologyID(optional(ontologyIRI), optional(versionIRI)); + ontology.getOWLOntologyManager().applyChange(new SetOntologyID(ontology, ontologyID)); + } + + @Override + public void startFrame(@Nullable String name) { + currentId = null; + defaultNamespaceTagValue = null; + stanzaType = name; + termType = OBOVocabulary.TERM.getName().equals(stanzaType); + typedefType = false; + instanceType = false; + if (!termType) { + typedefType = OBOVocabulary.TYPEDEF.getName().equals(stanzaType); + if (!typedefType) { + instanceType = OBOVocabulary.INSTANCE.getName().equals(stanzaType); + } + } + } + + @Override + public void endFrame() { + if (!unionOfOperands.isEmpty()) { + createUnionEquivalentClass(); + unionOfOperands.clear(); + } + if (!intersectionOfOperands.isEmpty()) { + createIntersectionEquivalentClass(); + intersectionOfOperands.clear(); + } + } + + private void createUnionEquivalentClass() { + OWLClassExpression equivalentClass; + if (unionOfOperands.size() == 1) { + equivalentClass = unionOfOperands.iterator().next(); + } else { + equivalentClass = getDataFactory().getOWLObjectUnionOf(unionOfOperands); + } + createEquivalentClass(equivalentClass); + } + + private void createIntersectionEquivalentClass() { + OWLClassExpression equivalentClass; + if (intersectionOfOperands.size() == 1) { + equivalentClass = intersectionOfOperands.iterator().next(); + } else { + equivalentClass = getDataFactory().getOWLObjectIntersectionOf(intersectionOfOperands); + } + createEquivalentClass(equivalentClass); + } + + private void createEquivalentClass(OWLClassExpression classExpression) { + OWLAxiom ax = getDataFactory() + .getOWLEquivalentClassesAxiom(CollectionFactory.createSet(getCurrentClass(), + classExpression)); + getOWLOntologyManager().applyChange(new AddAxiom(ontology, ax)); + } + + @SuppressWarnings("null") + @Override + public void handleTagValue(String tag, String value, String qualifierBlock, String comment) { + try { + TagValueHandler handler = handlerMap.get(tag); + if (handler != null) { + handler.handle(currentId, value, qualifierBlock, comment); + } else if (inHeader) { + if (tag.equals(IMPORT_TAG_NAME)) { + String trim = value.trim(); + IRI uri = IRI.create(trim); + OWLImportsDeclaration decl = owlOntologyManager.getOWLDataFactory() + .getOWLImportsDeclaration(uri); + owlOntologyManager.makeLoadImportRequest(decl, configuration); + owlOntologyManager.applyChange(new AddImport(ontology, decl)); + } else { + // Ontology annotations + OWLLiteral con = getDataFactory().getOWLLiteral(unescapeTagValue(value)); + OWLAnnotationProperty property = getDataFactory() + .getOWLAnnotationProperty(getIRIFromTagName(tag)); + OWLAnnotation anno = getDataFactory().getOWLAnnotation(property, con); + owlOntologyManager.applyChange(new AddOntologyAnnotation(ontology, anno)); + } + } else if (currentId != null) { + // Add as annotation + if (configuration.isLoadAnnotationAxioms()) { + IRI subject = getIRI(currentId); + OWLLiteral con = getDataFactory().getOWLLiteral(unescapeTagValue(value)); + IRI annotationPropertyIRI = getIRIFromTagName(tag); + OWLAnnotationProperty property = getDataFactory() + .getOWLAnnotationProperty(annotationPropertyIRI); + OWLAnnotation anno = getDataFactory().getOWLAnnotation(property, con); + OWLAnnotationAssertionAxiom ax = getDataFactory() + .getOWLAnnotationAssertionAxiom(subject, anno); + owlOntologyManager.addAxiom(ontology, ax); + OWLDeclarationAxiom annotationPropertyDeclaration = getDataFactory() + .getOWLDeclarationAxiom( + property); + owlOntologyManager.addAxiom(ontology, annotationPropertyDeclaration); + } + } + } catch (UnloadableImportException e) { + LOGGER.error(e.getMessage(), e); + } + } + + public String unescapeTagValue(String value) { + String unquoted; + if (value.startsWith("\"") && value.endsWith("\"")) { + unquoted = value.substring(1, value.length() - 1); + } else { + unquoted = value; + } + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < unquoted.length(); i++) { + char ch = unquoted.charAt(i); + if (ch != '\\') { + sb.append(ch); + } + } + return sb.toString(); + } + + private OWLDataFactory getDataFactory() { + return getOWLOntologyManager().getOWLDataFactory(); + } + + @SuppressWarnings("null") + public OWLClass getCurrentClass() { + return getDataFactory().getOWLClass(getIRI(currentId)); + } + + @SuppressWarnings("null") + public OWLEntity getCurrentEntity() { + if (isTerm()) { + return getCurrentClass(); + } else if (isTypedef()) { + // Sometimes, we can have symbolic names e.g. has_part. It's not + // really clear how to tell the difference + IRI propertyIRI = getRelationIRIFromSymbolicIdOrOBOId(currentId); + return getDataFactory().getOWLObjectProperty(propertyIRI); + } else { + return getDataFactory().getOWLNamedIndividual(getIRI(currentId)); + } + } + + /** + * Gets an IRI from a tag name. + * + * @param tagName The tag name. + * @return The IRI for the tag name. For built in tags this is obtained from the {@link + * OBOVocabulary} enum. Not null. + * @throws NullPointerException if tagName is null. + */ + public IRI getIRIFromTagName(String tagName) { + checkNotNull(tagName, "tagName must not be null"); + IRI tagIRI = tagIRICache.get(tagName); + if (tagIRI != null) { + return tagIRI; + } else { + IRI freshTagIRI = IRI.create(OBOVocabulary.OBO_IRI_BASE, tagName); + tagIRICache.put(tagName, freshTagIRI); + return freshTagIRI; + } + } + + /** + * Gets an IRI from an OBO ID. The OBO ID may be a canonical OBO ID of the + * form idspace:sequence or it may be a non-canonical ID. + * + * @param oboId The OBO ID + * @return An IRI obtained from the translation of the OBO ID. + */ + public IRI getIRIFromOBOId(String oboId) { + checkNotNull(oboId, "oboId must not be null."); + return getIRI(oboId); + } + + public IRI getRelationIRIFromSymbolicIdOrOBOId(String symbolicIdOrOBOId) { + IRI fullIRI = symbolicIdCache.get(symbolicIdOrOBOId); + if (fullIRI != null) { + return fullIRI; + } + OBOIdType idType = OBOIdType.getIdType(symbolicIdOrOBOId); + if (idType == null) { + throw new OWLRuntimeException( + "Invalid ID: " + symbolicIdOrOBOId + " in frame " + currentId); + } else { + return idType + .getIRIFromOBOId(ontology.getOntologyID(), idSpaceManager, symbolicIdOrOBOId); + } + } + + private IRI getIRI(String s) { + String trimmed = s.trim(); + IRI iri = uriCache.get(trimmed); + if (iri != null) { + return iri; + } + OWLOntologyID ontologyID = getOntology().getOntologyID(); + OBOIdType type = OBOIdType.getIdType(trimmed); + if (type == null) { + throw new OWLRuntimeException("Not a valid OBO ID: " + s); + } + IRI freshIRI = type.getIRIFromOBOId(ontologyID, idSpaceManager, trimmed); + uriCache.put(trimmed, freshIRI); + return freshIRI; + } + + public OWLAnnotation parseXRef(String xref) { + Matcher matcher = XREF_PATTERN.matcher(xref); + if (matcher.matches()) { + OWLDataFactory df = getDataFactory(); + String xrefQuotedString = matcher.group(XREF_QUOTED_STRING_GROUP); + // the quoted string is a description of the xref. I can't find + // anywhere to put this. + // Just add as a comment for now + @Nonnull Set xrefDescriptions = new HashSet<>(); + if (xrefQuotedString != null) { + xrefDescriptions.add(df.getRDFSComment(xrefQuotedString)); + } + String xrefId = matcher.group(XREF_ID_GROUP).trim(); + OBOIdType idType = OBOIdType.getIdType(xrefId); + OWLAnnotationValue annotationValue; + if (idType != null) { + annotationValue = getIRIFromOBOId(xrefId); + } else { + annotationValue = getDataFactory().getOWLLiteral(xrefId); + } + OWLAnnotationProperty xrefProperty = df + .getOWLAnnotationProperty(OBOVocabulary.XREF.getIRI()); + return df.getOWLAnnotation(xrefProperty, annotationValue, xrefDescriptions); + } else { + OWLDataFactory df = getDataFactory(); + OWLAnnotationProperty xrefProperty = df + .getOWLAnnotationProperty(OBOVocabulary.XREF.getIRI()); + return df.getOWLAnnotation(xrefProperty, df.getOWLLiteral(xref)); + } + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOFrame.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOFrame.java new file mode 100644 index 0000000000..f96250d0e1 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOFrame.java @@ -0,0 +1,83 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, The University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.coode.owlapi.obo12.parser; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import javax.annotation.Nullable; + +/** + * Author: Matthew Horridge
+ * Stanford University
+ * Bio-Medical Informatics Research Group
+ * Date: 19/04/2012 + */ +class OBOFrame { + + private final List tagValuePairs; + @Nullable + private String frameType = null; + + public OBOFrame(List tagValuePairs) { + this.tagValuePairs = tagValuePairs; + } + + public OBOFrame(@Nullable String frameType, List tagValuePairs) { + this.frameType = frameType; + this.tagValuePairs = new ArrayList<>(tagValuePairs); + } + + @Nullable + public String getFrameType() { + return frameType; + } + + public List getTagValuePairs() { + return Collections.unmodifiableList(tagValuePairs); + } + + public boolean isHeaderFrame() { + return frameType == null; + } + + public boolean isTypeDefFrame() { + return OBOVocabulary.TYPEDEF.getName().equals(frameType); + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOIdTranslator.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOIdTranslator.java new file mode 100644 index 0000000000..2aff84a2ad --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOIdTranslator.java @@ -0,0 +1,65 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, The University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.coode.owlapi.obo12.parser; + +import org.semanticweb.owlapi.model.IRI; + +/** + * Author: Matthew Horridge
+ * Stanford University
+ * Bio-Medical Informatics Research Group
+ * Date: 19/04/2012 + */ +@SuppressWarnings("all") +class OBOIdTranslator { + + /** + * @return null + */ + public IRI getIRIFromOBOId(String oboId) { + return null; + } + + /** + * @return null + */ + public String getOBOIdFromIRI() { + return null; + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOIdType.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOIdType.java new file mode 100644 index 0000000000..df8a0c15ad --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOIdType.java @@ -0,0 +1,159 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, The University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.coode.owlapi.obo12.parser; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.annotation.Nullable; + +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntologyID; + +/** + * Author: Matthew Horridge
+ * Stanford University
+ * Bio-Medical Informatics Research Group
+ * Date: 19/04/2012 + *

+ * Describes the types of OBO IDs that can be found in OBO Files. Taken from Section 2.5 of the OBO + * Syntax and Semantics Specification. + *

+ */ +interface OBOIDConstants { + public static final Pattern CANONICAL_PREFIXED_ID_PATTERN = + Pattern.compile("([A-Za-z][A-Za-z_]*):([0-9]*)"); + public static final Pattern NON_CANONICAL_PREFIXED_ID_ID_PATTERN = + Pattern.compile("([^\\s:]*):([^\\s]*)"); + public static final Pattern URL_AS_ID_PATTERN = Pattern.compile("(http:|https:)[^\\s]*"); + public static final Pattern UNPREFIXED_ID_PATTERN = Pattern.compile("[^\\s:]*"); +} + + +@SuppressWarnings("all") +enum OBOIdType implements OBOIDConstants { + //@formatter:off + /** Any string with an http: or https: prefix. */ + URL_AS_ID(URL_AS_ID_PATTERN, (ontologyID, idSpaceManager, id) -> IRI.create(id)), + /** Any unprefixed ID. Does not contain a colon character. The spec implies the empty string matches this ID. */ + UNPREFIXED_ID(UNPREFIXED_ID_PATTERN, (ontologyID, idSpaceManager, id) -> { + String ns; + if (!ontologyID.isAnonymous()) { + ns = ontologyID.getOntologyIRI() + "#"; + } else { + ns = "anonymous#"; + } + return IRI.create(ns, id); + }), + /** + * Must contain a colon character in the ID. The idspace must only + * consist of Alpha-Chars and possibly an underscore. The local id must + * only consist of digits (possibly none). + */ + CANONICAL_PREFIXED_ID(CANONICAL_PREFIXED_ID_PATTERN, (ontologyID, idSpaceManager, id) -> { + Matcher matcher = CANONICAL_PREFIXED_ID_PATTERN.matcher(id); + matcher.matches(); + String idspace = matcher.group(1); + String localid = matcher.group(2); + String iriPrefix = idSpaceManager.getIRIPrefix(idspace); + return IRI.create(iriPrefix, idspace + "_" + localid); + }), + /** + * Must contain a colon character somewhere in the ID. Any kind of + * prefix plus a local Id. The prefix doesn't contain a colon character. + */ + NON_CANONICAL_PREFIXED_ID(NON_CANONICAL_PREFIXED_ID_ID_PATTERN, (ontologyID, idSpaceManager, id) -> { + Matcher matcher = NON_CANONICAL_PREFIXED_ID_ID_PATTERN.matcher(id); + matcher.matches(); + String idspace = matcher.group(1); + String localid = matcher.group(2); + String iriPrefix = idSpaceManager.getIRIPrefix(idspace); + return IRI.create(iriPrefix + idspace + "#", "_" + localid); + }); + //@formatter:on + + private Pattern pattern; + private OBOIIdTranslator translator; + + private OBOIdType(Pattern pattern, OBOIIdTranslator translator) { + this.pattern = pattern; + this.translator = translator; + } + + /** + * Gets the OBOIdType for a given OBO ID. + * + * @param oboId The OBO ID. Must not be null. + * @return The OBOIdType for the specified oboId, or null if the specified oboId + * does not conform to any OBO Id type. + */ + public static @Nullable OBOIdType getIdType(String oboId) { + checkNotNull(oboId, "oboId must not be null"); + for (OBOIdType idType : values()) { + Pattern pattern = idType.getPattern(); + Matcher matcher = pattern.matcher(oboId); + if (matcher.matches()) { + return idType; + } + } + return null; + } + + /** + * @return the pattern + */ + public Pattern getPattern() { + return pattern; + } + + /** + * @return the translated iri + */ + public IRI getIRIFromOBOId(OWLOntologyID ontologyID, IDSpaceManager idSpaceManager, + String oboId) { + return translator.getIRIFromOBOId(ontologyID, idSpaceManager, oboId); + } + + private static interface OBOIIdTranslator { + + IRI getIRIFromOBOId(OWLOntologyID ontologyID, IDSpaceManager idSpaceManager, String id); + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOParser.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOParser.java new file mode 100644 index 0000000000..822824e2a2 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOParser.java @@ -0,0 +1,309 @@ +/* OBOParser.java */ +/* Generated By:JavaCC: Do not edit this line. OBOParser.java */ +package org.coode.owlapi.obo12.parser; + +import org.semanticweb.owlapi.model.*; +import java.net.*; +import java.util.*; + +@SuppressWarnings("all") +public class OBOParser implements OBOParserConstants { + + private OBOParserHandler handler; + + public void setHandler(OBOParserHandler handler) { + this.handler = handler; + } + + final public void parse() throws ParseException { + Header(); + label_1: + while (true) { + Stanza(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case OPEN_SQUARE_BRACKET:{ + ; + break; + } + default: + jj_la1[0] = jj_gen; + break label_1; + } + } + jj_consume_token(0); +} + + final public void Header() throws ParseException { +handler.startHeader(); + label_2: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case TAG_NAME:{ + ; + break; + } + default: + jj_la1[1] = jj_gen; + break label_2; + } + TagValuePair(); + } +handler.endHeader(); +} + + final public void Stanza() throws ParseException {Token t; + jj_consume_token(OPEN_SQUARE_BRACKET); + t = jj_consume_token(STANZA_TYPE); +handler.startFrame(t.image); + jj_consume_token(CLOSE_SQUARE_BRACKET); + label_3: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case TAG_NAME:{ + ; + break; + } + default: + jj_la1[2] = jj_gen; + break label_3; + } + TagValuePair(); + } +handler.endFrame(); +} + + final public void TagValuePair() throws ParseException {Token tagToken = null; + Token valToken = null; + String qualifierBlock = ""; + String comment = ""; + Token t; + StringBuilder sb = new StringBuilder(); + tagToken = jj_consume_token(TAG_NAME); + label_4: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case QUOTED_STRING: + case STRING: + case TAG_VALUE_WS:{ + ; + break; + } + default: + jj_la1[3] = jj_gen; + break label_4; + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case QUOTED_STRING:{ + t = jj_consume_token(QUOTED_STRING); +sb.append(t.image); + break; + } + case STRING:{ + t = jj_consume_token(STRING); +sb.append(t.image); + break; + } + case TAG_VALUE_WS:{ + t = jj_consume_token(TAG_VALUE_WS); +sb.append(t.image); + break; + } + default: + jj_la1[4] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMENT:{ + comment = Comment(); + break; + } + default: + jj_la1[5] = jj_gen; + ; + } +String name = tagToken.image.trim(); + String val = sb.toString().trim(); + // This a real mess. The OBO format allows qualifier blocks at the end of lines. However, things that look + // like qualifier blocks can appear in the middle of values for comment tags. + if(val.endsWith("}")) { + int qualifierStart = val.lastIndexOf("{"); + if(qualifierStart != -1) { + qualifierBlock = val.substring(qualifierStart); + val = val.substring(0, qualifierStart).trim(); + } + } + handler.handleTagValue(name, val, qualifierBlock, comment); +} + + final public String Comment() throws ParseException {Token t; + t = jj_consume_token(COMMENT); +return t.image; +} + + /** Generated Token Manager. */ + public OBOParserTokenManager token_source; + JavaCharStream jj_input_stream; + /** Current token. */ + public Token token; + /** Next token. */ + public Token jj_nt; + private int jj_ntk; + private int jj_gen; + final private int[] jj_la1 = new int[6]; + static private int[] jj_la1_0; + static { + jj_la1_init_0(); + } + private static void jj_la1_init_0() { + jj_la1_0 = new int[] {0x8,0x40,0x40,0x3200,0x3200,0x10000,}; + } + + /** Constructor. */ + public OBOParser(Provider stream) { + jj_input_stream = new JavaCharStream(stream, 1, 1); + token_source = new OBOParserTokenManager(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 6; i++) jj_la1[i] = -1; + } + + /** Constructor. */ + public OBOParser(String dsl) throws ParseException, TokenMgrException { + this(new StringProvider(dsl)); + } + + public void ReInit(String s) { + ReInit(new StringProvider(s)); + } + /** Reinitialise. */ + public void ReInit(Provider stream) { + if (jj_input_stream == null) { + jj_input_stream = new JavaCharStream(stream, 1, 1); + } else { + jj_input_stream.ReInit(stream, 1, 1); + } + if (token_source == null) { + token_source = new OBOParserTokenManager(jj_input_stream); + } + + token_source.ReInit(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 6; i++) jj_la1[i] = -1; + } + + /** Constructor with generated Token Manager. */ + public OBOParser(OBOParserTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 6; i++) jj_la1[i] = -1; + } + + /** Reinitialise. */ + public void ReInit(OBOParserTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 6; i++) jj_la1[i] = -1; + } + + private Token jj_consume_token(int kind) throws ParseException { + Token oldToken; + if ((oldToken = token).next != null) token = token.next; + else token = token.next = token_source.getNextToken(); + jj_ntk = -1; + if (token.kind == kind) { + jj_gen++; + return token; + } + token = oldToken; + jj_kind = kind; + throw generateParseException(); + } + + +/** Get the next Token. */ + final public Token getNextToken() { + if (token.next != null) token = token.next; + else token = token.next = token_source.getNextToken(); + jj_ntk = -1; + jj_gen++; + return token; + } + +/** Get the specific Token. */ + final public Token getToken(int index) { + Token t = token; + for (int i = 0; i < index; i++) { + if (t.next != null) t = t.next; + else t = t.next = token_source.getNextToken(); + } + return t; + } + + private int jj_ntk_f() { + if ((jj_nt=token.next) == null) + return (jj_ntk = (token.next=token_source.getNextToken()).kind); + else + return (jj_ntk = jj_nt.kind); + } + + private java.util.List jj_expentries = new java.util.ArrayList(); + private int[] jj_expentry; + private int jj_kind = -1; + + /** Generate ParseException. */ + public ParseException generateParseException() { + jj_expentries.clear(); + boolean[] la1tokens = new boolean[19]; + if (jj_kind >= 0) { + la1tokens[jj_kind] = true; + jj_kind = -1; + } + for (int i = 0; i < 6; i++) { + if (jj_la1[i] == jj_gen) { + for (int j = 0; j < 32; j++) { + if ((jj_la1_0[i] & (1< } + +///////////////////////////////////////////////////////////////////////////////////// + + SKIP : {} +TOKEN: { : IN_STANZA_HEADER} + TOKEN: {} + TOKEN: { : DEFAULT} +TOKEN: { : IN_TAG_VALUE_PAIR} + SKIP:{ : IN_TAG_VALUE} + SKIP: { : IN_QUOTED_STRING } + TOKEN : { } + SKIP : { + : IN_TAG_VALUE // To allow for malformed files - they do exist! +} + SKIP : { : DEFAULT } + TOKEN: { } + TOKEN : { } + SKIP: { : DEFAULT } + SKIP:{ : IN_COMMENT} + TOKEN:{ } + SKIP :{ : DEFAULT} +TOKEN: { } + +public void parse() : { } { Header()(Stanza())+ } + +void Header() : { } +{ + {handler.startHeader();} + ((TagValuePair())*) + {handler.endHeader();} +} + +void Stanza() : +{ Token t; } +{ + (t={handler.startFrame(t.image);} (TagValuePair())*) + {handler.endFrame();} +} + + +void TagValuePair() : +{ + Token tagToken = null; + Token valToken = null; + String qualifierBlock = ""; + String comment = ""; + Token t; + StringBuilder sb = new StringBuilder(); + +} +{ + tagToken= ((t={sb.append(t.image);} + | t={sb.append(t.image);} + | t={sb.append(t.image);}))* (comment=Comment())? + { + String name = tagToken.image.trim(); + String val = sb.toString().trim(); + // This a real mess. The OBO format allows qualifier blocks at the end of lines. However, things that look + // like qualifier blocks can appear in the middle of values for comment tags. + if(val.endsWith("}")) { + int qualifierStart = val.lastIndexOf("{"); + if(qualifierStart != -1) { + qualifierBlock = val.substring(qualifierStart); + val = val.substring(0, qualifierStart).trim(); + } + } + handler.handleTagValue(name, val, qualifierBlock, comment); + } +} + +String Comment() : { Token t; } { t= {return t.image;} } \ No newline at end of file diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOParserConstants.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOParserConstants.java new file mode 100644 index 0000000000..d051d7cf34 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOParserConstants.java @@ -0,0 +1,84 @@ +/* Generated By:JavaCC: Do not edit this line. OBOParserConstants.java */ +package org.coode.owlapi.obo12.parser; + + +/** + * Token literal values and constants. + * Generated by org.javacc.parser.OtherFilesGen#start() + */ +interface OBOParserConstants { + + /** End of File. */ + int EOF = 0; + /** RegularExpression Id. */ + int LINE_COMMENTED_OUT = 2; + /** RegularExpression Id. */ + int OPEN_SQUARE_BRACKET = 3; + /** RegularExpression Id. */ + int STANZA_TYPE = 4; + /** RegularExpression Id. */ + int CLOSE_SQUARE_BRACKET = 5; + /** RegularExpression Id. */ + int TAG_NAME = 6; + /** RegularExpression Id. */ + int TAG_COLON = 7; + /** RegularExpression Id. */ + int QUOTED_STRING_START = 8; + /** RegularExpression Id. */ + int QUOTED_STRING = 9; + /** RegularExpression Id. */ + int QUOTED_STRING_DBL_QUOTE_TERMINATOR = 10; + /** RegularExpression Id. */ + int QUOTED_STRING_NEW_LINE_TERMINATOR = 11; + /** RegularExpression Id. */ + int STRING = 12; + /** RegularExpression Id. */ + int TAG_VALUE_WS = 13; + /** RegularExpression Id. */ + int TAG_END = 14; + /** RegularExpression Id. */ + int COMMENT_START = 15; + /** RegularExpression Id. */ + int COMMENT = 16; + /** RegularExpression Id. */ + int COMMENT_END = 17; + /** RegularExpression Id. */ + int ERROR = 18; + + /** Lexical state. */ + int DEFAULT = 0; + /** Lexical state. */ + int IN_STANZA_HEADER = 1; + /** Lexical state. */ + int IN_TAG_VALUE_PAIR = 2; + /** Lexical state. */ + int IN_TAG_VALUE = 3; + /** Lexical state. */ + int IN_QUOTED_STRING = 4; + /** Lexical state. */ + int IN_COMMENT = 5; + + /** Literal token values. */ + String[] tokenImage = { + "", + "", + "", + "\"[\"", + "", + "\"]\"", + "", + "", + "\"\\\"\"", + "", + "", + "", + "", + "", + "", + "\"!\"", + "", + "", + "", + }; + +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOParserException.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOParserException.java new file mode 100644 index 0000000000..1917524ff3 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOParserException.java @@ -0,0 +1,63 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.coode.owlapi.obo12.parser; + +import org.semanticweb.owlapi.io.OWLParserException; + +/** + * Author: Matthew Horridge
+ * The University Of Manchester
+ * Bio-Health Informatics Group
+ * Date: 13-Apr-2007
+ *
+ */ +class OBOParserException extends OWLParserException { + + public OBOParserException(String message) { + super(message); + } + + public OBOParserException(String message, Throwable cause) { + super(message, cause); + } + + public OBOParserException(Throwable cause) { + super(cause); + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOParserHandler.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOParserHandler.java new file mode 100644 index 0000000000..3be5d0aa96 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOParserHandler.java @@ -0,0 +1,62 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.coode.owlapi.obo12.parser; + +import javax.annotation.Nullable; + +/** + * Author: Matthew Horridge
+ * The University Of Manchester
+ * Bio-Health Informatics Group
+ * Date: 10-Jan-2007
+ *
+ */ +@SuppressWarnings("javadoc") +public interface OBOParserHandler { + + void startHeader(); + + void endHeader(); + + void startFrame(@Nullable String name); + + void endFrame(); + + void handleTagValue(String tag, String value, String qualifierBlock, String comment); +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOParserTokenManager.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOParserTokenManager.java new file mode 100644 index 0000000000..a800433877 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOParserTokenManager.java @@ -0,0 +1,1036 @@ +/* OBOParserTokenManager.java */ +/* Generated By:JavaCC: Do not edit this line. OBOParserTokenManager.java */ +package org.coode.owlapi.obo12.parser; +import org.semanticweb.owlapi.model.*; +import java.net.*; +import java.util.*; + +/** Token Manager. */ @SuppressWarnings("all") +class OBOParserTokenManager implements OBOParserConstants { + + /** Debug output. */ + public java.io.PrintStream debugStream = System.out; + /** Set debug output. */ + public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } +private int jjMoveStringLiteralDfa0_4() +{ + return jjMoveNfa_4(5, 0); +} +static final long[] jjbitVec0 = { + 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL +}; +static final long[] jjbitVec2 = { + 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL +}; +private int jjMoveNfa_4(int startState, int curPos) +{ + int startsAt = 0; + jjnewStateCnt = 7; + int i = 1; + jjstateSet[0] = startState; + int kind = 0x7fffffff; + for (;;) + { + if (++jjround == 0x7fffffff) + ReInitRounds(); + if (curChar < 64) + { + long l = 1L << curChar; + do + { + switch(jjstateSet[--i]) + { + case 5: + if ((0xfffffffbffffdbffL & l) != 0L) + { + if (kind > 9) + kind = 9; + { jjCheckNAddTwoStates(0, 1); } + } + else if ((0x2400L & l) != 0L) + { + if (kind > 11) + kind = 11; + } + else if (curChar == 34) + { + if (kind > 10) + kind = 10; + } + break; + case 0: + if ((0xfffffffbffffdbffL & l) == 0L) + break; + kind = 9; + { jjCheckNAddTwoStates(0, 1); } + break; + case 2: + if (curChar != 34) + break; + if (kind > 9) + kind = 9; + { jjCheckNAddTwoStates(0, 1); } + break; + case 3: + if (curChar != 10) + break; + if (kind > 9) + kind = 9; + { jjCheckNAddTwoStates(0, 1); } + break; + case 4: + if (curChar != 13) + break; + if (kind > 9) + kind = 9; + { jjCheckNAddTwoStates(0, 1); } + break; + case 6: + if ((0x2400L & l) != 0L && kind > 11) + kind = 11; + break; + default : break; + } + } while(i != startsAt); + } + else if (curChar < 128) + { + long l = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + case 5: + if (kind > 9) + kind = 9; + { jjCheckNAddTwoStates(0, 1); } + if (curChar == 92) + { jjAddStates(0, 2); } + break; + case 0: + if (kind > 9) + kind = 9; + { jjCheckNAddTwoStates(0, 1); } + break; + case 1: + if (curChar == 92) + { jjAddStates(0, 2); } + break; + default : break; + } + } while(i != startsAt); + } + else + { + int hiByte = (curChar >> 8); + int i1 = hiByte >> 6; + long l1 = 1L << (hiByte & 077); + int i2 = (curChar & 0xff) >> 6; + long l2 = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + case 5: + case 0: + if (!jjCanMove_0(hiByte, i1, i2, l1, l2)) + break; + if (kind > 9) + kind = 9; + { jjCheckNAddTwoStates(0, 1); } + break; + default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break; + } + } while(i != startsAt); + } + if (kind != 0x7fffffff) + { + jjmatchedKind = kind; + jjmatchedPos = curPos; + kind = 0x7fffffff; + } + ++curPos; + if ((i = jjnewStateCnt) == (startsAt = 7 - (jjnewStateCnt = startsAt))) + return curPos; + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { return curPos; } + } +} +private final int jjStopStringLiteralDfa_3(int pos, long active0){ + switch (pos) + { + default : + return -1; + } +} +private final int jjStartNfa_3(int pos, long active0){ + return jjMoveNfa_3(jjStopStringLiteralDfa_3(pos, active0), pos + 1); +} +private int jjStopAtPos(int pos, int kind) +{ + jjmatchedKind = kind; + jjmatchedPos = pos; + return pos + 1; +} +private int jjMoveStringLiteralDfa0_3(){ + switch(curChar) + { + case 33: + return jjStopAtPos(0, 15); + case 34: + return jjStartNfaWithStates_3(0, 8, 0); + default : + return jjMoveNfa_3(2, 0); + } +} +private int jjStartNfaWithStates_3(int pos, int kind, int state) +{ + jjmatchedKind = kind; + jjmatchedPos = pos; + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { return pos + 1; } + return jjMoveNfa_3(state, pos + 1); +} +private int jjMoveNfa_3(int startState, int curPos) +{ + int startsAt = 0; + jjnewStateCnt = 3; + int i = 1; + jjstateSet[0] = startState; + int kind = 0x7fffffff; + for (;;) + { + if (++jjround == 0x7fffffff) + ReInitRounds(); + if (curChar < 64) + { + long l = 1L << curChar; + do + { + switch(jjstateSet[--i]) + { + case 2: + if ((0xfffffffcffffd9ffL & l) != 0L) + { + if (kind > 12) + kind = 12; + { jjCheckNAdd(0); } + } + else if ((0x2400L & l) != 0L) + { + if (kind > 14) + kind = 14; + } + else if ((0x100000200L & l) != 0L) + { + if (kind > 13) + kind = 13; + { jjCheckNAdd(1); } + } + break; + case 0: + if ((0xfffffffcffffd9ffL & l) == 0L) + break; + kind = 12; + { jjCheckNAdd(0); } + break; + case 1: + if ((0x100000200L & l) == 0L) + break; + kind = 13; + { jjCheckNAdd(1); } + break; + default : break; + } + } while(i != startsAt); + } + else if (curChar < 128) + { + long l = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + case 2: + case 0: + kind = 12; + { jjCheckNAdd(0); } + break; + default : break; + } + } while(i != startsAt); + } + else + { + int hiByte = (curChar >> 8); + int i1 = hiByte >> 6; + long l1 = 1L << (hiByte & 077); + int i2 = (curChar & 0xff) >> 6; + long l2 = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + case 2: + case 0: + if (!jjCanMove_0(hiByte, i1, i2, l1, l2)) + break; + if (kind > 12) + kind = 12; + { jjCheckNAdd(0); } + break; + default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break; + } + } while(i != startsAt); + } + if (kind != 0x7fffffff) + { + jjmatchedKind = kind; + jjmatchedPos = curPos; + kind = 0x7fffffff; + } + ++curPos; + if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt))) + return curPos; + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { return curPos; } + } +} +private final int jjStopStringLiteralDfa_0(int pos, long active0){ + switch (pos) + { + default : + return -1; + } +} +private final int jjStartNfa_0(int pos, long active0){ + return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); +} +private int jjMoveStringLiteralDfa0_0(){ + switch(curChar) + { + case 91: + return jjStopAtPos(0, 3); + default : + return jjMoveNfa_0(0, 0); + } +} +private int jjMoveNfa_0(int startState, int curPos) +{ + int startsAt = 0; + jjnewStateCnt = 4; + int i = 1; + jjstateSet[0] = startState; + int kind = 0x7fffffff; + for (;;) + { + if (++jjround == 0x7fffffff) + ReInitRounds(); + if (curChar < 64) + { + long l = 1L << curChar; + do + { + switch(jjstateSet[--i]) + { + case 0: + if ((0xfbffffffffffdbffL & l) != 0L) + { + if (kind > 6) + kind = 6; + { jjCheckNAdd(3); } + } + if ((0x100002600L & l) != 0L) + { + if (kind > 1) + kind = 1; + } + else if (curChar == 33) + { + if (kind > 2) + kind = 2; + { jjCheckNAdd(2); } + } + break; + case 1: + if (curChar != 33) + break; + if (kind > 2) + kind = 2; + { jjCheckNAdd(2); } + break; + case 2: + if ((0xffffffffffffdbffL & l) == 0L) + break; + if (kind > 2) + kind = 2; + { jjCheckNAdd(2); } + break; + case 3: + if ((0xfbffffffffffdbffL & l) == 0L) + break; + if (kind > 6) + kind = 6; + { jjCheckNAdd(3); } + break; + default : break; + } + } while(i != startsAt); + } + else if (curChar < 128) + { + long l = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + case 0: + case 3: + if ((0xfffffffff7ffffffL & l) == 0L) + break; + if (kind > 6) + kind = 6; + { jjCheckNAdd(3); } + break; + case 2: + if (kind > 2) + kind = 2; + jjstateSet[jjnewStateCnt++] = 2; + break; + default : break; + } + } while(i != startsAt); + } + else + { + int hiByte = (curChar >> 8); + int i1 = hiByte >> 6; + long l1 = 1L << (hiByte & 077); + int i2 = (curChar & 0xff) >> 6; + long l2 = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + case 0: + case 3: + if (!jjCanMove_0(hiByte, i1, i2, l1, l2)) + break; + if (kind > 6) + kind = 6; + { jjCheckNAdd(3); } + break; + case 2: + if (!jjCanMove_0(hiByte, i1, i2, l1, l2)) + break; + if (kind > 2) + kind = 2; + jjstateSet[jjnewStateCnt++] = 2; + break; + default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break; + } + } while(i != startsAt); + } + if (kind != 0x7fffffff) + { + jjmatchedKind = kind; + jjmatchedPos = curPos; + kind = 0x7fffffff; + } + ++curPos; + if ((i = jjnewStateCnt) == (startsAt = 4 - (jjnewStateCnt = startsAt))) + return curPos; + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { return curPos; } + } +} +private final int jjStopStringLiteralDfa_1(int pos, long active0){ + switch (pos) + { + default : + return -1; + } +} +private final int jjStartNfa_1(int pos, long active0){ + return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0), pos + 1); +} +private int jjMoveStringLiteralDfa0_1(){ + switch(curChar) + { + case 93: + return jjStopAtPos(0, 5); + default : + return jjMoveNfa_1(0, 0); + } +} +private int jjMoveNfa_1(int startState, int curPos) +{ + int startsAt = 0; + jjnewStateCnt = 1; + int i = 1; + jjstateSet[0] = startState; + int kind = 0x7fffffff; + for (;;) + { + if (++jjround == 0x7fffffff) + ReInitRounds(); + if (curChar < 64) + { + long l = 1L << curChar; + do + { + switch(jjstateSet[--i]) + { + case 0: + kind = 4; + jjstateSet[jjnewStateCnt++] = 0; + break; + default : break; + } + } while(i != startsAt); + } + else if (curChar < 128) + { + long l = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + case 0: + if ((0xffffffffdfffffffL & l) == 0L) + break; + kind = 4; + jjstateSet[jjnewStateCnt++] = 0; + break; + default : break; + } + } while(i != startsAt); + } + else + { + int hiByte = (curChar >> 8); + int i1 = hiByte >> 6; + long l1 = 1L << (hiByte & 077); + int i2 = (curChar & 0xff) >> 6; + long l2 = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + case 0: + if (!jjCanMove_0(hiByte, i1, i2, l1, l2)) + break; + if (kind > 4) + kind = 4; + jjstateSet[jjnewStateCnt++] = 0; + break; + default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break; + } + } while(i != startsAt); + } + if (kind != 0x7fffffff) + { + jjmatchedKind = kind; + jjmatchedPos = curPos; + kind = 0x7fffffff; + } + ++curPos; + if ((i = jjnewStateCnt) == (startsAt = 1 - (jjnewStateCnt = startsAt))) + return curPos; + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { return curPos; } + } +} +private int jjMoveStringLiteralDfa0_5() +{ + return jjMoveNfa_5(5, 0); +} +private int jjMoveNfa_5(int startState, int curPos) +{ + int startsAt = 0; + jjnewStateCnt = 5; + int i = 1; + jjstateSet[0] = startState; + int kind = 0x7fffffff; + for (;;) + { + if (++jjround == 0x7fffffff) + ReInitRounds(); + if (curChar < 64) + { + long l = 1L << curChar; + do + { + switch(jjstateSet[--i]) + { + case 5: + if ((0xffffffffffffdbffL & l) != 0L) + { + if (kind > 16) + kind = 16; + { jjCheckNAddTwoStates(0, 1); } + } + else if ((0x2400L & l) != 0L) + { + if (kind > 17) + kind = 17; + { jjCheckNAdd(4); } + } + break; + case 0: + if ((0xffffffffffffdbffL & l) == 0L) + break; + kind = 16; + { jjCheckNAddTwoStates(0, 1); } + break; + case 2: + if (curChar != 10) + break; + if (kind > 16) + kind = 16; + { jjCheckNAddTwoStates(0, 1); } + break; + case 3: + if (curChar != 13) + break; + if (kind > 16) + kind = 16; + { jjCheckNAddTwoStates(0, 1); } + break; + case 4: + if ((0x2400L & l) == 0L) + break; + if (kind > 17) + kind = 17; + { jjCheckNAdd(4); } + break; + default : break; + } + } while(i != startsAt); + } + else if (curChar < 128) + { + long l = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + case 5: + if (kind > 16) + kind = 16; + { jjCheckNAddTwoStates(0, 1); } + if (curChar == 92) + { jjAddStates(3, 4); } + break; + case 0: + if (kind > 16) + kind = 16; + { jjCheckNAddTwoStates(0, 1); } + break; + case 1: + if (curChar == 92) + { jjAddStates(3, 4); } + break; + default : break; + } + } while(i != startsAt); + } + else + { + int hiByte = (curChar >> 8); + int i1 = hiByte >> 6; + long l1 = 1L << (hiByte & 077); + int i2 = (curChar & 0xff) >> 6; + long l2 = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + case 5: + case 0: + if (!jjCanMove_0(hiByte, i1, i2, l1, l2)) + break; + if (kind > 16) + kind = 16; + { jjCheckNAddTwoStates(0, 1); } + break; + default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break; + } + } while(i != startsAt); + } + if (kind != 0x7fffffff) + { + jjmatchedKind = kind; + jjmatchedPos = curPos; + kind = 0x7fffffff; + } + ++curPos; + if ((i = jjnewStateCnt) == (startsAt = 5 - (jjnewStateCnt = startsAt))) + return curPos; + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { return curPos; } + } +} +private int jjMoveStringLiteralDfa0_2() +{ + return jjMoveNfa_2(0, 0); +} +private int jjMoveNfa_2(int startState, int curPos) +{ + int startsAt = 0; + jjnewStateCnt = 2; + int i = 1; + jjstateSet[0] = startState; + int kind = 0x7fffffff; + for (;;) + { + if (++jjround == 0x7fffffff) + ReInitRounds(); + if (curChar < 64) + { + long l = 1L << curChar; + do + { + switch(jjstateSet[--i]) + { + case 0: + if (curChar != 58) + break; + kind = 7; + { jjCheckNAdd(1); } + break; + case 1: + if (curChar != 32) + break; + kind = 7; + { jjCheckNAdd(1); } + break; + default : break; + } + } while(i != startsAt); + } + else if (curChar < 128) + { + long l = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + default : break; + } + } while(i != startsAt); + } + else + { + int hiByte = (curChar >> 8); + int i1 = hiByte >> 6; + long l1 = 1L << (hiByte & 077); + int i2 = (curChar & 0xff) >> 6; + long l2 = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break; + } + } while(i != startsAt); + } + if (kind != 0x7fffffff) + { + jjmatchedKind = kind; + jjmatchedPos = curPos; + kind = 0x7fffffff; + } + ++curPos; + if ((i = jjnewStateCnt) == (startsAt = 2 - (jjnewStateCnt = startsAt))) + return curPos; + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { return curPos; } + } +} + +/** Token literal values. */ +public static final String[] jjstrLiteralImages = { +"", null, null, "\133", null, "\135", null, null, null, null, null, null, null, +null, null, null, null, null, null, }; +protected Token jjFillToken() +{ + final Token t; + final String curTokenImage; + final int beginLine; + final int endLine; + final int beginColumn; + final int endColumn; + String im = jjstrLiteralImages[jjmatchedKind]; + curTokenImage = (im == null) ? input_stream.GetImage() : im; + beginLine = input_stream.getBeginLine(); + beginColumn = input_stream.getBeginColumn(); + endLine = input_stream.getEndLine(); + endColumn = input_stream.getEndColumn(); + t = Token.newToken(jjmatchedKind, curTokenImage); + + t.beginLine = beginLine; + t.endLine = endLine; + t.beginColumn = beginColumn; + t.endColumn = endColumn; + + return t; +} +static final int[] jjnextStates = { + 2, 3, 4, 2, 3, +}; +private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) +{ + switch(hiByte) + { + case 0: + return ((jjbitVec2[i2] & l2) != 0L); + default : + if ((jjbitVec0[i1] & l1) != 0L) + return true; + return false; + } +} + +int curLexState = 0; +int defaultLexState = 0; +int jjnewStateCnt; +int jjround; +int jjmatchedPos; +int jjmatchedKind; + +/** Get the next Token. */ +public Token getNextToken() +{ + Token matchedToken; + int curPos = 0; + + EOFLoop : + for (;;) + { + try + { + curChar = input_stream.BeginToken(); + } + catch(Exception e) + { + jjmatchedKind = 0; + jjmatchedPos = -1; + matchedToken = jjFillToken(); + return matchedToken; + } + + switch(curLexState) + { + case 0: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_0(); + if (jjmatchedPos == 0 && jjmatchedKind > 18) + { + jjmatchedKind = 18; + } + break; + case 1: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_1(); + break; + case 2: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_2(); + break; + case 3: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_3(); + break; + case 4: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_4(); + break; + case 5: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_5(); + break; + } + if (jjmatchedKind != 0x7fffffff) + { + if (jjmatchedPos + 1 < curPos) + input_stream.backup(curPos - jjmatchedPos - 1); + if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) + { + matchedToken = jjFillToken(); + if (jjnewLexState[jjmatchedKind] != -1) + curLexState = jjnewLexState[jjmatchedKind]; + return matchedToken; + } + else + { + if (jjnewLexState[jjmatchedKind] != -1) + curLexState = jjnewLexState[jjmatchedKind]; + continue EOFLoop; + } + } + int error_line = input_stream.getEndLine(); + int error_column = input_stream.getEndColumn(); + String error_after = null; + boolean EOFSeen = false; + try { input_stream.readChar(); input_stream.backup(1); } + catch (java.io.IOException e1) { + EOFSeen = true; + error_after = curPos <= 1 ? "" : input_stream.GetImage(); + if (curChar == '\n' || curChar == '\r') { + error_line++; + error_column = 0; + } + else + error_column++; + } + if (!EOFSeen) { + input_stream.backup(1); + error_after = curPos <= 1 ? "" : input_stream.GetImage(); + } + throw new TokenMgrException(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrException.LEXICAL_ERROR); + } +} + +void SkipLexicalActions(Token matchedToken) +{ + switch(jjmatchedKind) + { + default : + break; + } +} +void MoreLexicalActions() +{ + jjimageLen += (lengthOfMatch = jjmatchedPos + 1); + switch(jjmatchedKind) + { + default : + break; + } +} +void TokenLexicalActions(Token matchedToken) +{ + switch(jjmatchedKind) + { + default : + break; + } +} +private void jjCheckNAdd(int state) +{ + if (jjrounds[state] != jjround) + { + jjstateSet[jjnewStateCnt++] = state; + jjrounds[state] = jjround; + } +} +private void jjAddStates(int start, int end) +{ + do { + jjstateSet[jjnewStateCnt++] = jjnextStates[start]; + } while (start++ != end); +} +private void jjCheckNAddTwoStates(int state1, int state2) +{ + jjCheckNAdd(state1); + jjCheckNAdd(state2); +} + + /** Constructor. */ + public OBOParserTokenManager(JavaCharStream stream){ + + if (JavaCharStream.staticFlag) + throw new RuntimeException("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); + + input_stream = stream; + } + + /** Constructor. */ + public OBOParserTokenManager (JavaCharStream stream, int lexState){ + ReInit(stream); + SwitchTo(lexState); + } + + /** Reinitialise parser. */ + + public void ReInit(JavaCharStream stream) + { + + + jjmatchedPos = + jjnewStateCnt = + 0; + curLexState = defaultLexState; + input_stream = stream; + ReInitRounds(); + } + + private void ReInitRounds() + { + int i; + jjround = 0x80000001; + for (i = 7; i-- > 0;) + jjrounds[i] = 0x80000000; + } + + /** Reinitialise parser. */ + public void ReInit(JavaCharStream stream, int lexState) + + { + ReInit(stream); + SwitchTo(lexState); + } + + /** Switch to specified lex state. */ + public void SwitchTo(int lexState) + { + if (lexState >= 6 || lexState < 0) + throw new TokenMgrException("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrException.INVALID_LEXICAL_STATE); + else + curLexState = lexState; + } + + +/** Lexer state names. */ +public static final String[] lexStateNames = { + "DEFAULT", + "IN_STANZA_HEADER", + "IN_TAG_VALUE_PAIR", + "IN_TAG_VALUE", + "IN_QUOTED_STRING", + "IN_COMMENT", +}; + +/** Lex State array. */ +public static final int[] jjnewLexState = { + -1, -1, -1, 1, -1, 0, 2, 3, 4, -1, 3, 0, -1, -1, 0, 5, -1, 0, -1, +}; +static final long[] jjtoToken = { + 0x53279L, +}; +static final long[] jjtoSkip = { + 0x2cd86L, +}; +static final long[] jjtoSpecial = { + 0x0L, +}; +static final long[] jjtoMore = { + 0x0L, +}; + protected JavaCharStream input_stream; + + private final int[] jjrounds = new int[7]; + private final int[] jjstateSet = new int[2 * 7]; + private final StringBuilder jjimage = new StringBuilder(); + private StringBuilder image = jjimage; + private int jjimageLen; + private int lengthOfMatch; + protected int curChar; +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOPrefix.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOPrefix.java new file mode 100644 index 0000000000..77d0c01214 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOPrefix.java @@ -0,0 +1,73 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, The University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.coode.owlapi.obo12.parser; + +/** + * Author: Matthew Horridge
+ * Stanford University
+ * Bio-Medical Informatics Research Group
+ * Date: 18/04/2012 + */ +public enum OBOPrefix { + /** + * obo prefix + */ + OBO("http://purl.obolibrary.org/obo/"), + /** + * iao prefix + */ + IAO(OBOPrefix.OBO + "IAO_"), + /** + * obo owl prefix + */ + OBO_IN_OWL("http://www.geneontology.org/formats/oboInOwl#"); + + private final String prefix; + + private OBOPrefix(String prefix) { + this.prefix = prefix; + } + + /** + * @return the prefix + */ + public String getPrefix() { + return prefix; + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOTagValuePair.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOTagValuePair.java new file mode 100644 index 0000000000..3b853a33b4 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOTagValuePair.java @@ -0,0 +1,101 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, The University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.coode.owlapi.obo12.parser; + +import javax.annotation.Nonnull; + +/** + * Author: Matthew Horridge
+ * Stanford University
+ * Bio-Medical Informatics Research Group
+ * Date: 19/04/2012 + */ +@SuppressWarnings("all") +class OBOTagValuePair { + + private final @Nonnull + String tagName; + private final @Nonnull + String value; + private final @Nonnull + String qualifier; + private final @Nonnull + String comment; + + /** + * @param tagName + * @param value + * @param qualifier + * @param comment + */ + public OBOTagValuePair(String tagName, String value, String qualifier, String comment) { + this.tagName = tagName; + this.value = value; + this.qualifier = qualifier; + this.comment = comment; + } + + /** + * @return the tag name + */ + public String getTagName() { + return tagName; + } + + /** + * @return the value + */ + public String getValue() { + return value; + } + + /** + * @return the qualifier + */ + public String getQualifier() { + return qualifier; + } + + /** + * @return the comment + */ + public String getComment() { + return comment; + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOVocabulary.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOVocabulary.java new file mode 100644 index 0000000000..1f680c7c04 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OBOVocabulary.java @@ -0,0 +1,300 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.coode.owlapi.obo12.parser; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.vocab.DublinCoreVocabulary; +import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; + +/** + * Author: Matthew Horridge
+ * The University Of Manchester
+ * Bio-Health Informatics Group
+ * Date: 10-Jan-2007
+ *
+ */ +@SuppressWarnings("javadoc") +public enum OBOVocabulary implements HasIRI { + DATA_VERSION("data-version"), + VERSION("version"), + DATE("date", DublinCoreVocabulary.DATE.getIRI()), + SAVED_BY("saved-by"), + AUTO_GENERATED_BY("auto-generated-by"), + ONTOLOGY("ontology"), + SUBSETDEF("subsetdef", OBOPrefix.OBO_IN_OWL, "SubsetProperty"), + IMPORT("import"), + SYNONYM_TYPE_DEF("synonymtypedef", OBOPrefix.OBO_IN_OWL, "SynonymTypeProperty"), + SYNONYM_TYPE("synonym-type", OBOPrefix.OBO_IN_OWL, "hasSynonymType"), + ID_SPACE("id_space"), + DEFAULT_RELATIONSHIP_ID_PREFIX("default-relationship-id-prefix"), + ID_MAPPING("id-mapping"), + REMARK("remark"), + ID("id"), + NAME("name", OWLRDFVocabulary.RDFS_LABEL.getIRI()), + FORMAT_VERSION("format-version"), + TYPEDEF("Typedef"), + ALT_ID("alt_id", OBOPrefix.OBO_IN_OWL, "hasAlternativeId"), + SHORT_HAND("shorthand", OBOPrefix.OBO_IN_OWL, "shorthand"), + ALT_NAME("alt_name"), + NAMESPACE("namespace"), + DEFAULT_NAMESPACE("default-namespace"), + DEF("def"), + COMMENT("comment", OWLRDFVocabulary.RDFS_COMMENT.getIRI()), + SUBSET("subset", OBOPrefix.OBO_IN_OWL, "inSubset"), + SYNONYM("synonym"), + HAS_SCOPE("hasScope", OBOPrefix.OBO_IN_OWL), + RELATED_SYNONYM("relatedSynonym", OBOPrefix.OBO_IN_OWL, "hasRelatedSynonym"), + EXACT_SYNONYM("exactSynonym", OBOPrefix.OBO_IN_OWL, "hasExactSynonym"), + BROAD_SYNONYM("broadSynonym", OBOPrefix.OBO_IN_OWL, "hasBroadSynonym"), + NARROW_SYNONYM("narrowSynonym", OBOPrefix.OBO_IN_OWL, "hasNarrowSynonym"), + XREF("xref", OBOPrefix.OBO_IN_OWL), + XREF_ANALOGUE("xref_analogue"), + XREF_UNKNOWN("xref_unk"), + IS_A("is_a"), + IS_OBSOLETE("is_obsolete", OWLRDFVocabulary.OWL_DEPRECATED.getIRI()), + PART_OF("part_of"), + RELATIONSHIP("relationship"), + REPLACED_BY("replaced_by"), + CONSIDER("consider", OBOPrefix.OBO_IN_OWL, "consider"), + USE_TERM("use_term"), + DOMAIN("domain"), + RANGE("range"), + IS_CYCLIC("is_cyclic"), + IS_TRANSITIVE("is_transitive"), + IS_SYMMETRIC("is_symmetric"), + IS_ASYMMETRIC("is_asymmetric"), + IS_REFLEXIVE("is_reflexive"), + INVERSE("inverse"), + TRANSITIVE_OVER("transitive_over"), + INTERSECTION_OF("intersection_of"), + UNION_OF("union_of"), + DISJOINT_FROM("disjoint_from"), + TERM("Term"), + BUILTIN("builtin"), + IS_METADATA_TAG("is_metadata_tag"), + CARDINALITY("cardinality"), + MAX_CARDINALITY("maxCardinality"), + MIN_CARDINALITY("minCardinality"), + INSTANCE("Instance"), + INSTANCE_OF("instance_of"), + PROPERTY_VALUE("property_value"), + IS_ANONYMOUS("is_anonymous"); + + /** + * @deprecated Use {@link #OBO_IRI_BASE} + */ + @Deprecated + public static final String ONTOLOGY_URI_BASE = "http://purl.org/obo/owl"; + /** + * @deprecated Use {@link #OBO_IRI_BASE} + */ + @Deprecated + public static final String ANNOTATION_URI_BASE = OBOPrefix.OBO_IN_OWL.getPrefix(); + public static final String OBO_IRI_BASE = OBOPrefix.OBO.getPrefix(); + public static final String LEGACY_OBO_IRI_BASE = "http://purl.org/obo/owl/";// + /** + * The pattern for OBO IDs. Specified at + * http://www. + * obofoundry.org/id-policy.shtml + */ + public static final Pattern OBO_ID_PATTERN = Pattern.compile("(([^:]+):)?(.+)"); + private static final String bases = + Pattern.quote(OBO_IRI_BASE) + "|" + Pattern.quote(ONTOLOGY_URI_BASE + "/") + "|" + + Pattern.quote(LEGACY_OBO_IRI_BASE) + "|" + Pattern.quote(ANNOTATION_URI_BASE); + public static final Pattern OBO_IRI_PATTERN = Pattern.compile("(" + bases + ")" + + "(([^\\_]*)\\_)?([A-Za-z0-9\\_\\-]*)"); + private static final IDSpaceManager DEFAULT_ID_SPACE_MANAGER = new IDSpaceManager() { + + @Override + public void setIRIPrefix(String idPrefix, String iriPrefix) { + throw new OWLRuntimeException( + "The default id space manager must not be used for custom prefixes."); + } + }; + private static final List headerTags = Arrays + .asList(FORMAT_VERSION, DATA_VERSION, DATE, SAVED_BY, + AUTO_GENERATED_BY, SUBSETDEF, IMPORT, SYNONYM_TYPE_DEF, ID_SPACE, + DEFAULT_RELATIONSHIP_ID_PREFIX, ID_MAPPING, + REMARK); + private static final List termStanzaTags = Arrays + .asList(ID, NAME, NAMESPACE, ALT_ID, DEF, COMMENT, + SUBSET, SYNONYM, XREF, IS_A, INTERSECTION_OF, UNION_OF, DISJOINT_FROM, RELATIONSHIP, + IS_OBSOLETE, REPLACED_BY, + CONSIDER); + private static final List typeDefStanzaTags = Arrays + .asList(ID, NAME, NAMESPACE, ALT_ID, DEF, + COMMENT, SUBSET, SYNONYM, XREF, DOMAIN, RANGE, IS_ASYMMETRIC, IS_CYCLIC, IS_REFLEXIVE, + IS_SYMMETRIC, + IS_TRANSITIVE, IS_A, INVERSE, TRANSITIVE_OVER, RELATIONSHIP, IS_METADATA_TAG, + IS_OBSOLETE, REPLACED_BY, + CONSIDER); + private static final List instanceStanzaTags = Arrays + .asList(ID, NAME, NAMESPACE, ALT_ID, DEF, + COMMENT, SYNONYM, XREF, INSTANCE_OF, PROPERTY_VALUE, IS_OBSOLETE, REPLACED_BY, + CONSIDER); + private final String name; + private final IRI iri; + + OBOVocabulary(String name) { + this.name = name; + iri = IRI.create(OBOPrefix.OBO.getPrefix(), name); + } + + OBOVocabulary(String name, OBOPrefix prefix) { + this.name = name; + iri = IRI.create(prefix.getPrefix(), name); + } + + OBOVocabulary(String name, OBOPrefix prefix, String localName) { + this.name = name; + iri = IRI.create(prefix.getPrefix(), localName); + } + + OBOVocabulary(String name, IRI iri) { + this.name = name; + this.iri = iri; + } + + /** + * Converts OBO Ids to IRIs. The conversion is defined at + * http://www. + * obofoundry.org/id-policy.shtml + * + * @param oboId The Id to convert + * @return The IRI of the converted Id + */ + public static IRI ID2IRI(String oboId) { + return ID2IRI(oboId, DEFAULT_ID_SPACE_MANAGER); + } + + /** + * Converts OBO Ids to IRIs. The conversion is defined at + * http://www. + * obofoundry.org/id-policy.shtml. + * + * @param oboId The OBO Id to convert. + * @param idSpaceManager An {@link IDSpaceManager} which can be used to customise the IRI + * prefixes used in the conversion. + * @return The IRI of the converted Id. + */ + public static IRI ID2IRI(String oboId, IDSpaceManager idSpaceManager) { + Matcher matcher = OBO_ID_PATTERN.matcher(oboId); + if (matcher.matches()) { + String idSpace = matcher.group(2); + String localId = matcher.group(3); + StringBuilder sb = new StringBuilder(); + String iriPrefix = idSpaceManager.getIRIPrefix(idSpace); + sb.append(iriPrefix); + if (idSpace != null && !idSpace.isEmpty()) { + sb.append(idSpace); + sb.append("_"); + } + sb.append(localId); + return IRI.create(sb.toString()); + } else { + return IRI.create(oboId); + } + } + + // Format of Foundry-compliant URIs + // FOUNDRY_OBO_URI ::= "http://purl.obolibrary.org/obo/" IDSPACE "_" LOCALID + // Format of OBO legacy URIs + // Those are found in documents that were natively authored using the OBO + // format and which were converted using the NCBOoboInOwl script before this + // policy was put in place. + // LEGACY_OBO_URI ::= "http://purl.org/obo/owl/" IDSPACE "#" IDSPACE "_" + // LOCALID + public static String IRI2ID(IRI oboIRI) { + Matcher matcher = OBO_IRI_PATTERN.matcher(oboIRI.toString()); + if (matcher.matches()) { + String idSpace = matcher.group(3); + String localId = matcher.group(4); + StringBuilder sb = new StringBuilder(); + if (idSpace != null) { + sb.append(idSpace); + sb.append(":"); + } + sb.append(localId); + return sb.toString(); + } else { + throw new OWLRuntimeException("Not an OBO IRI"); + } + } + + public static boolean isOBOIRI(IRI oboIRI) { + return OBO_ID_PATTERN.matcher(oboIRI.toString()).matches(); + } + + public static List getHeaderTags() { + return new ArrayList<>(headerTags); + } + + public static List getTermStanzaTags() { + return new ArrayList<>(termStanzaTags); + } + + public static List getTypeDefStanzaTags() { + return new ArrayList<>(typeDefStanzaTags); + } + + public static List getInstanceStanzaTags() { + return new ArrayList<>(instanceStanzaTags); + } + + public String getName() { + return name; + } + + @Override + public IRI getIRI() { + return iri; + } + + @Override + public String toString() { + return name; + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OWLOBO12Parser.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OWLOBO12Parser.java new file mode 100644 index 0000000000..9696353ad2 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/OWLOBO12Parser.java @@ -0,0 +1,143 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.coode.owlapi.obo12.parser; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import java.io.IOException; +import java.io.Reader; +import java.util.List; +import org.semanticweb.owlapi.io.AbstractOWLParser; +import org.semanticweb.owlapi.io.DocumentSources; +import org.semanticweb.owlapi.io.OWLOntologyDocumentSource; +import org.semanticweb.owlapi.io.OWLOntologyInputSourceException; +import org.semanticweb.owlapi.io.OWLParserException; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLDocumentFormatFactory; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyAlreadyExistsException; +import org.semanticweb.owlapi.model.OWLOntologyChangeException; +import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration; +import org.semanticweb.owlapi.model.UnloadableImportException; + +/** + * Author: Matthew Horridge
+ * The University Of Manchester
+ * Bio-Health Informatics Group
+ * Date: 10-Jan-2007
+ *
+ */ +class OWLOBO12Parser extends AbstractOWLParser { + + private static void parseFrames(RawFrameHandler rawFrameHandler, OBOConsumer oboConsumer) { + parseHeaderFrame(rawFrameHandler, oboConsumer); + parseFrames(oboConsumer, rawFrameHandler.getTypeDefFrames()); + parseFrames(oboConsumer, rawFrameHandler.getNonTypeDefFrames()); + } + + private static void parseHeaderFrame(RawFrameHandler rawFrameHandler, OBOConsumer consumer) { + consumer.startHeader(); + parseFrameTagValuePairs(consumer, verifyNotNull(rawFrameHandler.getHeaderFrame())); + consumer.endHeader(); + } + + private static void parseFrames(OBOConsumer oboConsumer, List frames) { + for (OBOFrame frame : frames) { + parseFrame(oboConsumer, frame); + } + } + + private static void parseFrame(OBOConsumer oboConsumer, OBOFrame frame) { + oboConsumer.startFrame(frame.getFrameType()); + parseFrameTagValuePairs(oboConsumer, frame); + oboConsumer.endFrame(); + } + + private static void parseFrameTagValuePairs(OBOConsumer oboConsumer, OBOFrame frame) { + for (OBOTagValuePair tagValuePair : frame.getTagValuePairs()) { + oboConsumer.handleTagValue(tagValuePair.getTagName(), tagValuePair.getValue(), + tagValuePair.getQualifier(), + tagValuePair.getComment()); + } + } + + @Override + public OWLDocumentFormat parse(OWLOntologyDocumentSource source, OWLOntology ontology, + OWLOntologyLoaderConfiguration config) { + RawFrameHandler rawFrameHandler = new RawFrameHandler(); + OBOConsumer oboConsumer = new OBOConsumer(ontology, config, source.getDocumentIRI()); + try (Reader r = DocumentSources.wrapInputAsReader(source, config)) { + OBOParser parser = new OBOParser(new StreamProvider(r)); + parser.setHandler(rawFrameHandler); + parser.parse(); + parseFrames(rawFrameHandler, oboConsumer); + } catch (ParseException e) { + if (e.getCause() != null && e.getCause() instanceof OWLOntologyChangeException) { + throw (OWLOntologyChangeException) e.getCause(); + } + if (e.getCause() != null && e.getCause() instanceof OWLOntologyAlreadyExistsException) { + OWLOntologyAlreadyExistsException ex = (OWLOntologyAlreadyExistsException) e + .getCause(); + IRI importedOntologyIRI = ex.getOntologyID().getOntologyIRI().get(); + throw new UnloadableImportException(ex, + ontology.getOWLOntologyManager().getOWLDataFactory() + .getOWLImportsDeclaration(importedOntologyIRI)); + } + Token currentToken = e.currentToken; + if (currentToken != null) { + int beginLine = currentToken.beginLine; + int beginColumn = currentToken.beginColumn; + throw new OWLParserException(e, beginLine, beginColumn); + } else { + throw new OWLParserException(e); + } + } catch (TokenMgrError | OWLOntologyInputSourceException | IOException e) { + throw new OWLParserException(e); + } + OBO12DocumentFormat format = new OBO12DocumentFormat(); + format.setIDSpaceManager(oboConsumer.getIdSpaceManager()); + return format; + } + + @Override + public OWLDocumentFormatFactory getSupportedFormat() { + return new OBO12DocumentFormatFactory(); + } +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/ParseException.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/ParseException.java new file mode 100644 index 0000000000..c6f88b9c39 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/ParseException.java @@ -0,0 +1,216 @@ +/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 7.0 */ +/* JavaCCOptions:KEEP_LINE_COLUMN=true */ +package org.coode.owlapi.obo12.parser; + +/** + * This exception is thrown when parse errors are encountered. + * You can explicitly create objects of this exception type by + * calling the method generateParseException in the generated + * parser. + * + * You can modify this class to customize your error reporting + * mechanisms so long as you retain the public fields. + */ +@SuppressWarnings("all") + class ParseException extends org.semanticweb.owlapi.io.OWLParserException { + + /** + * The version identifier for this Serializable class. + * Increment only if the serialized form of the + * class changes. + */ + private static final long serialVersionUID = 1L; + + private static final String INDENT = " "; + + /** + * The end of line string (we do not use System.getProperty("") so that we are compatible with Android/GWT); + */ + protected static String EOL = "\n"; + + + public ParseException(Token currentTokenVal, + int[][] expectedTokenSequencesVal, + String[] tokenImageVal + ) + { + this (currentTokenVal, expectedTokenSequencesVal, tokenImageVal, null); + } + + + /** + * This constructor is used by the method "generateParseException" + * in the generated parser. Calling this constructor generates + * a new object of this type with the fields "currentToken", + * "expectedTokenSequences", and "tokenImage" set. + */ + public ParseException(Token currentTokenVal, + int[][] expectedTokenSequencesVal, + String[] tokenImageVal, + String lexicalStateName + ) + { + super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal, lexicalStateName)); + currentToken = currentTokenVal; + expectedTokenSequences = expectedTokenSequencesVal; + tokenImage = tokenImageVal; + } + + /** + * The following constructors are for use by you for whatever + * purpose you can think of. Constructing the exception in this + * manner makes the exception behave in the normal way - i.e., as + * documented in the class "Throwable". The fields "errorToken", + * "expectedTokenSequences", and "tokenImage" do not contain + * relevant information. The JavaCC generated code does not use + * these constructors. + */ + + public ParseException() { + super(); + } + + /** Constructor with message. */ + public ParseException(String message) { + super(message); + } + + + /** + * This is the last token that has been consumed successfully. If + * this object has been created due to a parse error, the token + * followng this token will (therefore) be the first error token. + */ + public Token currentToken; + + /** + * Each entry in this array is an array of integers. Each array + * of integers represents a sequence of tokens (by their ordinal + * values) that is expected at this point of the parse. + */ + public int[][] expectedTokenSequences; + + /** + * This is a reference to the "tokenImage" array of the generated + * parser within which the parse error occurred. This array is + * defined in the generated ...Constants interface. + */ + public String[] tokenImage; + + /** + * It uses "currentToken" and "expectedTokenSequences" to generate a parse + * error message and returns it. If this object has been created + * due to a parse error, and you do not catch it (it gets thrown + * from the parser) the correct error message + * gets displayed. + */ + private static String initialise(Token currentToken, + int[][] expectedTokenSequences, + String[] tokenImage, + String lexicalStateName) { + StringBuilder sb = new StringBuilder(); + StringBuffer expected = new StringBuffer(); + + int maxSize = 0; + java.util.TreeSet sortedOptions = new java.util.TreeSet(); + for (int i = 0; i < expectedTokenSequences.length; i++) { + if (maxSize < expectedTokenSequences[i].length) { + maxSize = expectedTokenSequences[i].length; + } + for (int j = 0; j < expectedTokenSequences[i].length; j++) { + sortedOptions.add(tokenImage[expectedTokenSequences[i][j]]); + } + } + + for (String option : sortedOptions) { + expected.append(INDENT).append(option).append(EOL); + } + + sb.append("Encountered unexpected token:"); + + Token tok = currentToken.next; + for (int i = 0; i < maxSize; i++) { + String tokenText = tok.image; + String escapedTokenText = add_escapes(tokenText); + if (i != 0) { + sb.append(" "); + } + if (tok.kind == 0) { + sb.append(tokenImage[0]); + break; + } + sb.append(" \""); + sb.append(escapedTokenText); + sb.append("\""); + sb.append(" " + tokenImage[tok.kind]); + tok = tok.next; + } + sb.append(EOL).append(INDENT).append("at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn); + sb.append(".").append(EOL); + + if (expectedTokenSequences.length == 0) { + // Nothing to add here + } else { + int numExpectedTokens = expectedTokenSequences.length; + sb.append(EOL).append("Was expecting"+ (numExpectedTokens == 1 ? ":" : " one of:") + EOL + EOL); + sb.append(expected.toString()); + } + // 2013/07/30 --> Seems to be inaccurate as represents the readahead state, not the lexical state BEFORE the unknown token +// if (lexicalStateName != null) { +// sb.append(EOL).append("** Lexical State : ").append(lexicalStateName).append(EOL).append(EOL); +// } + + return sb.toString(); + } + + + /** + * Used to convert raw characters to their escaped version + * when these raw version cannot be used as part of an ASCII + * string literal. + */ + static String add_escapes(String str) { + StringBuffer retval = new StringBuffer(); + char ch; + for (int i = 0; i < str.length(); i++) { + switch (str.charAt(i)) + { + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u" + s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + continue; + } + } + return retval.toString(); + } + +} +/* JavaCC - OriginalChecksum=c99902cc38ccb3acc249d8b828ae78d5 (do not edit this line) */ diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/Provider.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/Provider.java new file mode 100644 index 0000000000..a636c10a64 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/Provider.java @@ -0,0 +1,26 @@ +/* Generated By:JavaCC: Do not edit this line. Provider.java Version 7.0 */ +/* JavaCCOptions:KEEP_LINE_COLUMN=true */ +package org.coode.owlapi.obo12.parser; + + +import java.io.IOException; +@SuppressWarnings("all") +interface Provider { + /** + * Reads characters into an array + * @param buffer Destination buffer + * @param offset Offset at which to start storing characters + * @param length The maximum possible number of characters to read + * @return The number of characters read, or -1 if all read + * @exception IOException + */ + int read(char buffer[], int offset, int length) throws IOException; + + /** + * Closes the stream and releases any system resources associated with + * it. + * @exception IOException + */ + void close() throws IOException; +} +/* JavaCC - OriginalChecksum=79549555636a80f34c8f3c69d5c2f8aa (do not edit this line) */ diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/StreamProvider.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/StreamProvider.java new file mode 100644 index 0000000000..58a3f908da --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/StreamProvider.java @@ -0,0 +1,59 @@ +/* Generated By:JavaCC: Do not edit this line. StreamProvider.java Version 7.0 */ +/* JavaCCOptions:KEEP_LINE_COLUMN=true */ +package org.coode.owlapi.obo12.parser; + + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; + +/** + * NOTE : This generated class can be safely deleted if installing in a GWT installation (use StringProvider instead) + */ +@SuppressWarnings("all") +class StreamProvider implements Provider { + + Reader _reader; + + public StreamProvider(Reader reader) { + _reader = reader; + } + + public StreamProvider(InputStream stream) throws IOException { + _reader = new BufferedReader(new InputStreamReader(stream)); + } + + public StreamProvider(InputStream stream, String charsetName) throws IOException { + _reader = new BufferedReader(new InputStreamReader(stream, charsetName)); + } + + @Override + public int read(char[] buffer, int off, int len) throws IOException { + int result = _reader.read(buffer, off, len); + + /* CBA -- Added 2014/03/29 -- + This logic allows the generated Java code to be easily translated to C# (via sharpen) - + as in C# 0 represents end of file, and in Java, -1 represents end of file + See : http://msdn.microsoft.com/en-us/library/9kstw824(v=vs.110).aspx + ** Technically, this is not required for java but the overhead is extremely low compared to the code generation benefits. + */ + + if (result == 0) { + if (off < buffer.length && len > 0) { + result = -1; + } + } + + return result; + } + + @Override + public void close() throws IOException { + _reader.close(); + } + +} + +/* JavaCC - OriginalChecksum=b4de1c904d41de47f8f28276e202d4f3 (do not edit this line) */ diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/StringProvider.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/StringProvider.java new file mode 100644 index 0000000000..928bc84bda --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/StringProvider.java @@ -0,0 +1,48 @@ +/* Generated By:JavaCC: Do not edit this line. StringProvider.java Version 7.0 */ +/* JavaCCOptions:KEEP_LINE_COLUMN=true */ +package org.coode.owlapi.obo12.parser; + + + import java.io.IOException; + @SuppressWarnings("all") + class StringProvider implements Provider { + + String _string; + int _position = 0; + int _size; + + public StringProvider(String string) { + _string = string; + _size = string.length(); + } + + @Override + public int read(char[] cbuf, int off, int len) throws IOException { + int numCharsOutstandingInString = _size - _position; + + if (numCharsOutstandingInString == 0) { + return -1; + } + + int numBytesInBuffer = cbuf.length; + int numBytesToRead = numBytesInBuffer -off; + numBytesToRead = numBytesToRead > len ? len : numBytesToRead; + + if (numBytesToRead > numCharsOutstandingInString) { + numBytesToRead = numCharsOutstandingInString; + } + + _string.getChars(_position, _position + numBytesToRead, cbuf, off); + + _position += numBytesToRead; + + return numBytesToRead; + } + + @Override + public void close() throws IOException { + _string = null; + } + + } +/* JavaCC - OriginalChecksum=ffa145984f2540a8f8f15dba547986d4 (do not edit this line) */ diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/SynonymScope.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/SynonymScope.java new file mode 100644 index 0000000000..d1d6ffc55b --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/SynonymScope.java @@ -0,0 +1,64 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, The University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.coode.owlapi.obo12.parser; + +/** + * Author: Matthew Horridge
+ * Stanford University
+ * Bio-Medical Informatics Research Group
+ * Date: 18/04/2012 + */ +public enum SynonymScope { + /** + * exact synonym + */ + EXACT, + /** + * less specific + */ + BROAD, + /** + * more specific + */ + NARROW, + /** + * related + */ + RELATED +} diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/Token.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/Token.java new file mode 100644 index 0000000000..61fec218e4 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/Token.java @@ -0,0 +1,132 @@ +/* Generated By:JavaCC: Do not edit this line. Token.java Version 7.0 */ +/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COLUMN=true,SUPPORT_CLASS_VISIBILITY_PUBLIC=false */ +package org.coode.owlapi.obo12.parser; + +/** + * Describes the input token stream. + */ +@SuppressWarnings("all") +class Token implements java.io.Serializable { + + /** + * The version identifier for this Serializable class. + * Increment only if the serialized form of the + * class changes. + */ + private static final long serialVersionUID = 1L; + + /** + * An integer that describes the kind of this token. This numbering + * system is determined by JavaCCParser, and a table of these numbers is + * stored in the file ...Constants.java. + */ + public int kind; + + /** The line number of the first character of this Token. */ + public int beginLine; + /** The column number of the first character of this Token. */ + public int beginColumn; + /** The line number of the last character of this Token. */ + public int endLine; + /** The column number of the last character of this Token. */ + public int endColumn; + + /** + * The string image of the token. + */ + public String image; + + /** + * A reference to the next regular (non-special) token from the input + * stream. If this is the last token from the input stream, or if the + * token manager has not read tokens beyond this one, this field is + * set to null. This is true only if this token is also a regular + * token. Otherwise, see below for a description of the contents of + * this field. + */ + public Token next; + + /** + * This field is used to access special tokens that occur prior to this + * token, but after the immediately preceding regular (non-special) token. + * If there are no such special tokens, this field is set to null. + * When there are more than one such special token, this field refers + * to the last of these special tokens, which in turn refers to the next + * previous special token through its specialToken field, and so on + * until the first special token (whose specialToken field is null). + * The next fields of special tokens refer to other special tokens that + * immediately follow it (without an intervening regular token). If there + * is no such token, this field is null. + */ + public Token specialToken; + + /** + * An optional attribute value of the Token. + * Tokens which are not used as syntactic sugar will often contain + * meaningful values that will be used later on by the compiler or + * interpreter. This attribute value is often different from the image. + * Any subclass of Token that actually wants to return a non-null value can + * override this method as appropriate. + */ + public Object getValue() { + return null; + } + + /** + * No-argument constructor + */ + public Token() {} + + /** + * Constructs a new token for the specified Image. + */ + public Token(int kind) + { + this(kind, null); + } + + /** + * Constructs a new token for the specified Image and Kind. + */ + public Token(int kind, String image) + { + this.kind = kind; + this.image = image; + } + + /** + * Returns the image. + */ + @Override + public String toString() + { + return image; + } + + /** + * Returns a new Token object, by default. However, if you want, you + * can create and return subclass objects based on the value of ofKind. + * Simply add the cases to the switch for all those special cases. + * For example, if you have a subclass of Token called IDToken that + * you want to create if ofKind is ID, simply add something like : + * + * case MyParserConstants.ID : return new IDToken(ofKind, image); + * + * to the following switch statement. Then you can cast matchedToken + * variable to the appropriate type and use sit in your lexical actions. + */ + public static Token newToken(int ofKind, String image) + { + switch(ofKind) + { + default : return new Token(ofKind, image); + } + } + + public static Token newToken(int ofKind) + { + return newToken(ofKind, null); + } + +} +/* JavaCC - OriginalChecksum=a8a8b4e040521f5cca8cf8428ebd4df6 (do not edit this line) */ diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/TokenMgrError.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/TokenMgrError.java new file mode 100644 index 0000000000..67a8916fda --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/TokenMgrError.java @@ -0,0 +1,189 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, The University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */ +/* JavaCCOptions: */ +package org.coode.owlapi.obo12.parser; + +import org.semanticweb.owlapi.model.OWLRuntimeException; + +/** + * Token Manager Error. + */ +@SuppressWarnings("javadoc") +class TokenMgrError extends OWLRuntimeException { + + /* + * Ordinals for various reasons why an Error of this type can be thrown. + */ + /** + * Lexical error occurred. + */ + static final int LEXICAL_ERROR = 0; + /** + * An attempt was made to create a second instance of a static token + * manager. + */ + static final int STATIC_LEXER_ERROR = 1; + /** + * Tried to change to an invalid lexical state. + */ + static final int INVALID_LEXICAL_STATE = 2; + /** + * Detected (and bailed out of) an infinite loop in the token manager. + */ + static final int LOOP_DETECTED = 3; + /** + * Indicates the reason why the exception is thrown. It will have one of the + * above 4 values. + */ + int errorCode; + + /** + * No arg constructor. + */ + public TokenMgrError() { + } + + /** + * Constructor with message and reason. + */ + public TokenMgrError(String message, int reason) { + super(message); + errorCode = reason; + } + + /** + * Full Constructor. + */ + public TokenMgrError(boolean EOFSeen, int errorLine, int errorColumn, + String errorAfter, char curChar, int reason) { + this( + LexicalError(EOFSeen, errorLine, errorColumn, errorAfter, + curChar), reason); + } + + /* + * Constructors of various flavors follow. + */ + + /** + * Replaces unprintable characters by their escaped (or unicode escaped) + * equivalents in the given string + */ + protected static final String addEscapes(String str) { + StringBuffer retval = new StringBuffer(); + char ch; + for (int i = 0; i < str.length(); i++) { + switch (str.charAt(i)) { + case 0: + continue; + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u" + + s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + continue; + } + } + return retval.toString(); + } + + /** + * Returns a detailed message for the Error when it is thrown by the token + * manager to indicate a lexical error. Parameters : EOFSeen : indicates if + * EOF caused the lexical error curLexState : lexical state in which this + * error occurred errorLine : line number when the error occurred + * errorColumn : column number when the error occurred errorAfter : prefix + * that was seen before this error occurred curchar : the offending + * character Note: You can customize the lexical error message by modifying + * this method. + */ + protected static String LexicalError(boolean EOFSeen, int errorLine, + int errorColumn, String errorAfter, char curChar) { + return "Lexical error at line " + + errorLine + + ", column " + + errorColumn + + ". Encountered: " + + (EOFSeen ? " " : "\"" + + addEscapes(String.valueOf(curChar)) + "\"" + " (" + + (int) curChar + "), ") + "after : \"" + + addEscapes(errorAfter) + "\""; + } + + /** + * You can also modify the body of this method to customize your error + * messages. For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE + * are not of end-users concern, so you can return something like : + * "Internal Error : Please file a bug report .... " from this method for + * such cases in the release version of your parser. + */ + @Override + public String getMessage() { + return super.getMessage(); + } +} +/* JavaCC - OriginalChecksum=859631795247d8e08a6fc52abe1a8c01 (do not edit this line) */ diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/TokenMgrException.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/TokenMgrException.java new file mode 100644 index 0000000000..e15235946b --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/TokenMgrException.java @@ -0,0 +1,147 @@ +/* Generated By:JavaCC: Do not edit this line. TokenMgrException.java Version 7.0 */ +/* JavaCCOptions: */ +package org.coode.owlapi.obo12.parser; + +@SuppressWarnings("all") +class TokenMgrException extends org.semanticweb.owlapi.io.OWLParserException +{ + + /** + * The version identifier for this Serializable class. + * Increment only if the serialized form of the + * class changes. + */ + private static final long serialVersionUID = 1L; + + /* + * Ordinals for various reasons why an Error of this type can be thrown. + */ + + /** + * Lexical error occurred. + */ + public static final int LEXICAL_ERROR = 0; + + /** + * An attempt was made to create a second instance of a static token manager. + */ + public static final int STATIC_LEXER_ERROR = 1; + + /** + * Tried to change to an invalid lexical state. + */ + public static final int INVALID_LEXICAL_STATE = 2; + + /** + * Detected (and bailed out of) an infinite loop in the token manager. + */ + public static final int LOOP_DETECTED = 3; + + /** + * Indicates the reason why the exception is thrown. It will have + * one of the above 4 values. + */ + int errorCode; + + /** + * Replaces unprintable characters by their escaped (or unicode escaped) + * equivalents in the given string + */ + protected static final String addEscapes(String str) { + StringBuffer retval = new StringBuffer(); + char ch; + for (int i = 0; i < str.length(); i++) { + switch (str.charAt(i)) + { + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u" + s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + continue; + } + } + return retval.toString(); + } + + /** + * Returns a detailed message for the Error when it is thrown by the + * token manager to indicate a lexical error. + * Parameters : + * EOFSeen : indicates if EOF caused the lexical error + * curLexState : lexical state in which this error occurred + * errorLine : line number when the error occurred + * errorColumn : column number when the error occurred + * errorAfter : prefix that was seen before this error occurred + * curchar : the offending character + * Note: You can customize the lexical error message by modifying this method. + */ + protected static String LexicalErr(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar) { + char curChar1 = (char)curChar; + return("Lexical error at line " + + errorLine + ", column " + + errorColumn + ". Encountered: " + + (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar1)) + "\"") + " (" + curChar + "), ") + + "after : \"" + addEscapes(errorAfter) + "\""); + } + + /** + * You can also modify the body of this method to customize your error messages. + * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not + * of end-users concern, so you can return something like : + * + * "Internal Error : Please file a bug report .... " + * + * from this method for such cases in the release version of your parser. + */ + @Override + public String getMessage() { + return super.getMessage(); + } + + /* + * Constructors of various flavors follow. + */ + + /** No arg constructor. */ + public TokenMgrException() { + } + + /** Constructor with message and reason. */ + public TokenMgrException(String message, int reason) { + super(message); + errorCode = reason; + } + + /** Full Constructor. */ + public TokenMgrException(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar, int reason) { + this(LexicalErr(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); + } +} +/* JavaCC - OriginalChecksum=c9425ea9a55b7552cb4ed7f86332fdb8 (do not edit this line) */ diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/package-info.java b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/package-info.java new file mode 100644 index 0000000000..d736aafdab --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * obo 1.2 compatibility package. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.coode.owlapi.obo12.parser; diff --git a/compatibility/src/main/java/org/coode/owlapi/obo12/parser/packageinfo b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/packageinfo new file mode 100644 index 0000000000..992045e711 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/obo12/parser/packageinfo @@ -0,0 +1 @@ +version 6.0.0 diff --git a/compatibility/src/main/java/org/coode/owlapi/turtle/TurtleOntologyFormat.java b/compatibility/src/main/java/org/coode/owlapi/turtle/TurtleOntologyFormat.java new file mode 100644 index 0000000000..69062b6d7f --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/turtle/TurtleOntologyFormat.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.coode.owlapi.turtle; + +import org.semanticweb.owlapi.vocab.PrefixOWLOntologyFormat; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group, Date: + * 26-Jan-2008 + * @deprecated use {@link org.semanticweb.owlapi.formats.TurtleDocumentFormat} + */ +@Deprecated +public class TurtleOntologyFormat extends + org.semanticweb.owlapi.formats.TurtleDocumentFormat implements + PrefixOWLOntologyFormat { + +} diff --git a/compatibility/src/main/java/org/coode/owlapi/turtle/packageinfo b/compatibility/src/main/java/org/coode/owlapi/turtle/packageinfo new file mode 100644 index 0000000000..3e36a90ba1 --- /dev/null +++ b/compatibility/src/main/java/org/coode/owlapi/turtle/packageinfo @@ -0,0 +1 @@ +version 5.0.1 diff --git a/compatibility/src/main/java/org/obolibrary/owl/LabelFunctionalFormat.java b/compatibility/src/main/java/org/obolibrary/owl/LabelFunctionalFormat.java new file mode 100644 index 0000000000..60970bab88 --- /dev/null +++ b/compatibility/src/main/java/org/obolibrary/owl/LabelFunctionalFormat.java @@ -0,0 +1,18 @@ +package org.obolibrary.owl; + +import org.semanticweb.owlapi.model.OWLOntologyFormat; + +/** + * Format for serializing an OWL ontology in a functional syntax format and + * labels instead of identifiers. WARNING: This will produce a file, which + * cannot be read with the OWL-API. This is only intended to be used as basis + * for human readable version version control diffs. + * + * @deprecated use {@link org.semanticweb.owlapi.formats.LabelFunctionalDocumentFormat} + */ +@Deprecated +public class LabelFunctionalFormat extends + org.semanticweb.owlapi.formats.LabelFunctionalDocumentFormat implements + OWLOntologyFormat { + +} diff --git a/compatibility/src/main/java/org/obolibrary/owl/packageinfo b/compatibility/src/main/java/org/obolibrary/owl/packageinfo new file mode 100644 index 0000000000..3e36a90ba1 --- /dev/null +++ b/compatibility/src/main/java/org/obolibrary/owl/packageinfo @@ -0,0 +1 @@ +version 5.0.1 diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/expression/ParserException.java b/compatibility/src/main/java/org/semanticweb/owlapi/expression/ParserException.java new file mode 100644 index 0000000000..f109e2262b --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/expression/ParserException.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.expression; + +/** + * The Class ParserException. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + * @deprecated use {@link org.semanticweb.owlapi.manchestersyntax.renderer.ParserException} + */ +@Deprecated +public class ParserException + extends org.semanticweb.owlapi.manchestersyntax.renderer.ParserException { + + @SuppressWarnings("javadoc") + public ParserException( + org.semanticweb.owlapi.manchestersyntax.renderer.ParserException delegate) { + super(delegate); + } +} diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/expression/packageinfo b/compatibility/src/main/java/org/semanticweb/owlapi/expression/packageinfo new file mode 100644 index 0000000000..3e36a90ba1 --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/expression/packageinfo @@ -0,0 +1 @@ +version 5.0.1 diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/io/OWLFunctionalSyntaxOntologyFormat.java b/compatibility/src/main/java/org/semanticweb/owlapi/io/OWLFunctionalSyntaxOntologyFormat.java new file mode 100644 index 0000000000..765490536f --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/io/OWLFunctionalSyntaxOntologyFormat.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.vocab.PrefixOWLOntologyFormat; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group, Date: + * 02-Jan-2007 + * @deprecated use {@link org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat} + */ +@Deprecated +public class OWLFunctionalSyntaxOntologyFormat extends + FunctionalSyntaxDocumentFormat implements PrefixOWLOntologyFormat { + + @Override + public String toString() { + return "OWL Functional Syntax"; + } +} diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/io/OWLXMLOntologyFormat.java b/compatibility/src/main/java/org/semanticweb/owlapi/io/OWLXMLOntologyFormat.java new file mode 100644 index 0000000000..4cee5ce851 --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/io/OWLXMLOntologyFormat.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.vocab.PrefixOWLOntologyFormat; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group, Date: + * 02-Jan-2007 + * @deprecated use {@link org.semanticweb.owlapi.formats.OWLXMLDocumentFormat} + */ +@Deprecated +public class OWLXMLOntologyFormat extends OWLXMLDocumentFormat implements + PrefixOWLOntologyFormat { + + @Override + public String toString() { + return "OWL/XML"; + } +} diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/io/RDFXMLOntologyFormat.java b/compatibility/src/main/java/org/semanticweb/owlapi/io/RDFXMLOntologyFormat.java new file mode 100644 index 0000000000..da35e3f725 --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/io/RDFXMLOntologyFormat.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.io; + +import org.semanticweb.owlapi.vocab.PrefixOWLOntologyFormat; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group, Date: + * 02-Jan-2007 + * @deprecated use {@link org.semanticweb.owlapi.formats.RDFXMLDocumentFormat} + */ +@Deprecated +public class RDFXMLOntologyFormat extends + org.semanticweb.owlapi.formats.RDFXMLDocumentFormat implements + PrefixOWLOntologyFormat { + +} diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/io/packageinfo b/compatibility/src/main/java/org/semanticweb/owlapi/io/packageinfo new file mode 100644 index 0000000000..dc4ac9fa8d --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/io/packageinfo @@ -0,0 +1 @@ +version 5.2.2 diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationPropertyProvider.java b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationPropertyProvider.java new file mode 100644 index 0000000000..a6bab21c1d --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLAnnotationPropertyProvider.java @@ -0,0 +1,25 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.model.providers.AnnotationPropertyProvider; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + * @deprecated use AnnotationPropertyProvider + */ +@Deprecated +public interface OWLAnnotationPropertyProvider extends AnnotationPropertyProvider { + +} diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLAnonymousIndividualByIdProvider.java b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLAnonymousIndividualByIdProvider.java new file mode 100644 index 0000000000..6af5b4cb02 --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLAnonymousIndividualByIdProvider.java @@ -0,0 +1,29 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.model.providers.AnonymousIndividualByIdProvider; + +/** + * An interface to an object that can provide instances of + * {@link OWLAnonymousIndividual}. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + * @deprecated use AnonymousIndividualByIdProvider + */ +@Deprecated +public interface OWLAnonymousIndividualByIdProvider extends + AnonymousIndividualByIdProvider { + +} diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLAnonymousIndividualProvider.java b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLAnonymousIndividualProvider.java new file mode 100644 index 0000000000..7731a779ed --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLAnonymousIndividualProvider.java @@ -0,0 +1,29 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.model.providers.AnonymousIndividualProvider; + +/** + * An interface to an object that can provide instances if + * {@link OWLAnonymousIndividual}. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 4.0.0 + * @deprecated use AnonymousIndividualProvider + */ +@Deprecated +public interface OWLAnonymousIndividualProvider extends + AnonymousIndividualProvider { + +} diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLClassProvider.java b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLClassProvider.java new file mode 100644 index 0000000000..fd92ffabd7 --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLClassProvider.java @@ -0,0 +1,25 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.model.providers.ClassProvider; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + * @deprecated use ClassProvider + */ +@Deprecated +public interface OWLClassProvider extends ClassProvider { + +} diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyProvider.java b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyProvider.java new file mode 100644 index 0000000000..30599e13e5 --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLDataPropertyProvider.java @@ -0,0 +1,25 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.model.providers.DataPropertyProvider; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + * @deprecated use DataPropertyProvider + */ +@Deprecated +public interface OWLDataPropertyProvider extends DataPropertyProvider { + +} diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLDatatypeProvider.java b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLDatatypeProvider.java new file mode 100644 index 0000000000..ce4840806a --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLDatatypeProvider.java @@ -0,0 +1,25 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.model.providers.DatatypeProvider; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + * @deprecated use DatatypeProvider + */ +@Deprecated +public interface OWLDatatypeProvider extends DatatypeProvider { + +} diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLEntityByTypeProvider.java b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLEntityByTypeProvider.java new file mode 100644 index 0000000000..c109e34c26 --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLEntityByTypeProvider.java @@ -0,0 +1,25 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.model.providers.EntityByTypeProvider; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + * @deprecated use EntityByTypeProvider + */ +@Deprecated +public interface OWLEntityByTypeProvider extends EntityByTypeProvider { + +} diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLEntityProvider.java b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLEntityProvider.java new file mode 100644 index 0000000000..e2d2874294 --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLEntityProvider.java @@ -0,0 +1,25 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.model.providers.EntityProvider; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + * @deprecated use EntityProvider + */ +@Deprecated +public interface OWLEntityProvider extends EntityProvider { + +} diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLNamedIndividualProvider.java b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLNamedIndividualProvider.java new file mode 100644 index 0000000000..4cd8276678 --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLNamedIndividualProvider.java @@ -0,0 +1,25 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.model.providers.NamedIndividualProvider; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + * @deprecated use NamedIndividualProvider + */ +@Deprecated +public interface OWLNamedIndividualProvider extends NamedIndividualProvider { + +} diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyProvider.java b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyProvider.java new file mode 100644 index 0000000000..33198f5091 --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLObjectPropertyProvider.java @@ -0,0 +1,25 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.model.providers.ObjectPropertyProvider; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.4.6 + * @deprecated use ObjectPropertyProvider + */ +@Deprecated +public interface OWLObjectPropertyProvider extends ObjectPropertyProvider { + +} diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLOntologyFormat.java b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLOntologyFormat.java new file mode 100644 index 0000000000..7943c70ef7 --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/model/OWLOntologyFormat.java @@ -0,0 +1,9 @@ +package org.semanticweb.owlapi.model; + +/** + * @deprecated this interface is here only to help with backwards compatibility + */ +@Deprecated +public interface OWLOntologyFormat extends OWLDocumentFormat { + +} diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/model/SWRLDataFactory.java b/compatibility/src/main/java/org/semanticweb/owlapi/model/SWRLDataFactory.java new file mode 100644 index 0000000000..1045ed538f --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/model/SWRLDataFactory.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.model; + +import org.semanticweb.owlapi.model.providers.SWRLProvider; + +/** + * An interface to a factory that can create SWRL objects. + * + * @author Matthew Horridge, The University Of Manchester, Medical Informatics Group + * @since 2.0.0 + * @deprecated use SWRLProvider + */ +@Deprecated +public interface SWRLDataFactory extends SWRLProvider { + +} diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/model/packageinfo b/compatibility/src/main/java/org/semanticweb/owlapi/model/packageinfo new file mode 100644 index 0000000000..baa1c4d206 --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/model/packageinfo @@ -0,0 +1 @@ +version 5.4.0 diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/util/DeprecatedOWLEntityCollector.java b/compatibility/src/main/java/org/semanticweb/owlapi/util/DeprecatedOWLEntityCollector.java new file mode 100644 index 0000000000..83118447c5 --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/util/DeprecatedOWLEntityCollector.java @@ -0,0 +1,205 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.verifyNotNull; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * A utility class that visits axioms, class expressions etc. and accumulates + * the named objects that are referred to in those axioms, class expressions + * etc. For example, if the collector visited the axiom (propP some C) + * subClassOf (propQ some D), it would contain the objects propP, C, propQ and + * D. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group, Date: + * 13-Nov-2006 + * @deprecated the old OWLEntityCollector is still used in non trivial ways in third party software. + * For new code, use OWLEntityCollector. + */ +@Deprecated +public class DeprecatedOWLEntityCollector extends AbstractCollectorEx { + + @Nullable + private final Collection anonymousIndividuals; + private boolean collectClasses = true; + private boolean collectObjectProperties = true; + private boolean collectDataProperties = true; + private boolean collectIndividuals = true; + private boolean collectDatatypes = true; + + /** + * @param toReturn the set that will contain the results + * @param anonsToReturn the set that will contain the anon individuals + */ + public DeprecatedOWLEntityCollector(Set toReturn, + @Nullable Collection anonsToReturn) { + super(toReturn); + anonymousIndividuals = anonsToReturn; + } + + /** + * @param toReturn the set that will contain the results + */ + public DeprecatedOWLEntityCollector(Set toReturn) { + this(toReturn, null); + } + + /** + * Deprecated default constructor: use one of the other constructors to get + * more efficient set creation. + */ + @Deprecated + public DeprecatedOWLEntityCollector() { + this(new HashSet(), new HashSet()); + } + + /** + * Clears all objects that have accumulated during the course of visiting + * axioms, class expressions etc. + * + * @param toReturn the set that will contain the results + */ + public void reset(Set toReturn) { + objects = toReturn; + if (anonymousIndividuals != null) { + anonymousIndividuals.clear(); + } + } + + /** + * @param collectClasses true to collect classes + */ + public void setCollectClasses(boolean collectClasses) { + this.collectClasses = collectClasses; + } + + /** + * @param collectObjectProperties true to collect object properties + */ + public void setCollectObjectProperties(boolean collectObjectProperties) { + this.collectObjectProperties = collectObjectProperties; + } + + /** + * @param collectDataProperties true to collect data properties + */ + public void setCollectDataProperties(boolean collectDataProperties) { + this.collectDataProperties = collectDataProperties; + } + + /** + * @param collectIndividuals true to collect individuals + */ + public void setCollectIndividuals(boolean collectIndividuals) { + this.collectIndividuals = collectIndividuals; + } + + /** + * @param collectDatatypes true to collect datatypes + */ + public void setCollectDatatypes(boolean collectDatatypes) { + this.collectDatatypes = collectDatatypes; + } + + /** + * A convenience method. Although anonymous individuals are not entities + * they are collected by this collector and stored in a separate set. This + * method returns collected individuals. Deprecated: if the non deprecated + * constructors are used, this method is useless and inefficient + * + * @return The set of anonymous individuals that were collected by the collector + */ + @Deprecated + public Set getAnonymousIndividuals() { + if (anonymousIndividuals == null) { + return CollectionFactory.createLinkedSet(); + } + return CollectionFactory.createSet(verifyNotNull(anonymousIndividuals)); + } + + @Override + public Collection visit(OWLClass desc) { + if (collectClasses) { + objects.add(desc); + } + return objects; + } + + @Override + public Collection visit(OWLObjectProperty property) { + if (collectObjectProperties) { + objects.add(property); + } + return objects; + } + + @Override + public Collection visit(OWLDataProperty property) { + if (collectDataProperties) { + objects.add(property); + } + return objects; + } + + @Override + public Collection visit(OWLNamedIndividual individual) { + if (collectIndividuals) { + objects.add(individual); + } + return objects; + } + + @Override + public Collection visit(OWLDatatype datatype) { + if (collectDatatypes) { + objects.add(datatype); + } + return objects; + } + + @Override + public Collection visit(OWLAnonymousIndividual individual) { + // Anon individuals aren't entities + // But store them in a set anyway for utility + if (anonymousIndividuals != null) { + anonymousIndividuals.add(individual); + } + return objects; + } + + @Override + public Collection visit(OWLOntology ontology) { + objects.addAll(ontology.getSignature()); + return objects; + } + + @Override + public Collection visit(OWLAnnotationProperty property) { + objects.add(property); + return objects; + } +} diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/util/NonMappingOntologyIRIMapper.java b/compatibility/src/main/java/org/semanticweb/owlapi/util/NonMappingOntologyIRIMapper.java new file mode 100644 index 0000000000..16c2c2b512 --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/util/NonMappingOntologyIRIMapper.java @@ -0,0 +1,38 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import java.io.Serializable; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.annotations.HasPriority; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntologyIRIMapper; + +/** + * An ontology URI mapper that simply returns the ontology URI without + * performing any mapping operation. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + * @deprecated not useful. If no mapping is found, the code already returns the input IRI. + */ +@HasPriority(10) +@Deprecated +public class NonMappingOntologyIRIMapper implements OWLOntologyIRIMapper, Serializable { + + @Override + @Nullable + public IRI getDocumentIRI(IRI ontologyIRI) { + return ontologyIRI; + } +} diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/util/packageinfo b/compatibility/src/main/java/org/semanticweb/owlapi/util/packageinfo new file mode 100644 index 0000000000..131c449ad4 --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/util/packageinfo @@ -0,0 +1 @@ +version 7.0.1 diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/vocab/PrefixOWLOntologyFormat.java b/compatibility/src/main/java/org/semanticweb/owlapi/vocab/PrefixOWLOntologyFormat.java new file mode 100644 index 0000000000..b82b97db87 --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/vocab/PrefixOWLOntologyFormat.java @@ -0,0 +1,16 @@ +package org.semanticweb.owlapi.vocab; + +import java.io.Serializable; +import org.semanticweb.owlapi.model.OWLOntologyFormat; +import org.semanticweb.owlapi.model.PrefixManager; + +/** + * Transition interface, for compatibility purposes. + * + * @deprecated use PrefixDocumentFormat instead + */ +@Deprecated +public interface PrefixOWLOntologyFormat extends OWLOntologyFormat, + PrefixManager, Serializable { + +} diff --git a/compatibility/src/main/java/org/semanticweb/owlapi/vocab/packageinfo b/compatibility/src/main/java/org/semanticweb/owlapi/vocab/packageinfo new file mode 100644 index 0000000000..992045e711 --- /dev/null +++ b/compatibility/src/main/java/org/semanticweb/owlapi/vocab/packageinfo @@ -0,0 +1 @@ +version 6.0.0 diff --git a/compatibility/src/main/java/uk/ac/manchester/cs/owl/owlapi/mansyntaxrenderer/ManchesterOWLSyntaxFrameRenderer.java b/compatibility/src/main/java/uk/ac/manchester/cs/owl/owlapi/mansyntaxrenderer/ManchesterOWLSyntaxFrameRenderer.java new file mode 100644 index 0000000000..0a28c6163e --- /dev/null +++ b/compatibility/src/main/java/uk/ac/manchester/cs/owl/owlapi/mansyntaxrenderer/ManchesterOWLSyntaxFrameRenderer.java @@ -0,0 +1,38 @@ +package uk.ac.manchester.cs.owl.owlapi.mansyntaxrenderer; + +import java.io.Writer; +import java.util.Collection; + +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.util.ShortFormProvider; + +/** + * @deprecated use + * {@link org.semanticweb.owlapi.manchestersyntax.renderer.ManchesterOWLSyntaxFrameRenderer} + */ +@Deprecated +public class ManchesterOWLSyntaxFrameRenderer + extends org.semanticweb.owlapi.manchestersyntax.renderer.ManchesterOWLSyntaxFrameRenderer { + + /** + * @param ontology ontology + * @param writer writer + * @param entityShortFormProvider provider + */ + public ManchesterOWLSyntaxFrameRenderer(OWLOntology ontology, Writer writer, + ShortFormProvider entityShortFormProvider) { + super(ontology, writer, entityShortFormProvider); + } + + /** + * Instantiates a new manchester owl syntax frame renderer. + * + * @param ontologies the ontologies + * @param writer the writer + * @param entityShortFormProvider the entity short form provider + */ + public ManchesterOWLSyntaxFrameRenderer(Collection ontologies, Writer writer, + ShortFormProvider entityShortFormProvider) { + super(ontologies, writer, entityShortFormProvider); + } +} diff --git a/compatibility/src/main/java/uk/ac/manchester/cs/owl/owlapi/mansyntaxrenderer/ManchesterOWLSyntaxObjectRenderer.java b/compatibility/src/main/java/uk/ac/manchester/cs/owl/owlapi/mansyntaxrenderer/ManchesterOWLSyntaxObjectRenderer.java new file mode 100644 index 0000000000..3917de563d --- /dev/null +++ b/compatibility/src/main/java/uk/ac/manchester/cs/owl/owlapi/mansyntaxrenderer/ManchesterOWLSyntaxObjectRenderer.java @@ -0,0 +1,37 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package uk.ac.manchester.cs.owl.owlapi.mansyntaxrenderer; + +import java.io.Writer; + +import org.semanticweb.owlapi.util.ShortFormProvider; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + * @deprecated use + * {@link org.semanticweb.owlapi.manchestersyntax.renderer.ManchesterOWLSyntaxObjectRenderer} + */ +@Deprecated +public class ManchesterOWLSyntaxObjectRenderer + extends org.semanticweb.owlapi.manchestersyntax.renderer.ManchesterOWLSyntaxObjectRenderer { + + /** + * @param writer writer + * @param entityShortFormProvider entityShortFormProvider + */ + public ManchesterOWLSyntaxObjectRenderer(Writer writer, + ShortFormProvider entityShortFormProvider) { + super(writer, entityShortFormProvider); + } +} diff --git a/compatibility/src/main/java/uk/ac/manchester/cs/owl/owlapi/mansyntaxrenderer/ManchesterOWLSyntaxRenderer.java b/compatibility/src/main/java/uk/ac/manchester/cs/owl/owlapi/mansyntaxrenderer/ManchesterOWLSyntaxRenderer.java new file mode 100644 index 0000000000..7711af9e08 --- /dev/null +++ b/compatibility/src/main/java/uk/ac/manchester/cs/owl/owlapi/mansyntaxrenderer/ManchesterOWLSyntaxRenderer.java @@ -0,0 +1,25 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package uk.ac.manchester.cs.owl.owlapi.mansyntaxrenderer; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + * @deprecated use + * {@link org.semanticweb.owlapi.manchestersyntax.renderer.ManchesterOWLSyntaxRenderer} + */ +@Deprecated +public class ManchesterOWLSyntaxRenderer + extends org.semanticweb.owlapi.manchestersyntax.renderer.ManchesterOWLSyntaxRenderer { + +} diff --git a/compatibility/src/main/java/uk/ac/manchester/cs/owl/owlapi/mansyntaxrenderer/package-info.java b/compatibility/src/main/java/uk/ac/manchester/cs/owl/owlapi/mansyntaxrenderer/package-info.java new file mode 100644 index 0000000000..690f9cca50 --- /dev/null +++ b/compatibility/src/main/java/uk/ac/manchester/cs/owl/owlapi/mansyntaxrenderer/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Manchester syntax renderer compatibility package. + */ +@javax.annotation.ParametersAreNonnullByDefault +package uk.ac.manchester.cs.owl.owlapi.mansyntaxrenderer; diff --git a/compatibility/src/main/java/uk/ac/manchester/cs/owl/owlapi/mansyntaxrenderer/packageinfo b/compatibility/src/main/java/uk/ac/manchester/cs/owl/owlapi/mansyntaxrenderer/packageinfo new file mode 100644 index 0000000000..3e36a90ba1 --- /dev/null +++ b/compatibility/src/main/java/uk/ac/manchester/cs/owl/owlapi/mansyntaxrenderer/packageinfo @@ -0,0 +1 @@ +version 5.0.1 diff --git a/compatibility/src/main/java/uk/ac/manchester/cs/owlapi/dlsyntax/DLSyntaxHTMLOntologyFormat.java b/compatibility/src/main/java/uk/ac/manchester/cs/owlapi/dlsyntax/DLSyntaxHTMLOntologyFormat.java new file mode 100644 index 0000000000..8ab777ffa5 --- /dev/null +++ b/compatibility/src/main/java/uk/ac/manchester/cs/owlapi/dlsyntax/DLSyntaxHTMLOntologyFormat.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package uk.ac.manchester.cs.owlapi.dlsyntax; + +import org.semanticweb.owlapi.model.OWLOntologyFormat; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group, Date: + * 10-Feb-2008 + * @deprecated use {@link org.semanticweb.owlapi.formats.DLSyntaxHTMLDocumentFormat} + */ +@Deprecated +public class DLSyntaxHTMLOntologyFormat extends + org.semanticweb.owlapi.formats.DLSyntaxHTMLDocumentFormat implements + OWLOntologyFormat { + +} diff --git a/compatibility/src/main/java/uk/ac/manchester/cs/owlapi/dlsyntax/DLSyntaxOntologyFormat.java b/compatibility/src/main/java/uk/ac/manchester/cs/owlapi/dlsyntax/DLSyntaxOntologyFormat.java new file mode 100644 index 0000000000..2ce60e80cc --- /dev/null +++ b/compatibility/src/main/java/uk/ac/manchester/cs/owlapi/dlsyntax/DLSyntaxOntologyFormat.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package uk.ac.manchester.cs.owlapi.dlsyntax; + +import org.semanticweb.owlapi.model.OWLOntologyFormat; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group, Date: + * 10-Feb-2008 + * @deprecated use {@link org.semanticweb.owlapi.formats.DLSyntaxDocumentFormat} + */ +@Deprecated +public class DLSyntaxOntologyFormat extends + org.semanticweb.owlapi.formats.DLSyntaxDocumentFormat implements + OWLOntologyFormat { + +} diff --git a/compatibility/src/main/java/uk/ac/manchester/cs/owlapi/dlsyntax/packageinfo b/compatibility/src/main/java/uk/ac/manchester/cs/owlapi/dlsyntax/packageinfo new file mode 100644 index 0000000000..8ce0371286 --- /dev/null +++ b/compatibility/src/main/java/uk/ac/manchester/cs/owlapi/dlsyntax/packageinfo @@ -0,0 +1 @@ +version 5.0.0 diff --git a/contract/pom.xml b/contract/pom.xml new file mode 100644 index 0000000000..291f42dbe1 --- /dev/null +++ b/contract/pom.xml @@ -0,0 +1,17 @@ + + 4.0.0 + owlapi-contract + OWLAPI :: Tests and Tutorials + + net.sourceforge.owlapi + owlapi-parent + 5.1.18 + + + + ${project.groupId} + owlapi-apibinding + ${project.version} + + + diff --git a/contract/src/main/java/uk/ac/manchester/owl/owlapi/PrepareForRelease.java b/contract/src/main/java/uk/ac/manchester/owl/owlapi/PrepareForRelease.java new file mode 100644 index 0000000000..bb1411f27f --- /dev/null +++ b/contract/src/main/java/uk/ac/manchester/owl/owlapi/PrepareForRelease.java @@ -0,0 +1,50 @@ +package uk.ac.manchester.owl.owlapi; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.PrintStream; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; +import java.util.stream.Collectors; + +public class PrepareForRelease { + public static void main(String[] args) throws IOException { + String newVersion = "5.1.18"; + String[] toReplace = new String[] {"5.1.18-SNAPSHOT", "5.1.17", "5.1.17-SNAPSHOT"}; + treat(newVersion, toReplace, + "../api/src/main/java/org/semanticweb/owlapi/util/VersionInfo.java"); + treat(newVersion, toReplace, + "../osgidistribution/src/test/java/org/semanticweb/owlapi/api/test/VerifyVersionInfoIntegrationTestCase.java"); + treat(newVersion, toReplace, "../pom.xml"); + treat(newVersion, toReplace, "../api/pom.xml"); + treat(newVersion, toReplace, "../impl/pom.xml"); + treat(newVersion, toReplace, "../tools/pom.xml"); + treat(newVersion, toReplace, "../parsers/pom.xml"); + treat(newVersion, toReplace, "../oboformat/pom.xml"); + treat(newVersion, toReplace, "../rio/pom.xml"); + treat(newVersion, toReplace, "../compatibility/pom.xml"); + treat(newVersion, toReplace, "../apibinding/pom.xml"); + treat(newVersion, toReplace, "../contract/pom.xml"); + treat(newVersion, toReplace, "../distribution/pom.xml"); + treat(newVersion, toReplace, "../osgidistribution/pom.xml"); + } + + protected static void treat(String newVersion, String[] toReplace, String fileName) + throws IOException, FileNotFoundException { + List lines = Files.readAllLines(Paths.get(fileName)); + try (PrintStream out = new PrintStream(new File(fileName))) { + out.println(lines.stream().map(s -> replaceall(s, newVersion, toReplace)) + .collect(Collectors.joining("\n"))); + } + } + + private static String replaceall(String in, String replacement, String... values) { + String toReturn = in; + for (String s : values) { + toReturn = toReturn.replace(s, replacement); + } + return toReturn; + } +} diff --git a/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/Debugger.java b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/Debugger.java new file mode 100644 index 0000000000..58db97fa11 --- /dev/null +++ b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/Debugger.java @@ -0,0 +1,99 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package uk.ac.manchester.owl.owlapi.tutorialowled2011; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.io.PrintWriter; +import java.util.Set; + +import javax.annotation.Nonnull; + +import org.semanticweb.owlapi.debugging.BlackBoxOWLDebugger; +import org.semanticweb.owlapi.debugging.OWLDebugger; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLException; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.reasoner.OWLReasoner; +import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; + +/** + * This class demonstrates some aspects of the OWL API. It expects three arguments: + *
    + *
  1. The URI of an ontology
  2. + *
  3. The URI of a reasoner
  4. + *
  5. A location to place the results.
  6. + *
+ * When executed, the class will find all inconsistent classes in the ontology. For each + * inconsistent class, the debugger will be used to determine the set of support for the + * inconsistency. A report will then be written to the output file. + * + * @author Sean Bechhofer, The University Of Manchester, Information Management Group + * @since 2.0.0 + */ +@SuppressWarnings("javadoc") +public class Debugger { + + @Nonnull + private final OWLOntology ontology; + @Nonnull + private final OWLDebugger debugger; + private final OWLReasoner checker; + + public Debugger(OWLOntologyManager manager, OWLOntology ontology, + OWLReasonerFactory reasonerFactory) { + this.ontology = ontology; + checker = reasonerFactory.createNonBufferingReasoner(ontology); + /* Create a new debugger */ + debugger = new BlackBoxOWLDebugger(manager, ontology, reasonerFactory); + } + + public void report(PrintWriter writer) throws OWLException { + OWLTutorialSyntaxObjectRenderer renderer = new OWLTutorialSyntaxObjectRenderer(writer); + /* Write a header */ + renderer.header(); + /* Collect the unsatisfiable classes that aren't bottom. */ + Set unsatisfiables = asSet(ontology.classesInSignature() + .filter(c -> !checker.isSatisfiable(c) && !c.isOWLNothing())); + writer.println("

Ontology Debugging Report

"); + writer.println("
Ontology: " + ontology.getOntologyID() + "
"); + if (unsatisfiables.isEmpty()) { + writer.println("
No Unsatisfiable Classes found
"); + } else { + for (OWLClass unsatisfiable : unsatisfiables) { + writer.println("
\n"); + writer.println("

"); + unsatisfiable.accept(renderer); + writer.println("

"); + writer.println("
Axioms causing inconsistency:
"); + writer.println("
    "); + /* + * Find the set of support for the inconsistency. This will return us a collection + * of axioms + */ + Set sos = debugger.getSOSForInconsistentClass(unsatisfiable); + /* Print the axioms. */ + for (OWLAxiom axiom : sos) { + writer.println("
  • "); + axiom.accept(renderer); + writer.println("
  • "); + } + writer.println("
"); + writer.println("
\n"); + } + } + renderer.footer(); + } +} diff --git a/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/Formatter.java b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/Formatter.java new file mode 100644 index 0000000000..d1cd9ace75 --- /dev/null +++ b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/Formatter.java @@ -0,0 +1,80 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package uk.ac.manchester.owl.owlapi.tutorialowled2011; + +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +@SuppressWarnings("javadoc") +public final class Formatter { + + private Formatter() {} + + @SuppressWarnings("resource") + public static void main(String[] args) throws Exception { + Map specials = new HashMap<>(); + specials.put("public void test", "\\begin{beamerboxesrounded}{"); + specials.put("() throws Exception \\{", "}\n\\scriptsize"); + String[] keywords = + {" class ", " void ", " extends ", "public", " static final", "return", "throws"}; + Pattern stringPattern = Pattern.compile("(\"[\\w\\.\\:\\s\\#/\\-]*\")"); + BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream( + "../OWLAPI3/tutorial2011/uk/ac/manchester/owl/owlapi/tutorialowled2011/TutorialSnippets.java"))); + String line = r.readLine(); + while (line != null) { + line = line.trim(); + if (line.isEmpty()) { + System.out.println("\\end{beamerboxesrounded}\n\n"); + } else { + line = line.replace("{", "\\{").replace("}", "\\}").replace("_", "\\_"); + if (line.trim().startsWith("//")) { + System.out.println("\\codecomment{" + line + "}\\\\"); + } else { + // regular code + for (Map.Entry e : specials.entrySet()) { + line = line.replace(e.getKey(), e.getValue()); + } + for (String s : keywords) { + line = line.replace(s, "\\codekeyword{" + s + '}'); + } + line = line.replace("\t", "\\hspace{4mm}").replace(" ", "\\hspace{4mm}") + .replace("\\hspace{4mm}\\hspace{4mm}", "\\hspace{4mm}"); + Matcher match = stringPattern.matcher(line); + List strings = new ArrayList<>(); + while (match.find()) { + strings.add(match.group(1)); + } + for (String s : strings) { + line = line.replace(s, "\\codestring{" + s + '}'); + } + if (!line.contains("beamerboxesrounded")) { + System.out.print("\\coderegular{"); + System.out.print(line); + System.out.println("}\\\\"); + } else { + System.out.println(line); + } + } + } + line = r.readLine(); + } + r.close(); + } +} diff --git a/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/OWLTutorialSyntaxObjectRenderer.java b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/OWLTutorialSyntaxObjectRenderer.java new file mode 100644 index 0000000000..d5fbc95ba7 --- /dev/null +++ b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/OWLTutorialSyntaxObjectRenderer.java @@ -0,0 +1,711 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package uk.ac.manchester.owl.owlapi.tutorialowled2011; + +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; +import java.util.stream.Stream; +import javax.annotation.Nonnull; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLCardinalityRestriction; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataComplementOf; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLImportsDeclaration; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectInverseOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLObjectVisitor; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLPropertyExpression; +import org.semanticweb.owlapi.model.OWLQuantifiedDataRestriction; +import org.semanticweb.owlapi.model.OWLQuantifiedObjectRestriction; +import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; +import org.semanticweb.owlapi.util.QNameShortFormProvider; +import org.semanticweb.owlapi.util.ShortFormProvider; + +/** + * A renderer that provides an HTML version of the ontology. + * + * @author Sean Bechhofer, The University Of Manchester, Information Management Group + * @since 2.0.0 + */ +@SuppressWarnings({"javadoc"}) +public class OWLTutorialSyntaxObjectRenderer implements OWLObjectVisitor { + + private static final boolean TABLES = true; + private static final int TABLE_COLUMNS = 3; + private final @Nonnull ShortFormProvider shortForms; + private final Writer writer; + int lastNewLinePos; + private int pos; + + public OWLTutorialSyntaxObjectRenderer(Writer writer) { + this.writer = writer; + shortForms = new QNameShortFormProvider(); + } + + public String labelFor(OWLEntity entity) { + return shortForms.getShortForm(entity); + } + + private OWLTutorialSyntaxObjectRenderer write(String s) { + try { + int newLineIndex = s.indexOf('\n'); + if (newLineIndex != -1) { + lastNewLinePos = pos + newLineIndex; + } + pos += s.length(); + writer.write(s); + } catch (IOException e) { + throw new OWLRuntimeException(e); + } + return this; + } + + private OWLTutorialSyntaxObjectRenderer write(int i) { + try { + String s = " " + i + ' '; + pos += s.length(); + writer.write(s); + } catch (IOException e) { + throw new OWLRuntimeException(e); + } + return this; + } + + private OWLTutorialSyntaxObjectRenderer write(IRI iri) { + write("<").write(iri.toQuotedString()).write(">"); + return this; + } + + public void header() { + write( + "\n\n\n\n"); + } + + public void footer() { + write("\n\n"); + } + + private OWLTutorialSyntaxObjectRenderer writeCollection( + Stream objects) { + if (TABLES) { + return writeTable(objects); + } + return writeList(objects); + } + + private OWLTutorialSyntaxObjectRenderer writeTable(Stream objects) { + writeTableStart(); + int count = 0; + for (Iterator it = objects.iterator(); it.hasNext();) { + if (count % TABLE_COLUMNS == 0) { + if (count > 0) { + writeTableRowEnd(); + } + writeTableRowStart(); + } + writeTableCellStart(); + it.next().accept(this); + writeTableCellEnd(); + count++; + } + writeTableRowEnd(); + writeTableEnd(); + return this; + } + + private OWLTutorialSyntaxObjectRenderer writeList(Stream objects) { + writeListStart(); + for (Iterator it = objects.iterator(); it.hasNext();) { + writeListItemStart(); + it.next().accept(this); + writeListItemEnd(); + } + writeListEnd(); + return this; + } + + @Override + public void visit(OWLOntology ontology) { + header(); + write("

").write(ontology.getOntologyID().toString()).write("

\n"); + write("
\n"); + ontology.importsDeclarations() + .forEach(d -> write("Imports: ").write(d.getIRI()).write("\n")); + write("

Classes

\n").writeCollection(ontology.classesInSignature()); + write("
\n
\n

Properties

\n") + .writeCollection(ontology.objectPropertiesInSignature()) + .writeCollection(ontology.dataPropertiesInSignature()); + write("
\n
\n

Individuals

\n") + .writeCollection(ontology.individualsInSignature()).write("
"); + write("

Axioms

\n"); + writeListStart(); + ontology.axioms().forEach(ax -> { + writeListItemStart(); + ax.accept(this); + writeListEnd(); + }); + writeListEnd(); + write("
"); + footer(); + } + + public OWLTutorialSyntaxObjectRenderer write(String str, OWLObject o) { + write(str).write("("); + o.accept(this); + write(")"); + return this; + } + + private OWLTutorialSyntaxObjectRenderer write(Stream stream, + String separator) { + Iterator objects = stream.iterator(); + while (objects.hasNext()) { + objects.next().accept(this); + if (objects.hasNext()) { + writeSpace(); + write(separator); + writeSpace(); + } + } + return this; + } + + private OWLTutorialSyntaxObjectRenderer write(Stream objects) { + return write(objects, ""); + } + + public OWLTutorialSyntaxObjectRenderer writeOpenBracket() { + return write("("); + } + + public OWLTutorialSyntaxObjectRenderer writeCloseBracket() { + return write(")"); + } + + public OWLTutorialSyntaxObjectRenderer writeSpace() { + return write(" "); + } + + public OWLTutorialSyntaxObjectRenderer writeAnnotations( + @SuppressWarnings("unused") OWLAxiom ax) { + return this; + } + + public OWLTutorialSyntaxObjectRenderer writeListStart() { + return write("
    \n"); + } + + public OWLTutorialSyntaxObjectRenderer writeListEnd() { + return write("
\n"); + } + + public OWLTutorialSyntaxObjectRenderer writeTableStart() { + return write("\n"); + } + + public OWLTutorialSyntaxObjectRenderer writeTableEnd() { + return write("
\n"); + } + + public OWLTutorialSyntaxObjectRenderer writeTableRowStart() { + return write("\n"); + } + + public OWLTutorialSyntaxObjectRenderer writeTableRowEnd() { + return write("\n"); + } + + public OWLTutorialSyntaxObjectRenderer writeTableCellStart() { + return write("\n"); + } + + public OWLTutorialSyntaxObjectRenderer writeTableCellEnd() { + return write("\n"); + } + + public OWLTutorialSyntaxObjectRenderer writeListItemStart() { + return write("
  • \n"); + } + + public OWLTutorialSyntaxObjectRenderer writeListItemEnd() { + return write("
  • \n"); + } + + @SuppressWarnings("unused") + public OWLTutorialSyntaxObjectRenderer writePropertyCharacteristic(String str, OWLAxiom ax, + OWLPropertyExpression prop) { + write(keyword(str)); + writeSpace(); + prop.accept(this); + return this; + } + + @Override + public void visit(OWLAsymmetricObjectPropertyAxiom axiom) { + writePropertyCharacteristic("asymmetric", axiom, axiom.getProperty()); + } + + @Override + public void visit(OWLClassAssertionAxiom axiom) { + axiom.getIndividual().accept(this); + write(keyword(":")).writeSpace(); + axiom.getClassExpression().accept(this); + } + + @Override + public void visit(OWLDataPropertyAssertionAxiom axiom) { + axiom.getSubject().accept(this); + writeSpace(); + axiom.getProperty().accept(this); + writeSpace(); + axiom.getObject().accept(this); + } + + @Override + public void visit(OWLDataPropertyDomainAxiom axiom) { + axiom.getProperty().accept(this); + writeSpace(); + write(keyword("domain")); + writeSpace(); + axiom.getDomain().accept(this); + } + + @Override + public void visit(OWLDataPropertyRangeAxiom axiom) { + axiom.getProperty().accept(this); + writeSpace(); + write(keyword("range")); + writeSpace(); + axiom.getRange().accept(this); + } + + @Override + public void visit(OWLSubDataPropertyOfAxiom axiom) { + axiom.getSubProperty().accept(this); + writeSpace(); + write(keyword("subProperty")); + writeSpace(); + axiom.getSuperProperty().accept(this); + } + + @Override + public void visit(OWLDifferentIndividualsAxiom axiom) { + write(axiom.individuals(), keyword("!=")); + } + + @Override + public void visit(OWLDisjointClassesAxiom axiom) { + write(axiom.classExpressions(), keyword("|")); + } + + @Override + public void visit(OWLDisjointDataPropertiesAxiom axiom) { + write(axiom.properties(), keyword("|")); + } + + @Override + public void visit(OWLDisjointObjectPropertiesAxiom axiom) { + write(keyword("disjoint")).write(axiom.properties(), keyword("|")); + } + + @Override + public void visit(OWLDisjointUnionAxiom axiom) { + axiom.getOWLClass().accept(this); + writeSpace().write(keyword("==")).writeSpace().write(axiom.classExpressions(), + keyword("|")); + } + + @Override + public void visit(OWLEquivalentClassesAxiom axiom) { + write(axiom.classExpressions(), keyword("==")); + } + + @Override + public void visit(OWLEquivalentDataPropertiesAxiom axiom) { + write(axiom.properties(), keyword("==")); + } + + @Override + public void visit(OWLEquivalentObjectPropertiesAxiom axiom) { + write(axiom.properties(), keyword("==")); + } + + @Override + public void visit(OWLFunctionalDataPropertyAxiom axiom) { + writePropertyCharacteristic("functional", axiom, axiom.getProperty()); + } + + @Override + public void visit(OWLFunctionalObjectPropertyAxiom axiom) { + writePropertyCharacteristic("functional", axiom, axiom.getProperty()); + } + + public void visit(OWLImportsDeclaration axiom) { + write(keyword("imports")).write(axiom.getIRI()); + } + + @Override + public void visit(OWLInverseFunctionalObjectPropertyAxiom axiom) { + writePropertyCharacteristic("inversefunctional", axiom, axiom.getProperty()); + } + + @Override + public void visit(OWLInverseObjectPropertiesAxiom axiom) { + axiom.getFirstProperty().accept(this); + writeSpace().write(keyword("inverse")).writeSpace(); + axiom.getSecondProperty().accept(this); + } + + @Override + public void visit(OWLIrreflexiveObjectPropertyAxiom axiom) { + writePropertyCharacteristic("Irreflexive", axiom, axiom.getProperty()); + } + + @Override + public void visit(OWLNegativeDataPropertyAssertionAxiom axiom) { + axiom.getSubject().accept(this); + writeSpace().write(keyword("notvalue")); + axiom.getProperty().accept(this); + writeSpace(); + axiom.getObject().accept(this); + } + + @Override + public void visit(OWLNegativeObjectPropertyAssertionAxiom axiom) { + axiom.getSubject().accept(this); + writeSpace().write(keyword("notvalue")); + axiom.getProperty().accept(this); + writeSpace(); + axiom.getObject().accept(this); + } + + @Override + public void visit(OWLObjectPropertyAssertionAxiom axiom) { + axiom.getSubject().accept(this); + writeSpace(); + axiom.getProperty().accept(this); + writeSpace(); + axiom.getObject().accept(this); + } + + @Override + public void visit(OWLSubPropertyChainOfAxiom axiom) { + write("chain").writeOpenBracket().write(axiom.getPropertyChain().stream()) + .writeCloseBracket(); + writeSpace().write(keyword("subProperty")).writeSpace(); + axiom.getSuperProperty().accept(this); + } + + @Override + public void visit(OWLObjectPropertyDomainAxiom axiom) { + axiom.getProperty().accept(this); + writeSpace().write(keyword("domain")).writeSpace(); + axiom.getDomain().accept(this); + } + + @Override + public void visit(OWLObjectPropertyRangeAxiom axiom) { + axiom.getProperty().accept(this); + writeSpace().write(keyword("range")).writeSpace(); + axiom.getRange().accept(this); + } + + @Override + public void visit(OWLSubObjectPropertyOfAxiom axiom) { + axiom.getSubProperty().accept(this); + writeSpace().write(keyword("subProperty")).writeSpace(); + axiom.getSuperProperty().accept(this); + } + + @Override + public void visit(OWLReflexiveObjectPropertyAxiom axiom) { + writePropertyCharacteristic("reflexive", axiom, axiom.getProperty()); + } + + @Override + public void visit(OWLSameIndividualAxiom axiom) { + write(axiom.individuals(), keyword("=")); + } + + @Override + public void visit(OWLSubClassOfAxiom axiom) { + axiom.getSubClass().accept(this); + writeSpace().write(keyword("subClass")).writeSpace(); + axiom.getSuperClass().accept(this); + } + + @Override + public void visit(OWLSymmetricObjectPropertyAxiom axiom) { + writePropertyCharacteristic("symmetric", axiom, axiom.getProperty()); + } + + @Override + public void visit(OWLTransitiveObjectPropertyAxiom axiom) { + writePropertyCharacteristic("transitive", axiom, axiom.getProperty()); + } + + @Override + public void visit(OWLClass ce) { + write("" + labelFor(ce) + ""); + } + + private OWLTutorialSyntaxObjectRenderer writeRestriction(String str, + OWLCardinalityRestriction restriction, OWLPropertyExpression property) { + write(str).writeOpenBracket().write(restriction.getCardinality()).writeSpace(); + property.accept(this); + if (restriction.isQualified()) { + writeSpace(); + restriction.getFiller().accept(this); + } + writeCloseBracket(); + return this; + } + + private OWLTutorialSyntaxObjectRenderer writeRestriction(String str, + OWLQuantifiedDataRestriction restriction) { + return writeRestriction(str, restriction.getProperty(), restriction.getFiller()); + } + + private OWLTutorialSyntaxObjectRenderer writeRestriction(String str, + OWLQuantifiedObjectRestriction restriction) { + return writeRestriction(str, restriction.getProperty(), restriction.getFiller()); + } + + private OWLTutorialSyntaxObjectRenderer writeRestriction(String str, OWLPropertyExpression prop, + OWLObject filler) { + write(str).writeOpenBracket(); + prop.accept(this); + writeSpace(); + filler.accept(this); + writeCloseBracket(); + return this; + } + + @Override + public void visit(OWLDataAllValuesFrom ce) { + writeRestriction(operator("only"), ce); + } + + @Override + public void visit(OWLDataExactCardinality ce) { + writeRestriction("exact", ce, ce.getProperty()); + } + + @Override + public void visit(OWLDataMaxCardinality ce) { + writeRestriction("atmost", ce, ce.getProperty()); + } + + @Override + public void visit(OWLDataMinCardinality ce) { + writeRestriction("atleast", ce, ce.getProperty()); + } + + @Override + public void visit(OWLDataSomeValuesFrom ce) { + writeRestriction(operator("some"), ce); + } + + @Override + public void visit(OWLDataHasValue ce) { + writeRestriction("has-value", ce.getProperty(), ce.getFiller()); + } + + @Override + public void visit(OWLObjectAllValuesFrom ce) { + writeRestriction(operator("only"), ce); + } + + @Override + public void visit(OWLObjectComplementOf ce) { + write(operator("not"), ce.getOperand()); + } + + @Override + public void visit(OWLObjectExactCardinality ce) { + writeRestriction("exact", ce, ce.getProperty()); + } + + @Override + public void visit(OWLObjectIntersectionOf ce) { + writeOpenBracket().write(ce.operands(), keyword("and")).writeCloseBracket(); + } + + @Override + public void visit(OWLObjectMaxCardinality ce) { + writeRestriction("atmost", ce, ce.getProperty()); + } + + @Override + public void visit(OWLObjectMinCardinality ce) { + writeRestriction("atleast", ce, ce.getProperty()); + } + + @Override + public void visit(OWLObjectOneOf ce) { + write(operator("one-of")).writeOpenBracket().write(ce.individuals()).writeCloseBracket(); + } + + @Override + public void visit(OWLObjectHasSelf ce) { + write("self", ce.getProperty()); + } + + @Override + public void visit(OWLObjectSomeValuesFrom ce) { + writeRestriction(operator("some"), ce); + } + + @Override + public void visit(OWLObjectUnionOf ce) { + writeOpenBracket().write(ce.operands(), " or ").writeCloseBracket(); + } + + @Override + public void visit(OWLObjectHasValue ce) { + writeRestriction("hasValue", ce.getProperty(), ce.getFiller()); + } + + @Override + public void visit(OWLDataComplementOf node) { + write(operator("not"), node.getDataRange()); + } + + @Override + public void visit(OWLDataOneOf node) { + write(operator("one-of")).write("(").write(node.values()).write(")"); + } + + @Override + public void visit(OWLDatatype node) { + write("Datatype").writeOpenBracket().write(node.getIRI()).writeCloseBracket(); + } + + @Override + public void visit(OWLDatatypeRestriction node) { + write("DatatypeRestriction").writeOpenBracket(); + node.getDatatype().accept(this); + node.facetRestrictions().forEach(r -> { + writeSpace(); + r.accept(this); + }); + writeCloseBracket(); + } + + @Override + public void visit(OWLFacetRestriction node) { + write(node.getFacet().getIRI()).writeSpace(); + node.getFacetValue().accept(this); + } + + @Override + public void visit(OWLLiteral node) { + write("\"").write(node.getLiteral()).write("\""); + if (node.hasLang()) { + write("@").write(node.getLang()); + } else { + write("^^").write(node.getDatatype().getIRI()); + } + } + + @Override + public void visit(OWLDataProperty property) { + write("" + labelFor(property) + ""); + } + + @Override + public void visit(OWLObjectProperty property) { + write("" + labelFor(property) + ""); + } + + @Override + public void visit(OWLObjectInverseOf property) { + write("inv").writeOpenBracket(); + property.getInverse().accept(this); + writeCloseBracket(); + } + + @Override + public void visit(OWLNamedIndividual individual) { + write("" + labelFor(individual) + ""); + } + + public String keyword(String str) { + return "" + str + ""; + } + + public String operator(String str) { + return "" + str + ""; + } +} diff --git a/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/OWLTutorialSyntaxOntologyFormat.java b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/OWLTutorialSyntaxOntologyFormat.java new file mode 100644 index 0000000000..9ec93270e9 --- /dev/null +++ b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/OWLTutorialSyntaxOntologyFormat.java @@ -0,0 +1,27 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package uk.ac.manchester.owl.owlapi.tutorialowled2011; + +import org.semanticweb.owlapi.formats.PrefixDocumentFormatImpl; + +/** + * @author Sean Bechhofer, The University Of Manchester, Information Management Group + * @since 2.0.0 + */ +public class OWLTutorialSyntaxOntologyFormat extends PrefixDocumentFormatImpl { + + @Override + public String getKey() { + return "OWL Tutorial Syntax"; + } +} diff --git a/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/OWLTutorialSyntaxOntologyFormatFactory.java b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/OWLTutorialSyntaxOntologyFormatFactory.java new file mode 100644 index 0000000000..168ef76ff4 --- /dev/null +++ b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/OWLTutorialSyntaxOntologyFormatFactory.java @@ -0,0 +1,39 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package uk.ac.manchester.owl.owlapi.tutorialowled2011; + +import java.util.Collections; + +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.util.OWLDocumentFormatFactoryImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +public class OWLTutorialSyntaxOntologyFormatFactory extends OWLDocumentFormatFactoryImpl { + /** Default MIME type is text/plain */ + public OWLTutorialSyntaxOntologyFormatFactory() { + super(Collections.singletonList("text/plain")); + } + + @Override + public String getKey() { + return "OWL Tutorial Syntax"; + } + + @Override + public OWLDocumentFormat createFormat() { + return new OWLTutorialSyntaxOntologyFormat(); + } +} diff --git a/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/OWLTutorialSyntaxRenderer.java b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/OWLTutorialSyntaxRenderer.java new file mode 100644 index 0000000000..91ef1c0890 --- /dev/null +++ b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/OWLTutorialSyntaxRenderer.java @@ -0,0 +1,37 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package uk.ac.manchester.owl.owlapi.tutorialowled2011; + +import java.io.PrintWriter; +import org.semanticweb.owlapi.io.AbstractOWLRenderer; +import org.semanticweb.owlapi.io.OWLRendererIOException; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLRuntimeException; + +/** + * @author Sean Bechhofer, The University Of Manchester, Information Management Group + * @since 2.0.0 + */ +public class OWLTutorialSyntaxRenderer extends AbstractOWLRenderer { + + @Override + public void render(OWLOntology ontology, PrintWriter writer) throws OWLRendererIOException { + try { + OWLTutorialSyntaxObjectRenderer ren = new OWLTutorialSyntaxObjectRenderer(writer); + ontology.accept(ren); + writer.flush(); + } catch (OWLRuntimeException ex) { + throw new OWLRendererIOException(ex); + } + } +} diff --git a/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/TutorialSyntaxStorer.java b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/TutorialSyntaxStorer.java new file mode 100644 index 0000000000..3cd9e0cdc9 --- /dev/null +++ b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/TutorialSyntaxStorer.java @@ -0,0 +1,45 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package uk.ac.manchester.owl.owlapi.tutorialowled2011; + +import java.io.PrintWriter; +import org.semanticweb.owlapi.annotations.HasPriority; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.util.AbstractOWLStorer; + +/** + * @author Sean Bechhofer, The University Of Manchester, Information Management Group + * @since 2.0.0 + */ +@HasPriority(-1) +public class TutorialSyntaxStorer extends AbstractOWLStorer { + + @Override + public boolean canStoreOntology(OWLDocumentFormat ontologyFormat) { + return ontologyFormat instanceof OWLTutorialSyntaxOntologyFormat; + } + + @Override + protected void storeOntology(OWLOntology ontology, PrintWriter writer, OWLDocumentFormat format) + throws OWLOntologyStorageException { + try { + OWLTutorialSyntaxRenderer renderer = new OWLTutorialSyntaxRenderer(); + renderer.render(ontology, writer); + } catch (OWLRuntimeException e) { + throw new OWLRuntimeException(e); + } + } +} diff --git a/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/TutorialSyntaxStorerFactory.java b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/TutorialSyntaxStorerFactory.java new file mode 100644 index 0000000000..79d413d59f --- /dev/null +++ b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/TutorialSyntaxStorerFactory.java @@ -0,0 +1,58 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2014, Commonwealth Scientific and Industrial Research Organisation + * + * This program is free software: you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If + * not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, + * Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable + * instead of those above. + * + * Copyright 2014, Commonwealth Scientific and Industrial Research Organisation + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package uk.ac.manchester.owl.owlapi.tutorialowled2011; + +import org.semanticweb.owlapi.model.OWLStorer; +import org.semanticweb.owlapi.util.OWLStorerFactoryImpl; + +/** + * @author Peter Ansell p_ansell@yahoo.com + * @since 4.0.0 + */ +public class TutorialSyntaxStorerFactory extends OWLStorerFactoryImpl { + + /** + * Default constructor. + */ + public TutorialSyntaxStorerFactory() { + super(new OWLTutorialSyntaxOntologyFormatFactory()); + } + + @Override + public OWLStorer createStorer() { + return new TutorialSyntaxStorer(); + } +} diff --git a/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/package-info.java b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/package-info.java new file mode 100644 index 0000000000..c35ba2e270 --- /dev/null +++ b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/package-info.java @@ -0,0 +1,16 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Tutorial classes. + */ +package uk.ac.manchester.owl.owlapi.tutorialowled2011; diff --git a/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/packageinfo b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/packageinfo new file mode 100644 index 0000000000..ca54300068 --- /dev/null +++ b/contract/src/main/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/packageinfo @@ -0,0 +1 @@ +version 5 diff --git a/contract/src/test/java/org/obolibrary/obo2owl/ImportsAndFailuresTestCase.java b/contract/src/test/java/org/obolibrary/obo2owl/ImportsAndFailuresTestCase.java new file mode 100644 index 0000000000..a62657ed35 --- /dev/null +++ b/contract/src/test/java/org/obolibrary/obo2owl/ImportsAndFailuresTestCase.java @@ -0,0 +1,80 @@ +package org.obolibrary.obo2owl; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.OBODocumentFormat; +import org.semanticweb.owlapi.io.StringDocumentSource; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; + +class ImportsAndFailuresTestCase extends TestBase { + + private static final IRI TEST_IMPORT = iri("http://purl.obolibrary.org/obo/uberon/", "test_import.owl"); + private static final IRI UBERON = IRI.create("urn:test:uberon"); + + protected StringDocumentSource inputSource(String input) { + return new StringDocumentSource(input, UBERON, new OBODocumentFormat(), null); + } + + static final String NO_INPUT = + "ontology: uberon\n" + "[Term]\nid: X:1\nname: x1\nrelationship: part_of X:2\n\n" + + "[Typedef]\nid: part_of\nxref: BFO:0000050"; + + static final String UBERON_CORE = "format-version: 1.2\n" + "ontology: uberon/core\n" + "\n" + "[Term]\n" + + "id: UBERON:0004138\n" + "name: somitomeric trunk muscle\n" + + "property_value: seeAlso \"string\"\n" + "\n" + "[Typedef]\n" + "id: seeAlso\n" + + "name: seeAlso\n" + "is_metadata_tag: true\n" + "is_class_level: true"; + + static final String UBERON_PATO = "format-version: 1.2\n" + + "import: http://purl.obolibrary.org/obo/uberon/pato_import.owl\n" + + "ontology: uberon/core\n" + "\n" + "[Term]\n" + "id: UBERON:0004138\n" + + "name: somitomeric trunk muscle\n" + "property_value: seeAlso \"string\"\n" + "\n" + + "[Typedef]\n" + "id: seeAlso\n" + "name: seeAlso\n" + "is_metadata_tag: true\n" + + "is_class_level: true"; + + static final String EMPTY_IMPORT = "ontology: uberon\n" + + "import: http://purl.obolibrary.org/obo/uberon/test_import.owl\n\n" + + "[Term]\nid: X:1\nname: x1\nrelationship: part_of X:2\n\n" + + "[Typedef]\nid: part_of\nxref: BFO:0000050"; + + @Test + void shouldNotFailOnEmptyImport() + throws OWLOntologyCreationException, OWLOntologyStorageException { + m1.createOntology(TEST_IMPORT); + OWLOntology o = m1.loadOntologyFromOntologyDocument(inputSource(EMPTY_IMPORT)); + StringDocumentTarget target = new StringDocumentTarget(); + o.saveOntology(new OBODocumentFormat(), target); + m.createOntology(TEST_IMPORT); + OWLOntology o1 = m.loadOntologyFromOntologyDocument(inputSource(EMPTY_IMPORT)); + equal(o, o1); + } + + @Test + void shouldNotFailOnNoImport() + throws OWLOntologyCreationException, OWLOntologyStorageException { + OWLOntology o = m1.loadOntologyFromOntologyDocument(inputSource(NO_INPUT)); + roundTrip(o, new OBODocumentFormat()); + } + + @Test + void shouldNotFailOnPatoImport() + throws OWLOntologyCreationException, OWLOntologyStorageException { + loadOntology("pato_import.owl", m1); + OWLOntology o = m1.loadOntologyFromOntologyDocument(inputSource(UBERON_PATO)); + loadOntology("pato_import.owl", m); + StringDocumentTarget target = new StringDocumentTarget(); + o.saveOntology(new OBODocumentFormat(), target); + OWLOntology o1 = m.loadOntologyFromOntologyDocument(inputSource(UBERON_PATO)); + equal(o, o1); + } + + @Test + void shouldNotFailOnNoPatoImport() + throws OWLOntologyCreationException, OWLOntologyStorageException { + OWLOntology o = m1.loadOntologyFromOntologyDocument(inputSource(UBERON_CORE)); + roundTrip(o, new OBODocumentFormat()); + } +} diff --git a/contract/src/test/java/org/obolibrary/oboformat/BasicsTestCase.java b/contract/src/test/java/org/obolibrary/oboformat/BasicsTestCase.java new file mode 100644 index 0000000000..ff5a7f12ae --- /dev/null +++ b/contract/src/test/java/org/obolibrary/oboformat/BasicsTestCase.java @@ -0,0 +1,1218 @@ +package org.obolibrary.oboformat; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import static org.semanticweb.owlapi.model.AxiomType.DISJOINT_CLASSES; +import static org.semanticweb.owlapi.model.AxiomType.EQUIVALENT_CLASSES; +import static org.semanticweb.owlapi.model.AxiomType.SUBCLASS_OF; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.StringReader; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.junit.jupiter.api.Test; +import org.obolibrary.macro.MacroExpansionGCIVisitor; +import org.obolibrary.macro.MacroExpansionVisitor; +import org.obolibrary.macro.ManchesterSyntaxTool; +import org.obolibrary.obo2owl.OWLAPIObo2Owl; +import org.obolibrary.obo2owl.OWLAPIOwl2Obo; +import org.obolibrary.obo2owl.Obo2OWLConstants.Obo2OWLVocabulary; +import org.obolibrary.oboformat.diff.Diff; +import org.obolibrary.oboformat.diff.OBODocDiffer; +import org.obolibrary.oboformat.model.Clause; +import org.obolibrary.oboformat.model.Frame; +import org.obolibrary.oboformat.model.Frame.FrameType; +import org.obolibrary.oboformat.model.FrameStructureException; +import org.obolibrary.oboformat.model.OBODoc; +import org.obolibrary.oboformat.model.QualifierValue; +import org.obolibrary.oboformat.model.Xref; +import org.obolibrary.oboformat.parser.OBOFormatConstants.OboFormatTag; +import org.obolibrary.oboformat.parser.OBOFormatParser; +import org.obolibrary.oboformat.parser.OBOFormatParserException; +import org.obolibrary.oboformat.parser.XrefExpander; +import org.obolibrary.oboformat.writer.OBOFormatWriter; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.OBODocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.io.OWLOntologyDocumentTarget; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationSubject; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLImportsDeclaration; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.search.Searcher; +import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; + +/** + * Tests for the conversion of rdfs:comment in OWL to remark tag in OBO. This is necessary as + * OBO-Edit won't load any OBO ontology containing a comment-tag in the ontology header. WARNING: + * This conversion will not conserve the order of remark tags in a round-trip via OWL. + */ +class BasicsTestCase extends OboFormatTestBasics { + + private static final String OBO_IN_OWL = "http://www.geneontology.org/formats/oboInOwl#"; + private static final String OBO = "http://purl.obolibrary.org/obo/"; + private static final String PART_OF = "part_of"; + private static final String HAS_PART = "has_part"; + private static final String CARO_OBO = "caro.obo"; + private static final String GENE_ONTOLOGY = "gene_ontology"; + private static final String BFO_0000050 = "BFO:0000050"; + private static final String X_1 = "X:1"; + private static final IRI SHORTHAND = iri(OBO_IN_OWL, "shorthand"); + private static final IRI ID = iri(OBO_IN_OWL, "id"); + private static final IRI BFO50 = iri(OBO, "BFO_0000050"); + private static final IRI RO2111 = iri(OBO, "RO_0002111"); + private static final IRI BAR1 = iri(OBO, "BAR_0000001"); + private static final IRI BFO51 = iri(OBO, "BFO_0000051"); + + private static void assertAnnotationPropertyCountEquals(OWLOntology owlOnt, IRI subjectIRI, + OWLAnnotationProperty property, int expected) { + List matches = asList(owlOnt + .annotationAssertionAxioms(subjectIRI).filter(ax -> ax.getProperty().equals(property))); + assertEquals( + + expected, matches.size(), + subjectIRI + " has too many annotations of type " + property + ":\n\t" + matches); + } + + private static void checkIdSpace(OBODoc doc) { + Frame headerFrame = doc.getHeaderFrame(); + assertNotNull(headerFrame); + Clause clause = headerFrame.getClause(OboFormatTag.TAG_IDSPACE); + assertNotNull(clause); + Collection values = clause.getValues(); + assertNotNull(values); + assertEquals(3, values.size()); + Iterator it = values.iterator(); + assertEquals("GO", it.next()); + assertEquals("urn:lsid:bioontology.org:GO:", it.next()); + assertEquals("gene ontology terms", it.next()); + } + + private static void checkIntersection(OWLClassExpression expression, String genus, String relId, + String differentia) { + OWLObjectIntersectionOf intersection = (OWLObjectIntersectionOf) expression; + List list = intersection.getOperandsAsList(); + OWLClass cls = (OWLClass) list.get(0); + assertEquals(genus, OWLAPIOwl2Obo.getIdentifier(cls.getIRI())); + OWLClassExpression rhs = list.get(1); + OWLClass cls2 = rhs.classesInSignature().iterator().next(); + assertEquals(differentia, OWLAPIOwl2Obo.getIdentifier(cls2.getIRI())); + OWLObjectProperty property = rhs.objectPropertiesInSignature().iterator().next(); + assertEquals(relId, OWLAPIOwl2Obo.getIdentifier(property.getIRI())); + } + + private static OBODoc createPVDoc() { + OBODoc oboDoc = new OBODoc(); + Frame headerFrame = new Frame(FrameType.HEADER); + headerFrame.addClause(new Clause(OboFormatTag.TAG_FORMAT_VERSION, "1.2")); + headerFrame.addClause(new Clause(OboFormatTag.TAG_ONTOLOGY, "test")); + addPropertyValue(headerFrame, "http://purl.org/dc/elements/1.1/title", + "Ontology for Biomedical Investigation", "xsd:string"); + addPropertyValue(headerFrame, "defaultLanguage", "en", "xsd:string"); + oboDoc.setHeaderFrame(headerFrame); + return oboDoc; + } + + private static void addPropertyValue(Frame frame, String v1, String v2, @Nullable String v3) { + Clause cl = new Clause(OboFormatTag.TAG_PROPERTY_VALUE); + cl.addValue(v1); + cl.addValue(v2); + if (v3 != null) { + cl.addValue(v3); + } + frame.addClause(cl); + } + + private static void checkFrame(OBODoc doc, String id, String name, String namespace) { + Frame frame = doc.getTermFrame(id); + if (frame == null) { + frame = doc.getTypedefFrame(id); + } + assertNotNull(frame); + assertEquals(name, frame.getTagValue(OboFormatTag.TAG_NAME)); + assertEquals(namespace, frame.getTagValue(OboFormatTag.TAG_NAMESPACE)); + } + + private static void checkOBODoc2(OBODoc obodoc) { + // OBODoc tests + Frame tf = obodoc.getTermFrame("x1"); // TODO - may change + assert tf != null; + Collection cs = tf.getClauses(OboFormatTag.TAG_INTERSECTION_OF); + assertNotEquals(1, cs.size()); + // there should NEVER be a situation with single intersection tags + // TODO - add validation step prior to saving + } + + @Test + void testCommentRemarkConversion() throws Exception { + OBODoc obo = parseOBOFile("comment_remark_conversion.obo", true, Collections.emptyMap()); + Frame headerFrame = obo.getHeaderFrame(); + assertNotNull(headerFrame); + Collection remarks = + headerFrame.getTagValues(OboFormatTag.TAG_REMARK, String.class); + OWLAPIObo2Owl obo2Owl = new OWLAPIObo2Owl(m1); + OWLOntology owlOntology = obo2Owl.convert(obo); + Set comments = + asUnorderedSet(owlOntology.annotations(df.getRDFSComment()).map(OWLAnnotation::getValue) + .filter(a -> a instanceof OWLLiteral).map(a -> ((OWLLiteral) a).getLiteral())); + // check that all remarks have been translated to rdfs:comment + assertEquals(remarks.size(), comments.size()); + assertTrue(comments.containsAll(remarks)); + assertTrue(remarks.containsAll(comments)); + OWLAPIOwl2Obo owl2Obo = new OWLAPIOwl2Obo(m1); + OBODoc oboRoundTrip = owl2Obo.convert(owlOntology); + Frame headerFrameRoundTrip = oboRoundTrip.getHeaderFrame(); + assertNotNull(headerFrameRoundTrip); + Collection remarksRoundTrip = + headerFrameRoundTrip.getTagValues(OboFormatTag.TAG_REMARK, String.class); + assertEquals(remarks.size(), remarksRoundTrip.size()); + assertTrue(remarksRoundTrip.containsAll(remarks)); + assertTrue(remarks.containsAll(remarksRoundTrip)); + } + + @Test + void testBFOROXrefCorrectIdAnnotationCount() { + OWLOntology owlOnt = convertOBOFile("rel_xref_test.obo"); + assertEquals(4, owlOnt.objectPropertiesInSignature().count()); + OWLAnnotationProperty OBO_ID = df.getOWLAnnotationProperty(ID); + // Check ID Property Count Exactly 1 + assertAnnotationPropertyCountEquals(owlOnt, BAR1, OBO_ID, 1); + assertAnnotationPropertyCountEquals(owlOnt, RO2111, OBO_ID, 1); + assertAnnotationPropertyCountEquals(owlOnt, BFO50, OBO_ID, 1); + assertAnnotationPropertyCountEquals(owlOnt, BFO51, OBO_ID, 2); + } + + @Test + void testBFOROXrefRelationXrefConversion() { + OWLOntology owlOnt = convertOBOFile("rel_xref_test.obo"); + // test initial conversion + OWLAnnotationProperty ap = df.getOWLAnnotationProperty(SHORTHAND); + assertEquals(4, owlOnt.objectPropertiesInSignature().count()); + Stream aaas = owlOnt.annotationAssertionAxioms(BFO51); + boolean ok = aaas.filter(ax -> ax.getProperty().equals(ap)) + .map(a -> (OWLLiteral) a.getValue()).anyMatch(v -> v.getLiteral().equals(HAS_PART)); + assertTrue(ok); + aaas = owlOnt.annotationAssertionAxioms(BFO50); + assertTrue(aaas.count() > 0); + aaas = owlOnt.annotationAssertionAxioms(RO2111); + assertTrue(aaas.count() > 0); + aaas = owlOnt.annotationAssertionAxioms(BAR1); + assertTrue(aaas.count() > 0); + OWLAPIOwl2Obo revbridge = new OWLAPIOwl2Obo(m1); + OBODoc d2 = revbridge.convert(owlOnt); + Frame partOf = d2.getTypedefFrame(PART_OF); + assert partOf != null; + Collection xrcs = partOf.getClauses(OboFormatTag.TAG_XREF); + boolean okBfo = false; + boolean okOboRel = false; + for (Clause c : xrcs) { + Xref value = c.getValue(Xref.class); + if (value.getIdref().equals(BFO_0000050)) { + okBfo = true; + } + if (value.getIdref().equals("OBO_REL:part_of")) { + okOboRel = true; + } + } + assertTrue(okBfo); + assertTrue(okOboRel); + Frame a = d2.getTermFrame("TEST:a"); + assert a != null; + Clause rc = a.getClause(OboFormatTag.TAG_RELATIONSHIP); + assert rc != null; + assertEquals(PART_OF, rc.getValue()); + assertEquals("TEST:b", rc.getValue2()); + } + + @Test + void testParseCARO() { + OBODoc obodoc = parseOBOFile(CARO_OBO); + assertTrue(obodoc.getTermFrames().size() > 2); + Frame cc = obodoc.getTermFrame("CARO:0000014"); + assertNotNull(cc); + assertEquals("cell component", cc.getTagValue(OboFormatTag.TAG_NAME)); + assertEquals("Anatomical structure that is a direct part of the cell.", + cc.getTagValue(OboFormatTag.TAG_DEF)); + Clause dc = cc.getClause(OboFormatTag.TAG_DEF); + assertNotNull(dc); + Collection dcxs = dc.getXrefs(); + assertEquals("CARO:MAH", dcxs.iterator().next().getIdref()); + /* + * Collection defxrefs = cc.getTagXrefs("def"); + * System.out.println("def xrefs = "+defxrefs); + * assertTrue(defxrefs.iterator().next().getIdref().equals("CARO:MAH")); + */ + // assertTrue(frame.getClause(OboFormatTag.TAG_NAME.getTag()).getValue().equals("x1")); + } + + @Test + void testDanglingOwl2OboConversion() throws Exception { + OBODoc doc = convert(parseOWLFile("dangling_owl2_obo_test.owl")); + Frame f = doc.getTermFrame("UBERON:0000020"); + assert f != null; + Clause rc = f.getClause(OboFormatTag.TAG_NAME); + assert rc != null; + assertEquals("sense organ", rc.getValue()); + Collection ics = f.getClauses(OboFormatTag.TAG_INTERSECTION_OF); + assertEquals(2, ics.size()); + writeOBO(doc); + } + + @Test + void testExpandChebiXRef() { + OBODoc obodoc = parseOBOFile("chebi_problematic_xref.obo"); + assertNotNull(obodoc); + } + + @Test + void testCurlyBracesInComments() { + /* + * Expect an parser exception, as the comment line contains '{' and '}'. This will lead the + * parser to try and parse it as a trailing qualifier, which fails in this case. + */ + assertThrows(OBOFormatParserException.class, () -> parseOBOFile("fbbt_comment_test.obo")); + } + + @Test + void testWriteCurlyBracesInComments() throws Exception { + OBODoc doc = new OBODoc(); + Frame h = new Frame(FrameType.HEADER); + h.addClause(new Clause(OboFormatTag.TAG_ONTOLOGY, "test")); + doc.setHeaderFrame(h); + Frame t = new Frame(FrameType.TERM); + String id = "TEST:0001"; + t.setId(id); + t.addClause(new Clause(OboFormatTag.TAG_ID, id)); + String comment = "Comment with a '{' curly braces '}'"; + t.addClause(new Clause(OboFormatTag.TAG_COMMENT, comment)); + doc.addFrame(t); + String oboString = renderOboToString(doc); + assertTrue(oboString.contains("comment: Comment with a '\\{' curly braces '\\}'")); + OBODoc doc2 = parseOboToString(oboString); + assertNotNull(doc2); + Frame termFrame = doc2.getTermFrame(id); + assertNotNull(termFrame); + assertEquals(comment, termFrame.getTagValue(OboFormatTag.TAG_COMMENT)); + } + + @Test + void testDanglingRestrictionOwl2OboConversion() throws Exception { + // this is a test ontology that has had its imports axioms removed + OBODoc doc = convert(parseOWLFile("dangling_restriction_test.owl")); + Frame f = doc.getTermFrame("FUNCARO:0000014"); + assert f != null; + Clause rc = f.getClause(OboFormatTag.TAG_NAME); + assert rc != null; + assertEquals("digestive system", rc.getValue()); + Collection isas = f.getClauses(OboFormatTag.TAG_IS_A); + assertEquals(1, isas.size()); + Collection rs = f.getClauses(OboFormatTag.TAG_RELATIONSHIP); + assertEquals(1, rs.size()); + writeOBO(doc); + } + + @Test + void testDanglingRoundTripConvertXPs() throws Exception { + OWLOntology owlOnt = convertOBOFile("dangling_roundtrip_test.obo"); + OWLAPIOwl2Obo revbridge = new OWLAPIOwl2Obo(m1); + OBODoc d2 = revbridge.convert(owlOnt); + Frame f = d2.getTermFrame("UBERON:0000020"); + assert f != null; + Clause rc = f.getClause(OboFormatTag.TAG_NAME); + assert rc != null; + assertEquals("sense organ", rc.getValue()); + OBOFormatWriter w = new OBOFormatWriter(); + w.write(d2, File.createTempFile("zzz", ".obo")); + } + + @Test + void testDbXrefCommentsRoundtrip() throws Exception { + OBODoc obodoc = parseOBOFile("db_xref_comments.obo"); + Frame frame = obodoc.getTermFrame("MOD:00516"); + assertNotNull(frame); + Clause defClause = frame.getClause(OboFormatTag.TAG_DEF); + assertNotNull(defClause); + Collection xrefs = defClause.getXrefs(); + assertEquals(2, xrefs.size()); + Iterator iterator = xrefs.iterator(); + Xref xref1 = iterator.next(); + assertEquals("RESID:AA0151", xref1.getIdref()); + String annotation = xref1.getAnnotation(); + assertEquals("variant", annotation); + Xref xref2 = iterator.next(); + assertEquals("UniMod:148", xref2.getIdref()); + String original = readResource("db_xref_comments.obo"); + String renderedOboString = renderOboToString(obodoc); + assertEquals(original, renderedOboString); + } + + @Test + void testDuplicateTags() throws Exception { + OWLOntology owl = parseOWLFile("duplicate-def.ofn"); + final List duplicates = new ArrayList<>(); + OWLAPIOwl2Obo owl2Obo = new OWLAPIOwl2Obo(m1) { + + @Override + protected boolean handleDuplicateClause(Frame frame, Clause clause) { + duplicates.add(clause); + return super.handleDuplicateClause(frame, clause); + } + }; + OBODoc convert = owl2Obo.convert(owl); + assertEquals(1, duplicates.size()); + // test that no exception is thrown during write. + renderOboToString(convert); + } + + @Test + void testEmptyFirstLine() { + OBODoc obodoc = parseOBOFile("empty_lines.obo"); + Collection frames = obodoc.getTermFrames(); + assertEquals(1, frames.size()); + assertEquals("GO:0009555", frames.iterator().next().getId()); + } + + @Test + void testConvertEquivalentTo() throws Exception { + // PARSE TEST FILE + OWLOntology ontology = convert(parseOBOFile("equivtest.obo")); + // TEST CONTENTS OF OWL ONTOLOGY + assertEquals(2, ontology.axioms(EQUIVALENT_CLASSES).count()); + // CONVERT BACK TO OBO + OWLAPIOwl2Obo owl2obo = new OWLAPIOwl2Obo(m1); + OBODoc obodoc = owl2obo.convert(ontology); + checkOBODoc(obodoc); + // ROUNDTRIP AND TEST AGAIN + OBOFormatWriter w = new OBOFormatWriter(); + ByteArrayOutputStream os = new ByteArrayOutputStream(); + try (OutputStreamWriter osw = new OutputStreamWriter(os, StandardCharsets.UTF_8); + BufferedWriter out = new BufferedWriter(osw); + PrintWriter bufferedWriter = new PrintWriter(out);) { + w.write(obodoc, bufferedWriter); + } + OBOFormatParser p = new OBOFormatParser(); + obodoc = p.parse( + new BufferedReader(new InputStreamReader(new ByteArrayInputStream(os.toByteArray())))); + checkOBODoc(obodoc); + } + + void checkOBODoc(OBODoc obodoc) { + // OBODoc tests + // test ECA between named classes is persisted using correct tag + Frame tf = obodoc.getTermFrame(X_1); + assert tf != null; + Collection cs = tf.getClauses(OboFormatTag.TAG_EQUIVALENT_TO); + assertEquals(1, cs.size()); + Object v = cs.iterator().next().getValue(); + assertEquals("X:2", v); + // test ECA between named class and anon class is persisted as + // genus-differentia intersection_of tags + tf = obodoc.getTermFrame(X_1); + assert tf != null; + cs = tf.getClauses(OboFormatTag.TAG_INTERSECTION_OF); + assertEquals(2, cs.size()); + boolean okGenus = false; + boolean okDifferentia = false; + for (Clause c : cs) { + Collection vs = c.getValues(); + if (vs.size() == 2) { + if (c.getValue().equals("R:1") && c.getValue2().equals("Z:1")) { + okDifferentia = true; + } + } else if (vs.size() == 1) { + if (c.getValue().equals("Y:1")) { + okGenus = true; + } + } else { + fail(); + } + } + assertTrue(okGenus); + assertTrue(okDifferentia); + // check reciprocal direction + Frame tf2 = obodoc.getTermFrame("X:2"); + assert tf2 != null; + Collection cs2 = tf2.getClauses(OboFormatTag.TAG_EQUIVALENT_TO); + Frame tf1 = obodoc.getTermFrame(X_1); + assert tf1 != null; + Collection cs1 = tf1.getClauses(OboFormatTag.TAG_EQUIVALENT_TO); + assertTrue(cs1.size() == 1 || cs2.size() == 1); + assertTrue("X:2".equals(cs1.iterator().next().getValue(String.class)) + || X_1.equals(cs2.iterator().next().getValue(String.class))); + } + + @Test + void testExpandExpressionGCI() { + OWLOntology ontology = convert(parseOBOFile("no_overlap.obo")); + MacroExpansionGCIVisitor mev = new MacroExpansionGCIVisitor(m1, ontology, false); + OWLOntology gciOntology = mev.createGCIOntology(); + int axiomCount = gciOntology.getAxiomCount(); + assertTrue(axiomCount > 0); + assertEquals(1, gciOntology.disjointClassesAxioms(C2).count()); + gciOntology.axioms(EQUIVALENT_CLASSES).forEach(eca -> { + Set ces = asUnorderedSet(eca.classExpressions()); + OWLObjectPropertyExpression p = df.getOWLObjectProperty(OBO, "RO_0002104"); + OWLClassExpression cet4 = df.getOWLObjectSomeValuesFrom(p, C4); + OWLClassExpression cet5 = df.getOWLObjectSomeValuesFrom(p, C5); + if (ces.contains(cet4)) { + ces.remove(cet4); + OWLClassExpression clst4ex = ces.iterator().next(); + assertEquals("ObjectSomeValuesFrom(" + BFO51.toQuotedString() + + " ObjectIntersectionOf( ObjectSomeValuesFrom(" + + BFO51.toQuotedString() + " " + C4.getIRI().toQuotedString() + ")))", + clst4ex.toString()); + } else if (ces.contains(cet5)) { + ces.remove(cet5); + OWLClassExpression clst5ex = ces.iterator().next(); + assertEquals("ObjectSomeValuesFrom(" + BFO51.toQuotedString() + + " ObjectIntersectionOf( ObjectSomeValuesFrom(" + + BFO51.toQuotedString() + " )))", + clst5ex.toString()); + } else { + fail("Unknown OWLEquivalentClassesAxiom: " + eca); + } + }); + } + + @Test + void testExpandExpression() { + OWLOntology ontology = convert(parseOBOFile("no_overlap.obo")); + MacroExpansionVisitor mev = new MacroExpansionVisitor(ontology); + OWLOntology outputOntology = mev.expandAll(); + assertEquals(1, outputOntology.disjointClassesAxioms(C2).count()); + assertEquals(1, outputOntology.subClassAxiomsForSubClass(C3).count()); + assertEquals("SubClassOf( ObjectSomeValuesFrom(" + + BFO51.toQuotedString() + + " ObjectIntersectionOf( ObjectSomeValuesFrom(" + + BFO51.toQuotedString() + " ))))", + outputOntology.subClassAxiomsForSubClass(C3).iterator().next().toString()); + AtomicBoolean ok = new AtomicBoolean(false); + outputOntology.equivalentClassesAxioms(C4) + .flatMap(OWLEquivalentClassesAxiom::classExpressions) + .filter(ce -> ce instanceof OWLObjectIntersectionOf) + .flatMap(x -> ((OWLObjectIntersectionOf) x).operands()) + .filter(y -> y instanceof OWLObjectSomeValuesFrom) + .map(y -> ((OWLObjectSomeValuesFrom) y).getProperty().toString()).forEach(pStr -> { + assertEquals(BFO51.toQuotedString(), pStr); + ok.set(true); + }); + assertTrue(ok.get()); + writeOWL(ontology); + } + + @Test + void testExpandSynapsedTo() { + OWLOntology ontology = convert(parseOBOFile("synapsed_to.obo")); + MacroExpansionGCIVisitor mev = new MacroExpansionGCIVisitor(m1, ontology, false); + OWLOntology gciOntology = mev.createGCIOntology(); + int axiomCount = gciOntology.getAxiomCount(); + assertTrue(axiomCount > 0); + assertEquals(4, gciOntology.axioms().count()); + } + + @Test + void testExpandWithAnnotations() { + OWLOntology ontology = convert(parseOBOFile("annotated_no_overlap.obo")); + MacroExpansionVisitor mev = new MacroExpansionVisitor(ontology, true, true); + OWLOntology gciOntology = mev.expandAll(); + gciOntology.axioms(DISJOINT_CLASSES) + .forEach(ax -> assertEquals(2, ax.annotations().count())); + } + + @Test + void testExpandNothing() { + OWLOntology ontology = convert(parseOBOFile("nothing_expansion_test.obo")); + MacroExpansionGCIVisitor mev = new MacroExpansionGCIVisitor(m1, ontology, false); + OWLOntology gciOntology = mev.createGCIOntology(); + int axiomCount = gciOntology.getAxiomCount(); + assertEquals(2, axiomCount); + assertEquals(2, gciOntology.axioms().count()); + } + + @Test + void testConvertGCIQualifier() { + // PARSE TEST FILE, CONVERT TO OWL, AND WRITE TO OWL FILE + OWLOntology ontology = convert(parseOBOFile("gci_qualifier_test.obo")); + long scas = ontology.axioms(SUBCLASS_OF).count(); + boolean ok = scas > 0; + assertTrue(ok); + // CONVERT BACK TO OBO + OBODoc obodoc = convert(ontology); + // test that relation IDs are converted back to symbolic form + Frame tf = obodoc.getTermFrame(X_1); + assert tf != null; + Collection clauses = tf.getClauses(OboFormatTag.TAG_RELATIONSHIP); + assertEquals(2, clauses.size()); + } + + /** + * During the conversion of the RDF/XML file the ontology header tags are lost. The possible + * reason is that the RDFXMLOntologyFormat format writes the annotation assertion axioms as + * annotations. + */ + @Test + void testHeaderLostBug() { + OWLOntology ontology = + roundTrip(convert(parseOBOFile("header_lost_bug.obo")), new RDFXMLDocumentFormat()); + IRI ontologyIRI = iri(OBO, "test.owl"); + // two tags in the header of the obo file are translated as annotation + // assertions, so the axioms + // should have two axioms in count. + assertEquals(2, ontology.annotationsAsList().size()); + assertEquals(0, ontology.annotationAssertionAxioms(ontologyIRI).count()); + } + + @Test + void testExpandHomeomorphicRelation() { + OWLOntology owlOnt = convertOBOFile("homrel.obo"); + assertNotNull(owlOnt); + } + + @Test + void testIdSpace() throws Exception { + OBODoc doc1 = parseOBOFile("idspace_test.obo"); + checkIdSpace(doc1); + String oboString = renderOboToString(doc1); + assertTrue( + oboString.contains("idspace: GO urn:lsid:bioontology.org:GO: \"gene ontology terms\"")); + OBODoc doc2 = parseOboToString(oboString); + checkIdSpace(doc2); + } + + @Test + void testIgnoreImportAnnotations() { + OBODoc oboDoc = parseOBOFile("annotated_import.obo"); + Frame headerFrame = oboDoc.getHeaderFrame(); + assertNotNull(headerFrame); + Collection imports = headerFrame.getClauses(OboFormatTag.TAG_IMPORT); + assertEquals(1, imports.size()); + Clause clause = imports.iterator().next(); + Collection qualifierValues = clause.getQualifierValues(); + assertTrue(qualifierValues.isEmpty()); + } + + @Test + void testImportsConverted() throws OWLOntologyCreationException { + Map cache = new HashMap<>(); + IRI iri = iri("http://purl.obolibrary.org/obo/tests/", "test.obo"); + cache.put(iri.toString(), new OBODoc()); + m.createOntology(iri); + OBODoc oboDoc = parseOBOFile("annotated_import.obo", false, cache); + OWLAPIObo2Owl toOWL = new OWLAPIObo2Owl(m); + Stream imports = toOWL.convert(oboDoc).importsDeclarations(); + assertTrue(imports.allMatch(i -> i.getIRI().equals(iri))); + } + + @Test + void testConvertLogicalDefinitionPropertyView() { + // PARSE TEST FILE + OWLOntology owlOntology = + convert(parseOBOFile("logical-definition-view-relation-test.obo")); + OWLObjectProperty op = df.getOWLObjectProperty(OBO, "BFO_0000050"); + boolean ok = + owlOntology.axioms(EQUIVALENT_CLASSES).anyMatch(eca -> eca.classExpressions().anyMatch( + x -> x instanceof OWLObjectSomeValuesFrom && x.containsEntityInSignature(op))); + assertTrue(ok); + // reverse translation + OBODoc obodoc = convert(owlOntology); + Frame fr = obodoc.getTermFrame(X_1); + assert fr != null; + Collection clauses = fr.getClauses(OboFormatTag.TAG_INTERSECTION_OF); + assertEquals(2, clauses.size()); + } + + /* + * + * Note there is currently a bug whereby blocks of constraints are not translated. E.g + * + * [Term] id: GO:0009657 name: plastid organization relationship: never_in_taxon NCBITaxon:33208 + * {id="GOTAX:0000492", source="PMID:21311032"} ! Metazoa relationship: never_in_taxon + * NCBITaxon:4751 {id="GOTAX:0000502", source="PMID:21311032"} ! Fungi relationship: + * never_in_taxon NCBITaxon:28009 {id="GOTAX:0000503", source="PMID:21311032"} ! + * Choanoflagellida relationship: never_in_taxon NCBITaxon:554915 {id="GOTAX:0000504", + * source="PMID:21311032"} ! Amoebozoa + */ + @Test + void testExpandTaxonConstraints() { + OWLOntology ontology = convert(parseOBOFile("taxon_constraints.obo")); + MacroExpansionVisitor mev = new MacroExpansionVisitor(ontology); + OWLOntology outputOntology = mev.expandAll(); + assertTrue(outputOntology.axioms(DISJOINT_CLASSES).iterator().hasNext()); + } + + @Test + void testParseManchesterSyntaxToolIds() { + OWLOntology owlOntology = convert(parseOBOFile("simplego.obo")); + ManchesterSyntaxTool parser = new ManchesterSyntaxTool(owlOntology); + OWLClassExpression expression = + parser.parseManchesterExpression("GO_0018901 AND BFO:0000050 some GO_0055124"); + checkIntersection(expression, "GO:0018901", BFO_0000050, "GO:0055124"); + } + + @Test + void testParseManchesterSyntaxToolNames() { + OWLOntology owlOntology = convert(parseOBOFile("simplego.obo")); + ManchesterSyntaxTool parser = new ManchesterSyntaxTool(owlOntology); + OWLClassExpression expression = parser.parseManchesterExpression( + "'2,4-dichlorophenoxyacetic acid metabolic process' AND 'part_of' some 'premature neural plate formation'"); + checkIntersection(expression, "GO:0018901", BFO_0000050, "GO:0055124"); + } + + @Test + void testCheckForMultipleCommentsinFrame() throws Exception { + OBODoc obodoc = parseOBOFile("multiple_comments_test.obo"); + assertEquals(1, obodoc.getTermFrames().size()); + Frame frame = obodoc.getTermFrames().iterator().next(); + assertNotNull(frame); + assertThrows(FrameStructureException.class, () -> renderOboToString(obodoc)); + } + + @Test + void testConvertCAROObo2Owl() { + OWLOntology owlOnt = convertOBOFile(CARO_OBO); + assertNotNull(owlOnt); + } + + @Test + void testConvertXPWithQVObo2Owl() { + OWLOntology owlOnt = convertOBOFile("testqvs.obo"); + assertNotNull(owlOnt); + } + + @Test + void testIdenticalOBODocDiffer() { + OBODoc obodoc1 = parseOBOFile(CARO_OBO); + OBODoc obodoc2 = parseOBOFile(CARO_OBO); + List diffs = OBODocDiffer.getDiffs(obodoc1, obodoc2); + assertEquals(0, diffs.size()); + } + + @Test + void testDiffOBODocDiffer() { + OBODoc obodoc1 = parseOBOFile(CARO_OBO); + OBODoc obodoc2 = parseOBOFile("caro_modified.obo"); + List diffs = OBODocDiffer.getDiffs(obodoc1, obodoc2); + assertEquals(19, diffs.size()); + } + + @Test + void writeTypeDefComments() throws Exception { + OBODoc doc = parseOBOFile("typedef_comments.obo", true, Collections.emptyMap()); + String original = readResource("typedef_comments.obo"); + String written = renderOboToString(doc); + assertEquals(original, written); + } + + @Test + void testOBOEscapeChars() { + OBODoc obodoc = parseOBOFile("escape_chars_test.obo"); + assertEquals(3, obodoc.getTermFrames().size()); + Frame f1 = obodoc.getTermFrame("GO:0033942"); + assertNotNull(f1); + assertEquals("GO:0033942", f1.getId()); + Clause nameClause = f1.getClause(OboFormatTag.TAG_NAME); + assertNotNull(nameClause); + assertEquals("4-alpha-D-{(1->4)-alpha-D-glucano}trehalose trehalohydrolase activity", + nameClause.getValue()); + Frame f2 = obodoc.getTermFrame("CL:0000096"); + assertNotNull(f2); + assertEquals("CL:0000096", f2.getId()); + Clause defClause = f2.getClause(OboFormatTag.TAG_DEF); + assertNotNull(defClause); + assertEquals("bla bla .\"", defClause.getValue()); + Clause commentClause = f2.getClause(OboFormatTag.TAG_COMMENT); + assertNotNull(commentClause); + assertEquals("bla bla bla.\nbla bla (bla).", commentClause.getValue()); + } + + @Test + void testOBORoundTripEscapeChars() throws Exception { + OBODoc oboDoc = parseOBOFile("escape_chars_test.obo"); + String oboToString = renderOboToString(oboDoc); + OBODoc oboDoc2 = parseOboToString(oboToString); + assertNotNull(oboDoc2); + List diffs = OBODocDiffer.getDiffs(oboDoc, oboDoc2); + assertEquals(0, diffs.size()); + String original = readResource("escape_chars_test.obo"); + assertEquals(original, oboToString); + } + + @Test + void testExpandPropertyValue() { + OBODoc obodoc = parseOBOFile("property_value_test.obo"); + Frame termFrame = obodoc.getTermFrame("UBERON:0004657"); + assertNotNull(termFrame); + Clause propertyValue = termFrame.getClause(OboFormatTag.TAG_PROPERTY_VALUE); + assertNotNull(propertyValue); + assertEquals("IAO:0000412", propertyValue.getValue()); + assertEquals("http://purl.obolibrary.org/obo/uberon.owl", propertyValue.getValue2()); + } + + @Test + void testWriteReadValuesPropertyValue() throws Exception { + OBODoc doc = createPVDoc(); + String oboString = renderOboToString(doc); + OBODoc doc2 = parseOboToString(oboString); + List diffs = OBODocDiffer.getDiffs(doc, doc2); + assertEquals(0, diffs.size()); + } + + @Test + void testParseOBOFileSimpleGO() { + OBODoc obodoc = parseOBOFile("simplego.obo"); + assertEquals(3, obodoc.getTermFrames().size()); + assertEquals(5, obodoc.getTypedefFrames().size()); + checkFrame(obodoc, "GO:0018901", "2,4-dichlorophenoxyacetic acid metabolic process", + "biological_process"); + checkFrame(obodoc, "GO:0055124", "premature neural plate formation", "biological_process"); + checkFrame(obodoc, "GO:0055125", "Nic96 complex", "cellular_component"); + checkFrame(obodoc, HAS_PART, HAS_PART, GENE_ONTOLOGY); + checkFrame(obodoc, "negatively_regulates", "negatively_regulates", GENE_ONTOLOGY); + checkFrame(obodoc, PART_OF, PART_OF, GENE_ONTOLOGY); + checkFrame(obodoc, "positively_regulates", "positively_regulates", GENE_ONTOLOGY); + checkFrame(obodoc, "regulates", "regulates", GENE_ONTOLOGY); + } + + @Test + void testParseOBOFileSingleIntersectionOfTag() throws Exception { + OBODoc obodoc = parseOBOFile("single_intersection_of_tag_test.obo"); + assertEquals(2, obodoc.getTermFrames().size()); + Frame frame = obodoc.getTermFrames().iterator().next(); + assertNotNull(frame); + assertThrows(FrameStructureException.class, () -> renderOboToString(obodoc)); + } + + @Test + void testIDs() throws OWLOntologyCreationException { + OBODoc doc = new OBODoc(); + Frame header = new Frame(FrameType.HEADER); + Clause c = new Clause(OboFormatTag.TAG_ONTOLOGY.getTag()); + c.setValue("test"); + header.addClause(c); + doc.setHeaderFrame(header); + OWLAPIObo2Owl obo2owl = new OWLAPIObo2Owl(m1); + OWLAPIOwl2Obo owl2Obo = new OWLAPIOwl2Obo(m1); + OWLOntology ontology = obo2owl.convert(doc); + owl2Obo.convert(ontology); + // Obo 2 OWL + IRI iri = obo2owl.oboIdToIRI("GO:001"); + assertEquals("http://purl.obolibrary.org/obo/GO_001", iri.toString()); + // OWL 2 obo + String oboId = OWLAPIOwl2Obo.getIdentifier(iri); + assertEquals("GO:001", oboId); + iri = obo2owl.oboIdToIRI("My_Ont:FOO_002"); + assertEquals("http://purl.obolibrary.org/obo/My_Ont#_FOO_002", iri.toString()); + oboId = OWLAPIOwl2Obo.getIdentifier(iri); + assertEquals("My_Ont:FOO_002", oboId); + iri = obo2owl.oboIdToIRI("My_Ont:002"); + assertEquals("http://purl.obolibrary.org/obo/My_Ont_002", iri.toString()); + // OWL 2 obo + oboId = OWLAPIOwl2Obo.getIdentifier(iri); + assertEquals("My_Ont:002", oboId); + // unprefixed IDs are prefixed with the current ontology ID + iri = obo2owl.oboIdToIRI("003"); + assertEquals("http://purl.obolibrary.org/obo/test#003", iri.toString()); + // OWL 2 obo + oboId = OWLAPIOwl2Obo.getIdentifier(iri); + assertEquals("003", oboId); + // arbitrary URL to obo ID + oboId = + OWLAPIOwl2Obo.getIdentifier(iri("http://purl.obolibrary.org/obo/alternate#", "abcdef")); + // todo - test this + // System.out.println("== "+oboId); + iri = obo2owl.oboIdToIRI(PART_OF); + assertEquals("http://purl.obolibrary.org/obo/test#part_of", iri.toString()); + // OWL 2 obo + oboId = OWLAPIOwl2Obo.getIdentifier(iri); + assertEquals(PART_OF, oboId); + iri = obo2owl.oboIdToIRI("OBO_REL:part_of"); + assertEquals("http://purl.obolibrary.org/obo/OBO_REL#_part_of", iri.toString()); + // OWL 2 obo + oboId = OWLAPIOwl2Obo.getIdentifier(iri); + assertEquals("OBO_REL:part_of", oboId); + iri = obo2owl.oboIdToIRI("http://purl.obolibrary.org/testont"); + assertEquals("http://purl.obolibrary.org/testont", iri.toString()); + // OWL 2 obo + oboId = OWLAPIOwl2Obo.getIdentifier(iri); + assertEquals("http://purl.obolibrary.org/testont", oboId); + iri = obo2owl.oboIdToIRI("http://purl.obolibrary.org/obo/BFO_0000050"); + assertEquals("http://purl.obolibrary.org/obo/BFO_0000050", iri.toString()); + // OWL 2 obo + oboId = OWLAPIOwl2Obo.getIdentifier(iri); + assertEquals(BFO_0000050, oboId); + // MGI IDs are perverse - they have a double-separator + iri = obo2owl.oboIdToIRI("MGI:MGI:1"); + assertEquals("http://purl.obolibrary.org/obo/MGI_MGI%3A1", iri.toString()); + // OWL 2 obo + oboId = OWLAPIOwl2Obo.getIdentifier(iri); + assertEquals("MGI:MGI:1", oboId); + } + + @Test + void testConvertObsoleteTerm() { + // PARSE TEST FILE + OWLOntology ontology = convert(parseOBOFile("obsolete_term_test.obo")); + // TEST CONTENTS OF OWL ONTOLOGY + OWLAnnotationSubject subj = iri(OBO, "XX_0000034"); + boolean okDeprecated = Searcher + .annotationObjects(ontology.annotationAssertionAxioms(subj), + df.getOWLAnnotationProperty(OWLRDFVocabulary.OWL_DEPRECATED)) + .map(OWLAnnotation::getValue).map(x -> (OWLLiteral) x).filter(OWLLiteral::isBoolean) + .filter(OWLLiteral::parseBoolean).findAny().isPresent(); + assertTrue(okDeprecated); + // CONVERT TO OWL FILE + writeOWL(ontology, new RDFXMLDocumentFormat()); + // CONVERT BACK TO OBO + OBODoc obodoc = convert(ontology); + Frame tf = obodoc.getTermFrame("XX:0000034"); + assert tf != null; + Clause c = tf.getClause(OboFormatTag.TAG_IS_OBSELETE); + assert c != null; + Object v = c.getValue(); + assertEquals(Boolean.TRUE, v); + } + + @Test + void testConvertXPsPropertyChain() { + assertNotNull(parseOBOFile("chaintest.obo", true, Collections.emptyMap())); + } + + @Test + void testConvertRelationShorthand() { + // PARSE TEST FILE, CONVERT TO OWL, AND WRITE TO OWL FILE + OWLOntology ontology = convert(parseOBOFile("relation_shorthand_test.obo")); + // TEST CONTENTS OF OWL ONTOLOGY + List scas = asList(ontology.axioms(SUBCLASS_OF)); + boolean ok = false; + for (OWLSubClassOfAxiom sca : scas) { + OWLClassExpression sup = sca.getSuperClass(); + if (sup instanceof OWLObjectSomeValuesFrom) { + OWLObjectProperty p = + (OWLObjectProperty) ((OWLObjectSomeValuesFrom) sup).getProperty(); + OWLClass v = (OWLClass) ((OWLObjectSomeValuesFrom) sup).getFiller(); + if (p.getIRI().equals(BFO51) + && v.getIRI().toString().equals("http://purl.obolibrary.org/obo/GO_0004055")) { + ok = true; + } + } + } + assertTrue(ok); + scas = asList(ontology.axioms(SUBCLASS_OF)); + ok = false; + for (OWLSubClassOfAxiom sca : scas) { + OWLClassExpression sup = sca.getSuperClass(); + if (sup instanceof OWLObjectSomeValuesFrom) { + OWLObjectProperty p = + (OWLObjectProperty) ((OWLObjectSomeValuesFrom) sup).getProperty(); + OWLClass v = (OWLClass) ((OWLObjectSomeValuesFrom) sup).getFiller(); + if (p.getIRI().equals(BFO50) + && v.getIRI().toString().equals("http://purl.obolibrary.org/obo/XX_0000001")) { + ok = true; + } + } + } + assertTrue(ok); + // CONVERT BACK TO OBO + OBODoc obodoc = convert(ontology); + // test that relation IDs are converted back to symbolic form + Frame tf = obodoc.getTermFrame("GO:0000050"); + assert tf != null; + Clause c = tf.getClause(OboFormatTag.TAG_RELATIONSHIP); + assert c != null; + Object v = c.getValue(); + // should be converted back to symbolic form + assertEquals(HAS_PART, v); + tf = obodoc.getTermFrame("GO:0004055"); + assert tf != null; + c = tf.getClause(OboFormatTag.TAG_RELATIONSHIP); + assert c != null; + v = c.getValue(); + // should be converted back to symbolic form + assertEquals(PART_OF, v); + tf = obodoc.getTypedefFrame(HAS_PART); + assert tf != null; + Collection cs = tf.getClauses(OboFormatTag.TAG_XREF); + assertEquals(1, cs.size()); + v = cs.iterator().next().getValue(Xref.class).getIdref(); + // should be converted back to symbolic form + assertEquals("BFO:0000051", v); + } + + @Test + void testRoundTripMultiLineDefinitions() throws Exception { + // create minimal ontology + OBODoc oboDocSource = new OBODoc(); + oboDocSource.setHeaderFrame(new Frame(FrameType.HEADER)); + oboDocSource.addDefaultOntologyHeader("caro"); + // add source frame that contains at least one new line + Frame sourceFrame = new Frame(FrameType.TERM); + sourceFrame.setId("CARO:0000049"); + sourceFrame.addClause(new Clause(OboFormatTag.TAG_DEF, + "Sequential hermaphroditic organism that produces\ngametes first of the male sex, and then later of the\nfemale sex.")); + oboDocSource.addTermFrame(sourceFrame); + // convert to OWL and retrieve def + OWLAPIObo2Owl bridge = new OWLAPIObo2Owl(m1); + OWLOntology owlOntology = bridge.convert(oboDocSource); + OWLDataFactory factory = owlOntology.getOWLOntologyManager().getOWLDataFactory(); + // IRI + IRI iri = bridge.oboIdToIRI("CARO:0000049"); + OWLClass c = factory.getOWLClass(iri); + // Def + OWLAnnotationProperty defProperty = + factory.getOWLAnnotationProperty(Obo2OWLVocabulary.IRI_IAO_0000115); + int counter = 0; + for (OWLAnnotationAssertionAxiom ax : asList( + owlOntology.annotationAssertionAxioms(c.getIRI()))) { + if (ax.getProperty().equals(defProperty)) { + counter++; + assertTrue(ax.getValue() instanceof OWLLiteral); + String owlDef = ((OWLLiteral) ax.getValue()).getLiteral(); + // check that owl def also contains at least one new line + assertTrue(owlDef.indexOf('\n') > 0); + } + } + assertEquals(1, counter); + // convert back to OBO + OWLAPIOwl2Obo owl2Obo = new OWLAPIOwl2Obo(m1); + OBODoc convertedOboDoc = owl2Obo.convert(owlOntology); + Frame convertedFrame = convertedOboDoc.getTermFrame("CARO:0000049"); + assert convertedFrame != null; + String convertedDef = convertedFrame.getTagValue(OboFormatTag.TAG_DEF, String.class); + assert convertedDef != null; + // check that round trip still contains newlines + assertTrue(convertedDef.indexOf('\n') > 0); + } + + @Test + void testConvertSubset() { + // PARSE TEST FILE + OWLOntology ontology = convert(parseOBOFile("subset_test.obo")); + OWLAnnotationSubject subj = iri(OBO, "GO_0000003"); + OWLAnnotationProperty p = df.getOWLAnnotationProperty(OBO_IN_OWL, "inSubset"); + boolean ok = + ontology.annotationAssertionAxioms(subj).anyMatch(a -> a.getProperty().equals(p)); + assertTrue(ok); + } + + @Test + void testConvertSynonym() { + // PARSE TEST FILE + assertNotNull(convert(parseOBOFile("synonym_test.obo"))); + } + + @Test + void testUnionOf() { + OWLOntology owlOnt = convertOBOFile("taxon_union_terms.obo"); + assertNotNull(owlOnt); + OWLClass cls = df.getOWLClass(OBO, "NCBITaxon_Union_0000000"); + boolean ok = owlOnt.equivalentClassesAxioms(cls).flatMap(ax -> ax.classExpressions()) + .anyMatch(ce -> ce instanceof OWLObjectUnionOf); + assertTrue(ok); + } + + @Test + void testConvertUnmappableExpressions() throws Exception { + OWLAPIOwl2Obo bridge = new OWLAPIOwl2Obo(m1); + bridge.setMuteUntranslatableAxioms(true); + OBODoc doc = bridge.convert(parseOWLFile("nesting.owl")); + assertEquals(1, bridge.getUntranslatableAxioms().size()); + OBODoc obodoc = doc; + // checkOBODoc(obodoc); + // ROUNDTRIP AND TEST AGAIN + String file = writeOBO(obodoc); + obodoc = parseOBOFile(new StringReader(file), false, Collections.emptyMap()); + checkOBODoc2(obodoc); + } + + @Test + void testConvertXPBridgeFile() { + OWLOntology owlOnt = convertOBOFile("xptest.obo"); + assertNotNull(owlOnt); + } + + @Test + void testXRefExpander() { + OBODoc obodoc = parseOBOFile("treat_xrefs_test.obo"); + XrefExpander x = new XrefExpander(obodoc); + x.expandXrefs(); + OBODoc tdoc = obodoc.getImportedOBODocs().iterator().next(); + assertTrue(!tdoc.getTermFrames().isEmpty()); + Frame termFrame = tdoc.getTermFrame("ZFA:0001689"); + assertNotNull(termFrame); + assertEquals(2, termFrame.getClauses(OboFormatTag.TAG_INTERSECTION_OF).size()); + termFrame = tdoc.getTermFrame("EHDAA:571"); + assertNotNull(termFrame); + Clause clause = termFrame.getClause(OboFormatTag.TAG_IS_A); + assertNotNull(clause); + assertEquals("UBERON:0002539", clause.getValue()); + termFrame = tdoc.getTermFrame("UBERON:0006800"); + assertNotNull(termFrame); + clause = termFrame.getClause(OboFormatTag.TAG_IS_A); + assertNotNull(clause); + assertEquals("CARO:0000008", clause.getValue()); + } + + @Test + void testXRefExpanderIntoSeparateBridges() { + OBODoc obodoc = parseOBOFile("treat_xrefs_test.obo"); + XrefExpander x = new XrefExpander(obodoc, "bridge"); + x.expandXrefs(); + int n = 0; + for (OBODoc tdoc : obodoc.getImportedOBODocs()) { + Frame hf = tdoc.getHeaderFrame(); + if (hf == null) { + continue; + } + Clause impClause = hf.getClause(OboFormatTag.TAG_ONTOLOGY); + assertNotNull(impClause); + String tid = impClause.getValue(String.class).replace("bridge-", ""); + if (tid.equals("zfa")) { + Frame termFrame = tdoc.getTermFrame("ZFA:0001689"); + assertNotNull(termFrame); + assertEquals(2, termFrame.getClauses(OboFormatTag.TAG_INTERSECTION_OF).size()); + Frame pf = tdoc.getTypedefFrame(PART_OF); + assert pf != null; + Clause clause = pf.getClause(OboFormatTag.TAG_XREF); + assertNotNull(clause); + assertEquals(BFO_0000050, clause.getValue().toString()); + n++; + } + if (tid.equals("ehdaa")) { + Frame termFrame = tdoc.getTermFrame("EHDAA:571"); + assertNotNull(termFrame); + Clause clause = termFrame.getClause(OboFormatTag.TAG_IS_A); + assertNotNull(clause); + assertEquals("UBERON:0002539", clause.getValue()); + n++; + } + if (tid.equals("caro")) { + Frame termFrame = tdoc.getTermFrame("UBERON:0006800"); + assertNotNull(termFrame); + Clause clause = termFrame.getClause(OboFormatTag.TAG_IS_A); + assertNotNull(clause); + assertEquals("CARO:0000008", clause.getValue()); + n++; + } + } + assertEquals(3, n); + // assertTrue(frame.getClause("name").getValue().equals("x1")); + } + /* + * @Test void testUberonHeader() throws Exception { OBODoc obodoc = + * parseOBOFile("uberon_header_test.obo"); XrefExpander x = new XrefExpander(obodoc, "bridge"); + * x.expandXrefs(); } + */ + + @Test + void testConversionXRefExpanderIRI() throws Exception { + OWLOntology ontology = parseOWLFile("xrefIRItest.owl"); + OBODoc doc = convert(ontology); + doc.getTermFrame("FOO:1"); + writeOBO(doc); + } + + @Test + void testUntranslatableAxiomsInHeader() throws Exception { + untranslatableAxiomsInHeader(parseOWLFile("untranslatable_axioms.owl")); + } + + @Test + void testUntranslatableAxiomsInHeader2() throws Exception { + untranslatableAxiomsInHeader(parseOWLFile("untranslatable_axioms2.owl")); + } + + @Test + void testNoDeadlock() throws OWLOntologyStorageException, OWLOntologyCreationException { + OWLOntology o = OWLManager.createConcurrentOWLOntologyManager() + .createOntology(iri("urn:test:ontology")); + o.add(df.getOWLSubClassOfAxiom(df.getOWLNothing(), df.getOWLThing())); + OWLOntologyDocumentTarget target = new StringDocumentTarget(); + o.saveOntology(new OBODocumentFormat(), target); + } + + void untranslatableAxiomsInHeader(OWLOntology original) + throws IOException, OWLOntologyCreationException { + OWLAPIOwl2Obo owl2Obo = new OWLAPIOwl2Obo(m1); + OBODoc obo = owl2Obo.convert(original); + renderOboToString(obo); + Frame headerFrame = obo.getHeaderFrame(); + assertNotNull(headerFrame); + String owlAxiomString = headerFrame.getTagValue(OboFormatTag.TAG_OWL_AXIOMS, String.class); + assertNotNull(owlAxiomString); + OWLAPIObo2Owl obo2Owl = new OWLAPIObo2Owl(m1); + OWLOntology converted = obo2Owl.convert(obo); + Set originalEqAxioms = + asUnorderedSet(original.axioms(EQUIVALENT_CLASSES)); + Set convertedEqAxioms = + asUnorderedSet(converted.axioms(EQUIVALENT_CLASSES)); + assertEquals(originalEqAxioms, convertedEqAxioms); + } + + @Test + void testPropertyValueQuotes() throws OWLOntologyStorageException { + String in = "Prefix(:=)\n" + + "Prefix(owl:=)\n" + + "Prefix(rdf:=)\n" + + "Prefix(xml:=)\n" + + "Prefix(xsd:=)\n" + + "Prefix(rdfs:=)\n\n" + + "Ontology(\n" + + "Declaration(Class())\n" + + "Declaration(Class())\n" + + "AnnotationAssertion( \"xx\"^^xsd:string)\n\n" + + "AnnotationAssertion( \"1\"^^xsd:int)\n\n" + + ")"; + OWLOntology o = loadOntologyFromString(in, new FunctionalSyntaxDocumentFormat()); + StringDocumentTarget target = new StringDocumentTarget(); + o.saveOntology(new OBODocumentFormat(), target); + assertEquals( + "format-version: 1.2\nontology: test\n\n" + + "[Term]\nid: X:1\nproperty_value: rdfs:seeAlso \"xx\" xsd:string\n\n" + + "[Term]\nid: X:2\nproperty_value: rdfs:seeAlso \"1\" xsd:int\n\n", + target.toString()); + } +} diff --git a/contract/src/test/java/org/obolibrary/oboformat/CreatedBySpaceTest.java b/contract/src/test/java/org/obolibrary/oboformat/CreatedBySpaceTest.java new file mode 100644 index 0000000000..80a31ec276 --- /dev/null +++ b/contract/src/test/java/org/obolibrary/oboformat/CreatedBySpaceTest.java @@ -0,0 +1,14 @@ +package org.obolibrary.oboformat; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.formats.OBODocumentFormat; +import org.semanticweb.owlapi.model.IRI; + +public class CreatedBySpaceTest extends OboFormatTestBasics { + + @Test + public void testCreatedByWithSpace() { + String input = "ontology: test\n[Typedef]\nid: R:1\nname: r1\ncreated_by: John Doe"; + loadOntologyFromString(input, IRI.generateDocumentIRI(), new OBODocumentFormat()); + } +} diff --git a/contract/src/test/java/org/obolibrary/oboformat/LoadAnonymousTestCase.java b/contract/src/test/java/org/obolibrary/oboformat/LoadAnonymousTestCase.java new file mode 100644 index 0000000000..c13ca8cb5f --- /dev/null +++ b/contract/src/test/java/org/obolibrary/oboformat/LoadAnonymousTestCase.java @@ -0,0 +1,155 @@ +package org.obolibrary.oboformat; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Annotation; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Declaration; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectSomeValuesFrom; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.RDFSComment; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.RDFSLabel; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubAnnotationPropertyOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubClassOf; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; +import static org.semanticweb.owlapi.vocab.OWL2Datatype.XSD_STRING; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.OBODocumentFormat; +import org.semanticweb.owlapi.model.MissingImportHandlingStrategy; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationSubject; +import org.semanticweb.owlapi.model.OWLAnnotationValue; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration; + +class LoadAnonymousTestCase extends TestBase { + + private static final String OBO = "http://purl.obolibrary.org/obo/"; + private static final String OBO_UO = "http://purl.obolibrary.org/obo/uo#"; + private static final String OBO_IN_OWL = "http://www.geneontology.org/formats/oboInOwl#"; + + private static OWLLiteral literal(String s) { + return Literal(s, XSD_STRING); + } + + private static OWLAnnotationAssertionAxiom comment(OWLAnnotationSubject s, + OWLAnnotationValue v) { + return AnnotationAssertion(RDFSComment(), s, v); + } + + private static OWLAnnotationAssertionAxiom label(OWLAnnotationSubject s, OWLAnnotationValue v) { + return AnnotationAssertion(RDFSLabel(), s, v); + } + + private static OWLAnnotationProperty ap(String s, String r) { + return df.getOWLAnnotationProperty(s, r); + } + + @Test + void shouldLoad() throws OWLOntologyCreationException { + OWLOntologyLoaderConfiguration loaderConfig = new OWLOntologyLoaderConfiguration() + .setMissingImportHandlingStrategy(MissingImportHandlingStrategy.SILENT); + OWLOntology ontology = loadOntologyFromString(TestFiles.loadOboAnonymous, + new OBODocumentFormat(), loaderConfig); + OWLAnnotationProperty date = ap(OBO_IN_OWL, "date"); + OWLAnnotationProperty mpathSlim = ap(OBO_UO, "mpath_slim"); + OWLAnnotationProperty subsetProperty = ap(OBO_IN_OWL, "SubsetProperty"); + OWLAnnotationProperty attributeSlim = ap(OBO_UO, "attribute_slim"); + OWLAnnotationProperty hasOBONamespace = ap(OBO_IN_OWL, "hasOBONamespace"); + OWLAnnotationProperty autogeneratedby = ap(OBO_IN_OWL, "auto-generated-by"); + OWLAnnotationProperty hasDbXref = ap(OBO_IN_OWL, "hasDbXref"); + OWLAnnotationProperty defaultnamespace = ap(OBO_IN_OWL, "default-namespace"); + OWLAnnotationProperty hasOBOFormatVersion = ap(OBO_IN_OWL, "hasOBOFormatVersion"); + OWLAnnotationProperty iao0000115 = ap(OBO, "IAO_0000115"); + OWLAnnotationProperty namespaceIdRule = ap(OBO_IN_OWL, "NamespaceIdRule"); + OWLAnnotationProperty createdBy = ap(OBO_IN_OWL, "created_by"); + OWLAnnotationProperty inSubset = ap(OBO_IN_OWL, "inSubset"); + OWLAnnotationProperty savedby = ap(OBO_IN_OWL, "saved-by"); + OWLClass pato0001708 = Class(IRI(OBO, "PATO_0001708")); + OWLClass uo0 = Class(IRI(OBO, "UO_0000000")); + OWLClass uo1 = Class(IRI(OBO, "UO_0000001")); + OWLAnnotationProperty id = ap(OBO_IN_OWL, "id"); + OWLAnnotationProperty abnormalSlim = ap(OBO_UO, "abnormal_slim"); + OWLAnnotationProperty scalarSlim = ap(OBO_UO, "scalar_slim"); + OWLLiteral literal = literal("Wikipedia:Wikipedia"); + OWLAnnotationProperty unitSlim = ap(OBO_UO, "unit_slim"); + OWLAnnotationProperty absentSlim = ap(OBO_UO, "absent_slim"); + OWLObjectProperty isUnitOf = ObjectProperty(IRI(OBO_UO, "is_unit_of")); + OWLAnnotationProperty cellQuality = ap(OBO_UO, "cell_quality"); + OWLAnnotationProperty unitGroupSlim = ap(OBO_UO, "unit_group_slim"); + OWLAnnotationProperty valueSlim = ap(OBO_UO, "value_slim"); + OWLAnnotationProperty prefixSlim = ap(OBO_UO, "prefix_slim"); + OWLAnnotationProperty dispositionSlim = ap(OBO_UO, "disposition_slim"); + OWLAnnotationProperty relationalSlim = ap(OBO_UO, "relational_slim"); + Set expected = new HashSet<>(Arrays.asList(Declaration(date), + Declaration(autogeneratedby), Declaration(hasDbXref), Declaration(defaultnamespace), + Declaration(subsetProperty), Declaration(hasOBOFormatVersion), Declaration(iao0000115), + Declaration(namespaceIdRule), Declaration(createdBy), Declaration(inSubset), + Declaration(savedby), Declaration(pato0001708), Declaration(uo0), + Declaration(RDFSComment()), Declaration(RDFSLabel()), Declaration(hasOBONamespace), + Declaration(uo1), Declaration(id), SubAnnotationPropertyOf(mpathSlim, subsetProperty), + AnnotationAssertion(hasOBONamespace, uo1.getIRI(), literal("unit.ontology")), + comment(attributeSlim.getIRI(), literal("Attribute slim")), + label(iao0000115.getIRI(), literal("definition")), + AnnotationAssertion(hasOBONamespace, uo0.getIRI(), literal("unit.ontology")), + SubAnnotationPropertyOf(unitSlim, subsetProperty), + comment(valueSlim.getIRI(), literal("Value slim")), + SubAnnotationPropertyOf(absentSlim, subsetProperty), + SubAnnotationPropertyOf(abnormalSlim, subsetProperty), + label(uo1.getIRI(), literal("length unit")), + label(hasOBOFormatVersion.getIRI(), literal("has_obo_format_version")), + label(namespaceIdRule.getIRI(), literal("namespace-id-rule")), + SubClassOf(uo1, ObjectSomeValuesFrom(isUnitOf, pato0001708)), + SubAnnotationPropertyOf(cellQuality, subsetProperty), + comment(relationalSlim.getIRI(), literal( + "Relational slim: types of quality that require an additional entity in order to exist")), + SubAnnotationPropertyOf(prefixSlim, subsetProperty), + SubAnnotationPropertyOf(scalarSlim, subsetProperty), + comment(scalarSlim.getIRI(), literal("Scalar slim")), + comment(abnormalSlim.getIRI(), literal("Abnormal/normal slim")), + SubAnnotationPropertyOf(attributeSlim, subsetProperty), + label(uo0.getIRI(), literal("unit")), + SubAnnotationPropertyOf(dispositionSlim, subsetProperty), + comment(unitSlim.getIRI(), literal("unit slim")), + SubAnnotationPropertyOf(relationalSlim, subsetProperty), + AnnotationAssertion(id, uo1.getIRI(), literal("UO:0000001")), + comment(mpathSlim.getIRI(), literal("Pathology slim")), + AnnotationAssertion(createdBy, uo1.getIRI(), literal("george gkoutos")), + label(hasDbXref.getIRI(), literal("database_cross_reference")), SubClassOf(uo1, uo0), + label(hasOBONamespace.getIRI(), literal("has_obo_namespace")), + AnnotationAssertion(id, uo0.getIRI(), literal("UO:0000000")), + AnnotationAssertion(createdBy, uo0.getIRI(), literal("george gkoutos")), + comment(prefixSlim.getIRI(), literal("prefix slim")), + comment(cellQuality.getIRI(), literal("cell_quality")), + comment(absentSlim.getIRI(), literal("Absent/present slim")), + label(subsetProperty.getIRI(), literal("subset_property")), + SubAnnotationPropertyOf(unitGroupSlim, subsetProperty), + comment(unitGroupSlim.getIRI(), literal("unit group slim")), + comment(dispositionSlim.getIRI(), literal("Disposition slim")), + label(inSubset.getIRI(), literal("in_subset")), + SubAnnotationPropertyOf(valueSlim, subsetProperty), + AnnotationAssertion(inSubset, uo1.getIRI(), unitGroupSlim.getIRI()), + df.getOWLAnnotationAssertionAxiom(iao0000115, uo0.getIRI(), + literal("A unit of measurement is a standardized quantity of a physical quality."), + singleton(Annotation(hasDbXref, literal))), + df.getOWLAnnotationAssertionAxiom(iao0000115, uo1.getIRI(), + literal("A unit which is a standard measure of the distance between two points."), + singleton(Annotation(hasDbXref, literal))))); + assertEquals(expected, asUnorderedSet(ontology.axioms())); + } +} diff --git a/contract/src/test/java/org/obolibrary/oboformat/OBOCommentsTestCase.java b/contract/src/test/java/org/obolibrary/oboformat/OBOCommentsTestCase.java new file mode 100644 index 0000000000..683345eb65 --- /dev/null +++ b/contract/src/test/java/org/obolibrary/oboformat/OBOCommentsTestCase.java @@ -0,0 +1,31 @@ +package org.obolibrary.oboformat; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.OBODocumentFormat; +import org.semanticweb.owlapi.model.OWLOntology; + +class OBOCommentsTestCase extends TestBase { + + @Test + void shouldAllowCommentInDate() { + String in1 = "format-version: 1.2\n" + "data-version: beta2 ! WSIO Beta 2\n" + + "date: 19:06:2014 18:57 ! CE(S)T"; + OWLOntology o1 = + loadOntologyFromString(in1, iri("urn:test#", "test1"), new OBODocumentFormat()); + String in2 = "format-version: 1.2\n" + "date: 19:06:2014 18:57 ! CE(S)T" + + "data-version: beta2 ! WSIO Beta 2\n"; + OWLOntology o2 = + loadOntologyFromString(in2, iri("urn:test#", "test2"), new OBODocumentFormat()); + assertTrue(o1.equalAxioms(o2)); + } + + @Test + void shouldAllowInstanceStanza() { + loadOntologyFromString(TestFiles.allowInstanceStanza, iri("urn:test#", "test"), + new OBODocumentFormat()); + } +} diff --git a/contract/src/test/java/org/obolibrary/oboformat/OBOFormatWriterTestCase.java b/contract/src/test/java/org/obolibrary/oboformat/OBOFormatWriterTestCase.java new file mode 100644 index 0000000000..2da5558760 --- /dev/null +++ b/contract/src/test/java/org/obolibrary/oboformat/OBOFormatWriterTestCase.java @@ -0,0 +1,134 @@ +package org.obolibrary.oboformat; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileInputStream; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.junit.jupiter.api.Test; +import org.obolibrary.oboformat.model.Clause; +import org.obolibrary.oboformat.model.Frame; +import org.obolibrary.oboformat.model.OBODoc; +import org.obolibrary.oboformat.parser.OBOFormatConstants.OboFormatTag; +import org.obolibrary.oboformat.writer.OBOFormatWriter; + +/** + * Tests for {@link OBOFormatWriter}. + */ +class OBOFormatWriterTestCase extends OboFormatTestBasics { + + private static List createSynonymClauses(String... labels) { + List clauses = new ArrayList<>(labels.length); + for (String label : labels) { + Clause clause = new Clause(OboFormatTag.TAG_SYNONYM, label); + clauses.add(clause); + } + return clauses; + } + + private static String writeObsolete(Object value) throws Exception { + Clause cl = new Clause(OboFormatTag.TAG_IS_OBSELETE); + cl.addValue(value); + StringWriter out = new StringWriter(); + try (BufferedWriter bufferedWriter = new BufferedWriter(out)) { + OBOFormatWriter.write(cl, bufferedWriter, null); + } + return out.toString().trim(); + } + + /** + * Test a special case of the specification. For intersections put the genus before the + * differentia, instead of the default case-insensitive alphabetical ordering. + */ + @Test + void testSortTermClausesIntersectionOf() { + OBODoc oboDoc = parseOBOFile("equivtest.obo"); + Frame frame = oboDoc.getTermFrame("X:1"); + assert frame != null; + List clauses = new ArrayList<>(frame.getClauses(OboFormatTag.TAG_INTERSECTION_OF)); + OBOFormatWriter.sortTermClauses(clauses); + assertEquals("Y:1", clauses.get(0).getValue()); + assertEquals("R:1", clauses.get(1).getValue()); + assertEquals("Z:1", clauses.get(1).getValue2()); + } + + /** + * Test for sorting clauses according to alphabetical case-insensitive order. Prefer upper-case + * over lower case for equal strings. Prefer shorter strings over longer strings. + */ + @Test + void testSortTermClausesSynonyms() { + List clauses = createSynonymClauses("cc", "ccc", "AAA", "aaa", "bbbb"); + OBOFormatWriter.sortTermClauses(clauses); + assertEquals("AAA", clauses.get(0).getValue()); + assertEquals("aaa", clauses.get(1).getValue()); + assertEquals("bbbb", clauses.get(2).getValue()); + assertEquals("cc", clauses.get(3).getValue()); + assertEquals("ccc", clauses.get(4).getValue()); + } + + @Test + void testWriteObsolete() throws Exception { + assertEquals("", writeObsolete(Boolean.FALSE)); + assertEquals("", writeObsolete(Boolean.FALSE.toString())); + assertEquals("is_obsolete: true", writeObsolete(Boolean.TRUE)); + assertEquals("is_obsolete: true", writeObsolete(Boolean.TRUE.toString())); + } + + /** + * Test that the OBO format writer only writes one new-line at the end of the file. + */ + @Test + void testWriteEndOfFile() throws Exception { + OBODoc oboDoc = parseOBOFile("caro.obo"); + String oboString = renderOboToString(oboDoc); + int length = oboString.length(); + assertTrue(length > 0); + int newLineCount = 0; + for (int i = length - 1; i >= 0; i--) { + char c = oboString.charAt(i); + if (Character.isWhitespace(c)) { + if (c == '\n') { + newLineCount++; + } + } else { + break; + } + } + assertEquals(2, newLineCount, "GO always had an empty newline at the end."); + } + + @Test + void testWriteOpaqueIdsAsComments() throws Exception { + OBODoc oboDoc = parseOBOFile("opaque_ids_test.obo"); + String oboString = renderOboToString(oboDoc); + assertTrue(Arrays.stream(oboString.split("\n")).anyMatch( + line -> line.startsWith("relationship:") && line.contains("named relation y1"))); + } + + @Test + void testPropertyValueOrder() throws Exception { + StringBuilder sb = new StringBuilder(); + try (InputStream inputStream = new FileInputStream(getFile("tag_order_test.obo")); + InputStreamReader in = new InputStreamReader(inputStream); + BufferedReader reader = new BufferedReader(in);) { + String line; + while ((line = reader.readLine()) != null) { + sb.append(line); + sb.append('\n'); + } + } + String input = sb.toString(); + OBODoc obodoc = parseOboToString(input); + String written = renderOboToString(obodoc); + assertEquals(input, written); + } +} diff --git a/contract/src/test/java/org/obolibrary/oboformat/OboFormatTestBasics.java b/contract/src/test/java/org/obolibrary/oboformat/OboFormatTestBasics.java new file mode 100644 index 0000000000..390f62aa70 --- /dev/null +++ b/contract/src/test/java/org/obolibrary/oboformat/OboFormatTestBasics.java @@ -0,0 +1,193 @@ +package org.obolibrary.oboformat; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.io.Reader; +import java.io.StringReader; +import java.io.StringWriter; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.Collections; +import java.util.Map; +import java.util.Optional; + +import javax.annotation.Nullable; + +import org.obolibrary.obo2owl.OWLAPIObo2Owl; +import org.obolibrary.obo2owl.OWLAPIOwl2Obo; +import org.obolibrary.oboformat.model.OBODoc; +import org.obolibrary.oboformat.parser.OBOFormatParser; +import org.obolibrary.oboformat.writer.OBOFormatWriter; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; +import org.semanticweb.owlapi.model.OWLRuntimeException; + +public class OboFormatTestBasics extends TestBase { + + protected static String renderOboToString(OBODoc oboDoc) throws IOException { + OBOFormatWriter writer = new OBOFormatWriter(); + writer.setCheckStructure(true); + StringWriter out = new StringWriter(); + writer.write(oboDoc, new PrintWriter(out)); + return out.getBuffer().toString(); + } + + protected static OBODoc parseOboToString(String oboString) throws IOException { + return new OBOFormatParser().parse(new StringReader(oboString)); + } + + protected OBODoc parseOBOFile(String fn) { + return parseOBOFile(fn, false, Collections.emptyMap()); + } + + protected OBODoc parseOBOFile(String fn, boolean allowEmptyFrames, Map cache) { + try (InputStream inputStream = new FileInputStream(getFile(fn))) { + OBOFormatParser p = new OBOFormatParser(cache); + OBODoc obodoc = p.parse(new BufferedReader(new InputStreamReader(inputStream))); + assertNotNull(obodoc); + if (obodoc.getTermFrames().isEmpty() && !allowEmptyFrames) { + fail("Term frames should not be empty."); + } + return obodoc; + } catch (IOException e) { + throw new OWLRuntimeException(e); + } + } + + protected OBODoc parseOBOFile(Reader fn, boolean allowEmptyFrames, Map cache) throws IOException { + OBOFormatParser p = new OBOFormatParser(cache); + OBODoc obodoc = p.parse(new BufferedReader(fn)); + assertNotNull(obodoc); + if (obodoc.getTermFrames().isEmpty() && !allowEmptyFrames) { + fail("Term frames should not be empty."); + } + return obodoc; + } + + protected File getFile(String fn) { + URL inputStream = OboFormatTestBasics.class.getResource(fn); + if (inputStream == null) { + inputStream = getClass().getResource("obo/" + fn); + } + if (inputStream == null) { + inputStream = ClassLoader.getSystemResource(fn); + } + if (inputStream == null) { + inputStream = ClassLoader.getSystemResource("obo/" + fn); + } + if (inputStream == null) { + return new File("obo/" + fn); + } + try { + return new File(inputStream.toURI()); + } catch (URISyntaxException e) { + throw new OWLRuntimeException(e); + } + } + + protected OBODoc parseOBOFile(File file) throws IOException { + OBOFormatParser p = new OBOFormatParser(); + return p.parse(file.getCanonicalPath()); + } + + protected OWLOntology parseOWLFile(String fn) throws OWLOntologyCreationException { + OWLOntologyManager manager = setupManager(); + // TODO replace + return manager.loadOntologyFromOntologyDocument(getFile(fn)); + } + + protected OWLOntology convert(OBODoc obodoc) { + OWLAPIObo2Owl bridge = new OWLAPIObo2Owl(setupManager()); + OWLOntology ontology; + try { + ontology = bridge.convert(obodoc); + return ontology; + } catch (OWLOntologyCreationException e) { + throw new OWLRuntimeException(e); + } + } + + protected OWLOntology convertOBOFile(String fn) { + OWLOntology convert = convert(parseOBOFile(fn)); + writeOWL(convert); + return convert; + } + + protected OBODoc convert(OWLOntology ontology) { + return convert(ontology, false); + } + + protected OBODoc convert(OWLOntology ontology, boolean strictness) { + OWLAPIOwl2Obo bridge = new OWLAPIOwl2Obo(setupManager()); + bridge.setStrictConversion(strictness); + return bridge.convert(ontology); + } + + protected String writeOBO(OBODoc obodoc) throws IOException { + StringWriter target = new StringWriter(); + OBOFormatWriter oboWriter = new OBOFormatWriter(); + BufferedWriter bw = new BufferedWriter(target); + oboWriter.write(obodoc, new PrintWriter(bw)); + bw.flush(); + return target.toString(); + } + + protected StringDocumentTarget writeOWL(OWLOntology ontology) { + return writeOWL(ontology, new OWLXMLDocumentFormat()); + } + + protected StringDocumentTarget writeOWL(OWLOntology ontology, OWLDocumentFormat format) { + StringDocumentTarget target = new StringDocumentTarget(); + try { + ontology.saveOntology(format, target); + } catch (OWLOntologyStorageException e) { + throw new OWLRuntimeException(e); + } + return target; + } + + protected @Nullable IRI getIriByLabel(OWLOntology ontology, String label) { + Optional anyMatch = + ontology.axioms(AxiomType.ANNOTATION_ASSERTION) + .filter(aa -> aa.getProperty().isLabel() && aa.getValue() instanceof OWLLiteral + && label.equals(((OWLLiteral) aa.getValue()).getLiteral())) + .filter(aa -> aa.getSubject().isIRI()).findAny(); + if (anyMatch.isPresent()) { + return (IRI) anyMatch.get().getSubject(); + } + return null; + } + + protected String readResource(String resource) throws IOException { + StringBuilder sb = new StringBuilder(); + try (InputStream inputStream = new FileInputStream(getFile(resource)); + Reader r = new InputStreamReader(inputStream); + BufferedReader reader = new BufferedReader(r);) { + String line; + while ((line = reader.readLine()) != null) { + sb.append(line).append('\n'); + } + } + return sb.toString(); + } +} diff --git a/contract/src/test/java/org/obolibrary/oboformat/Owl2OboTestCase.java b/contract/src/test/java/org/obolibrary/oboformat/Owl2OboTestCase.java new file mode 100644 index 0000000000..23a1dd803e --- /dev/null +++ b/contract/src/test/java/org/obolibrary/oboformat/Owl2OboTestCase.java @@ -0,0 +1,177 @@ +package org.obolibrary.oboformat; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Collection; +import java.util.Optional; + +import org.junit.jupiter.api.Test; +import org.obolibrary.obo2owl.OWLAPIObo2Owl; +import org.obolibrary.obo2owl.OWLAPIOwl2Obo; +import org.obolibrary.obo2owl.Obo2OWLConstants; +import org.obolibrary.obo2owl.Obo2OWLConstants.Obo2OWLVocabulary; +import org.obolibrary.oboformat.model.Clause; +import org.obolibrary.oboformat.model.Frame; +import org.obolibrary.oboformat.model.OBODoc; +import org.obolibrary.oboformat.parser.OBOFormatConstants.OboFormatTag; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationValue; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedObject; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; + +class Owl2OboTestCase extends OboFormatTestBasics { + + private static final String TEST_0001 = "TEST:0001"; + private static final String OBO = "http://purl.obolibrary.org/obo/"; + private static final String COMMENT = "Comment"; + + private static void addLabelAndId(OWLNamedObject obj, String label, String id, OWLOntology o) { + OWLDataFactory f = o.getOWLOntologyManager().getOWLDataFactory(); + addAnnotation(obj, f.getRDFSLabel(), f.getOWLLiteral(label), o); + OWLAnnotationProperty idProp = + f.getOWLAnnotationProperty(OWLAPIObo2Owl.trTagToIRI(OboFormatTag.TAG_ID.getTag())); + addAnnotation(obj, idProp, f.getOWLLiteral(id), o); + } + + private static void setAltId(OWLNamedObject obj, OWLOntology o) { + OWLDataFactory f = o.getOWLOntologyManager().getOWLDataFactory(); + addAnnotation(obj, f.getOWLAnnotationProperty(Obo2OWLVocabulary.IRI_IAO_0100001.getIRI()), + f.getOWLLiteral(TEST_0001), o); + addAnnotation(obj, f.getOWLAnnotationProperty(Obo2OWLConstants.IRI_IAO_0000231), + Obo2OWLConstants.IRI_IAO_0000227, o); + addAnnotation(obj, f.getOWLDeprecated(), f.getOWLLiteral(true), o); + } + + private static void addAnnotation(OWLNamedObject obj, OWLAnnotationProperty p, + OWLAnnotationValue v, OWLOntology ont) { + ont.add(df.getOWLAnnotationAssertionAxiom(obj.getIRI(), df.getOWLAnnotation(p, v))); + } + + @Test + void testConversion() throws Exception { + OWLOntology ontology = convert(parseOBOFile("caro.obo")); + OBODoc doc = convert(ontology); + writeOBO(doc); + } + + @Test + void testIRTsConversion() throws Exception { + IRI ontologyIRI = iri(OBO, "test.owl"); + OWLOntology ontology = m.createOntology(ontologyIRI); + convert(ontology); + String ontId = OWLAPIOwl2Obo.getOntologyId(ontology); + assertEquals("test", ontId); + IRI iri = iri(OBO, "OBI_0000306"); + String id = OWLAPIOwl2Obo.getIdentifier(iri); + assertTrue("OBI:0000306".endsWith(id)); + iri = iri(OBO, "IAO_0000119"); + id = OWLAPIOwl2Obo.getIdentifier(iri); + assertEquals("IAO:0000119", id); + iri = iri(OBO, "caro_part_of"); + id = OWLAPIOwl2Obo.getIdentifier(iri); + assertEquals("http://purl.obolibrary.org/obo/caro_part_of", id); + iri = iri("http://purl.obolibrary.org/obo/MyOnt#", "_part_of"); + id = OWLAPIOwl2Obo.getIdentifier(iri); + assertEquals("MyOnt:part_of", id); + iri = iri("http://purl.obolibrary.org/obo/MyOnt#", "termid"); + id = OWLAPIOwl2Obo.getIdentifier(iri); + assertEquals("termid", id); + // unprefixed IDs from different ontology + iri = iri("http://purl.obolibrary.org/obo/MyOnt#", "termid"); + id = OWLAPIOwl2Obo.getIdentifier(iri); + // assertTrue("http://purl.obolibrary.org/obo/MyOnt#termid".equals(id)); + iri = df.getOWLTopObjectProperty().getIRI(); + id = OWLAPIOwl2Obo.getIdentifier(iri); + assertEquals("owl:topObjectProperty", id); + } + + @Test + void testOwl2OboAltIdClass() throws Exception { + OWLOntology simple = getOWLOntology(); + // add class A + OWLClass classA = df.getOWLClass(Obo2OWLConstants.DEFAULT_IRI_PREFIX, "TEST_0001"); + simple.add(df.getOWLDeclarationAxiom(classA)); + // add a label and OBO style ID + addLabelAndId(classA, "test1", TEST_0001, simple); + // add deprecated class B as an alternate ID for A + OWLClass classB = df.getOWLClass(Obo2OWLConstants.DEFAULT_IRI_PREFIX, "TEST_0002"); + simple.add(df.getOWLDeclarationAxiom(classB)); + setAltId(classB, simple); + // add comment to alt_id class, which is not expressible in OBO + addAnnotation(classB, df.getRDFSComment(), df.getOWLLiteral(COMMENT), simple); + // translate to OBO + OWLAPIOwl2Obo owl2obo = new OWLAPIOwl2Obo(simple.getOWLOntologyManager()); + OBODoc oboDoc = owl2obo.convert(simple); + // check result: expect only one term frame for class TEST:0001 with + // alt_id Test:0002 + Collection termFrames = oboDoc.getTermFrames(); + assertEquals(1, termFrames.size()); + Frame frame = termFrames.iterator().next(); + assertEquals(TEST_0001, frame.getId()); + Collection altIdClauses = frame.getClauses(OboFormatTag.TAG_ALT_ID); + assertEquals(1, altIdClauses.size()); + String altId = altIdClauses.iterator().next().getValue(String.class); + assertEquals("TEST:0002", altId); + // roundtrip back to OWL, check that comment is still there + OWLAPIObo2Owl obo2owl = new OWLAPIObo2Owl(m1); + OWLOntology roundTripped = obo2owl.convert(oboDoc); + // three for the alt-id plus one + assertEquals(4, roundTripped.annotationAssertionAxioms(classB.getIRI()).count()); + // for the comment + Optional comment = findComment(classB.getIRI(), roundTripped); + assertTrue(comment.isPresent()); + assertEquals(COMMENT, comment.get().getLiteral()); + } + + protected Optional findComment(IRI i, OWLOntology roundTripped) { + return roundTripped.annotationAssertionAxioms(i).filter(ax -> ax.getProperty().isComment()) + .map(ax -> ax.getValue().asLiteral()).filter(l -> l.isPresent()).findAny() + .orElse(Optional.empty()); + } + + @Test + void testOwl2OboProperty() throws Exception { + OWLOntology simple = getOWLOntology(); + // add prop1 + OWLObjectProperty p1 = + df.getOWLObjectProperty(Obo2OWLConstants.DEFAULT_IRI_PREFIX, "TEST_0001"); + simple.add(df.getOWLDeclarationAxiom(p1)); + // add label and OBO style id for + addLabelAndId(p1, "prop1", TEST_0001, simple); + // add deprecated prop 2 as an alternate ID for prop 1 + OWLObjectProperty p2 = + df.getOWLObjectProperty(Obo2OWLConstants.DEFAULT_IRI_PREFIX, "TEST_0002"); + simple.add(df.getOWLDeclarationAxiom(p2)); + setAltId(p2, simple); + // add comment to alt_id class, which is not expressible in OBO + addAnnotation(p2, df.getRDFSComment(), df.getOWLLiteral(COMMENT), simple); + // translate to OBO + OWLAPIOwl2Obo owl2obo = new OWLAPIOwl2Obo(simple.getOWLOntologyManager()); + OBODoc oboDoc = owl2obo.convert(simple); + // check result: expect only one typdef frame for prop TEST:0001 with + // alt_id Test:0002 + Collection termFrames = oboDoc.getTypedefFrames(); + assertEquals(1, termFrames.size()); + Frame frame = termFrames.iterator().next(); + assertEquals(TEST_0001, frame.getId()); + Collection altIdClauses = frame.getClauses(OboFormatTag.TAG_ALT_ID); + assertEquals(1, altIdClauses.size()); + String altId = altIdClauses.iterator().next().getValue(String.class); + assertEquals("TEST:0002", altId); + // roundtrip back to OWL, check that comment is still there + OWLAPIObo2Owl obo2owl = new OWLAPIObo2Owl(m1); + OWLOntology roundTripped = obo2owl.convert(oboDoc); + // three for the alt-id plus one for the comment + assertEquals(4, roundTripped.annotationAssertionAxioms(p2.getIRI()).count()); + // for the comment + Optional comment = findComment(p2.getIRI(), roundTripped); + assertTrue(comment.isPresent()); + assertEquals(COMMENT, comment.get().getLiteral()); + } +} diff --git a/contract/src/test/java/org/obolibrary/oboformat/RoundTripTestBasics.java b/contract/src/test/java/org/obolibrary/oboformat/RoundTripTestBasics.java new file mode 100644 index 0000000000..efd83dfcf6 --- /dev/null +++ b/contract/src/test/java/org/obolibrary/oboformat/RoundTripTestBasics.java @@ -0,0 +1,78 @@ +package org.obolibrary.oboformat; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.IOException; +import java.util.Collection; +import java.util.List; + +import javax.annotation.Nullable; + +import org.obolibrary.obo2owl.OWLAPIOwl2Obo; +import org.obolibrary.oboformat.diff.Diff; +import org.obolibrary.oboformat.diff.OBODocDiffer; +import org.obolibrary.oboformat.model.OBODoc; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; + +class RoundTripTestBasics extends OboFormatTestBasics { + + private static boolean compareOWLOntologiesPartial(OWLOntology oo, OWLOntology oo2, + boolean isExpectRoundtrip, @Nullable Collection untranslatableAxioms) { + if (isExpectRoundtrip) { + int untranslatedSize = 0; + if (untranslatableAxioms != null) { + untranslatedSize = untranslatableAxioms.size(); + } + long expectedSize = oo.getAxiomCount(); + long foundSize = oo2.getAxiomCount(); + assertEquals(expectedSize, foundSize + untranslatedSize); + return false; + } + return true; + } + + public List roundTripOBOFile(String fn, boolean isExpectRoundtrip) throws Exception { + OBODoc obodoc = parseOBOFile(fn); + return roundTripOBODoc(obodoc, isExpectRoundtrip); + } + + public List roundTripOBODoc(OBODoc obodoc, boolean isExpectRoundtrip) throws Exception { + OWLOntology oo = convert(obodoc); + StringDocumentTarget oo2 = new StringDocumentTarget(); + StringDocumentTarget oo1 = new StringDocumentTarget(); + oo.saveOntology(oo1); + OBODoc obodoc2 = convert(oo); + convert(obodoc2).saveOntology(oo2); + String s1 = oo1.toString(); + String s2 = oo2.toString(); + assertEquals(s1, s2); + obodoc2.check(); + List diffs = OBODocDiffer.getDiffs(obodoc, obodoc2); + if (isExpectRoundtrip) { + assertEquals(0, diffs.size(), "Expected no diffs but " + diffs); + } + return diffs; + } + + public boolean roundTripOWLFile(String fn, boolean isExpectRoundtrip) + throws IOException, OWLOntologyCreationException { + OWLOntology oo = parseOWLFile(fn); + return roundTripOWLOOntology(oo, isExpectRoundtrip); + } + + public boolean roundTripOWLOOntology(OWLOntology oo, boolean isExpectRoundtrip) + throws IOException { + OWLAPIOwl2Obo bridge = new OWLAPIOwl2Obo(m1); + OBODoc obodoc = bridge.convert(oo); + writeOBO(obodoc); + obodoc.check(); + OWLOntology oo2 = convert(obodoc); + writeOWL(oo2); + boolean ok = compareOWLOntologiesPartial(oo, oo2, isExpectRoundtrip, + bridge.getUntranslatableAxioms()); + return ok || !isExpectRoundtrip; + } +} diff --git a/contract/src/test/java/org/obolibrary/oboformat/RoundTripTestCase.java b/contract/src/test/java/org/obolibrary/oboformat/RoundTripTestCase.java new file mode 100644 index 0000000000..de9e4ac51f --- /dev/null +++ b/contract/src/test/java/org/obolibrary/oboformat/RoundTripTestCase.java @@ -0,0 +1,388 @@ +package org.obolibrary.oboformat; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +import org.junit.jupiter.api.Test; +import org.obolibrary.obo2owl.OWLAPIObo2Owl; +import org.obolibrary.obo2owl.OWLAPIOwl2Obo; +import org.obolibrary.obo2owl.Obo2OWLConstants; +import org.obolibrary.obo2owl.Obo2OWLConstants.Obo2OWLVocabulary; +import org.obolibrary.oboformat.diff.Diff; +import org.obolibrary.oboformat.diff.OBODocDiffer; +import org.obolibrary.oboformat.model.Clause; +import org.obolibrary.oboformat.model.Frame; +import org.obolibrary.oboformat.model.OBODoc; +import org.obolibrary.oboformat.model.QualifierValue; +import org.obolibrary.oboformat.parser.OBOFormatConstants.OboFormatTag; +import org.obolibrary.oboformat.parser.OBOFormatParser; +import org.obolibrary.oboformat.writer.OBOFormatWriter; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.OBODocumentFormat; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; + +class RoundTripTestCase extends RoundTripTestBasics { + + private static final String OBO = "http://purl.obolibrary.org/obo/"; + private static final String REGULATES = "regulates"; + + private static void checkAsAltId(IRI iri, OWLOntology ont, String replacedBy) { + assertTrue( + ont.annotationAssertionAxioms(iri).anyMatch(ax -> ax.getProperty().isDeprecated())); + assertTrue(ont.annotationAssertionAxioms(iri) + .filter(ax -> ax.getProperty().getIRI().equals(Obo2OWLConstants.IRI_IAO_0000231)) + .map(ax -> ax.getValue().asIRI()).filter(Optional::isPresent) + .anyMatch(p -> Obo2OWLConstants.IRI_IAO_0000227.equals(p.get()))); + String altId = ont.annotationAssertionAxioms(iri) + .filter(ax -> Obo2OWLVocabulary.IRI_IAO_0100001.sameIRI(ax.getProperty())) + .map(ax -> ax.getValue().asIRI()).filter(Optional::isPresent) + .map(p -> OWLAPIOwl2Obo.getIdentifier(p.get())).findAny().orElse(null); + assertEquals(replacedBy, altId); + } + + @Test + void testAltIds() throws Exception { + OBODoc input = parseOBOFile("alt_id_test.obo"); + OWLOntology owl = convert(input); + // check round trip + OBODoc output = convert(owl); + String outObo = renderOboToString(output); + assertEquals(readResource("alt_id_test.obo").trim(), outObo.trim()); + // check owl + // check that both alt_id is declared as deprecated class and has + // appropriate annotations + IRI alt_id_t1 = iri(OBO, "TEST_1000"); + IRI alt_id_r1 = iri(OBO, "TEST_REL_1000"); + checkAsAltId(alt_id_t1, owl, "TEST:0001"); + checkAsAltId(alt_id_r1, owl, "TEST_REL:0001"); + } + + @Test + void testRoundTripCardinality() throws Exception { + // create minimal ontology + OBODoc oboDocSource = parseOBOFile("roundtrip_cardinality.obo"); + // convert to OWL and retrieve def + OWLAPIObo2Owl bridge = new OWLAPIObo2Owl(m1); + OWLOntology owlOntology = bridge.convert(oboDocSource); + OWLDataFactory factory = owlOntology.getOWLOntologyManager().getOWLDataFactory(); + OWLClass c = factory.getOWLClass(bridge.oboIdToIRI("PR:000027136")); + // Relations + boolean foundRel1 = false; + boolean foundRel2 = false; + List axioms = asList(owlOntology.subClassAxiomsForSubClass(c)); + assertEquals(3, axioms.size()); + for (OWLSubClassOfAxiom axiom : axioms) { + OWLClassExpression superClass = axiom.getSuperClass(); + if (superClass instanceof OWLObjectExactCardinality) { + OWLObjectExactCardinality cardinality = (OWLObjectExactCardinality) superClass; + OWLClassExpression filler = cardinality.getFiller(); + assertFalse(filler.isAnonymous()); + IRI iri = filler.asOWLClass().getIRI(); + if (iri.equals(bridge.oboIdToIRI("PR:000005116"))) { + foundRel1 = true; + assertEquals(1, cardinality.getCardinality()); + } else if (iri.equals(bridge.oboIdToIRI("PR:000027122"))) { + foundRel2 = true; + assertEquals(2, cardinality.getCardinality()); + } + } + } + assertTrue(foundRel1); + assertTrue(foundRel2); + // convert back to OBO + OWLAPIOwl2Obo owl2Obo = new OWLAPIOwl2Obo(OWLManager.createOWLOntologyManager()); + OBODoc convertedOboDoc = owl2Obo.convert(owlOntology); + Frame convertedFrame = convertedOboDoc.getTermFrame("PR:000027136"); + assert convertedFrame != null; + Collection clauses = convertedFrame.getClauses(OboFormatTag.TAG_RELATIONSHIP); + // check that round trip still contains relationships + assertEquals(2, clauses.size()); + for (Clause clause : clauses) { + Collection qualifierValues = clause.getQualifierValues(); + assertEquals(1, qualifierValues.size()); + QualifierValue value = qualifierValues.iterator().next(); + assertEquals("cardinality", value.getQualifier()); + if (clause.getValue2().equals("PR:000005116")) { + assertEquals("1", value.getValue()); + } else if (clause.getValue2().equals("PR:000027122")) { + assertEquals("2", value.getValue()); + } + } + } + + @Test + void testRoundTripLabeledXrefs() throws Exception { + OBODoc source = parseOBOFile("labeled_xrefs.obo"); + String written = renderOboToString(source); + OBODoc parsed = parseOboToString(written); + List diffs = OBODocDiffer.getDiffs(source, parsed); + assertEquals(0, diffs.size()); + } + + @Test + void testDefinitionsMultipleDefXref() { + OWLAnnotationProperty hasDbXref = df + .getOWLAnnotationProperty("http://www.geneontology.org/formats/oboInOwl#", "hasDbXref"); + OWLOntology owlOnt = convertOBOFile("multiple_def_xref_test.obo"); + AtomicInteger n = new AtomicInteger(0); + owlOnt.axioms().forEach(ax -> ax.annotations(hasDbXref).forEach(a -> { + OWLLiteral v = (OWLLiteral) a.getValue(); + // expect this twice, as we have annotations on synonyms + if (v.getLiteral().equals("BTO:0001750")) { + n.incrementAndGet(); + } + if (v.getLiteral().equals("Wikipedia:Mandibular_condyle")) { + n.incrementAndGet(); + } + })); + assertEquals(3, n.intValue()); + } + + @Test + void testWriteNamespaceIdRule() throws Exception { + OBODoc oboDoc = parseOBOFile("namespace-id-rule.obo"); + String oboString = renderOboToString(oboDoc); + assertTrue(oboString.contains("\nnamespace-id-rule: * test:$sequence(7,0,9999999)$\n")); + } + + @Test + void testWriteReadConvertedOWLNamespaceIdRule() throws Exception { + OBODoc oboDoc = parseOBOFile("namespace-id-rule.obo"); + OWLOntology owlOntology = convert(oboDoc); + StringDocumentTarget documentTarget = new StringDocumentTarget(); + owlOntology.saveOntology(new OWLXMLDocumentFormat(), documentTarget); + String owlString = documentTarget.toString(); + OWLOntology reloadedOwl = loadOntologyFromString(owlString, new OWLXMLDocumentFormat()); + assertEquals(owlOntology.getAxiomCount(), reloadedOwl.getAxiomCount()); + } + + @Test + void shouldRoundTripVersionInfo() throws OWLOntologyStorageException, IOException { + String in = "Prefix(:=)\n" + + "Prefix(owl:=)\n" + + "Prefix(rdf:=)\n" + + "Prefix(xml:=)\n" + + "Prefix(xsd:=)\n" + + "Prefix(rdfs:=)\n\n" + + "Ontology(\n" + + "Annotation( \"1.2\")\n" + + "Annotation(owl:versionInfo \"2020-06-30\")\n" + + "Declaration(AnnotationProperty())\n" + + "AnnotationAssertion( \"has_obo_format_version\")\n)"; + + OWLOntology o = loadOntologyFromString(in, new FunctionalSyntaxDocumentFormat()); + StringDocumentTarget saved = saveOntology(o, new OBODocumentFormat()); + OWLOntology o1 = loadOntologyFromString(saved, new OBODocumentFormat()); + equal(o, o1); + + OBODoc oboDoc1 = convert(o); + // write OBO + String expected = "format-version: 1.2\n" + "ontology: myont\n" + + "property_value: owl:versionInfo \"2020-06-30\" xsd:string"; + String actual = renderOboToString(oboDoc1).trim(); + assertEquals(expected, actual); + // parse OBO + OBOFormatParser p = new OBOFormatParser(); + OBODoc oboDoc2 = p.parse(new BufferedReader(new StringReader(actual))); + assertEquals(expected, renderOboToString(oboDoc2).trim()); + + List diffs = OBODocDiffer.getDiffs(oboDoc1, oboDoc2); + assertEquals(0, diffs.size(), diffs.toString()); + } + + /** + * Test that the converted RO from OWL to OBO can be written and parsed back into OBO, and also + * round-trip back into OWL. + */ + @Test + void testRoundTripOWLRO() throws Exception { + OWLOntology oo1 = parseOWLFile("ro.owl"); + OBODoc oboDoc1 = convert(oo1); + // write OBO + String oboString = renderOboToString(oboDoc1); + // parse OBO + OBOFormatParser p = new OBOFormatParser(); + OBODoc oboDoc2 = p.parse(new BufferedReader(new StringReader(oboString))); + // check that the annotations are pre-served on the property values + Frame typedefFrame = oboDoc2.getTypedefFrame("RO:0002224"); + assert typedefFrame != null; + Collection propertyValues = + typedefFrame.getClauses(OboFormatTag.TAG_PROPERTY_VALUE); + boolean found = false; + for (Clause clause : propertyValues) { + if ("IAO:0000118".equals(clause.getValue()) + && "started by".equals(clause.getValue2())) { + Collection values = clause.getQualifierValues(); + assertEquals(1, values.size()); + QualifierValue value = values.iterator().next(); + assertEquals("http://purl.obolibrary.org/obo/IAO_0000116", value.getQualifier()); + assertEquals("From Allen terminology", value.getValue()); + found = true; + } + } + assertTrue(found, "The expected annotations on the property value are missing."); + // convert back into OWL + convert(oboDoc2); + // check that the two oboDocs are equal + List diffs = OBODocDiffer.getDiffs(oboDoc1, oboDoc2); + assertEquals(1, diffs.size(), + "Expected one diff, the oboformat diff is missing from the conversion"); + } + + @Test + void testOBOIsInferredAnnotation() throws Exception { + OBODoc input = parseOBOFile("is_inferred_annotation.obo"); + OWLOntology owl = convert(input); + // check round trip + OBODoc output = convert(owl); + String outObo = renderOboToString(output); + assertEquals(readResource("is_inferred_annotation.obo"), outObo); + // check owl + IRI t1 = iri(OBO, "TEST_0001"); + IRI t3 = iri(OBO, "TEST_0003"); + IRI isInferredIRI = iri(Obo2OWLConstants.OIOVOCAB_IRI_PREFIX, "is_inferred"); + AtomicBoolean hasAnnotation = new AtomicBoolean(false); + OWLAnnotationProperty infIRI = df.getOWLAnnotationProperty(isInferredIRI); + owl.axioms(AxiomType.SUBCLASS_OF).forEach(axiom -> { + OWLClassExpression superClassCE = axiom.getSuperClass(); + OWLClassExpression subClassCE = axiom.getSubClass(); + if (superClassCE.isNamed() && subClassCE.isNamed()) { + OWLClass superClass = (OWLClass) superClassCE; + OWLClass subClass = (OWLClass) subClassCE; + if (superClass.getIRI().equals(t1) && subClass.getIRI().equals(t3)) { + axiom.annotations(infIRI).map(OWLAnnotation::getValue).forEach(v -> { + if (v instanceof OWLLiteral) { + assertEquals("true", ((OWLLiteral) v).getLiteral()); + } else { + fail("The value is not the expected type, expected OWLiteral but was: " + + v.getClass().getName()); + } + hasAnnotation.set(true); + }); + } + } + }); + assertTrue(hasAnnotation.get(), + "The sub class relation between t3 and t1 should have an is_inferred=true annotation"); + } + + @Test + void testRequireEmptyXrefList() throws Exception { + OBODoc obo = parseOBOFile("synonym_test.obo"); + // Get synonym clause with an empty xref list + Frame frame = obo.getTermFrame("GO:0009579"); + assertNotNull(frame); + // write frame + StringWriter stringWriter = new StringWriter(); + BufferedWriter bufferedWriter = new BufferedWriter(stringWriter); + OBOFormatWriter oboWriter = new OBOFormatWriter(); + oboWriter.write(frame, bufferedWriter, null); + bufferedWriter.flush(); + // get written frame + String line = stringWriter.getBuffer().toString(); + // check that written frame has line: + // synonym: "photosynthetic membrane" RELATED [] + assertTrue(line.contains("\nsynonym: \"photosynthetic membrane\" RELATED []\n")); + } + + @Test + void testConvertVersionIRI() { + OWLOntology owlOnt = convertOBOFile("version_iri_test.obo"); + assertNotNull(owlOnt); + IRI v = owlOnt.getOntologyID().getVersionIRI().get(); + assertEquals("http://purl.obolibrary.org/obo/go/2012-01-01/go.owl", v.toString()); + } + + @Test + void shouldContainExpectedAnnotationXrefescapecolon() { + OBODoc oboFile = parseOBOFile("xref_escapecolon.obo"); + OWLOntology o = convert(oboFile); + IRI expected = iri(OBO, "GO_0042062%3A"); + assertEquals(18, o.annotationAssertionAxioms(expected).count()); + } + + @Test + void testConvertTransitiveOver() { + // PARSE TEST FILE, CONVERT TO OWL + OWLOntology ontology = convert(parseOBOFile("relation_shorthand_test.obo")); + // TEST CONTENTS OF OWL ONTOLOGY + IRI regulatesIRI = getIriByLabel(ontology, REGULATES); + assertNotNull(regulatesIRI); + boolean ok = false; + // test that transitive over is translated to a property chain + List axioms = + asList(ontology.axioms(AxiomType.SUB_PROPERTY_CHAIN_OF)); + for (OWLSubPropertyChainOfAxiom axiom : axioms) { + OWLObjectProperty p = (OWLObjectProperty) axiom.getSuperProperty(); + if (regulatesIRI.equals(p.getIRI())) { + List chain = axiom.getPropertyChain(); + assertEquals(2, chain.size()); + assertEquals(p, chain.get(0)); + assertEquals("http://purl.obolibrary.org/obo/BFO_0000050", + ((OWLObjectProperty) chain.get(1)).getIRI().toString()); + ok = true; + } + } + assertTrue(ok); + // CONVERT BACK TO OBO + OBODoc obodoc = convert(ontology); + // test that transitive over is converted back + Frame tf = obodoc.getTypedefFrame(REGULATES); + assert tf != null; + assertEquals(3, tf.getClauses().size()); + assertEquals(REGULATES, tf.getTagValue(OboFormatTag.TAG_ID)); + assertEquals(REGULATES, tf.getTagValue(OboFormatTag.TAG_NAME)); + Clause clause = tf.getClause(OboFormatTag.TAG_TRANSITIVE_OVER); + assert clause != null; + assertEquals(1, clause.getValues().size()); + assertEquals("part_of", clause.getValue()); + assertTrue(clause.getQualifierValues().isEmpty()); + } + + @Test + void shouldRoundtripAll() { + String in = "Prefix(:=)\n" + + "Ontology(\n" + "Declaration(Class(:A))\n" + + "Declaration(Class(:B))\n" + "Declaration(ObjectProperty(:part_of))\n" + + "SubClassOf(:A ObjectAllValuesFrom(:part_of :B)))"; + OWLOntology o1 = loadOntologyFromString(in, new FunctionalSyntaxDocumentFormat()); + StringDocumentTarget saveOntology = saveOntology(o1, new OBODocumentFormat()); + OWLOntology o2 = loadOntologyFromString(saveOntology, new OBODocumentFormat()); + assertEquals(asSet(o1.logicalAxioms()), asSet(o2.logicalAxioms())); + } +} diff --git a/contract/src/test/java/org/obolibrary/oboformat/SimpleRoundTripTestCase.java b/contract/src/test/java/org/obolibrary/oboformat/SimpleRoundTripTestCase.java new file mode 100644 index 0000000000..e9c18aea4a --- /dev/null +++ b/contract/src/test/java/org/obolibrary/oboformat/SimpleRoundTripTestCase.java @@ -0,0 +1,27 @@ +package org.obolibrary.oboformat; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +class SimpleRoundTripTestCase extends RoundTripTestBasics { + + @ParameterizedTest + @ValueSource(strings = {"roundtrip_cardinality.obo", "caro.obo", + "roundtrip_equivalent_to_chain.obo", "multiple_def_xref_test.obo", + "namespace-id-rule.obo", "roundtrip_non_standard_synonyms.obo", + "property_value_test.obo", "property_value_qualifier_test.obo", + "relationship_vs_property.obo", "simplego.obo", "synonym_test.obo", + "version_iri_test.obo", "xref_escapecolon.obo", "xref_annotation.obo", + "relation_shorthand_test.obo", "dc_header_test.obo", + /** + * Round trip trailing qualifiers via obo2owl and owl2obo. Uses a slightly modified test + * file. Idspace tags do not survive the obo2owl translation. They are only directives for + * the translation. + * + * @see TrailingQualifierTest + */ + "trailing_qualifier_roundtrip.obo"}) + void roundTrip(String file) throws Exception { + roundTripOBOFile(file, true); + } +} diff --git a/contract/src/test/java/org/obolibrary/oboformat/TagTestCase.java b/contract/src/test/java/org/obolibrary/oboformat/TagTestCase.java new file mode 100644 index 0000000000..86f378b12b --- /dev/null +++ b/contract/src/test/java/org/obolibrary/oboformat/TagTestCase.java @@ -0,0 +1,129 @@ +package org.obolibrary.oboformat; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.BufferedReader; +import java.io.StringReader; + +import org.junit.jupiter.api.Test; +import org.obolibrary.oboformat.model.Clause; +import org.obolibrary.oboformat.model.Frame; +import org.obolibrary.oboformat.model.OBODoc; +import org.obolibrary.oboformat.parser.OBOFormatConstants.OboFormatTag; +import org.obolibrary.oboformat.parser.OBOFormatParser; + +class TagTestCase extends OboFormatTestBasics { + + private static final String A_B_C = "a b c"; + + private static Clause parseLine(String line) { + StringReader sr = new StringReader(line); + OBOFormatParser p = new OBOFormatParser(); + BufferedReader br = new BufferedReader(sr); + p.setReader(br); + return p.parseTermFrameClause(); + } + + private static OBODoc parseFrames(String s) { + StringReader sr = new StringReader(s); + OBOFormatParser p = new OBOFormatParser(); + BufferedReader br = new BufferedReader(sr); + p.setReader(br); + OBODoc obodoc = new OBODoc(); + p.parseTermFrame(obodoc); + return obodoc; + } + + private static OBODoc parseOBODoc(String s) { + StringReader sr = new StringReader(s); + OBOFormatParser p = new OBOFormatParser(); + BufferedReader br = new BufferedReader(sr); + p.setReader(br); + OBODoc obodoc = new OBODoc(); + p.parseOBODoc(obodoc); + return obodoc; + } + + @Test + void testParseOBOFile() { + OBODoc obodoc = parseOBOFile("tag_test.obo"); + assertEquals(4, obodoc.getTermFrames().size()); + assertEquals(1, obodoc.getTypedefFrames().size()); + Frame frame = obodoc.getTermFrame("X:1"); + assert frame != null; + assertEquals("x1", frame.getTagValue(OboFormatTag.TAG_NAME)); + } + + @Test + void testParseOBOFile2() { + OBODoc obodoc = parseOBOFile("testqvs.obo"); + assertEquals(4, obodoc.getTermFrames().size()); + assertEquals(1, obodoc.getTypedefFrames().size()); + } + + @Test + void testParseOBODoc() { + OBODoc obodoc = parseOBODoc("[Term]\nid: x\nname: foo\n\n\n[Term]\nid: y\nname: y"); + assertEquals(2, obodoc.getTermFrames().size()); + Frame frame = obodoc.getTermFrame("x"); + assert frame != null; + assertEquals("foo", frame.getTagValue(OboFormatTag.TAG_NAME)); + } + + @Test + void testParseFrames() { + OBODoc obodoc = parseFrames("[Term]\nid: x\nname: foo"); + assertEquals(1, obodoc.getTermFrames().size()); + Frame frame = obodoc.getTermFrames().iterator().next(); + assertEquals("foo", frame.getTagValue(OboFormatTag.TAG_NAME)); + } + + @Test + void testParseDefTag() { + Clause cl = parseLine("def: \"a b c\" [foo:1, bar:2]"); + assertEquals(OboFormatTag.TAG_DEF.getTag(), cl.getTag()); + assertEquals(A_B_C, cl.getValue()); + assertEquals(1, cl.getValues().size()); + } + + @Test + void testParseDefTag2() { + Clause cl = parseLine("def: \"a b c\" [foo:1 \"blah blah\", bar:2]"); + assertEquals(OboFormatTag.TAG_DEF.getTag(), cl.getTag()); + assertEquals(A_B_C, cl.getValue()); + } + + @Test + void testParseCreationDateTag() { + Clause cl = parseLine("creation_date: 2009-04-28T10:29:37Z"); + assertEquals(OboFormatTag.TAG_CREATION_DATE.getTag(), cl.getTag()); + } + + @Test + void testParseNameTag() { + Clause cl = parseLine("name: a b c"); + assertEquals(cl.getTag(), OboFormatTag.TAG_NAME.getTag()); + assertEquals(A_B_C, cl.getValue()); + } + + @Test + void testParseNameTag2() { + Clause cl = parseLine("name: a b c"); + assertEquals(OboFormatTag.TAG_NAME.getTag(), cl.getTag()); + assertEquals(A_B_C, cl.getValue()); + } + + @Test + void testParseNamespaceTag() { + Clause cl = parseLine("namespace: foo"); + assertEquals(cl.getTag(), OboFormatTag.TAG_NAMESPACE.getTag()); + assertEquals("foo", cl.getValue()); + } + + @Test + void testParseIsATag() { + Clause cl = parseLine("is_a: x ! foo"); + assertEquals(OboFormatTag.TAG_IS_A.getTag(), cl.getTag()); + assertEquals("x", cl.getValue()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/AxiomSubjectProviderExTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/AxiomSubjectProviderExTestCase.java new file mode 100644 index 0000000000..fd5818d94f --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/AxiomSubjectProviderExTestCase.java @@ -0,0 +1,125 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.util.AxiomSubjectProviderEx; + +class AxiomSubjectProviderExTestCase { + + private static final String TEST_IRI = "urn:test:test#iri"; + private static final String BUILT_IN_ATOM = + "BuiltInAtom( Variable() Variable())"; + private static final String IRI = ""; + private static final String I = ""; + private static final String C = ""; + private static final String DP = ""; + private static final String ANN = ""; + private static final String OP = ""; + + static Collection getData() { + Builder b = new Builder(); + Map map = new LinkedHashMap<>(); + map.put(b.dDp(), DP); + map.put(b.dOp(), IRI); + map.put(b.du(), C); + map.put(b.ec(), C); + map.put(b.eDp(), DP); + map.put(b.eOp(), IRI); + map.put(b.fdp(), DP); + map.put(b.fop(), OP); + map.put(b.ifp(), OP); + map.put(b.iop(), OP); + map.put(b.irr(), OP); + map.put(b.ndp(), I); + map.put(b.nop(), I); + map.put(b.opa(), I); + map.put(b.opaInv(), I); + map.put(b.opaInvj(), I); + map.put(b.oDom(), OP); + map.put(b.oRange(), OP); + map.put(b.chain(), OP); + map.put(b.ref(), OP); + map.put(b.same(), I); + map.put(b.subAnn(), ANN); + map.put(b.subClass(), C); + map.put(b.subData(), DP); + map.put(b.subObject(), OP); + map.put(b.rule(), BUILT_IN_ATOM); + map.put(b.symm(), OP); + map.put(b.trans(), OP); + map.put(b.hasKey(), C); + map.put(b.bigRule(), BUILT_IN_ATOM); + map.put(b.ann(), TEST_IRI); + map.put(b.asymm(), OP); + map.put(b.annDom(), ANN); + map.put(b.annRange(), ANN); + map.put(b.ass(), I); + map.put(b.assAnd(), I); + map.put(b.assOr(), I); + map.put(b.dRangeAnd(), DP); + map.put(b.dRangeOr(), DP); + map.put(b.assNot(), I); + map.put(b.assNotAnon(), "_:id"); + map.put(b.assSome(), I); + map.put(b.assAll(), I); + map.put(b.assHas(), I); + map.put(b.assMin(), I); + map.put(b.assMax(), I); + map.put(b.assEq(), I); + map.put(b.assHasSelf(), I); + map.put(b.assOneOf(), I); + map.put(b.assDSome(), I); + map.put(b.assDAll(), I); + map.put(b.assDHas(), I); + map.put(b.assDMin(), I); + map.put(b.assDMax(), I); + map.put(b.assDEq(), I); + map.put(b.dOneOf(), DP); + map.put(b.dNot(), DP); + map.put(b.dRangeRestrict(), DP); + map.put(b.assD(), I); + map.put(b.assDPlain(), I); + map.put(b.dDom(), DP); + map.put(b.dRange(), DP); + map.put(b.dDef(), "http://www.w3.org/2001/XMLSchema#double"); + map.put(b.decC(), C); + map.put(b.decOp(), OP); + map.put(b.decDp(), DP); + map.put(b.decDt(), ""); + map.put(b.decAp(), ANN); + map.put(b.decI(), I); + map.put(b.assDi(), I); + map.put(b.dc(), C); + Collection toReturn = new ArrayList<>(); + map.forEach((k, v) -> toReturn.add(new Object[] {k, v})); + return toReturn; + } + + @ParameterizedTest + @MethodSource("getData") + void testAssertion(OWLAxiom object, String expected) { + AxiomSubjectProviderEx testsubject = new AxiomSubjectProviderEx(); + String result = object.accept(testsubject).toString(); + assertEquals(expected, result); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/Builder.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/Builder.java new file mode 100644 index 0000000000..fe933aa8a5 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/Builder.java @@ -0,0 +1,378 @@ +package org.semanticweb.owlapi.api.test; + +import static org.semanticweb.owlapi.api.test.baseclasses.TestBase.set; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.*; + +public class Builder { + + private static final String SWRL = "urn:swrl:var#"; + private static final String NS = "urn:test:test#"; + private static OWLDataFactory df = OWLManager.getOWLDataFactory(); + private final OWLAnnotationProperty ap = df.getOWLAnnotationProperty(NS, "ann"); + private final OWLObjectProperty op = df.getOWLObjectProperty(NS, "op"); + private final OWLDataProperty dp = df.getOWLDataProperty(NS, "dp"); + private final OWLLiteral lit = df.getOWLLiteral(false); + private final OWLLiteral plainlit = df.getOWLLiteral("string", "en"); + private final IRI iri = TestBase.iri(NS, "iri"); + private final List as = set(df.getOWLAnnotation(ap, df.getOWLLiteral("test"))); + private final OWLClass ce = df.getOWLClass(NS, "c"); + private final OWLNamedIndividual i = df.getOWLNamedIndividual(NS, "i"); + private final OWLNamedIndividual j = df.getOWLNamedIndividual(NS, "j"); + private final OWLDatatype d = df.getOWLDatatype(NS, "datatype"); + private final List dps = Arrays.asList(df.getOWLDataProperty(iri), dp); + private final List ops = Arrays.asList(df.getOWLObjectProperty(iri), op); + private final List classes = Arrays.asList(df.getOWLClass(iri), ce); + private final List inds = Arrays.asList(i, df.getOWLNamedIndividual(iri)); + private final SWRLAtom v1 = df.getSWRLBuiltInAtom(TestBase.iri(SWRL, "v1"), Arrays.asList((SWRLDArgument) df.getSWRLVariable(SWRL, "var3"), df.getSWRLVariable(SWRL, "var4"))); + private final SWRLAtom v2 = df.getSWRLBuiltInAtom(TestBase.iri(SWRL, "v2"), Arrays.asList((SWRLDArgument) df.getSWRLVariable(SWRL, "var5"), df.getSWRLVariable(SWRL, "var6"))); + private final List body = Arrays.asList(v1); + private final List head = Arrays.asList(v2); + private final SWRLDArgument var1 = df.getSWRLVariable(SWRL, "var1"); + private final List var1list = Arrays.asList(var1); + private final SWRLIArgument var2 = df.getSWRLVariable(SWRL, "var2"); + private final List body2 = Arrays.asList(v1, df.getSWRLClassAtom(ce, var2), + df.getSWRLDataRangeAtom(d, var1), df.getSWRLBuiltInAtom(iri, var1list), + df.getSWRLDifferentIndividualsAtom(var2, df.getSWRLIndividualArgument(i)), + df.getSWRLSameIndividualAtom(var2, + df.getSWRLIndividualArgument(df.getOWLNamedIndividual(iri))), + df.getSWRLBuiltInAtom(iri, var1list)); + private final List head2 = + Arrays.asList(v2, df.getSWRLDataPropertyAtom(dp, var2, df.getSWRLLiteralArgument(lit)), + df.getSWRLObjectPropertyAtom(op, var2, var2)); + private final OWLOntologyManager m = getManager(); + + // no parsers and storers injected + private static OWLOntologyManager getManager() { + OWLOntologyManager instance = OWLManager.createOWLOntologyManager(); + instance.getOntologyParsers().clear(); + instance.getOntologyStorers().clear(); + return instance; + } + + public SWRLRule bigRule() { + return df.getSWRLRule(body2, head2, as); + } + + public OWLHasKeyAxiom hasKey() { + Set set = new HashSet<>(); + set.add(df.getOWLObjectProperty(iri)); + set.add(op); + set.add(dp); + return df.getOWLHasKeyAxiom(ce, set, as); + } + + public OWLSymmetricObjectPropertyAxiom symm() { + return df.getOWLSymmetricObjectPropertyAxiom(op, as); + } + + public OWLTransitiveObjectPropertyAxiom trans() { + return df.getOWLTransitiveObjectPropertyAxiom(op, as); + } + + public SWRLRule rule() { + return df.getSWRLRule(body, head); + } + + public OWLSubObjectPropertyOfAxiom subObject() { + return df.getOWLSubObjectPropertyOfAxiom(op, df.getOWLTopObjectProperty(), as); + } + + public OWLSubDataPropertyOfAxiom subData() { + return df.getOWLSubDataPropertyOfAxiom(dp, df.getOWLTopDataProperty()); + } + + public OWLSubClassOfAxiom subClass() { + return df.getOWLSubClassOfAxiom(ce, df.getOWLThing(), as); + } + + public OWLSubAnnotationPropertyOfAxiom subAnn() { + return df.getOWLSubAnnotationPropertyOfAxiom(ap, df.getRDFSLabel(), as); + } + + public OWLSameIndividualAxiom same() { + return df.getOWLSameIndividualAxiom(inds, as); + } + + public OWLReflexiveObjectPropertyAxiom ref() { + return df.getOWLReflexiveObjectPropertyAxiom(op, as); + } + + public OWLSubPropertyChainOfAxiom chain() { + return df.getOWLSubPropertyChainOfAxiom(new ArrayList<>(ops), op, as); + } + + public OWLObjectPropertyRangeAxiom oRange() { + return df.getOWLObjectPropertyRangeAxiom(op, ce, as); + } + + public OWLObjectPropertyDomainAxiom oDom() { + return df.getOWLObjectPropertyDomainAxiom(op, ce, as); + } + + public OWLObjectPropertyAssertionAxiom opaInv() { + return df.getOWLObjectPropertyAssertionAxiom(df.getOWLObjectInverseOf(op), i, i, as); + } + + public OWLObjectPropertyAssertionAxiom opaInvj() { + return df.getOWLObjectPropertyAssertionAxiom(df.getOWLObjectInverseOf(op), i, j, as); + } + + public OWLObjectPropertyAssertionAxiom opa() { + return df.getOWLObjectPropertyAssertionAxiom(op, i, i, as); + } + + public OWLNegativeObjectPropertyAssertionAxiom nop() { + return df.getOWLNegativeObjectPropertyAssertionAxiom(op, i, i, as); + } + + public OWLNegativeDataPropertyAssertionAxiom ndp() { + return df.getOWLNegativeDataPropertyAssertionAxiom(dp, i, lit, as); + } + + public OWLIrreflexiveObjectPropertyAxiom irr() { + return df.getOWLIrreflexiveObjectPropertyAxiom(op, as); + } + + public OWLInverseObjectPropertiesAxiom iop() { + return df.getOWLInverseObjectPropertiesAxiom(op, op, as); + } + + public OWLInverseFunctionalObjectPropertyAxiom ifp() { + return df.getOWLInverseFunctionalObjectPropertyAxiom(op, as); + } + + public OWLFunctionalObjectPropertyAxiom fop() { + return df.getOWLFunctionalObjectPropertyAxiom(op, as); + } + + public OWLFunctionalDataPropertyAxiom fdp() { + return df.getOWLFunctionalDataPropertyAxiom(dp, as); + } + + public OWLEquivalentObjectPropertiesAxiom eOp() { + return df.getOWLEquivalentObjectPropertiesAxiom(ops, as); + } + + public OWLEquivalentDataPropertiesAxiom eDp() { + return df.getOWLEquivalentDataPropertiesAxiom(dps, as); + } + + public OWLEquivalentClassesAxiom ec() { + return df.getOWLEquivalentClassesAxiom(classes, as); + } + + public OWLDisjointUnionAxiom du() { + return df.getOWLDisjointUnionAxiom(ce, classes, as); + } + + public OWLDisjointObjectPropertiesAxiom dOp() { + return df.getOWLDisjointObjectPropertiesAxiom(ops, as); + } + + public OWLDisjointDataPropertiesAxiom dDp() { + return df.getOWLDisjointDataPropertiesAxiom(dps, as); + } + + public OWLDisjointClassesAxiom dc() { + return df.getOWLDisjointClassesAxiom(ce, df.getOWLClass(iri)); + } + + public OWLDifferentIndividualsAxiom assDi() { + return df.getOWLDifferentIndividualsAxiom(i, df.getOWLNamedIndividual(iri)); + } + + public OWLDeclarationAxiom decI() { + return df.getOWLDeclarationAxiom(i, as); + } + + public OWLDeclarationAxiom decAp() { + return df.getOWLDeclarationAxiom(ap, as); + } + + public OWLDeclarationAxiom decDt() { + return df.getOWLDeclarationAxiom(d, as); + } + + public OWLDeclarationAxiom decDp() { + return df.getOWLDeclarationAxiom(dp, as); + } + + public OWLDeclarationAxiom decOp() { + return df.getOWLDeclarationAxiom(op, as); + } + + public OWLDeclarationAxiom decC() { + return df.getOWLDeclarationAxiom(ce, as); + } + + public OWLDatatypeDefinitionAxiom dDef() { + return df.getOWLDatatypeDefinitionAxiom(d, df.getDoubleOWLDatatype(), as); + } + + public OWLDataPropertyRangeAxiom dRange() { + return df.getOWLDataPropertyRangeAxiom(dp, d, as); + } + + public OWLDataPropertyDomainAxiom dDom() { + return df.getOWLDataPropertyDomainAxiom(dp, ce, as); + } + + public OWLDataPropertyAssertionAxiom assDPlain() { + return df.getOWLDataPropertyAssertionAxiom(dp, i, plainlit, as); + } + + public OWLDataPropertyAssertionAxiom assD() { + return df.getOWLDataPropertyAssertionAxiom(dp, i, lit, as); + } + + public OWLDataPropertyRangeAxiom dRangeRestrict() { + return df.getOWLDataPropertyRangeAxiom(dp, + df.getOWLDatatypeMinMaxExclusiveRestriction(5.0D, 6.0D), as); + } + + public OWLDataPropertyRangeAxiom dNot() { + return df.getOWLDataPropertyRangeAxiom(dp, + df.getOWLDataComplementOf(df.getOWLDataOneOf(lit)), as); + } + + public OWLDataPropertyRangeAxiom dOneOf() { + return df.getOWLDataPropertyRangeAxiom(dp, df.getOWLDataOneOf(lit), as); + } + + public OWLClassAssertionAxiom assDEq() { + return df.getOWLClassAssertionAxiom(df.getOWLDataExactCardinality(1, dp, d), i, as); + } + + public OWLClassAssertionAxiom assDMax() { + return df.getOWLClassAssertionAxiom(df.getOWLDataMaxCardinality(1, dp, d), i, as); + } + + public OWLClassAssertionAxiom assDMin() { + return df.getOWLClassAssertionAxiom(df.getOWLDataMinCardinality(1, dp, d), i, as); + } + + public OWLClassAssertionAxiom assDHas() { + return df.getOWLClassAssertionAxiom(df.getOWLDataHasValue(dp, lit), i, as); + } + + public OWLClassAssertionAxiom assDAll() { + return df.getOWLClassAssertionAxiom(df.getOWLDataAllValuesFrom(dp, d), i, as); + } + + public OWLClassAssertionAxiom assDSome() { + return df.getOWLClassAssertionAxiom(df.getOWLDataSomeValuesFrom(dp, d), i, as); + } + + public OWLClassAssertionAxiom assOneOf() { + return df.getOWLClassAssertionAxiom(df.getOWLObjectOneOf(i), i, as); + } + + public OWLClassAssertionAxiom assHasSelf() { + return df.getOWLClassAssertionAxiom(df.getOWLObjectHasSelf(op), i, as); + } + + public OWLClassAssertionAxiom assEq() { + return df.getOWLClassAssertionAxiom(df.getOWLObjectExactCardinality(1, op, ce), i, as); + } + + public OWLClassAssertionAxiom assMax() { + return df.getOWLClassAssertionAxiom(df.getOWLObjectMaxCardinality(1, op, ce), i, as); + } + + public OWLClassAssertionAxiom assMin() { + return df.getOWLClassAssertionAxiom(df.getOWLObjectMinCardinality(1, op, ce), i, as); + } + + public OWLClassAssertionAxiom assMinTop() { + return df.getOWLClassAssertionAxiom(df.getOWLObjectMinCardinality(1, op, df.getOWLThing()), + i, as); + } + + public OWLClassAssertionAxiom assHas() { + return df.getOWLClassAssertionAxiom(df.getOWLObjectHasValue(op, i), i, as); + } + + public OWLClassAssertionAxiom assAll() { + return df.getOWLClassAssertionAxiom(df.getOWLObjectAllValuesFrom(op, ce), i, as); + } + + public OWLClassAssertionAxiom assSome() { + return df.getOWLClassAssertionAxiom(df.getOWLObjectSomeValuesFrom(op, ce), i, as); + } + + public OWLClassAssertionAxiom assNotAnon() { + return df.getOWLClassAssertionAxiom(df.getOWLObjectComplementOf(ce), + df.getOWLAnonymousIndividual("id"), as); + } + + public OWLClassAssertionAxiom assNot() { + return df.getOWLClassAssertionAxiom(df.getOWLObjectComplementOf(ce), i, as); + } + + public OWLDataPropertyRangeAxiom dRangeOr() { + return df.getOWLDataPropertyRangeAxiom(dp, df.getOWLDataUnionOf(d, df.getOWLDataOneOf(lit)), + as); + } + + public OWLDataPropertyRangeAxiom dRangeAnd() { + return df.getOWLDataPropertyRangeAxiom(dp, + df.getOWLDataIntersectionOf(d, df.getOWLDataOneOf(lit)), as); + } + + public OWLClassAssertionAxiom assOr() { + return df.getOWLClassAssertionAxiom(df.getOWLObjectUnionOf(classes), i, as); + } + + public OWLClassAssertionAxiom assAnd() { + return df.getOWLClassAssertionAxiom(df.getOWLObjectIntersectionOf(classes), i, as); + } + + public OWLClassAssertionAxiom ass() { + return df.getOWLClassAssertionAxiom(ce, i, as); + } + + public OWLAnnotationPropertyRangeAxiom annRange() { + return df.getOWLAnnotationPropertyRangeAxiom(ap, iri, as); + } + + public OWLAnnotationPropertyDomainAxiom annDom() { + return df.getOWLAnnotationPropertyDomainAxiom(ap, iri, as); + } + + public OWLAsymmetricObjectPropertyAxiom asymm() { + return df.getOWLAsymmetricObjectPropertyAxiom(op, as); + } + + public OWLAnnotationAssertionAxiom ann() { + return df.getOWLAnnotationAssertionAxiom(ap, iri, lit, as); + } + + public OWLOntology onto() { + try { + return m.createOntology(TestBase.iri(NS, "test")); + } catch (OWLOntologyCreationException e) { + throw new RuntimeException(e); + } + } + + public List all() { + return Arrays.asList(ann(), asymm(), annDom(), annRange(), ass(), assAnd(), assOr(), + dRangeAnd(), dRangeOr(), assNot(), assNotAnon(), assSome(), assAll(), assHas(), + assMin(), assMax(), assEq(), assHasSelf(), assOneOf(), assDSome(), assDAll(), assDHas(), + assDMin(), assDMax(), assDEq(), dOneOf(), dNot(), dRangeRestrict(), assD(), assDPlain(), + dDom(), dRange(), dDef(), decC(), decOp(), decDp(), decDt(), decAp(), decI(), assDi(), + dc(), dDp(), dOp(), du(), ec(), eDp(), eOp(), fdp(), fop(), ifp(), iop(), irr(), ndp(), + nop(), opa(), opaInv(), opaInvj(), oDom(), oRange(), chain(), ref(), same(), subAnn(), + subClass(), subData(), subObject(), rule(), symm(), trans(), hasKey(), bigRule()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ConfigurationOptionsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ConfigurationOptionsTestCase.java new file mode 100644 index 0000000000..90040f1dff --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ConfigurationOptionsTestCase.java @@ -0,0 +1,60 @@ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.model.MissingImportHandlingStrategy.THROW_EXCEPTION; +import static org.semanticweb.owlapi.model.MissingOntologyHeaderStrategy.INCLUDE_GRAPH; +import static org.semanticweb.owlapi.model.PriorityCollectionSorting.ON_SET_INJECTION_ONLY; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.ACCEPT_HTTP_COMPRESSION; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.CONNECTION_TIMEOUT; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.FOLLOW_REDIRECTS; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.INDENTING; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.INDENT_SIZE; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.LABELS_AS_BANNER; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.LOAD_ANNOTATIONS; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.MISSING_IMPORT_HANDLING_STRATEGY; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.MISSING_ONTOLOGY_HEADER_STRATEGY; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.PARSE_WITH_STRICT_CONFIGURATION; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.PRIORITY_COLLECTION_SORTING; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.REMAP_IDS; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.REPORT_STACK_TRACES; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.RETRIES_TO_ATTEMPT; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.SAVE_IDS; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.TREAT_DUBLINCORE_AS_BUILTIN; +import static org.semanticweb.owlapi.model.parameters.ConfigurationOptions.USE_NAMESPACE_ENTITIES; + +import java.util.EnumMap; +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.model.parameters.ConfigurationOptions; + +class ConfigurationOptionsTestCase { + + static Stream values() { + return Stream.of(Arguments.of(ACCEPT_HTTP_COMPRESSION, Boolean.TRUE), + Arguments.of(CONNECTION_TIMEOUT, Integer.valueOf(20000)), + Arguments.of(FOLLOW_REDIRECTS, Boolean.TRUE), + Arguments.of(INDENT_SIZE, Integer.valueOf(4)), Arguments.of(INDENTING, Boolean.TRUE), + Arguments.of(LABELS_AS_BANNER, Boolean.FALSE), + Arguments.of(LOAD_ANNOTATIONS, Boolean.TRUE), + Arguments.of(PARSE_WITH_STRICT_CONFIGURATION, Boolean.FALSE), + Arguments.of(MISSING_IMPORT_HANDLING_STRATEGY, THROW_EXCEPTION), + Arguments.of(MISSING_ONTOLOGY_HEADER_STRATEGY, INCLUDE_GRAPH), + Arguments.of(PRIORITY_COLLECTION_SORTING, ON_SET_INJECTION_ONLY), + Arguments.of(REMAP_IDS, Boolean.TRUE), Arguments.of(REPORT_STACK_TRACES, Boolean.TRUE), + Arguments.of(RETRIES_TO_ATTEMPT, Integer.valueOf(5)), + Arguments.of(SAVE_IDS, Boolean.FALSE), + Arguments.of(TREAT_DUBLINCORE_AS_BUILTIN, Boolean.TRUE), + Arguments.of(USE_NAMESPACE_ENTITIES, Boolean.FALSE)); + } + + @ParameterizedTest + @MethodSource("values") + void shouldFindExpectedValue(ConfigurationOptions config, Object value) { + assertEquals(value, + config.getValue(value.getClass(), new EnumMap<>(ConfigurationOptions.class))); + assertEquals(value, config.getDefaultValue(value.getClass())); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/DLExpressivityCheckerTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/DLExpressivityCheckerTestCase.java new file mode 100644 index 0000000000..b9310aef0b --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/DLExpressivityCheckerTestCase.java @@ -0,0 +1,452 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.util.Construct.CONCEPT_COMPLEX_NEGATION; +import static org.semanticweb.owlapi.util.Construct.CONCEPT_INTERSECTION; +import static org.semanticweb.owlapi.util.Construct.CONCEPT_UNION; +import static org.semanticweb.owlapi.util.Construct.FULL_EXISTENTIAL; +import static org.semanticweb.owlapi.util.Construct.N; +import static org.semanticweb.owlapi.util.Construct.NOMINALS; +import static org.semanticweb.owlapi.util.Construct.ROLE_COMPLEX; +import static org.semanticweb.owlapi.util.Construct.ROLE_DOMAIN_RANGE; +import static org.semanticweb.owlapi.util.Construct.ROLE_HIERARCHY; +import static org.semanticweb.owlapi.util.Construct.ROLE_INVERSE; +import static org.semanticweb.owlapi.util.Construct.ROLE_REFLEXIVITY_CHAINS; +import static org.semanticweb.owlapi.util.Construct.ROLE_TRANSITIVE; +import static org.semanticweb.owlapi.util.Construct.UNIVERSAL_RESTRICTION; +import static org.semanticweb.owlapi.util.Languages.AL; +import static org.semanticweb.owlapi.util.Languages.ALC; +import static org.semanticweb.owlapi.util.Languages.ALCD; +import static org.semanticweb.owlapi.util.Languages.ALCF; +import static org.semanticweb.owlapi.util.Languages.ALCFD; +import static org.semanticweb.owlapi.util.Languages.ALCH; +import static org.semanticweb.owlapi.util.Languages.ALCHD; +import static org.semanticweb.owlapi.util.Languages.ALCHF; +import static org.semanticweb.owlapi.util.Languages.ALCHFD; +import static org.semanticweb.owlapi.util.Languages.ALCHI; +import static org.semanticweb.owlapi.util.Languages.ALCHID; +import static org.semanticweb.owlapi.util.Languages.ALCHIF; +import static org.semanticweb.owlapi.util.Languages.ALCHIFD; +import static org.semanticweb.owlapi.util.Languages.ALCHIN; +import static org.semanticweb.owlapi.util.Languages.ALCHIND; +import static org.semanticweb.owlapi.util.Languages.ALCHIQ; +import static org.semanticweb.owlapi.util.Languages.ALCHIQD; +import static org.semanticweb.owlapi.util.Languages.ALCHN; +import static org.semanticweb.owlapi.util.Languages.ALCHND; +import static org.semanticweb.owlapi.util.Languages.ALCHO; +import static org.semanticweb.owlapi.util.Languages.ALCHOD; +import static org.semanticweb.owlapi.util.Languages.ALCHOF; +import static org.semanticweb.owlapi.util.Languages.ALCHOFD; +import static org.semanticweb.owlapi.util.Languages.ALCHOI; +import static org.semanticweb.owlapi.util.Languages.ALCHOID; +import static org.semanticweb.owlapi.util.Languages.ALCHOIF; +import static org.semanticweb.owlapi.util.Languages.ALCHOIFD; +import static org.semanticweb.owlapi.util.Languages.ALCHOIN; +import static org.semanticweb.owlapi.util.Languages.ALCHOIND; +import static org.semanticweb.owlapi.util.Languages.ALCHOIQ; +import static org.semanticweb.owlapi.util.Languages.ALCHOIQD; +import static org.semanticweb.owlapi.util.Languages.ALCHON; +import static org.semanticweb.owlapi.util.Languages.ALCHOND; +import static org.semanticweb.owlapi.util.Languages.ALCHOQ; +import static org.semanticweb.owlapi.util.Languages.ALCHOQD; +import static org.semanticweb.owlapi.util.Languages.ALCHQ; +import static org.semanticweb.owlapi.util.Languages.ALCHQD; +import static org.semanticweb.owlapi.util.Languages.ALCI; +import static org.semanticweb.owlapi.util.Languages.ALCID; +import static org.semanticweb.owlapi.util.Languages.ALCIF; +import static org.semanticweb.owlapi.util.Languages.ALCIFD; +import static org.semanticweb.owlapi.util.Languages.ALCIN; +import static org.semanticweb.owlapi.util.Languages.ALCIND; +import static org.semanticweb.owlapi.util.Languages.ALCIQ; +import static org.semanticweb.owlapi.util.Languages.ALCIQD; +import static org.semanticweb.owlapi.util.Languages.ALCN; +import static org.semanticweb.owlapi.util.Languages.ALCND; +import static org.semanticweb.owlapi.util.Languages.ALCO; +import static org.semanticweb.owlapi.util.Languages.ALCOD; +import static org.semanticweb.owlapi.util.Languages.ALCOF; +import static org.semanticweb.owlapi.util.Languages.ALCOFD; +import static org.semanticweb.owlapi.util.Languages.ALCOI; +import static org.semanticweb.owlapi.util.Languages.ALCOID; +import static org.semanticweb.owlapi.util.Languages.ALCOIF; +import static org.semanticweb.owlapi.util.Languages.ALCOIFD; +import static org.semanticweb.owlapi.util.Languages.ALCOIN; +import static org.semanticweb.owlapi.util.Languages.ALCOIND; +import static org.semanticweb.owlapi.util.Languages.ALCOIQ; +import static org.semanticweb.owlapi.util.Languages.ALCOIQD; +import static org.semanticweb.owlapi.util.Languages.ALCON; +import static org.semanticweb.owlapi.util.Languages.ALCOND; +import static org.semanticweb.owlapi.util.Languages.ALCOQ; +import static org.semanticweb.owlapi.util.Languages.ALCOQD; +import static org.semanticweb.owlapi.util.Languages.ALCQ; +import static org.semanticweb.owlapi.util.Languages.ALCQD; +import static org.semanticweb.owlapi.util.Languages.ALCR; +import static org.semanticweb.owlapi.util.Languages.ALCRD; +import static org.semanticweb.owlapi.util.Languages.ALCRF; +import static org.semanticweb.owlapi.util.Languages.ALCRFD; +import static org.semanticweb.owlapi.util.Languages.ALCRI; +import static org.semanticweb.owlapi.util.Languages.ALCRID; +import static org.semanticweb.owlapi.util.Languages.ALCRIF; +import static org.semanticweb.owlapi.util.Languages.ALCRIFD; +import static org.semanticweb.owlapi.util.Languages.ALCRIN; +import static org.semanticweb.owlapi.util.Languages.ALCRIND; +import static org.semanticweb.owlapi.util.Languages.ALCRIQ; +import static org.semanticweb.owlapi.util.Languages.ALCRIQD; +import static org.semanticweb.owlapi.util.Languages.ALCRN; +import static org.semanticweb.owlapi.util.Languages.ALCRND; +import static org.semanticweb.owlapi.util.Languages.ALCRO; +import static org.semanticweb.owlapi.util.Languages.ALCROD; +import static org.semanticweb.owlapi.util.Languages.ALCROF; +import static org.semanticweb.owlapi.util.Languages.ALCROFD; +import static org.semanticweb.owlapi.util.Languages.ALCROI; +import static org.semanticweb.owlapi.util.Languages.ALCROID; +import static org.semanticweb.owlapi.util.Languages.ALCROIF; +import static org.semanticweb.owlapi.util.Languages.ALCROIFD; +import static org.semanticweb.owlapi.util.Languages.ALCROIN; +import static org.semanticweb.owlapi.util.Languages.ALCROIND; +import static org.semanticweb.owlapi.util.Languages.ALCROIQ; +import static org.semanticweb.owlapi.util.Languages.ALCROIQD; +import static org.semanticweb.owlapi.util.Languages.ALCRON; +import static org.semanticweb.owlapi.util.Languages.ALCROND; +import static org.semanticweb.owlapi.util.Languages.ALCROQ; +import static org.semanticweb.owlapi.util.Languages.ALCROQD; +import static org.semanticweb.owlapi.util.Languages.ALCRQ; +import static org.semanticweb.owlapi.util.Languages.ALCRQD; +import static org.semanticweb.owlapi.util.Languages.ALCRr; +import static org.semanticweb.owlapi.util.Languages.ALCRrD; +import static org.semanticweb.owlapi.util.Languages.ALCRrF; +import static org.semanticweb.owlapi.util.Languages.ALCRrFD; +import static org.semanticweb.owlapi.util.Languages.ALCRrN; +import static org.semanticweb.owlapi.util.Languages.ALCRrND; +import static org.semanticweb.owlapi.util.Languages.ALCRrO; +import static org.semanticweb.owlapi.util.Languages.ALCRrOD; +import static org.semanticweb.owlapi.util.Languages.ALCRrOF; +import static org.semanticweb.owlapi.util.Languages.ALCRrOFD; +import static org.semanticweb.owlapi.util.Languages.ALCRrON; +import static org.semanticweb.owlapi.util.Languages.ALCRrOND; +import static org.semanticweb.owlapi.util.Languages.ALCRrOQ; +import static org.semanticweb.owlapi.util.Languages.ALCRrOQD; +import static org.semanticweb.owlapi.util.Languages.ALCRrQ; +import static org.semanticweb.owlapi.util.Languages.ALCRrQD; +import static org.semanticweb.owlapi.util.Languages.ALE; +import static org.semanticweb.owlapi.util.Languages.EL; +import static org.semanticweb.owlapi.util.Languages.ELPLUSPLUS; +import static org.semanticweb.owlapi.util.Languages.FL; +import static org.semanticweb.owlapi.util.Languages.FL0; +import static org.semanticweb.owlapi.util.Languages.FLMINUS; +import static org.semanticweb.owlapi.util.Languages.SD; +import static org.semanticweb.owlapi.util.Languages.SF; +import static org.semanticweb.owlapi.util.Languages.SFD; +import static org.semanticweb.owlapi.util.Languages.SH; +import static org.semanticweb.owlapi.util.Languages.SHD; +import static org.semanticweb.owlapi.util.Languages.SHF; +import static org.semanticweb.owlapi.util.Languages.SHFD; +import static org.semanticweb.owlapi.util.Languages.SHI; +import static org.semanticweb.owlapi.util.Languages.SHID; +import static org.semanticweb.owlapi.util.Languages.SHIF; +import static org.semanticweb.owlapi.util.Languages.SHIFD; +import static org.semanticweb.owlapi.util.Languages.SHIN; +import static org.semanticweb.owlapi.util.Languages.SHIND; +import static org.semanticweb.owlapi.util.Languages.SHIQ; +import static org.semanticweb.owlapi.util.Languages.SHIQD; +import static org.semanticweb.owlapi.util.Languages.SHN; +import static org.semanticweb.owlapi.util.Languages.SHND; +import static org.semanticweb.owlapi.util.Languages.SHO; +import static org.semanticweb.owlapi.util.Languages.SHOD; +import static org.semanticweb.owlapi.util.Languages.SHOF; +import static org.semanticweb.owlapi.util.Languages.SHOFD; +import static org.semanticweb.owlapi.util.Languages.SHOI; +import static org.semanticweb.owlapi.util.Languages.SHOID; +import static org.semanticweb.owlapi.util.Languages.SHOIF; +import static org.semanticweb.owlapi.util.Languages.SHOIFD; +import static org.semanticweb.owlapi.util.Languages.SHOIN; +import static org.semanticweb.owlapi.util.Languages.SHOIND; +import static org.semanticweb.owlapi.util.Languages.SHOIQ; +import static org.semanticweb.owlapi.util.Languages.SHOIQD; +import static org.semanticweb.owlapi.util.Languages.SHON; +import static org.semanticweb.owlapi.util.Languages.SHOND; +import static org.semanticweb.owlapi.util.Languages.SHOQ; +import static org.semanticweb.owlapi.util.Languages.SHOQD; +import static org.semanticweb.owlapi.util.Languages.SHQ; +import static org.semanticweb.owlapi.util.Languages.SHQD; +import static org.semanticweb.owlapi.util.Languages.SI; +import static org.semanticweb.owlapi.util.Languages.SID; +import static org.semanticweb.owlapi.util.Languages.SIF; +import static org.semanticweb.owlapi.util.Languages.SIFD; +import static org.semanticweb.owlapi.util.Languages.SIN; +import static org.semanticweb.owlapi.util.Languages.SIND; +import static org.semanticweb.owlapi.util.Languages.SIQ; +import static org.semanticweb.owlapi.util.Languages.SIQD; +import static org.semanticweb.owlapi.util.Languages.SN; +import static org.semanticweb.owlapi.util.Languages.SND; +import static org.semanticweb.owlapi.util.Languages.SO; +import static org.semanticweb.owlapi.util.Languages.SOD; +import static org.semanticweb.owlapi.util.Languages.SOF; +import static org.semanticweb.owlapi.util.Languages.SOFD; +import static org.semanticweb.owlapi.util.Languages.SOI; +import static org.semanticweb.owlapi.util.Languages.SOID; +import static org.semanticweb.owlapi.util.Languages.SOIF; +import static org.semanticweb.owlapi.util.Languages.SOIFD; +import static org.semanticweb.owlapi.util.Languages.SOIN; +import static org.semanticweb.owlapi.util.Languages.SOIND; +import static org.semanticweb.owlapi.util.Languages.SOIQ; +import static org.semanticweb.owlapi.util.Languages.SOIQD; +import static org.semanticweb.owlapi.util.Languages.SON; +import static org.semanticweb.owlapi.util.Languages.SOND; +import static org.semanticweb.owlapi.util.Languages.SOQ; +import static org.semanticweb.owlapi.util.Languages.SOQD; +import static org.semanticweb.owlapi.util.Languages.SQ; +import static org.semanticweb.owlapi.util.Languages.SQD; +import static org.semanticweb.owlapi.util.Languages.SR; +import static org.semanticweb.owlapi.util.Languages.SRD; +import static org.semanticweb.owlapi.util.Languages.SRF; +import static org.semanticweb.owlapi.util.Languages.SRFD; +import static org.semanticweb.owlapi.util.Languages.SRI; +import static org.semanticweb.owlapi.util.Languages.SRID; +import static org.semanticweb.owlapi.util.Languages.SRIF; +import static org.semanticweb.owlapi.util.Languages.SRIFD; +import static org.semanticweb.owlapi.util.Languages.SRIN; +import static org.semanticweb.owlapi.util.Languages.SRIND; +import static org.semanticweb.owlapi.util.Languages.SRIQ; +import static org.semanticweb.owlapi.util.Languages.SRIQD; +import static org.semanticweb.owlapi.util.Languages.SRN; +import static org.semanticweb.owlapi.util.Languages.SRND; +import static org.semanticweb.owlapi.util.Languages.SRO; +import static org.semanticweb.owlapi.util.Languages.SROD; +import static org.semanticweb.owlapi.util.Languages.SROF; +import static org.semanticweb.owlapi.util.Languages.SROFD; +import static org.semanticweb.owlapi.util.Languages.SROI; +import static org.semanticweb.owlapi.util.Languages.SROID; +import static org.semanticweb.owlapi.util.Languages.SROIF; +import static org.semanticweb.owlapi.util.Languages.SROIFD; +import static org.semanticweb.owlapi.util.Languages.SROIN; +import static org.semanticweb.owlapi.util.Languages.SROIND; +import static org.semanticweb.owlapi.util.Languages.SROIQ; +import static org.semanticweb.owlapi.util.Languages.SROIQD; +import static org.semanticweb.owlapi.util.Languages.SRON; +import static org.semanticweb.owlapi.util.Languages.SROND; +import static org.semanticweb.owlapi.util.Languages.SROQ; +import static org.semanticweb.owlapi.util.Languages.SROQD; +import static org.semanticweb.owlapi.util.Languages.SRQ; +import static org.semanticweb.owlapi.util.Languages.SRQD; +import static org.semanticweb.owlapi.util.Languages.SRr; +import static org.semanticweb.owlapi.util.Languages.SRrD; +import static org.semanticweb.owlapi.util.Languages.SRrF; +import static org.semanticweb.owlapi.util.Languages.SRrFD; +import static org.semanticweb.owlapi.util.Languages.SRrN; +import static org.semanticweb.owlapi.util.Languages.SRrND; +import static org.semanticweb.owlapi.util.Languages.SRrO; +import static org.semanticweb.owlapi.util.Languages.SRrOD; +import static org.semanticweb.owlapi.util.Languages.SRrOF; +import static org.semanticweb.owlapi.util.Languages.SRrOFD; +import static org.semanticweb.owlapi.util.Languages.SRrON; +import static org.semanticweb.owlapi.util.Languages.SRrOND; +import static org.semanticweb.owlapi.util.Languages.SRrOQ; +import static org.semanticweb.owlapi.util.Languages.SRrOQD; +import static org.semanticweb.owlapi.util.Languages.SRrQ; +import static org.semanticweb.owlapi.util.Languages.SRrQD; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.util.Construct; +import org.semanticweb.owlapi.util.DLExpressivityChecker; +import org.semanticweb.owlapi.util.Languages; + +class DLExpressivityCheckerTestCase extends TestBase { + + static List l(Construct... t) { + return Arrays.asList(t); + } + + static List l(Languages... t) { + return Arrays.asList(t); + } + + static List l(OWLAxiom... t) { + return Arrays.asList(t); + } + + static Collection getData() { + Builder b = new Builder(); + return Arrays.asList( + //@formatter:off + new Object[] {"0 AL", "UNIVRESTR" , l(UNIVERSAL_RESTRICTION), l(FL0), belowUniversal(), l(FL0) , l(b.assAll())}, + new Object[] {"1 AL", "" , empty(), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.dDef())}, + new Object[] {"1 AL", "" , empty(), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.decC())}, + new Object[] {"1 AL", "" , empty(), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.decOp())}, + new Object[] {"1 AL", "" , empty(), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.decDp())}, + new Object[] {"1 AL", "" , empty(), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.decDt())}, + new Object[] {"1 AL", "" , empty(), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.decAp())}, + new Object[] {"1 AL", "" , empty(), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.decI())}, + new Object[] {"1 AL", "" , empty(), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.ec())}, + new Object[] {"1 AL", "" , empty(), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.nop())}, + new Object[] {"1 AL", "" , empty(), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.opa())}, + new Object[] {"1 AL", "" , empty(), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.subAnn())}, + new Object[] {"1 AL", "" , empty(), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.subClass())}, + new Object[] {"1 AL", "" , empty(), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.rule())}, + new Object[] {"1 AL", "" , empty(), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.ann())}, + new Object[] {"1 AL", "" , empty(), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.annDom())}, + new Object[] {"1 AL", "" , empty(), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.annRange())}, + new Object[] {"1 AL", "" , empty(), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.ass())}, + new Object[] {"2 ALCO", "CUO" , l(CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, NOMINALS), l(ALCO), belowCUO(), l(ALCO), l(b.assDi())}, + new Object[] {"3 ALC", "C" , l(CONCEPT_COMPLEX_NEGATION), l(ALC), belowC(), l(ALC), l(b.dc())}, + new Object[] {"3 ALC", "C" , l(CONCEPT_COMPLEX_NEGATION), l(ALC), belowC(), l(ALC), l(b.assNot())}, + new Object[] {"3 ALC", "C" , l(CONCEPT_COMPLEX_NEGATION), l(ALC), belowC(), l(ALC), l(b.assNotAnon())}, + new Object[] {"4 ALR", "R" , l(ROLE_COMPLEX), expressR(), belowR(), expressR(), l(b.dOp())}, + new Object[] {"4 ALR", "R" , l(ROLE_COMPLEX), expressR(), belowR(), expressR(), l(b.irr())}, + new Object[] {"4 ALR", "R" , l(ROLE_COMPLEX), expressR(), belowR(), expressR(), l(b.asymm())}, + new Object[] {"4 ALR", "R" , l(ROLE_COMPLEX), expressR(), belowR(), expressR(), l(b.assHasSelf())}, + new Object[] {"5 AL(D)", "RRESTR(D)" , l(ROLE_DOMAIN_RANGE, Construct.D), l(ALCD), belowALD(), l(ALCD), l(b.dRange())}, + new Object[] {"5 AL(D)", "RRESTR(D)" , l(ROLE_DOMAIN_RANGE, Construct.D), l(ALCD), belowALD(), l(ALCD), l(b.dRangeAnd())}, + new Object[] {"5 AL(D)", "RRESTR(D)" , l(ROLE_DOMAIN_RANGE, Construct.D), l(ALCD), belowALD(), l(ALCD), l(b.dRangeOr())}, + new Object[] {"5 AL(D)", "RRESTR(D)" , l(ROLE_DOMAIN_RANGE, Construct.D), l(ALCD), belowALD(), l(ALCD), l(b.dOneOf())}, + new Object[] {"5 AL(D)", "RRESTR(D)" , l(ROLE_DOMAIN_RANGE, Construct.D), l(ALCD), belowALD(), l(ALCD), l(b.dNot())}, + new Object[] {"5 AL(D)", "RRESTR(D)" , l(ROLE_DOMAIN_RANGE, Construct.D), l(ALCD), belowALD(), l(ALCD), l(b.dRangeRestrict())}, + new Object[] {"5 AL(D)", "RRESTR(D)" , l(ROLE_DOMAIN_RANGE, Construct.D), l(ALCD), belowALD(), l(ALCD), l(b.dDom())}, + new Object[] {"6 ALC", "CU" , l(CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION), l(ALC), belowCU(), l(ALC), l(b.du())}, + new Object[] {"7 ALH(D)", "H(D)" , l(ROLE_HIERARCHY, Construct.D), l(ALCHD), belowHD(), l(ALCHD), l(b.eDp())}, + new Object[] {"7 ALH(D)", "H(D)" , l(ROLE_HIERARCHY, Construct.D), l(ALCHD), belowHD(), l(ALCHD), l(b.subData())}, + new Object[] {"8 ALH", "H" , l(ROLE_HIERARCHY), l(ALCH), belowH(), l(ALCH), l(b.eOp())}, + new Object[] {"8 ALH", "H" , l(ROLE_HIERARCHY), l(ALCH), belowH(), l(ALCH), l(b.subObject())}, + new Object[] {"9 ALF(D)", "F(D)" , l(Construct.F, Construct.D), l(ALCFD), belowFD(), l(ALCFD), l(b.fdp())}, + new Object[] {"10 ALF", "F" , l(Construct.F), l(ALCF), belowF(), l(ALCF), l(b.fop())}, + new Object[] {"11 ALIF", "IF" , l(ROLE_INVERSE, Construct.F), l(ALCIF), belowIF(), l(ALCIF), l(b.ifp())}, + new Object[] {"12 ALI", "I" , l(ROLE_INVERSE), l(ALCI), belowI(), l(ALCI), l(b.iop())}, + new Object[] {"12 ALI", "I" , l(ROLE_INVERSE), l(ALCI), belowI(), l(ALCI), l(b.opaInv())}, + new Object[] {"12 ALI", "I" , l(ROLE_INVERSE), l(ALCI), belowI(), l(ALCI), l(b.opaInvj())}, + new Object[] {"12 ALI", "I" , l(ROLE_INVERSE), l(ALCI), belowI(), l(ALCI), l(b.symm())}, + new Object[] {"13 AL(D)", "(D)" , l(Construct.D), l(ALCD, ELPLUSPLUS), belowD(), l(ALCD, ELPLUSPLUS), l(b.dDp())}, + new Object[] {"13 AL(D)", "(D)" , l(Construct.D), l(ALCD, ELPLUSPLUS), belowD(), l(ALCD, ELPLUSPLUS), l(b.ndp())}, + new Object[] {"13 AL(D)", "(D)" , l(Construct.D), l(ALCD, ELPLUSPLUS), belowD(), l(ALCD, ELPLUSPLUS), l(b.assDAll())}, + new Object[] {"1 AL", "" , empty(), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.hasKey())}, + new Object[] {"1 AL", "" , empty(), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.bigRule())}, + new Object[] {"13 AL(D)", "(D)" , l(Construct.D), l(ALCD, ELPLUSPLUS), belowD(), l(ALCD, ELPLUSPLUS), l(b.assDHas())}, + new Object[] {"13 AL(D)", "(D)" , l(Construct.D), l(ALCD, ELPLUSPLUS), belowD(), l(ALCD, ELPLUSPLUS), l(b.assD())}, + new Object[] {"13 AL(D)", "(D)" , l(Construct.D), l(ALCD, ELPLUSPLUS), belowD(), l(ALCD, ELPLUSPLUS), l(b.assDPlain())}, + new Object[] {"14 ALO", "O" , l(NOMINALS), l(ALCO, ELPLUSPLUS), belowO(), l(ALCO,ELPLUSPLUS), l(b.same())}, + new Object[] {"15 AL+", "+" , l(ROLE_TRANSITIVE), l(Languages.S, ELPLUSPLUS), belowTRAN(),l(Languages.S, ELPLUSPLUS), l(b.trans())}, + new Object[] {"16 AL", "CINT" , l(CONCEPT_INTERSECTION), l(FL0, EL, ELPLUSPLUS), l(Languages.values()), l(FL0, EL, ELPLUSPLUS), l(b.assAnd())}, + new Object[] {"17 ALU", "U" , l(CONCEPT_UNION), l(ALC), belowU(), l(ALC), l(b.assOr())}, + new Object[] {"18 AL", "RRESTR" , l(ROLE_DOMAIN_RANGE), l(FL, EL), belowRRESTR(), l(FL, EL), l(b.oDom())}, + new Object[] {"18 AL", "RRESTR" , l(ROLE_DOMAIN_RANGE), l(FL, EL), belowRRESTR(), l(FL, EL), l(b.oRange())}, + new Object[] {"19 ALE", "E" , l(FULL_EXISTENTIAL), l(EL,ALE, ELPLUSPLUS), belowE(), l(EL,ALE, ELPLUSPLUS), l(b.assSome())}, + new Object[] {"20 ALEO", "EO" , l(FULL_EXISTENTIAL, NOMINALS), l(ALCO,ELPLUSPLUS), belowEO(), l(ALCO, ELPLUSPLUS), l(b.assHas())}, + new Object[] {"21 ALQ", "Q" , l(Construct.Q), l(ALCQ), belowQ(), l(ALCQ), l(b.assMin())}, + new Object[] {"21 ALQ", "Q" , l(Construct.Q), l(ALCQ), belowQ(), l(ALCQ), l(b.assMax())}, + new Object[] {"21 ALQ", "Q" , l(Construct.Q), l(ALCQ), belowQ(), l(ALCQ), l(b.assEq())}, + new Object[] {"22 ALUO", "UO" , l(CONCEPT_UNION, NOMINALS), l(ALCO), belowUO(), l(ALCO), l(b.assOneOf())}, + new Object[] {"23 ALE(D)", "E(D)" , l(FULL_EXISTENTIAL, Construct.D), l(ALCD,ELPLUSPLUS), belowED(), l(ALCD,ELPLUSPLUS), l(b.assDSome())}, + new Object[] {"24 ALQ(D)", "Q(D)" , l(Construct.Q, Construct.D), l(ALCQD), belowQD(), l(ALCQD), l(b.assDMin())}, + new Object[] {"24 ALQ(D)", "Q(D)" , l(Construct.Q, Construct.D), l(ALCQD), belowQD(), l(ALCQD), l(b.assDMax())}, + new Object[] {"24 ALQ(D)", "Q(D)" , l(Construct.Q, Construct.D), l(ALCQD), belowQD(), l(ALCQD), l(b.assDEq())}, + new Object[] {"25 ALR", "Rr" , l(ROLE_REFLEXIVITY_CHAINS), expressRr(), belowRr(), expressRr(), l(b.chain())}, + new Object[] {"25 ALR", "Rr" , l(ROLE_REFLEXIVITY_CHAINS), expressRr(), belowRr(), expressRr(), l(b.ref())}, + new Object[] {"26 ALR", "RIQ" , l(ROLE_COMPLEX, ROLE_INVERSE, Construct.Q), l(ALCRIQ), belowRIQ(), l(ALCRIQ), l(b.ref(), b.trans(), b.symm(), b.subObject(), b.fop(),b.assMinTop(), b.assMin()) }, + new Object[] {"27 ALN", "N" , l(N), l(ALCN), belowN(), l(ALCN), l(b.assMinTop())} + ); + //@formatter:on + } + + protected static List empty() { + return Collections.emptyList(); + } + + //@formatter:off + protected static List belowN() { return l(ALCRND, SHND, SHIND, ALCRN, ALCROIN, ALCHND, SRND, SROIN, ALCOND, SHIN, ALCHIN, ALCRON, SHOND, ALCON, ALCND, SOIN, SRON, ALCRrOND, ALCIN, SRN, SOIND, ALCRIND, SND, SHN, SRIND, SRrOND, ALCOIN, SIN, ALCHIND, SN, ALCIND, ALCRrND, ALCHOIN, ALCHN, SOND, ALCHOIND, SHOIN, SRrN, SRrON, SON, SHOIND, ALCOIND, ALCROND, SROIND, ALCROIND, SRrND, ALCHOND, ALCRrON, ALCN, SHON, ALCRIN, ALCRrN, SRIN, SROND, SIND, ALCHON); } + protected static List belowRIQ() { return l(ALCRIQD, SROIQ, SROIQD, SRIQD, ALCROIQD, SRIQ, ALCROIQ, ALCRIQ); } + protected static List belowRRESTR() { return l(FL, SROIQ, SROIQD, ALCHOID, ALCHIQ, ALCROF, SHQ, ALCIFD, SROD, ALCN, ALCRrF, SRD, ALCOID, ALCHOI, ALCHOIF, SHIQD, ALCHFD, ALCHN, SRIQD, ALCROID, ALCHOF, SRQD, SHIFD, ALCROQD, SRrN, SROID, ALCROIQ, ALCRQ, SI, SHOD, SHOIFD, ALCHOQ, ALCRrQ, ALCRrOD, SRIQ, ALCHID, SHQD, ALCHOIQD, ALCIN, ALCIQ, ALCOI, ALCOIQD, ALCRrD, ALCRD, SRrOQ, ALCROND, SIQD, SHIQ, ALCRr, ALCOQD, SRND, ALCRrOND, ALCRrOQ, ALCQ, SHN, SRrOF, SHO, SHD, ALCOIQ, SOIQ, SROND, ALCO, SIFD, SHOIND, ALCHO, SIND, SOI, SRQ, ALCHQD, SROIND, ALCIQD, SHOF, ALCROFD, ALCH, ALCOQ, ALCRON, ALCRrO, SHOIN, SRrOQD, EL, SN, ALCI, ALCRIQ, SOQ, SHF, ALCRO, SRN, SOQD, ALCHIFD, ALCOIN, SHON, SROF, SRr, SRID, ALCOFD, ALCOIFD, ALCHIND, SHOQD, SROQD, SQD, SHOFD, ALCHOIFD, ALCRFD, SND, ALCRrFD, SHFD, SFD, ALCHQ, SHIND, ALCRrOF, SHIN, SHOIQD, ALCRN, SHOQ, Languages.S, ALCOND, SOID, SRrOND, ALCOF, ALCRID, SRrF, ALCOD, ALCHON, SIF, ALCHD, SRrOFD, SHND, ALCRF, ALCRIQD, SRrD, SHOND, SRrON, SRIND, SROFD, SRON, SHID, ALCIND, SRrO, SRrND, SRO, ALCHOIN, SRI, SOIFD, ALCHOD, ALCIF, SROIFD, ALCHF, SID, ALCRrON, ALCD, SO, SROIF, SIN, SRF, ALCROIFD, ALCROIF, ALCHOND, SF, SOIND, ALCND, SRIN, ALCROI, ALCRND, SHI, ALCROIQD, ALC, ALCFD, SROIN, ALCRrQD, SHOIF, ALCID, ALCHOQD, ALCHIQD, ALCRIF, SOIN, ALCROIND, ALCRIND, ALCROQ, SH, SRIF, SD, SRFD, SRrQ, ALCR, ALCOIND, ALCHIF, ALCRrND, ALCF, ALCROIN, ALCHIN, ALCHOFD, ALCROD, SRrOD, SRrQD, SR, SOIF, ALCHOIQ, ALCON, ALCHND, ALCQD, SIQ, ALCRI, SRrFD, SQ, SOF, ALCHOIND, ALCHI, SROQ, SON, SOND, SOFD, SRIFD, ALCRIFD, SHOIQ, SOIQD, ALCRQD, SOD, SHOI, SROI, ALCRrOQD, SHIF, ALCRrN, ALCOIF, ALCRIN, SHOID, ALCRrOFD); } + protected static List belowALD() { return l(ALCHD, SRD, ALCQD, SID, ALCFD, ALCHOIND, SROFD, SQD, SHND, ALCHQD, ALCHOD, SIND, SHIFD, SRID, SRND, ALCRND, ALCROIQD, SRrOFD, ALCIND, ALCRrFD, SRrD, SHQD, ALCOID, SROIQD, ALCRFD, SOIFD, SRIQD, ALCOND, SRrFD, SOID, SROIFD, ALCOIQD, ALCRIFD, SIQD, SRIND, SROIND, SOQD, SHOND, ALCRrOQD, ALCND, ALCRD, ALCHIND, ALCHOND, ALCROIFD, ALCROQD, ALCROIND, ALCROND, SRrQD, ALCOIND, ALCHOID, SHOQD, SRQD, ALCOQD, SROID, SOND, ALCHFD, ALCHOQD, ALCRrOD, SROQD, ALCROID, ALCHID, ALCRrOFD, SHOFD, SRIFD, ALCIQD, SOIND, SHD, ALCIFD, SHOIQD, SHOID, ALCRQD, SND, SRrND, SHIQD, SROD, SOD, SRFD, ALCHND, ALCRrQD, ALCHOIQD, ALCRIQD, SRrOD, SOIQD, ALCROD, SFD, ALCID, ALCHOFD, ALCHOIFD, ALCRIND, ALCOIFD, ALCRID, SHOIND, SHIND, ALCHIFD, SHFD, ALCOFD, ALCOD, ALCRrD, SHOD, ALCROFD, SIFD, ALCRrND, SRrOND, ALCRrOND, SD, SRrOQD, SROND, SHOIFD, SOFD, ALCHIQD, SHID, ALCD); } + protected static List belowFD() { return l(SHFD, ALCROIFD, SRIFD, ALCHOFD, SHOIFD, ALCHFD, SOFD, ALCHIFD, SFD, ALCRIFD, SROIFD, ALCIFD, ALCOIFD, SOIFD, ALCHOIFD, ALCROFD, SHIFD, SROFD, ALCFD, SHOFD, SRFD, ALCRFD, ALCOFD, SIFD, SRrFD, SRrOFD, ALCRrFD, ALCRrOFD); } + protected static List belowE() { return l(EL, ALE, ALC, ALCD, ALCQ, ALCN, ALCF, ALCI, ALCO, ALCOI, ALCOF, ALCIF, ALCIN, ALCON, ALCOQ, ALCIQ, ALCOIQ, ALCOIN, ALCOIF, Languages.S, SI, SO, SF, SN, SQ, SOF, SIF, SON, SIN, SOQ, SIQ, SOI, SOIF, SOIN, SOIQ, SH, SHF, SHN, SHO, SHI, SHOF, SHIF, SHON, SHQ, SHOQ, SHIQ, SHOI, SHOIF, SHOIN, SHOIQ, SHIN, SHIND, SROIQ, SROIQD, ELPLUSPLUS, SOIFD, ALCHOND, ALCHOIF, SQD, ALCIFD, ALCHIN, SHOFD, SRIF, SND, SHOQD, SHID, ALCOID, ALCHOIFD, SHND, ALCROIQD, SD, ALCROQ, ALCH, ALCOD, SROIN, ALCHIND, SROIND, SRON, ALCHI, ALCID, ALCHIF, SRO, SROID, ALCRIF, ALCHOIQD, ALCRIN, ALCROQD, ALCHF, ALCROF, ALCHIQD, SRFD, ALCHN, SIQD, ALCRID, SHIQD, ALCOIND, SOQD, ALCRON, SHD, SR, ALCIND, ALCHID, ALCHOD, ALCOIFD, SRQ, SOIND, ALCRIFD, ALCHFD, SOD, ALCOQD, SRIND, ALCOFD, SRIFD, ALCRI, SHOND, SRID, ALCROIF, SRIQD, ALCRF, SOFD, SHFD, ALCROIN, ALCND, ALCHIQ, SHOIND, SID, SRIN, ALCHOID, ALCHOIN, ALCHOIND, ALCRQ, ALCHOI, ALCR, ALCROIND, SROQD, ALCHOF, ALCROND, ALCHQ, ALCQD, SROD, ALCROID, ALCOIQD, SROQ, ALCOND, ALCHND, ALCROD, SROFD, ALCHOQD, SHOIFD, ALCRIQ, SRF, SIND, ALCRIND, SHIFD, ALCRND, SRD, SROI, SROND, ALCHO, SHOD, ALCHD, ALCRFD, ALCHOIQ, SOND, SHQD, ALCRD, SRND, ALCRIQD, SOIQD, SFD, SROF, SROIF, SOID, SRN, ALCHIFD, SROIFD, SIFD, SRQD, SHOID, SRIQ, SHOIQD, ALCHON, ALCROFD, ALCHOQ, ALCRQD, ALCIQD, ALCROIQ, ALCHOFD, ALCROIFD, ALCHQD, ALCROI, SRI, ALCFD, ALCRN, ALCRO, ALCRrF, SRrN, ALCRrQ, ALCRrOD, ALCRrD, SRrOQ, ALCRr, ALCRrOND, ALCRrOQ, SRrOF, ALCRrO, SRrOQD, SRr, ALCRrFD, ALCRrOF, SRrOND, SRrF, SRrOFD, SRrD, SRrON, SRrO, SRrND, ALCRrON, ALCRrQD, SRrQ, ALCRrND, SRrOD, SRrQD, SRrFD, ALCRrOQD, ALCRrN, ALCRrOFD); } + protected static List belowU() { return l(ALC, ALCD, ALCQ, ALCN, ALCF, ALCI, ALCO, ALCOI, ALCOF, ALCIF, ALCIN, ALCON, ALCOQ, ALCIQ, ALCOIQ, ALCOIN, ALCOIF, Languages.S, SI, SO, SF, SN, SQ, SOF, SIF, SON, SIN, SOQ, SIQ, SOI, SOIF, SOIN, SOIQ, SH, SHF, SHN, SHO, SHI, SHOF, SHIF, SHON, SHQ, SHOQ, SHIQ, SHOI, SHOIF, SHOIN, SHOIQ, SHIN, SHIND, SROIQ, SROIQD, SHOQD, SIQD, ALCRIFD, ALCOD, ALCHID, SOIFD, SRIFD, SRF, ALCHND, ALCOIND, ALCHFD, SROIND, ALCHOIN, ALCROID, SRFD, ALCRIND, SND, ALCHOIFD, ALCROIN, SOND, ALCHOI, SHOIFD, SROIFD, ALCOIQD, ALCROQ, SHIFD, ALCHIQ, SOFD, SOID, ALCROQD, SRIF, SFD, ALCIND, ALCHOFD, SRID, ALCROF, ALCRIQ, ALCHOIQD, SOIQD, SROID, ALCHOID, ALCHIND, ALCRQD, SHIQD, SHOND, ALCROIFD, ALCRQ, ALCHO, SRD, SRIND, ALCROIQD, SOQD, SHOFD, ALCRIQD, ALCOID, ALCHI, ALCHOD, ALCHON, ALCIQD, ALCROIF, ALCHIQD, ALCHOQ, SROF, SROD, SROIF, ALCRO, SHD, SROIN, ALCRF, ALCHOIQ, ALCROI, ALCRN, ALCRON, SHID, ALCHIFD, SIFD, SRI, ALCND, ALCID, ALCHQ, SIND, SOIND, ALCOQD, SD, SHND, SHOID, ALCRIN, ALCOIFD, ALCROD, ALCHIN, ALCFD, ALCROIQ, SROND, SHQD, SOD, SRON, SHOIND, ALCHIF, SROQD, SHOD, ALCHF, ALCRIF, SQD, ALCRI, ALCRD, SRN, ALCHD, ALCHOF, ALCROND, SRND, ALCHOIND, SRQD, SID, ALCH, SRIQ, SRO, ALCHOND, ALCOND, SROFD, ALCROFD, SRIQD, ALCRFD, SHOIQD, SHFD, SROQ, ALCRND, ALCRID, ALCROIND, SRQ, ALCIFD, ALCR, SROI, SR, ALCHN, ALCHQD, SRIN, ALCQD, ALCHOIF, ALCOFD, ALCHOQD, SRrD, ALCRrOFD, ALCRr, SRrOND, ALCRrQ, SRrON, SRrOF, ALCRrN, SRrND, ALCRrO, ALCRrD, SRrQD, SRrN, SRrOD, SRrOQD, SRrF, ALCRrOND, SRrOFD, ALCRrFD, ALCRrOQ, ALCRrQD, ALCRrOQD, SRrQ, ALCRrF, SRrOQ, SRrO, ALCRrOD, ALCRrON, SRrFD, ALCRrOF, SRr, ALCRrND); } + protected static List belowTRAN() { return l(Languages.S, SI, SO, SF, SN, SQ, SOF, SIF, SON, SIN, SOQ, SIQ, SOI, SOIF, SOIN, SOIQ, SH, SHF, SHN, SHO, SHI, SHOF, SHIF, SHON, SHQ, SHOQ, SHIQ, SHOI, SHOIF, SHOIN, SHOIQ, SHIN, SHIND, SROIQ, SROIQD, SHOQD, SHD, SROIN, SIQD, SOIFD, SHID, SRIFD, SRF, SIFD, SRI, SROIND, SRFD, SIND, SOIND, SND, SD, SHND, SHOID, SOND, SHOIFD, SROIFD, SROND, SHQD, SOD, SRON, SHOIND, SHIFD, SOFD, SROQD, SHOD, SQD, SRN, SOID, SRIF, SFD, SRND, SRQD, SID, SRID, SRIQ, SRO, SROFD, SRIQD, SOIQD, SHOIQD, SHFD, SROID, SHIQD, SHOND, SROQ, SRD, SRIND, SOQD, SHOFD, SRQ, SROI, SR, SROF, SRIN, SROD, SROIF, SRrO, SRr, SRrOD, SRrD, SRrN, SRrQD, SRrOF, SRrQ, SRrON, SRrOND, SRrOQD, SRrOFD, ELPLUSPLUS, SRrOQ, SRrFD, SRrND, SRrF); } + protected static List belowED() { return l(ALCD, SHIND, SROIQD, ALCROIND, SROQD, SOIFD, ALCHOND, ALCROND, SQD, ALCQD, ALCIFD, SHOFD, SND, SHOQD, SHID, ALCOID, SROD, ALCROID, ALCOIQD, ALCHOIFD, SHND, ALCROIQD, SD, ALCOND, ALCHND, ALCOD, ALCROD, SROFD, ALCHOQD, ALCHIND, SHOIFD, SROIND, SIND, ALCRIND, SHIFD, ALCID, ALCRND, SRD, SROID, ALCHOIQD, SROND, ALCROQD, SHOD, ALCHD, ALCHIQD, SRFD, ALCRFD, SIQD, ALCRID, SHIQD, ALCOIND, SOND, SHQD, SOQD, ALCRD, SRND, SHD, ALCIND, ALCRIQD, ALCHID, ALCHOD, SOIQD, ALCOIFD, SFD, SOIND, ALCRIFD, SOID, ALCHFD, ALCHIFD, SOD, SROIFD, ALCOQD, SRIND, SIFD, ALCOFD, SRIFD, SRQD, SHOID, SHOND, SHOIQD, SRID, ALCROFD, ALCRQD, ALCIQD, SRIQD, SOFD, SHFD, ALCND, ALCHOFD, ALCROIFD, SHOIND, SID, ALCHQD, ALCHOID, ALCHOIND, ALCFD, SRrOFD, SRrD, ALCRrFD, ALCRrOFD, ELPLUSPLUS, ALCRrQD, ALCRrOQD, SRrOND, SRrND, ALCRrD, SRrQD, ALCRrOD, SRrOD, SRrOQD, SRrFD, ALCRrND, ALCRrOND); } + protected static List belowUO() { return l(ALCO, ALCOI, ALCOF, ALCON, ALCOQ, ALCOIQ, ALCOIN, ALCOIF, SO, SOF, SON, SOQ, SOI, SOIF, SOIN, SOIQ, SHO, SHOF, SHON, SHOQ, SHOI, SHOIF, SHOIN, SHOIQ, SROIQ, SROIQD, ALCROIND, SROQD, ALCHOF, SOIFD, ALCHOND, ALCHOIF, ALCROND, SHOFD, SHOQD, ALCOID, SROD, ALCROID, ALCOIQD, SROQ, ALCHOIFD, ALCROIQD, ALCROQ, ALCOND, ALCOD, ALCROD, SROFD, SROIN, ALCHOQD, SHOIFD, SROIND, SRON, SROI, SRO, SROID, ALCHOIQD, SROND, ALCROQD, ALCHO, SHOD, ALCROF, ALCHOIQ, ALCOIND, SOND, SOQD, ALCRON, ALCHOD, SOIQD, ALCOIFD, SOIND, SROF, SROIF, SOID, SOD, SROIFD, ALCOQD, ALCOFD, SHOID, SHOND, SHOIQD, ALCROIF, ALCHON, ALCROFD, ALCHOQ, SOFD, ALCROIQ, ALCROIN, ALCHOFD, ALCROIFD, SHOIND, ALCROI, ALCHOID, ALCHOIN, ALCHOIND, ALCHOI, ALCRO, SRrOFD, ALCRrOQ, ALCRrOFD, ALCRrOQD, SRrOND, SRrON, SRrOF, SRrOQ, SRrO, ALCRrO, ALCRrOD, SRrOD, ALCRrON, SRrOQD, ALCRrOF, ALCRrOND); } + protected static List belowEO() { return l(ALCO, ALCOI, ALCOF, ALCON, ALCOQ, ALCOIQ, ALCOIN, ALCOIF, SO, SOF, SON, SOQ, SOI, SOIF, SOIN, SOIQ, SHO, SHOF, SHON, SHOQ, SHOI, SHOIF, SHOIN, SHOIQ, SROIQ, SROIQD, ELPLUSPLUS, ALCROIND, SROQD, ALCHOF, SOIFD, ALCHOND, ALCHOIF, ALCROND, SHOFD, SHOQD, ALCOID, SROD, ALCROID, ALCOIQD, SROQ, ALCHOIFD, ALCROIQD, ALCROQ, ALCOND, ALCOD, ALCROD, SROFD, SROIN, ALCHOQD, SHOIFD, SROIND, SRON, SROI, SRO, SROID, ALCHOIQD, SROND, ALCROQD, ALCHO, SHOD, ALCROF, ALCHOIQ, ALCOIND, SOND, SOQD, ALCRON, ALCHOD, SOIQD, ALCOIFD, SOIND, SROF, SROIF, SOID, SOD, SROIFD, ALCOQD, ALCOFD, SHOID, SHOND, SHOIQD, ALCROIF, ALCHON, ALCROFD, ALCHOQ, SOFD, ALCROIQ, ALCROIN, ALCHOFD, ALCROIFD, SHOIND, ALCROI, ALCHOID, ALCHOIN, ALCHOIND, ALCHOI, ALCRO, ALCRrOF, SRrOND, SRrOFD, SRrON, SRrO, ALCRrON, ALCRrOD, SRrOQ, ALCRrOND, ALCRrOQ, SRrOF, SRrOD, ALCRrO, SRrOQD, ALCRrOQD, ALCRrOFD); } + protected static List belowO() { return l(ALCO, ALCOI, ALCOF, ALCON, ALCOQ, ALCOIQ, ALCOIN, ALCOIF, SO, SOF, SON, SOQ, SOI, SOIF, SOIN, SOIQ, SHO, SHOF, SHON, SHOQ, SHOI, SHOIF, SHOIN, SHOIQ, SROIQ, SROIQD, ELPLUSPLUS, ALCROF, SOND, ALCOQD, SHOIQD, ALCROI, ALCROND, ALCROIQD, SROIF, ALCHOD, ALCHOIN, ALCHOFD, SHOND, ALCHOI, ALCOFD, SROND, SHOID, ALCHON, ALCOIQD, SOQD, SOIQD, ALCHO, ALCRON, ALCROIQ, ALCROQD, ALCROFD, ALCOIFD, SHOD, ALCOID, ALCRO, SROFD, SROID, SHOIFD, ALCHOIQ, ALCROIN, ALCOND, ALCOD, SOIND, ALCHOF, ALCHOID, SROIN, ALCROIND, ALCROQ, ALCHOQD, SROQ, ALCOIND, ALCHOIF, ALCROID, ALCHOQ, ALCROIF, SROQD, ALCHOIQD, ALCHOIFD, SHOQD, ALCHOND, SROF, SOIFD, SOD, SROIFD, SHOFD, ALCROD, SRO, SOID, ALCROIFD, SHOIND, SROD, SRON, SROI, SROIND, ALCHOIND, SOFD, ALCRrOFD, ALCRrOD, SRrOD, SRrOF, SRrOFD, SRrOQ, SRrON, ALCRrOQ, SRrO, ALCRrOF, ALCRrOND, ALCRrON, SRrOQD, ALCRrOQD, ALCRrO, SRrOND); } + protected static List belowCUO() { return l(ALCO, ALCOI, ALCOF, ALCON, ALCOQ, ALCOIQ, ALCOIN, ALCOIF, SO, SOF, SON, SOQ, SOI, SOIF, SOIN, SOIQ, SHO, SHOF, SHON, SHOQ, SHOI, SHOIF, SHOIN, SHOIQ, SROIQ, SROIQD, ALCHOIND, ALCROI, SOIQD, ALCHOIQD, SHOIND, ALCROIFD, ALCHOQ, SOFD, ALCROFD, ALCOIND, SOND, SHOID, SROI, SHOD, ALCROIN, SROF, SHOFD, ALCROD, SOQD, SRO, ALCOFD, ALCROND, ALCHOI, ALCRON, SROQD, SROQ, ALCHON, ALCHOIQ, SOIFD, ALCHOD, SHOQD, ALCROID, SROIF, SROIN, ALCHOIF, SROIFD, SROD, ALCOID, ALCHOQD, SHOIQD, ALCRO, ALCROF, ALCROIQ, SHOIFD, SOID, SROFD, SROIND, ALCHOIN, SOD, ALCHOF, SHOND, SROID, ALCROIF, SRON, ALCROQ, SROND, ALCHOND, ALCHOID, ALCROQD, SOIND, ALCHO, ALCOIFD, ALCHOIFD, ALCROIQD, ALCOIQD, ALCOQD, ALCOD, ALCOND, ALCROIND, ALCHOFD, SRrOD, ALCRrOF, ALCRrOFD, SRrOQD, ALCRrOD, ALCRrOND, SRrOND, ALCRrO, SRrON, ALCRrOQ, SRrOFD, SRrOQ, SRrOF, SRrO, ALCRrON, ALCRrOQD); } + protected static List belowIF() { return l(ALCIF, ALCOIF, SIF, SOIF, SHIF, SHOIF, SOIFD, ALCRIFD, SRIF, ALCRIF, SROIFD, ALCROIF, SHOIFD, SROIF, ALCHIFD, ALCROIFD, ALCOIFD, SIFD, ALCIFD, ALCHOIFD, ALCHIF, ALCHOIF, SHIFD, SRIFD); } + protected static List belowF() { return l(ALCF, ALCOF, ALCIF, ALCOIF, SF, SOF, SIF, SOIF, SHF, SHOF, SHIF, SHOIF, SRF, ALCHOFD, ALCHIFD, ALCHIF, SROF, ALCHOIF, ALCRIFD, SHFD, SRFD, ALCRFD, SHIFD, SOIFD, SROIFD, ALCOIFD, ALCOFD, SRIFD, SFD, SRIF, ALCRIF, SROFD, SIFD, SHOFD, ALCROIF, ALCIFD, SHOIFD, ALCHOIFD, ALCROIFD, SOFD, ALCFD, ALCROF, ALCRF, SROIF, ALCHF, ALCROFD, ALCHFD, ALCHOF, SRrOFD, ALCRrFD, SRrFD, ALCRrOFD, SRrOF, ALCRrF, SRrF, ALCRrOF); } + protected static List belowCU() { return l(ALC, ALCD, ALCQ, ALCN, ALCF, ALCI, ALCO, ALCOI, ALCOF, ALCIF, ALCIN, ALCON, ALCOQ, ALCIQ, ALCOIQ, ALCOIN, ALCOIF, Languages.S, SI, SO, SF, SN, SQ, SOF, SIF, SON, SIN, SOQ, SIQ, SOI, SOIF, SOIN, SOIQ, SH, SHF, SHN, SHO, SHI, SHOF, SHIF, SHON, SHQ, SHOQ, SHIQ, SHOI, SHOIF, SHOIN, SHOIQ, SHIN, SHIND, SROIQ, SROIQD, SRIQD, SRQD, SHIQD, ALCROQ, ALCH, ALCRIQD, SROQD, SROIF, ALCROD, ALCOD, SIQD, ALCFD, ALCHOD, ALCID, ALCROIQD, ALCROIF, SROIN, SHOFD, ALCRD, SRN, SRIN, SROD, ALCND, SRO, ALCRQD, SHND, SROFD, SD, ALCRIQ, ALCRO, SRQ, ALCROID, SHOIFD, SRIND, ALCHIND, ALCHOIND, SOND, SHD, ALCRIFD, SROIND, ALCHD, SOIQD, SROND, ALCHOQD, SROF, ALCOID, SND, SRFD, SRD, SIFD, ALCRIF, SHID, SROQ, SROI, ALCOIND, ALCROF, SHIFD, ALCHI, ALCHOF, ALCHOID, ALCROIQ, ALCHOIQ, ALCIQD, ALCROI, SRIF, ALCROND, ALCIFD, ALCHIQD, SOD, SHQD, ALCHQD, SFD, ALCHQ, ALCHOI, SHOIQD, SRND, ALCOND, ALCOFD, ALCROIFD, ALCHOIQD, SHOIND, SOIFD, SROID, ALCHOND, ALCOQD, ALCHID, ALCRFD, ALCRI, ALCHIFD, SRIFD, ALCRID, SRF, ALCQD, ALCRND, ALCHN, ALCRN, ALCHFD, ALCHOIFD, ALCRON, ALCIND, SID, SQD, ALCHF, SHFD, ALCHIF, ALCR, ALCRIN, SIND, SRON, SHOQD, ALCHIN, ALCROFD, ALCHON, ALCOIFD, ALCHIQ, ALCHOQ, ALCRF, SRIQ, ALCROQD, ALCROIN, SR, ALCHOFD, SROIFD, ALCRIND, SOID, SOIND, SHOND, SRID, SRI, ALCHOIN, SHOID, SOFD, ALCHND, ALCHOIF, ALCRQ, ALCROIND, ALCHO, SOQD, SHOD, ALCOIQD, ALCRrQD, ALCRrOFD, ALCRrOD, SRrND, SRr, ALCRrOND, ALCRrQ, ALCRrO, ALCRrOQ, ALCRrF, SRrOFD, SRrN, SRrOQ, SRrOF, ALCRrFD, SRrOD, ALCRrOF, SRrQD, SRrOQD, SRrQ, ALCRr, ALCRrND, SRrFD, SRrOND, ALCRrN, SRrON, SRrF, SRrO, ALCRrON, ALCRrD, ALCRrOQD, SRrD); } + protected static List belowUniversal() { return l(FL0, FLMINUS, FL, AL, ALE, ALC, ALCD, ALCQ, ALCN, ALCF, ALCI, ALCO, ALCOI, ALCOF, ALCIF, ALCIN, ALCON, ALCOQ, ALCIQ, ALCOIQ, ALCOIN, ALCOIF, Languages.S, SI, SO, SF, SN, SQ, SOF, SIF, SON, SIN, SOQ, SIQ, SOI, SOIF, SOIN, SOIQ, SH, SHF, SHN, SHO, SHI, SHOF, SHIF, SHON, SHQ, SHOQ, SHIQ, SHOI, SHOIF, SHOIN, SHOIQ, SHIN, SHIND, SROIQ, SROIQD, SOFD, ALCROIND, ALCHOIQD, SOND, SRIQD, ALCQD, ALCIFD, ALCOFD, SIND, SRIFD, SHND, SIQD, ALCHID, SROI, SRI, ALCHOQ, SRND, SRIQ, SROQ, SRIND, ALCHN, ALCHIF, ALCHO, ALCHOIND, ALCRO, SRO, ALCROND, SRID, SRQ, ALCRIN, SOIND, SHIFD, SROND, ALCOD, SROD, ALCHOID, SHOID, SRIN, ALCRIF, ALCROQ, ALCRIQD, SRON, ALCROQD, SHOD, ALCHI, ALCFD, SROFD, ALCROIQD, SROIFD, SD, ALCHOIFD, SRQD, SHOIQD, ALCHOD, SOIQD, SOD, SROID, ALCHOQD, ALCHIFD, SHFD, ALCHOI, SHQD, ALCIND, ALCHOIN, SROIF, ALCROID, SOQD, SROIN, ALCOID, ALCHF, ALCHOND, ALCRIQ, ALCROD, ALCR, ALCROIN, ALCHOF, ALCHND, ALCOIND, ALCRF, SQD, ALCHIND, ALCHIQD, SHOND, SFD, ALCRI, ALCRON, ALCROI, ALCHFD, SHIQD, ALCHOIF, ALCROIQ, ALCOQD, ALCOIQD, ALCROIFD, SIFD, ALCND, ALCRFD, ALCRQD, SRF, SHD, ALCHIQ, ALCHD, SHOQD, SRD, ALCHOIQ, SRIF, ALCRND, SHID, ALCRIND, SHOFD, ALCRD, SRN, SROF, ALCROIF, SOID, ALCRQ, SRFD, ALCOIFD, ALCHON, ALCHQD, ALCRIFD, ALCROF, SHOIFD, ALCRID, ALCHIN, ALCHOFD, ALCOND, SROQD, SHOIND, ALCRN, SND, ALCHQ, SID, ALCIQD, SOIFD, ALCH, SROIND, SR, ALCROFD, ALCID, ALCRrQD, ALCRrOFD, ALCRrOD, SRrND, SRr, ALCRrOND, ALCRrQ, ALCRrO, ALCRrOQ, ALCRrF, SRrOFD, SRrN, SRrOQ, SRrOF, ALCRrFD, SRrOD, ALCRrOF, SRrQD, SRrOQD, SRrQ, ALCRr, ALCRrND, SRrFD, SRrOND, ALCRrN, SRrON, SRrF, SRrO, ALCRrON, ALCRrD, ALCRrOQD, SRrD); } + protected static List belowQD() { return l(ALCRIQD, SOQD, SRIQD, ALCHIQD, ALCIQD, SHIQD, SRQD, SQD, SHOQD, SIQD, SHOIQD, ALCHOQD, ALCHOIQD, SHQD, ALCROIQD, ALCOQD, SOIQD, SROQD, ALCHQD, ALCOIQD, SROIQD, ALCRQD, ALCROQD, ALCQD, SRrOQD, ALCRrOQD, ALCRrQD, SRrQD); } + protected static List belowQ() { return l(SRrQ, ALCHOIQD, SOIQ, SRIQ, SHQD, SRIQD, ALCHOQ, SRQD, ALCROIQ, ALCHQ, ALCRrOQ, SHOIQ, SOQD, SROQ, SIQ, ALCROQ, SOQ, ALCIQ, SHIQ, ALCHIQ, ALCRIQD, SHOQD, ALCHOQD, SRrOQD, ALCROIQD, ALCOQD, SHQ, ALCRrQD, SOIQD, SRrQD, ALCOQ, ALCRQ, ALCRrOQD, SQ, ALCHIQD, ALCRIQ, SROQD, SIQD, SHOIQD, ALCHQD, SROIQD, SHOQ, SQD, SRQ, ALCQD, ALCOIQ, SROIQ, ALCIQD, SHIQD, ALCHOIQ, ALCROQD, ALCRQD, SRrOQ, ALCRrQ, ALCQ, ALCOIQD); } + protected static List belowD() { return l(ALCD, SHIND, SROIQD, ALCROIQD, ALCHOQD, SHOID, ALCRND, ALCROND, SROND, SOFD, ALCHID, ALCRID, ALCROQD, SHOIFD, ALCQD, ALCRFD, SQD, SHOD, SOQD, ALCOND, ALCIQD, ALCROIND, SHOIQD, ALCOQD, SHOFD, ALCHFD, SND, SOIQD, ALCRIQD, ALCHOND, ALCRIND, ALCHQD, SOIFD, ALCHOD, ALCHND, SHD, SHIFD, SROFD, ALCOIQD, ALCHOID, SHID, ALCOID, ALCHOFD, ALCROIFD, ALCOIND, ALCHIND, SRQD, ALCIFD, SD, ALCHOIND, SHIQD, SROQD, SROIND, ALCROFD, SHOQD, SID, SOD, ALCOIFD, ALCFD, ALCRQD, SHOIND, SRFD, SRND, SRIND, ALCHIQD, SROD, SROIFD, SHQD, ALCROD, ALCID, SOIND, ALCHIFD, ALCIND, SHFD, ALCRD, SOND, ALCND, ALCOD, SIND, SOID, SHND, SIQD, SRD, SHOND, ALCOFD, ALCHOIQD, ALCROID, SFD, SROID, ALCHD, ALCHOIFD, SIFD, SRIFD, SRIQD, ALCRIFD, SRID, SRrOQD, ALCRrOQD, ALCRrQD, SRrND, ELPLUSPLUS, SRrQD, SRrOFD, SRrOND, ALCRrND, ALCRrD, SRrOD, ALCRrOFD, SRrD, ALCRrOND, ALCRrOD, ALCRrFD, SRrFD); } + protected static List belowH() { return l(SH, SHF, SHN, SHO, SHI, SHOF, SHIF, SHON, SHQ, SHOQ, SHIQ, SHOI, SHOIF, SHOIN, SHOIQ, SHIN, SHIND, ALCHOF, SHIQD, SHOFD, ALCHQ, ALCHOD, ALCHIQ, ALCHOND, ALCHIND, ALCHI, ALCHD, SHOIFD, ALCHOIN, ALCHIFD, ALCHOQD, ALCHOIQ, SHOND, ALCHON, ALCHOIFD, SHID, ALCHIF, ALCHND, ALCHOIND, ALCHIN, ALCHOIQD, ALCHIQD, ALCHOFD, ALCHQD, SHFD, ALCHOQ, ALCHO, ALCHFD, SHOQD, SHND, ALCHOI, SHOIND, SHQD, SHOID, ALCHOID, ALCHN, ALCHID, SHOD, ALCH, SHOIQD, ALCHF, ALCHOIF, SHD, SHIFD); } + protected static List belowHD() { return l(SHIND, ALCHOIND, SHOQD, ALCHOD, ALCHD, ALCHOFD, SHIQD, SHND, ALCHND, SHOIFD, ALCHOIQD, SHID, SHOD, SHOND, ALCHIQD, ALCHOND, ALCHIFD, ALCHOIFD, SHQD, SHFD, SHIFD, ALCHOID, SHD, SHOID, ALCHIND, ALCHOQD, SHOFD, SHOIND, ALCHQD, ALCHFD, ALCHID, SHOIQD); } + protected static List belowI() { return l(ALCI, ALCOI, ALCIF, ALCIN, ALCIQ, ALCOIQ, ALCOIN, ALCOIF, SI, SIF, SIN, SIQ, SOI, SOIF, SOIN, SOIQ, SHI, SHIF, SHIQ, SHOI, SHOIF, SHOIN, SHOIQ, SHIN, SHIND, SROIQ, SROIQD, SIQD, ALCRID, SRI, SRIQD, ALCOIND, ALCHOIF, SROIND, ALCHOID, SOID, ALCIND, SRIQ, ALCRI, SOIND, ALCRIND, SRIF, SHIQD, ALCID, ALCRIN, SRIN, ALCIQD, ALCRIQ, ALCROIF, ALCHIN, ALCHOIQ, ALCHIQD, ALCHI, ALCHID, SHOIQD, ALCRIQD, SRID, SRIND, ALCHIFD, SROID, SHOID, ALCOIQD, ALCHIF, ALCROIQD, ALCRIFD, SIND, ALCROID, SHID, SHIFD, SOIFD, ALCHIND, SROIFD, SROI, ALCOIFD, SHOIND, SRIFD, SROIN, ALCROIND, ALCHOIN, ALCRIF, ALCHIQ, SIFD, SOIQD, ALCHOI, ALCROI, ALCROIQ, ALCOID, ALCIFD, SHOIFD, ALCHOIFD, SID, ALCROIFD, ALCHOIND, SROIF, ALCHOIQD, ALCROIN); } + protected static List belowC() { return l(ALC, ALCD, ALCQ, ALCN, ALCF, ALCI, ALCO, ALCOI, ALCOF, ALCIF, ALCIN, ALCON, ALCOQ, ALCIQ, ALCOIQ, ALCOIN, ALCOIF, Languages.S, SI, SO, SF, SN, SQ, SOF, SIF, SON, SIN, SOQ, SIQ, SOI, SOIF, SOIN, SOIQ, SH, SHF, SHN, SHO, SHI, SHOF, SHIF, SHON, SHQ, SHOQ, SHIQ, SHOI, SHOIF, SHOIN, SHOIQ, SHIN, SHIND, SROIQ, SROIQD, ALCROIND, ALCOFD, ALCHOIQ, ALCRF, SR, ALCRIQ, ALCRD, SRIFD, ALCRO, SQD, SRI, ALCID, ALCH, SND, SOQD, SHOND, ALCRI, ALCHIND, ALCOND, ALCHIFD, SRIN, SOIND, SROIFD, SRO, SRF, ALCHOID, SROI, SROIN, ALCOID, ALCHIQD, SHND, ALCHOI, SROF, SHOIND, SHOD, SIQD, ALCQD, SHIQD, SOD, ALCHI, ALCHND, ALCHOIQD, ALCOIQD, ALCROF, SROIND, ALCRID, SFD, SHFD, ALCRFD, SROQD, SHOIFD, ALCROI, SHOQD, ALCRIQD, ALCFD, ALCHOD, ALCHF, ALCROIQD, SROFD, ALCHOIF, ALCRON, ALCROIF, ALCIND, ALCHIQ, SROD, ALCRIN, ALCHOQ, SID, ALCHQ, ALCHOND, ALCOQD, ALCRIFD, ALCRIF, ALCROFD, SRIQ, SRQ, ALCROD, ALCHD, ALCHN, SIFD, SRN, SRQD, SROND, ALCRIND, ALCHOF, SHOIQD, ALCHOFD, SHQD, ALCR, SD, SROID, SOID, ALCROIN, SRON, SRD, ALCRN, ALCRND, SOFD, ALCRQ, SRIND, ALCHOQD, ALCOIFD, ALCOD, SHIFD, ALCOIND, SIND, ALCHQD, ALCROQ, SOIQD, SHOFD, ALCHFD, ALCROQD, ALCHOIND, ALCHOIN, SROIF, ALCROID, ALCROIFD, ALCHIN, SROQ, SHID, SHD, ALCROND, ALCIFD, ALCIQD, ALCHOIFD, SRID, ALCHON, ALCRQD, SRFD, ALCROIQ, ALCHID, ALCND, SOIFD, SRND, SRIF, ALCHO, SHOID, ALCHIF, SOND, SRIQD, ALCRrQD, ALCRrOFD, ALCRrOD, SRrND, SRr, ALCRrOND, ALCRrQ, ALCRrO, ALCRrOQ, ALCRrF, SRrOFD, SRrN, SRrOQ, SRrOF, ALCRrFD, SRrOD, ALCRrOF, SRrQD, SRrOQD, SRrQ, ALCRr, ALCRrND, SRrFD, SRrOND, ALCRrN, SRrON, SRrF, SRrO, ALCRrON, ALCRrD, ALCRrOQD, SRrD); } + protected static List belowR() { return l(SROQD, SRIQD, ALCROQD, SROF, SRI, SROID, ALCROQ, SRIN, ALCROIFD, ALCRF, ALCROIND, SRF, ELPLUSPLUS, SRID, SROIQ, ALCRND, ALCROIQD, ALCRI, ALCROIF, ALCRD, ALCRON, SROD, ALCROIQ, ALCRO, ALCROF, SROIF, SROND, ALCRIF, SRQD, SRIFD, SRIND, SROFD, SROIND, ALCRQ, SROQ, ALCRFD, ALCROID, SRND, SROIN, ALCROND, ALCRIN, SRD, ALCR, ALCRQD, ALCRIQD, SROI, SRON, ALCROI, ALCRIFD, ALCRID, SRFD, ALCRN, SRIF, SR, SRN, SRO, SROIFD, ALCROFD, ALCRIND, ALCROIN, SRQ, ALCROD, SRIQ, SROIQD, ALCRIQ); } + protected static List belowRr() { return l(ALCRr, ALCRrON, SRrQD, SRrD, ALCRrO, ALCRrFD, ALCRrOQ, SRrOF, ALCRrOQD, ALCRrF, SRrQ, ALCRrN, ALCRrOFD, SRrON, SRrFD, ALCRrQ, SRrO, ALCRrQD, SRrND, ALCRrOND, SRrOND, ALCRrOF, SRrOQD, ALCRrD, SRrF, ALCRrND, SRrOD, SRrN, ALCRrOD, SRrOFD, SRrOQ, SRr); } + protected static List expressR() { return l(ALCR, ELPLUSPLUS); } + protected static List expressRr() { return l(ALCRr); } + //@formatter:on + + @ParameterizedTest + @MethodSource("getData") + void testAssertion(@SuppressWarnings("unused") String name, String expected, + List constructs, List expressible, List within, + List minimal, List objects) { + Set ont = ont(objects); + DLExpressivityChecker testsubject = new DLExpressivityChecker(ont); + List constructsFound = testsubject.getConstructs(); + List below = new ArrayList<>(); + List minimalLanguages = new ArrayList<>(); + for (Languages c : Languages.values()) { + if (testsubject.isWithin(c)) { + below.add(c); + } + if (testsubject.minimal(c)) { + minimalLanguages.add(c); + } + } + Collection expressibleInLanguages = testsubject.expressibleInLanguages(); + assertEquals(expressible, expressibleInLanguages, + expected + delta("expressible", expressible, expressibleInLanguages)); + assertEquals(constructs, constructsFound, expected); + assertEquals(new HashSet<>(within), new HashSet<>(below), + expected + delta("below", within, below)); + assertEquals(expected, testsubject.getDescriptionLogicName()); + assertEquals(new HashSet<>(minimal), new HashSet<>(minimalLanguages), + expected + delta("minimal", minimal, minimalLanguages)); + } + + private static String delta(String prefix, Collection within2, + Collection below) { + Set onlyFirst = new HashSet<>(within2); + onlyFirst.removeAll(below); + Set onlySecond = new HashSet<>(below); + onlySecond.removeAll(within2); + return prefix + "Only in first list: " + onlyFirst + " Only in second list: \n" + + onlySecond.stream().map(Languages::name).collect(Collectors.joining(", ")) + "\n\n"; + } + + Set ont(Collection objects) { + OWLOntology o = getOWLOntology(); + o.add(objects); + return Collections.singleton(o); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/DelegatingObjectVisitorExTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/DelegatingObjectVisitorExTestCase.java new file mode 100644 index 0000000000..4194f6876c --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/DelegatingObjectVisitorExTestCase.java @@ -0,0 +1,283 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataComplementOf; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataIntersectionOf; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDataUnionOf; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLHasKeyAxiom; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectInverseOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLObjectVisitorEx; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; +import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.SWRLBuiltInAtom; +import org.semanticweb.owlapi.model.SWRLClassAtom; +import org.semanticweb.owlapi.model.SWRLDataPropertyAtom; +import org.semanticweb.owlapi.model.SWRLDataRangeAtom; +import org.semanticweb.owlapi.model.SWRLDifferentIndividualsAtom; +import org.semanticweb.owlapi.model.SWRLIndividualArgument; +import org.semanticweb.owlapi.model.SWRLLiteralArgument; +import org.semanticweb.owlapi.model.SWRLObjectPropertyAtom; +import org.semanticweb.owlapi.model.SWRLRule; +import org.semanticweb.owlapi.model.SWRLSameIndividualAtom; +import org.semanticweb.owlapi.model.SWRLVariable; +import org.semanticweb.owlapi.util.DelegatingObjectVisitorEx; + +class DelegatingObjectVisitorExTestCase extends TestBase { + + @Test + void testAssertion() { + OWLObjectVisitorEx test = mock(OWLObjectVisitorEx.class); + DelegatingObjectVisitorEx testsubject = new DelegatingObjectVisitorEx<>(test); + testsubject.visit(mock(OWLDeclarationAxiom.class)); + testsubject.visit(mock(OWLDatatypeDefinitionAxiom.class)); + testsubject.visit(mock(OWLAnnotationPropertyRangeAxiom.class)); + testsubject.visit(mock(OWLAnnotationPropertyDomainAxiom.class)); + testsubject.visit(mock(OWLSubAnnotationPropertyOfAxiom.class)); + testsubject.visit(mock(OWLAnnotationAssertionAxiom.class)); + testsubject.visit(mock(OWLEquivalentDataPropertiesAxiom.class)); + testsubject.visit(mock(OWLClassAssertionAxiom.class)); + testsubject.visit(mock(OWLEquivalentClassesAxiom.class)); + testsubject.visit(mock(OWLDataPropertyAssertionAxiom.class)); + testsubject.visit(mock(OWLDisjointUnionAxiom.class)); + testsubject.visit(mock(OWLSymmetricObjectPropertyAxiom.class)); + testsubject.visit(mock(OWLDataPropertyRangeAxiom.class)); + testsubject.visit(mock(OWLFunctionalDataPropertyAxiom.class)); + testsubject.visit(mock(OWLSameIndividualAxiom.class)); + testsubject.visit(mock(OWLSubPropertyChainOfAxiom.class)); + testsubject.visit(mock(OWLInverseObjectPropertiesAxiom.class)); + testsubject.visit(mock(OWLHasKeyAxiom.class)); + testsubject.visit(mock(OWLTransitiveObjectPropertyAxiom.class)); + testsubject.visit(mock(OWLIrreflexiveObjectPropertyAxiom.class)); + testsubject.visit(mock(OWLSubDataPropertyOfAxiom.class)); + testsubject.visit(mock(OWLInverseFunctionalObjectPropertyAxiom.class)); + testsubject.visit(mock(OWLDisjointClassesAxiom.class)); + testsubject.visit(mock(OWLDataPropertyDomainAxiom.class)); + testsubject.visit(mock(OWLObjectPropertyDomainAxiom.class)); + testsubject.visit(mock(OWLEquivalentObjectPropertiesAxiom.class)); + testsubject.visit(mock(OWLSubClassOfAxiom.class)); + testsubject.visit(mock(OWLNegativeObjectPropertyAssertionAxiom.class)); + testsubject.visit(mock(OWLAsymmetricObjectPropertyAxiom.class)); + testsubject.visit(mock(OWLReflexiveObjectPropertyAxiom.class)); + testsubject.visit(mock(OWLObjectPropertyRangeAxiom.class)); + testsubject.visit(mock(OWLObjectPropertyAssertionAxiom.class)); + testsubject.visit(mock(OWLFunctionalObjectPropertyAxiom.class)); + testsubject.visit(mock(OWLSubObjectPropertyOfAxiom.class)); + testsubject.visit(mock(OWLNegativeDataPropertyAssertionAxiom.class)); + testsubject.visit(mock(OWLDifferentIndividualsAxiom.class)); + testsubject.visit(mock(OWLDisjointDataPropertiesAxiom.class)); + testsubject.visit(mock(OWLDisjointObjectPropertiesAxiom.class)); + testsubject.visit(mock(SWRLRule.class)); + testsubject.visit(mock(OWLDataAllValuesFrom.class)); + testsubject.visit(mock(OWLDataSomeValuesFrom.class)); + testsubject.visit(mock(OWLObjectOneOf.class)); + testsubject.visit(mock(OWLObjectHasSelf.class)); + testsubject.visit(mock(OWLObjectMaxCardinality.class)); + testsubject.visit(mock(OWLDataMaxCardinality.class)); + testsubject.visit(mock(OWLDataExactCardinality.class)); + testsubject.visit(mock(OWLDataMinCardinality.class)); + testsubject.visit(mock(OWLDataHasValue.class)); + testsubject.visit(mock(OWLObjectSomeValuesFrom.class)); + testsubject.visit(mock(OWLObjectComplementOf.class)); + testsubject.visit(mock(OWLObjectUnionOf.class)); + testsubject.visit(mock(OWLObjectIntersectionOf.class)); + testsubject.visit(mock(OWLObjectExactCardinality.class)); + testsubject.visit(mock(OWLObjectMinCardinality.class)); + testsubject.visit(mock(OWLObjectHasValue.class)); + testsubject.visit(mock(OWLObjectAllValuesFrom.class)); + testsubject.visit(mock(OWLClass.class)); + testsubject.visit(mock(OWLFacetRestriction.class)); + testsubject.visit(mock(OWLDatatypeRestriction.class)); + testsubject.visit(mock(OWLDataUnionOf.class)); + testsubject.visit(mock(OWLDataIntersectionOf.class)); + testsubject.visit(mock(OWLDataOneOf.class)); + testsubject.visit(mock(OWLDataComplementOf.class)); + testsubject.visit(mock(OWLDatatype.class)); + testsubject.visit(mock(OWLLiteral.class)); + testsubject.visit(mock(OWLObjectInverseOf.class)); + testsubject.visit(mock(OWLObjectProperty.class)); + testsubject.visit(mock(OWLDataProperty.class)); + testsubject.visit(mock(OWLAnnotationProperty.class)); + testsubject.visit(mock(OWLNamedIndividual.class)); + testsubject.visit(mock(OWLAnnotation.class)); + testsubject.visit(mock(IRI.class)); + testsubject.visit(mock(OWLAnonymousIndividual.class)); + testsubject.visit(mock(SWRLVariable.class)); + testsubject.visit(mock(SWRLIndividualArgument.class)); + testsubject.visit(mock(SWRLLiteralArgument.class)); + testsubject.visit(mock(SWRLSameIndividualAtom.class)); + testsubject.visit(mock(SWRLDifferentIndividualsAtom.class)); + testsubject.visit(mock(SWRLClassAtom.class)); + testsubject.visit(mock(SWRLDataRangeAtom.class)); + testsubject.visit(mock(SWRLObjectPropertyAtom.class)); + testsubject.visit(mock(SWRLDataPropertyAtom.class)); + testsubject.visit(mock(SWRLBuiltInAtom.class)); + testsubject.visit(mock(OWLOntology.class)); + verify(test).visit(any(OWLDeclarationAxiom.class)); + verify(test).visit(any(OWLDatatypeDefinitionAxiom.class)); + verify(test).visit(any(OWLAnnotationPropertyRangeAxiom.class)); + verify(test).visit(any(OWLAnnotationPropertyDomainAxiom.class)); + verify(test).visit(any(OWLSubAnnotationPropertyOfAxiom.class)); + verify(test).visit(any(OWLAnnotationAssertionAxiom.class)); + verify(test).visit(any(OWLEquivalentDataPropertiesAxiom.class)); + verify(test).visit(any(OWLClassAssertionAxiom.class)); + verify(test).visit(any(OWLEquivalentClassesAxiom.class)); + verify(test).visit(any(OWLDataPropertyAssertionAxiom.class)); + verify(test).visit(any(OWLDisjointUnionAxiom.class)); + verify(test).visit(any(OWLSymmetricObjectPropertyAxiom.class)); + verify(test).visit(any(OWLDataPropertyRangeAxiom.class)); + verify(test).visit(any(OWLFunctionalDataPropertyAxiom.class)); + verify(test).visit(any(OWLSameIndividualAxiom.class)); + verify(test).visit(any(OWLSubPropertyChainOfAxiom.class)); + verify(test).visit(any(OWLInverseObjectPropertiesAxiom.class)); + verify(test).visit(any(OWLHasKeyAxiom.class)); + verify(test).visit(any(OWLTransitiveObjectPropertyAxiom.class)); + verify(test).visit(any(OWLIrreflexiveObjectPropertyAxiom.class)); + verify(test).visit(any(OWLSubDataPropertyOfAxiom.class)); + verify(test).visit(any(OWLInverseFunctionalObjectPropertyAxiom.class)); + verify(test).visit(any(OWLDisjointClassesAxiom.class)); + verify(test).visit(any(OWLDataPropertyDomainAxiom.class)); + verify(test).visit(any(OWLObjectPropertyDomainAxiom.class)); + verify(test).visit(any(OWLEquivalentObjectPropertiesAxiom.class)); + verify(test).visit(any(OWLSubClassOfAxiom.class)); + verify(test).visit(any(OWLNegativeObjectPropertyAssertionAxiom.class)); + verify(test).visit(any(OWLAsymmetricObjectPropertyAxiom.class)); + verify(test).visit(any(OWLReflexiveObjectPropertyAxiom.class)); + verify(test).visit(any(OWLObjectPropertyRangeAxiom.class)); + verify(test).visit(any(OWLObjectPropertyAssertionAxiom.class)); + verify(test).visit(any(OWLFunctionalObjectPropertyAxiom.class)); + verify(test).visit(any(OWLSubObjectPropertyOfAxiom.class)); + verify(test).visit(any(OWLNegativeDataPropertyAssertionAxiom.class)); + verify(test).visit(any(OWLDifferentIndividualsAxiom.class)); + verify(test).visit(any(OWLDisjointDataPropertiesAxiom.class)); + verify(test).visit(any(OWLDisjointObjectPropertiesAxiom.class)); + verify(test).visit(any(SWRLRule.class)); + verify(test).visit(any(OWLDataAllValuesFrom.class)); + verify(test).visit(any(OWLDataSomeValuesFrom.class)); + verify(test).visit(any(OWLObjectOneOf.class)); + verify(test).visit(any(OWLObjectHasSelf.class)); + verify(test).visit(any(OWLObjectMaxCardinality.class)); + verify(test).visit(any(OWLDataMaxCardinality.class)); + verify(test).visit(any(OWLDataExactCardinality.class)); + verify(test).visit(any(OWLDataMinCardinality.class)); + verify(test).visit(any(OWLDataHasValue.class)); + verify(test).visit(any(OWLObjectSomeValuesFrom.class)); + verify(test).visit(any(OWLObjectComplementOf.class)); + verify(test).visit(any(OWLObjectUnionOf.class)); + verify(test).visit(any(OWLObjectIntersectionOf.class)); + verify(test).visit(any(OWLObjectExactCardinality.class)); + verify(test).visit(any(OWLObjectMinCardinality.class)); + verify(test).visit(any(OWLObjectHasValue.class)); + verify(test).visit(any(OWLObjectAllValuesFrom.class)); + verify(test).visit(any(OWLClass.class)); + verify(test).visit(any(OWLFacetRestriction.class)); + verify(test).visit(any(OWLDatatypeRestriction.class)); + verify(test).visit(any(OWLDataUnionOf.class)); + verify(test).visit(any(OWLDataIntersectionOf.class)); + verify(test).visit(any(OWLDataOneOf.class)); + verify(test).visit(any(OWLDataComplementOf.class)); + verify(test).visit(any(OWLDatatype.class)); + verify(test).visit(any(OWLLiteral.class)); + verify(test).visit(any(OWLObjectInverseOf.class)); + verify(test).visit(any(OWLObjectProperty.class)); + verify(test).visit(any(OWLDataProperty.class)); + verify(test).visit(any(OWLAnnotationProperty.class)); + verify(test).visit(any(OWLNamedIndividual.class)); + verify(test).visit(any(OWLAnnotation.class)); + verify(test).visit(any(IRI.class)); + verify(test).visit(any(OWLAnonymousIndividual.class)); + verify(test).visit(any(SWRLVariable.class)); + verify(test).visit(any(SWRLIndividualArgument.class)); + verify(test).visit(any(SWRLLiteralArgument.class)); + verify(test).visit(any(SWRLSameIndividualAtom.class)); + verify(test).visit(any(SWRLDifferentIndividualsAtom.class)); + verify(test).visit(any(SWRLClassAtom.class)); + verify(test).visit(any(SWRLDataRangeAtom.class)); + verify(test).visit(any(SWRLObjectPropertyAtom.class)); + verify(test).visit(any(SWRLDataPropertyAtom.class)); + verify(test).visit(any(SWRLBuiltInAtom.class)); + verify(test).visit(any(OWLOntology.class)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/GuessRDFSPropertyTypeTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/GuessRDFSPropertyTypeTestCase.java new file mode 100644 index 0000000000..58c7b8e7df --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/GuessRDFSPropertyTypeTestCase.java @@ -0,0 +1,164 @@ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.Collection; +import java.util.Collections; +import java.util.Set; +import java.util.stream.Stream; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.PrefixDocumentFormat; +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLProperty; +import org.semanticweb.owlapi.search.Filters; +import org.semanticweb.owlapi.search.Searcher; + +/** + * This is a test of the property type guessing for rdf:Property instances of the kind encountered + * when attempting to parse an RDFS schema. + *

    + * The CIDOC schema is a good test case, because it every property has a domain and a range + * specified; some properties have a range of Literal (and hence are data properties), and there are + * subclass relations specified for both data and object properties. + *

    + * There should be no Annotation Properties. + *

    + * See The CIDOC Web Site for more details. + */ +class GuessRDFSPropertyTypeTestCase extends TestBase { + + private static final String CIDOC_FILE = "cidoc_crm_v5.0.4_official_release.rdfs.xml"; + private static final String CIDOC_PREFIX = "http://www.cidoc-crm.org/cidoc-crm/"; + private OWLOntology cidocOntology; + private PrefixDocumentFormat prefixOWLDocumentFormat; + + @BeforeEach + void setUp() { + cidocOntology = ontologyFromClasspathFile(CIDOC_FILE, config); + assertNotNull(cidocOntology); + OWLDocumentFormat format = cidocOntology.getFormat(); + assertNotNull(format); + assertTrue(format.isPrefixOWLDocumentFormat()); + prefixOWLDocumentFormat = format.asPrefixOWLDocumentFormat(); + prefixOWLDocumentFormat.setDefaultPrefix(CIDOC_PREFIX); + } + + @Test + void testObjectProperty() { + testProperty("P11_had_participant", "E5_Event", "E39_Actor", + "P12_occurred_in_the_presence_of"); + } + + @Test + void testDataProperty() { + testProperty("P79_beginning_is_qualified_by", "E52_Time-Span", + "http://www.w3.org/2000/01/rdf-schema#Literal", "P3_has_note"); + } + + void testProperty(String propertyName, String expectedDomain, String expectedRange, + String expectedSuperProperty) { + IRI p11IRI = prefixOWLDocumentFormat.getIRI(propertyName); + Set hadParticipant = asUnorderedSet(cidocOntology.entitiesInSignature(p11IRI)); + assertEquals(1, hadParticipant.size(), "should have found " + propertyName); + OWLEntity entity = hadParticipant.iterator().next(); + assertTrue(OWLProperty.class.isAssignableFrom(entity.getClass())); + if (entity.isOWLObjectProperty()) { + testProperty(entity.asOWLObjectProperty(), expectedDomain, expectedRange, + expectedSuperProperty); + } + if (entity.isOWLDataProperty()) { + testProperty(entity.asOWLDataProperty(), expectedDomain, expectedRange, + expectedSuperProperty); + } + } + + private void testProperty(OWLObjectProperty p11property, String expectedDomain, + String expectedRange, String expectedSuperProperty) { + Stream rangeStream = + Searcher.range(cidocOntology.objectPropertyRangeAxioms(p11property)); + Collection ranges = asUnorderedSet(rangeStream); + assertEquals(1, ranges.size()); + HasIRI range = (HasIRI) ranges.iterator().next(); + IRI rangeIRI = range.getIRI(); + IRI expectedIRI = IRI.create(expectedRange); + if (!expectedIRI.isAbsolute()) { + expectedIRI = prefixOWLDocumentFormat.getIRI(expectedRange); + } + assertEquals(expectedIRI, rangeIRI); + Stream domainStream = + Searcher.domain(cidocOntology.objectPropertyDomainAxioms(p11property)); + Collection domains = asUnorderedSet(domainStream); + assertEquals(1, domains.size()); + HasIRI domain = (HasIRI) domains.iterator().next(); + IRI domainIRI = domain.getIRI(); + assertEquals(prefixOWLDocumentFormat.getIRI(expectedDomain), domainIRI); + Stream superStream = Searcher + .sup(cidocOntology.axioms(Filters.subObjectPropertyWithSub, p11property, INCLUDED)); + Collection superProperties = asUnorderedSet(superStream); + assertEquals(1, superProperties.size()); + HasIRI superProperty = (HasIRI) superProperties.iterator().next(); + IRI superPropertyIRI = superProperty.getIRI(); + assertEquals(prefixOWLDocumentFormat.getIRI(expectedSuperProperty), superPropertyIRI); + } + + private void testProperty(OWLDataProperty p11property, String expectedDomain, + String expectedRange, String expectedSuperProperty) { + Stream rangeClasses = + Searcher.range(cidocOntology.dataPropertyRangeAxioms(p11property)); + Collection ranges = asUnorderedSet(rangeClasses); + assertEquals(1, ranges.size()); + HasIRI range = (HasIRI) ranges.iterator().next(); + IRI rangeIRI = range.getIRI(); + IRI expectedIRI = IRI.create(expectedRange); + if (!expectedIRI.isAbsolute()) { + expectedIRI = prefixOWLDocumentFormat.getIRI(expectedRange); + } + assertEquals(expectedIRI, rangeIRI); + Stream domainStream = + Searcher.domain(cidocOntology.dataPropertyDomainAxioms(p11property)); + Collection domains = asUnorderedSet(domainStream); + assertEquals(1, domains.size()); + HasIRI domain = (HasIRI) domains.iterator().next(); + IRI domainIRI = domain.getIRI(); + assertEquals(prefixOWLDocumentFormat.getIRI(expectedDomain), domainIRI); + Stream supStream = Searcher + .sup(cidocOntology.axioms(Filters.subDataPropertyWithSub, p11property, INCLUDED)); + Collection superProperties = asUnorderedSet(supStream); + assertEquals(1, superProperties.size()); + HasIRI superProperty = (HasIRI) superProperties.iterator().next(); + IRI superPropertyIRI = superProperty.getIRI(); + assertEquals(prefixOWLDocumentFormat.getIRI(expectedSuperProperty), superPropertyIRI); + } + + @Test + void testObjectPropertyAndDataPropertySetsNonTriviallyDisjoint() { + Set objectProperties = + asUnorderedSet(cidocOntology.objectPropertiesInSignature()); + Set dataProperties = + asUnorderedSet(cidocOntology.dataPropertiesInSignature()); + assertFalse(objectProperties.isEmpty()); + assertFalse(dataProperties.isEmpty()); + assertTrue(Collections.disjoint(objectProperties, dataProperties)); + } + + @Test + void testAnnotationPropertyCount() { + assertEquals(2, cidocOntology.annotationPropertiesInSignature(INCLUDED).count()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/HeaderSignatureTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/HeaderSignatureTestCase.java new file mode 100644 index 0000000000..8d1190c670 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/HeaderSignatureTestCase.java @@ -0,0 +1,66 @@ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.model.AddOntologyAnnotation; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; + +/** + * Created by @ssz on 29.08.2020. + */ +class HeaderSignatureTestCase extends TestBase { + + @Test + void testContainsAnnotationPropertyIssue928() throws OWLOntologyCreationException { + OWLAnnotationProperty seeAlso = df.getRDFSSeeAlso(); + OWLDatatype intType = df.getIntegerOWLDatatype(); + OWLDatatype stringType = df.getStringOWLDatatype(); + + OWLOntology o = m.createOntology(IRI.create("http://XXXX")); + o.applyChange( + new AddOntologyAnnotation(o, df.getRDFSComment(df.getOWLLiteral("xxx", stringType)))); + o.applyChange(new AddOntologyAnnotation(o, + df.getOWLAnnotation(seeAlso, df.getOWLLiteral("42", intType)))); + + assertTrue(o.containsEntityInSignature(df.getRDFSComment())); + assertTrue(o.containsEntityInSignature(seeAlso)); + assertEquals(2, o.annotationPropertiesInSignature().count()); + + assertTrue(o.containsEntityInSignature(intType)); + assertTrue(o.containsEntityInSignature(stringType)); + } + + @Test + void testContainsDatatypesInHeaderIssue965() { + String s = "@prefix rdf: .\n" + + "@prefix owl: .\n" + + "@prefix rdfs: .\n" + + " a owl:Ontology ; " + "rdfs:comment \"the_comment\" . "; + + OWLOntology o = loadOntologyFromString(s, new TurtleDocumentFormat()); + + List header = o.annotations().collect(Collectors.toList()); + assertEquals(1, header.size()); + OWLAnnotation a = header.get(0); + + assertEquals(2, a.signature().count()); + assertEquals(1, a.annotationPropertiesInSignature().count()); + assertEquals(1, a.datatypesInSignature().count()); + + assertEquals(2, o.signature().count()); + assertEquals(1, o.annotationPropertiesInSignature().count()); + assertEquals(1, o.datatypesInSignature().count()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/HornAxiomVisitorExTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/HornAxiomVisitorExTestCase.java new file mode 100644 index 0000000000..a3b50e4488 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/HornAxiomVisitorExTestCase.java @@ -0,0 +1,116 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.util.HornAxiomVisitorEx; + +class HornAxiomVisitorExTestCase { + + static Collection getData() { + Builder b = new Builder(); + Map map = new LinkedHashMap<>(); + map.put(b.ann(), Boolean.TRUE); + map.put(b.asymm(), Boolean.FALSE); + map.put(b.annDom(), Boolean.TRUE); + map.put(b.annRange(), Boolean.TRUE); + map.put(b.ass(), Boolean.FALSE); + map.put(b.assAnd(), Boolean.FALSE); + map.put(b.assOr(), Boolean.FALSE); + map.put(b.dRangeAnd(), Boolean.FALSE); + map.put(b.dRangeOr(), Boolean.FALSE); + map.put(b.assNot(), Boolean.FALSE); + map.put(b.assNotAnon(), Boolean.FALSE); + map.put(b.assSome(), Boolean.FALSE); + map.put(b.assAll(), Boolean.FALSE); + map.put(b.assHas(), Boolean.FALSE); + map.put(b.assMin(), Boolean.FALSE); + map.put(b.assMax(), Boolean.FALSE); + map.put(b.assEq(), Boolean.FALSE); + map.put(b.assHasSelf(), Boolean.FALSE); + map.put(b.assOneOf(), Boolean.FALSE); + map.put(b.assDSome(), Boolean.FALSE); + map.put(b.assDAll(), Boolean.FALSE); + map.put(b.assDHas(), Boolean.FALSE); + map.put(b.assDMin(), Boolean.FALSE); + map.put(b.assDMax(), Boolean.FALSE); + map.put(b.assDEq(), Boolean.FALSE); + map.put(b.dOneOf(), Boolean.FALSE); + map.put(b.dNot(), Boolean.FALSE); + map.put(b.dRangeRestrict(), Boolean.FALSE); + map.put(b.assD(), Boolean.FALSE); + map.put(b.assDPlain(), Boolean.FALSE); + map.put(b.dDom(), Boolean.FALSE); + map.put(b.dRange(), Boolean.FALSE); + map.put(b.dDef(), Boolean.FALSE); + map.put(b.decC(), Boolean.TRUE); + map.put(b.decOp(), Boolean.TRUE); + map.put(b.decDp(), Boolean.TRUE); + map.put(b.decDt(), Boolean.TRUE); + map.put(b.decAp(), Boolean.TRUE); + map.put(b.decI(), Boolean.TRUE); + map.put(b.assDi(), Boolean.FALSE); + map.put(b.dc(), Boolean.TRUE); + map.put(b.dDp(), Boolean.FALSE); + map.put(b.dOp(), Boolean.FALSE); + map.put(b.du(), Boolean.TRUE); + map.put(b.ec(), Boolean.TRUE); + map.put(b.eDp(), Boolean.FALSE); + map.put(b.eOp(), Boolean.TRUE); + map.put(b.fdp(), Boolean.FALSE); + map.put(b.fop(), Boolean.TRUE); + map.put(b.ifp(), Boolean.TRUE); + map.put(b.iop(), Boolean.TRUE); + map.put(b.irr(), Boolean.FALSE); + map.put(b.ndp(), Boolean.FALSE); + map.put(b.nop(), Boolean.FALSE); + map.put(b.opa(), Boolean.FALSE); + map.put(b.opaInv(), Boolean.FALSE); + map.put(b.opaInvj(), Boolean.FALSE); + map.put(b.oDom(), Boolean.TRUE); + map.put(b.oRange(), Boolean.TRUE); + map.put(b.chain(), Boolean.FALSE); + map.put(b.ref(), Boolean.FALSE); + map.put(b.same(), Boolean.FALSE); + map.put(b.subAnn(), Boolean.TRUE); + map.put(b.subClass(), Boolean.TRUE); + map.put(b.subData(), Boolean.FALSE); + map.put(b.subObject(), Boolean.TRUE); + map.put(b.rule(), Boolean.FALSE); + map.put(b.symm(), Boolean.TRUE); + map.put(b.trans(), Boolean.TRUE); + map.put(b.hasKey(), Boolean.FALSE); + map.put(b.bigRule(), Boolean.FALSE); + Collection toReturn = new ArrayList<>(); + map.forEach((k, v) -> toReturn.add(new Object[] {k, v})); + return toReturn; + } + + @ParameterizedTest + @MethodSource("getData") + void testAssertion(OWLAxiom object, Boolean b) { + HornAxiomVisitorEx testsubject = new HornAxiomVisitorEx(); + Boolean result = object.accept(testsubject); + assertEquals(b, result); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/LanguagesTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/LanguagesTestCase.java new file mode 100644 index 0000000000..12ddb9693e --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/LanguagesTestCase.java @@ -0,0 +1,985 @@ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.util.Construct.ATOMIC_NEGATION; +import static org.semanticweb.owlapi.util.Construct.CONCEPT_COMPLEX_NEGATION; +import static org.semanticweb.owlapi.util.Construct.CONCEPT_INTERSECTION; +import static org.semanticweb.owlapi.util.Construct.CONCEPT_UNION; +import static org.semanticweb.owlapi.util.Construct.D; +import static org.semanticweb.owlapi.util.Construct.F; +import static org.semanticweb.owlapi.util.Construct.FULL_EXISTENTIAL; +import static org.semanticweb.owlapi.util.Construct.LIMITED_EXISTENTIAL; +import static org.semanticweb.owlapi.util.Construct.N; +import static org.semanticweb.owlapi.util.Construct.NOMINALS; +import static org.semanticweb.owlapi.util.Construct.Q; +import static org.semanticweb.owlapi.util.Construct.ROLE_COMPLEX; +import static org.semanticweb.owlapi.util.Construct.ROLE_DOMAIN_RANGE; +import static org.semanticweb.owlapi.util.Construct.ROLE_HIERARCHY; +import static org.semanticweb.owlapi.util.Construct.ROLE_INVERSE; +import static org.semanticweb.owlapi.util.Construct.ROLE_REFLEXIVITY_CHAINS; +import static org.semanticweb.owlapi.util.Construct.ROLE_TRANSITIVE; +import static org.semanticweb.owlapi.util.Construct.UNIVERSAL_RESTRICTION; +import static org.semanticweb.owlapi.util.Languages.AL; +import static org.semanticweb.owlapi.util.Languages.ALC; +import static org.semanticweb.owlapi.util.Languages.ALCD; +import static org.semanticweb.owlapi.util.Languages.ALCF; +import static org.semanticweb.owlapi.util.Languages.ALCFD; +import static org.semanticweb.owlapi.util.Languages.ALCH; +import static org.semanticweb.owlapi.util.Languages.ALCHD; +import static org.semanticweb.owlapi.util.Languages.ALCHF; +import static org.semanticweb.owlapi.util.Languages.ALCHFD; +import static org.semanticweb.owlapi.util.Languages.ALCHI; +import static org.semanticweb.owlapi.util.Languages.ALCHID; +import static org.semanticweb.owlapi.util.Languages.ALCHIF; +import static org.semanticweb.owlapi.util.Languages.ALCHIFD; +import static org.semanticweb.owlapi.util.Languages.ALCHIN; +import static org.semanticweb.owlapi.util.Languages.ALCHIND; +import static org.semanticweb.owlapi.util.Languages.ALCHIQ; +import static org.semanticweb.owlapi.util.Languages.ALCHIQD; +import static org.semanticweb.owlapi.util.Languages.ALCHN; +import static org.semanticweb.owlapi.util.Languages.ALCHND; +import static org.semanticweb.owlapi.util.Languages.ALCHO; +import static org.semanticweb.owlapi.util.Languages.ALCHOD; +import static org.semanticweb.owlapi.util.Languages.ALCHOF; +import static org.semanticweb.owlapi.util.Languages.ALCHOFD; +import static org.semanticweb.owlapi.util.Languages.ALCHOI; +import static org.semanticweb.owlapi.util.Languages.ALCHOID; +import static org.semanticweb.owlapi.util.Languages.ALCHOIF; +import static org.semanticweb.owlapi.util.Languages.ALCHOIFD; +import static org.semanticweb.owlapi.util.Languages.ALCHOIN; +import static org.semanticweb.owlapi.util.Languages.ALCHOIND; +import static org.semanticweb.owlapi.util.Languages.ALCHOIQ; +import static org.semanticweb.owlapi.util.Languages.ALCHOIQD; +import static org.semanticweb.owlapi.util.Languages.ALCHON; +import static org.semanticweb.owlapi.util.Languages.ALCHOND; +import static org.semanticweb.owlapi.util.Languages.ALCHOQ; +import static org.semanticweb.owlapi.util.Languages.ALCHOQD; +import static org.semanticweb.owlapi.util.Languages.ALCHQ; +import static org.semanticweb.owlapi.util.Languages.ALCHQD; +import static org.semanticweb.owlapi.util.Languages.ALCI; +import static org.semanticweb.owlapi.util.Languages.ALCID; +import static org.semanticweb.owlapi.util.Languages.ALCIF; +import static org.semanticweb.owlapi.util.Languages.ALCIFD; +import static org.semanticweb.owlapi.util.Languages.ALCIN; +import static org.semanticweb.owlapi.util.Languages.ALCIND; +import static org.semanticweb.owlapi.util.Languages.ALCIQ; +import static org.semanticweb.owlapi.util.Languages.ALCIQD; +import static org.semanticweb.owlapi.util.Languages.ALCN; +import static org.semanticweb.owlapi.util.Languages.ALCND; +import static org.semanticweb.owlapi.util.Languages.ALCO; +import static org.semanticweb.owlapi.util.Languages.ALCOD; +import static org.semanticweb.owlapi.util.Languages.ALCOF; +import static org.semanticweb.owlapi.util.Languages.ALCOFD; +import static org.semanticweb.owlapi.util.Languages.ALCOI; +import static org.semanticweb.owlapi.util.Languages.ALCOID; +import static org.semanticweb.owlapi.util.Languages.ALCOIF; +import static org.semanticweb.owlapi.util.Languages.ALCOIFD; +import static org.semanticweb.owlapi.util.Languages.ALCOIN; +import static org.semanticweb.owlapi.util.Languages.ALCOIND; +import static org.semanticweb.owlapi.util.Languages.ALCOIQ; +import static org.semanticweb.owlapi.util.Languages.ALCOIQD; +import static org.semanticweb.owlapi.util.Languages.ALCON; +import static org.semanticweb.owlapi.util.Languages.ALCOND; +import static org.semanticweb.owlapi.util.Languages.ALCOQ; +import static org.semanticweb.owlapi.util.Languages.ALCOQD; +import static org.semanticweb.owlapi.util.Languages.ALCQ; +import static org.semanticweb.owlapi.util.Languages.ALCQD; +import static org.semanticweb.owlapi.util.Languages.ALCR; +import static org.semanticweb.owlapi.util.Languages.ALCRD; +import static org.semanticweb.owlapi.util.Languages.ALCRF; +import static org.semanticweb.owlapi.util.Languages.ALCRFD; +import static org.semanticweb.owlapi.util.Languages.ALCRI; +import static org.semanticweb.owlapi.util.Languages.ALCRID; +import static org.semanticweb.owlapi.util.Languages.ALCRIF; +import static org.semanticweb.owlapi.util.Languages.ALCRIFD; +import static org.semanticweb.owlapi.util.Languages.ALCRIN; +import static org.semanticweb.owlapi.util.Languages.ALCRIND; +import static org.semanticweb.owlapi.util.Languages.ALCRIQ; +import static org.semanticweb.owlapi.util.Languages.ALCRIQD; +import static org.semanticweb.owlapi.util.Languages.ALCRN; +import static org.semanticweb.owlapi.util.Languages.ALCRND; +import static org.semanticweb.owlapi.util.Languages.ALCRO; +import static org.semanticweb.owlapi.util.Languages.ALCROD; +import static org.semanticweb.owlapi.util.Languages.ALCROF; +import static org.semanticweb.owlapi.util.Languages.ALCROFD; +import static org.semanticweb.owlapi.util.Languages.ALCROI; +import static org.semanticweb.owlapi.util.Languages.ALCROID; +import static org.semanticweb.owlapi.util.Languages.ALCROIF; +import static org.semanticweb.owlapi.util.Languages.ALCROIFD; +import static org.semanticweb.owlapi.util.Languages.ALCROIN; +import static org.semanticweb.owlapi.util.Languages.ALCROIND; +import static org.semanticweb.owlapi.util.Languages.ALCROIQ; +import static org.semanticweb.owlapi.util.Languages.ALCROIQD; +import static org.semanticweb.owlapi.util.Languages.ALCRON; +import static org.semanticweb.owlapi.util.Languages.ALCROND; +import static org.semanticweb.owlapi.util.Languages.ALCROQ; +import static org.semanticweb.owlapi.util.Languages.ALCROQD; +import static org.semanticweb.owlapi.util.Languages.ALCRQ; +import static org.semanticweb.owlapi.util.Languages.ALCRQD; +import static org.semanticweb.owlapi.util.Languages.ALCRr; +import static org.semanticweb.owlapi.util.Languages.ALCRrD; +import static org.semanticweb.owlapi.util.Languages.ALCRrF; +import static org.semanticweb.owlapi.util.Languages.ALCRrFD; +import static org.semanticweb.owlapi.util.Languages.ALCRrN; +import static org.semanticweb.owlapi.util.Languages.ALCRrND; +import static org.semanticweb.owlapi.util.Languages.ALCRrO; +import static org.semanticweb.owlapi.util.Languages.ALCRrOD; +import static org.semanticweb.owlapi.util.Languages.ALCRrOF; +import static org.semanticweb.owlapi.util.Languages.ALCRrOFD; +import static org.semanticweb.owlapi.util.Languages.ALCRrON; +import static org.semanticweb.owlapi.util.Languages.ALCRrOND; +import static org.semanticweb.owlapi.util.Languages.ALCRrOQ; +import static org.semanticweb.owlapi.util.Languages.ALCRrOQD; +import static org.semanticweb.owlapi.util.Languages.ALCRrQ; +import static org.semanticweb.owlapi.util.Languages.ALCRrQD; +import static org.semanticweb.owlapi.util.Languages.ALE; +import static org.semanticweb.owlapi.util.Languages.EL; +import static org.semanticweb.owlapi.util.Languages.ELPLUSPLUS; +import static org.semanticweb.owlapi.util.Languages.FL; +import static org.semanticweb.owlapi.util.Languages.FL0; +import static org.semanticweb.owlapi.util.Languages.FLMINUS; +import static org.semanticweb.owlapi.util.Languages.S; +import static org.semanticweb.owlapi.util.Languages.SD; +import static org.semanticweb.owlapi.util.Languages.SF; +import static org.semanticweb.owlapi.util.Languages.SFD; +import static org.semanticweb.owlapi.util.Languages.SH; +import static org.semanticweb.owlapi.util.Languages.SHD; +import static org.semanticweb.owlapi.util.Languages.SHF; +import static org.semanticweb.owlapi.util.Languages.SHFD; +import static org.semanticweb.owlapi.util.Languages.SHI; +import static org.semanticweb.owlapi.util.Languages.SHID; +import static org.semanticweb.owlapi.util.Languages.SHIF; +import static org.semanticweb.owlapi.util.Languages.SHIFD; +import static org.semanticweb.owlapi.util.Languages.SHIN; +import static org.semanticweb.owlapi.util.Languages.SHIND; +import static org.semanticweb.owlapi.util.Languages.SHIQ; +import static org.semanticweb.owlapi.util.Languages.SHIQD; +import static org.semanticweb.owlapi.util.Languages.SHN; +import static org.semanticweb.owlapi.util.Languages.SHND; +import static org.semanticweb.owlapi.util.Languages.SHO; +import static org.semanticweb.owlapi.util.Languages.SHOD; +import static org.semanticweb.owlapi.util.Languages.SHOF; +import static org.semanticweb.owlapi.util.Languages.SHOFD; +import static org.semanticweb.owlapi.util.Languages.SHOI; +import static org.semanticweb.owlapi.util.Languages.SHOID; +import static org.semanticweb.owlapi.util.Languages.SHOIF; +import static org.semanticweb.owlapi.util.Languages.SHOIFD; +import static org.semanticweb.owlapi.util.Languages.SHOIN; +import static org.semanticweb.owlapi.util.Languages.SHOIND; +import static org.semanticweb.owlapi.util.Languages.SHOIQ; +import static org.semanticweb.owlapi.util.Languages.SHOIQD; +import static org.semanticweb.owlapi.util.Languages.SHON; +import static org.semanticweb.owlapi.util.Languages.SHOND; +import static org.semanticweb.owlapi.util.Languages.SHOQ; +import static org.semanticweb.owlapi.util.Languages.SHOQD; +import static org.semanticweb.owlapi.util.Languages.SHQ; +import static org.semanticweb.owlapi.util.Languages.SHQD; +import static org.semanticweb.owlapi.util.Languages.SI; +import static org.semanticweb.owlapi.util.Languages.SID; +import static org.semanticweb.owlapi.util.Languages.SIF; +import static org.semanticweb.owlapi.util.Languages.SIFD; +import static org.semanticweb.owlapi.util.Languages.SIN; +import static org.semanticweb.owlapi.util.Languages.SIND; +import static org.semanticweb.owlapi.util.Languages.SIQ; +import static org.semanticweb.owlapi.util.Languages.SIQD; +import static org.semanticweb.owlapi.util.Languages.SN; +import static org.semanticweb.owlapi.util.Languages.SND; +import static org.semanticweb.owlapi.util.Languages.SO; +import static org.semanticweb.owlapi.util.Languages.SOD; +import static org.semanticweb.owlapi.util.Languages.SOF; +import static org.semanticweb.owlapi.util.Languages.SOFD; +import static org.semanticweb.owlapi.util.Languages.SOI; +import static org.semanticweb.owlapi.util.Languages.SOID; +import static org.semanticweb.owlapi.util.Languages.SOIF; +import static org.semanticweb.owlapi.util.Languages.SOIFD; +import static org.semanticweb.owlapi.util.Languages.SOIN; +import static org.semanticweb.owlapi.util.Languages.SOIND; +import static org.semanticweb.owlapi.util.Languages.SOIQ; +import static org.semanticweb.owlapi.util.Languages.SOIQD; +import static org.semanticweb.owlapi.util.Languages.SON; +import static org.semanticweb.owlapi.util.Languages.SOND; +import static org.semanticweb.owlapi.util.Languages.SOQ; +import static org.semanticweb.owlapi.util.Languages.SOQD; +import static org.semanticweb.owlapi.util.Languages.SQ; +import static org.semanticweb.owlapi.util.Languages.SQD; +import static org.semanticweb.owlapi.util.Languages.SR; +import static org.semanticweb.owlapi.util.Languages.SRD; +import static org.semanticweb.owlapi.util.Languages.SRF; +import static org.semanticweb.owlapi.util.Languages.SRFD; +import static org.semanticweb.owlapi.util.Languages.SRI; +import static org.semanticweb.owlapi.util.Languages.SRID; +import static org.semanticweb.owlapi.util.Languages.SRIF; +import static org.semanticweb.owlapi.util.Languages.SRIFD; +import static org.semanticweb.owlapi.util.Languages.SRIN; +import static org.semanticweb.owlapi.util.Languages.SRIND; +import static org.semanticweb.owlapi.util.Languages.SRIQ; +import static org.semanticweb.owlapi.util.Languages.SRIQD; +import static org.semanticweb.owlapi.util.Languages.SRN; +import static org.semanticweb.owlapi.util.Languages.SRND; +import static org.semanticweb.owlapi.util.Languages.SRO; +import static org.semanticweb.owlapi.util.Languages.SROD; +import static org.semanticweb.owlapi.util.Languages.SROF; +import static org.semanticweb.owlapi.util.Languages.SROFD; +import static org.semanticweb.owlapi.util.Languages.SROI; +import static org.semanticweb.owlapi.util.Languages.SROID; +import static org.semanticweb.owlapi.util.Languages.SROIF; +import static org.semanticweb.owlapi.util.Languages.SROIFD; +import static org.semanticweb.owlapi.util.Languages.SROIN; +import static org.semanticweb.owlapi.util.Languages.SROIND; +import static org.semanticweb.owlapi.util.Languages.SROIQ; +import static org.semanticweb.owlapi.util.Languages.SROIQD; +import static org.semanticweb.owlapi.util.Languages.SRON; +import static org.semanticweb.owlapi.util.Languages.SROND; +import static org.semanticweb.owlapi.util.Languages.SROQ; +import static org.semanticweb.owlapi.util.Languages.SROQD; +import static org.semanticweb.owlapi.util.Languages.SRQ; +import static org.semanticweb.owlapi.util.Languages.SRQD; +import static org.semanticweb.owlapi.util.Languages.SRr; +import static org.semanticweb.owlapi.util.Languages.SRrD; +import static org.semanticweb.owlapi.util.Languages.SRrF; +import static org.semanticweb.owlapi.util.Languages.SRrFD; +import static org.semanticweb.owlapi.util.Languages.SRrN; +import static org.semanticweb.owlapi.util.Languages.SRrND; +import static org.semanticweb.owlapi.util.Languages.SRrO; +import static org.semanticweb.owlapi.util.Languages.SRrOD; +import static org.semanticweb.owlapi.util.Languages.SRrOF; +import static org.semanticweb.owlapi.util.Languages.SRrOFD; +import static org.semanticweb.owlapi.util.Languages.SRrON; +import static org.semanticweb.owlapi.util.Languages.SRrOND; +import static org.semanticweb.owlapi.util.Languages.SRrOQ; +import static org.semanticweb.owlapi.util.Languages.SRrOQD; +import static org.semanticweb.owlapi.util.Languages.SRrQ; +import static org.semanticweb.owlapi.util.Languages.SRrQD; + +import java.util.Arrays; +import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.util.Construct; +import org.semanticweb.owlapi.util.Languages; + +class LanguagesTestCase { + private static EnumSet set(Construct... constructs) { + return EnumSet.copyOf(Arrays.asList(constructs)); + } + + private static void same(Languages l, Construct... constructs) { + assertEquals(set(constructs), l.components()); + } + + @Test + void shouldFindExpectedConstructs() { + same(FL0, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION); + same(FLMINUS, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(FL, ROLE_DOMAIN_RANGE, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(AL, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(EL, ROLE_DOMAIN_RANGE, FULL_EXISTENTIAL, CONCEPT_INTERSECTION); + same(ALE, FULL_EXISTENTIAL, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALC, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(S, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, D, + ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, F, + ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, F, + D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, N, + ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, N, + D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, Q, + ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, Q, + D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCI, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_INVERSE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCID, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_INVERSE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCIF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_INVERSE, F, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCIFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_INVERSE, F, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCIN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_INVERSE, N, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCIND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_INVERSE, N, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCIQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_INVERSE, Q, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCIQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_INVERSE, Q, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCO, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCOD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCOF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, F, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCOFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, F, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCON, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, N, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCOND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, N, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCOQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, Q, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCOQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, Q, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCOI, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, ROLE_INVERSE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCOID, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, ROLE_INVERSE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCOIF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, ROLE_INVERSE, F, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCOIFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, ROLE_INVERSE, F, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCOIN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, ROLE_INVERSE, N, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCOIND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, ROLE_INVERSE, N, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCOIQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, ROLE_INVERSE, Q, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCOIQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, ROLE_INVERSE, Q, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCH, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCHD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCHF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, F, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCHFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, F, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCHN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, N, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCHND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, N, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCHQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, Q, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCHQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, Q, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCHI, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, ROLE_INVERSE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHID, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, ROLE_INVERSE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHIF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, ROLE_INVERSE, F, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHIFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, ROLE_INVERSE, F, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHIN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, ROLE_INVERSE, N, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHIND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, ROLE_INVERSE, N, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHIQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, ROLE_INVERSE, Q, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHIQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, ROLE_INVERSE, Q, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHO, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCHOD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHOF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, F, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHOFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, F, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHON, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, N, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHOND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, N, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHOQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, Q, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHOQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, Q, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHOI, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHOID, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHOIF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, F, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHOIFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, F, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHOIN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, N, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHOIND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, N, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHOIQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, Q, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCHOIQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, Q, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRr, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCRrD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRrF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, F, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRrFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, F, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRrN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, N, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRrND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, N, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRrQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, Q, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRrQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, Q, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRrO, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, NOMINALS, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRrOD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, NOMINALS, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRrOF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, NOMINALS, F, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRrOFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, NOMINALS, F, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRrON, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, NOMINALS, N, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRrOND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, NOMINALS, N, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRrOQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, NOMINALS, Q, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRrOQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, NOMINALS, Q, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCR, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCRD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCRF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, F, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCRFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, F, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCRN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, N, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCRND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, N, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCRQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, Q, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCRQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, Q, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCRI, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, ROLE_INVERSE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRID, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, ROLE_INVERSE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRIF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, ROLE_INVERSE, F, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRIFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, ROLE_INVERSE, F, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRIN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, ROLE_INVERSE, N, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRIND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, ROLE_INVERSE, N, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRIQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, ROLE_INVERSE, Q, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRIQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, ROLE_INVERSE, Q, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRO, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCROD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCROF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, F, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCROFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, F, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCRON, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, N, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCROND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, N, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCROQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, Q, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(ALCROQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, Q, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCROI, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCROID, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCROIF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, F, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCROIFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, F, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCROIN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, N, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCROIND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, N, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCROIQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, Q, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ALCROIQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, Q, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(SF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, F, + ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(SFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, F, + ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(SN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, N, + ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(SND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, N, + ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(SQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, Q, + ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(SQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, Q, + ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(SI, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_INVERSE, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SID, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_INVERSE, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SIF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_INVERSE, F, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SIFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_INVERSE, F, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SIN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_INVERSE, N, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SIND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_INVERSE, N, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SIQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_INVERSE, Q, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SIQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_INVERSE, Q, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SO, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, + LIMITED_EXISTENTIAL); + same(SOD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SOF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, F, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SOFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, F, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SON, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, N, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SOND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, N, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SOQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, Q, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SOQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, Q, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SOI, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, ROLE_INVERSE, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SOID, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, ROLE_INVERSE, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SOIF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, ROLE_INVERSE, F, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SOIFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, ROLE_INVERSE, F, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SOIN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, ROLE_INVERSE, N, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SOIND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, ROLE_INVERSE, N, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SOIQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, ROLE_INVERSE, Q, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SOIQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + NOMINALS, ROLE_INVERSE, Q, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SH, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, F, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, F, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, N, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, N, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, Q, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, Q, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHI, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, ROLE_INVERSE, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHID, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, ROLE_INVERSE, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHIF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, ROLE_INVERSE, F, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHIFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, ROLE_INVERSE, F, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHIN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, ROLE_INVERSE, N, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHIND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, ROLE_INVERSE, N, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHIQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, ROLE_INVERSE, Q, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHIQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, ROLE_INVERSE, Q, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHO, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHOD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHOF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, F, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHOFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, F, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHON, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, N, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHOND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, N, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHOQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, Q, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHOQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, Q, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHOI, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, ROLE_TRANSITIVE, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHOID, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHOIF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, F, ROLE_TRANSITIVE, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHOIFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, F, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHOIN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, N, ROLE_TRANSITIVE, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHOIND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, N, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHOIQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, Q, ROLE_TRANSITIVE, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SHOIQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_HIERARCHY, NOMINALS, ROLE_INVERSE, Q, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRr, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRrD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRrF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, F, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRrFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, F, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRrN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, N, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRrND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, N, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRrQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, Q, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRrQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, Q, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRrO, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, NOMINALS, ROLE_TRANSITIVE, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRrOD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, NOMINALS, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRrOF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, NOMINALS, F, ROLE_TRANSITIVE, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRrOFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, NOMINALS, F, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRrON, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, NOMINALS, N, ROLE_TRANSITIVE, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRrOND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, NOMINALS, N, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRrOQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, NOMINALS, Q, ROLE_TRANSITIVE, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRrOQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_REFLEXIVITY_CHAINS, NOMINALS, Q, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SR, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, F, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, F, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, N, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, N, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, Q, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, Q, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRI, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, ROLE_INVERSE, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRID, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, ROLE_INVERSE, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRIF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, ROLE_INVERSE, F, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRIFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, ROLE_INVERSE, F, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRIN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, ROLE_INVERSE, N, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRIND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, ROLE_INVERSE, N, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRIQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, ROLE_INVERSE, Q, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRIQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, ROLE_INVERSE, Q, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRO, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SROD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SROF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, F, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SROFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, F, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SRON, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, N, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SROND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, N, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SROQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, Q, ROLE_TRANSITIVE, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SROQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, Q, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, CONCEPT_INTERSECTION, + UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SROI, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, ROLE_TRANSITIVE, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SROID, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SROIF, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, F, ROLE_TRANSITIVE, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SROIFD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, F, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SROIN, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, N, ROLE_TRANSITIVE, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SROIND, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, N, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SROIQ, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, Q, ROLE_TRANSITIVE, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(SROIQD, ROLE_DOMAIN_RANGE, CONCEPT_COMPLEX_NEGATION, CONCEPT_UNION, FULL_EXISTENTIAL, + ROLE_COMPLEX, NOMINALS, ROLE_INVERSE, Q, ROLE_TRANSITIVE, D, ATOMIC_NEGATION, + CONCEPT_INTERSECTION, UNIVERSAL_RESTRICTION, LIMITED_EXISTENTIAL); + same(ELPLUSPLUS, FULL_EXISTENTIAL, ROLE_COMPLEX, NOMINALS, ROLE_TRANSITIVE, D, + CONCEPT_INTERSECTION); + } + + // utility to write the enum declarations for variations of construct combinations + static void dump() { + // ALC || S (ALC + TRAN) + // H \subset R + // O + // I + // F \subset N \subset Q + // D + for (String s1 : new String[] {"ALC", "S"}) { + for (String s2 : new String[] {"", "H", "Rr", "R"}) { + for (String s3 : new String[] {"", "O"}) { + for (String s4 : new String[] {"", "I"}) { + for (String s5 : new String[] {"", "F", "N", "Q"}) { + for (String s6 : new String[] {"", "D"}) { + List list = Arrays.asList(s1, s2, s3, s4, s5, s6); + String name = list.stream().collect(Collectors.joining()); + String starter = " /** " + name + " language. */ "; + System.out.println(starter + + name + "(\"" + name + "\"," + list.stream() + .filter(s -> !s.isEmpty()).collect(Collectors.joining(", ")) + + "),"); + } + } + } + } + } + } + } + + public static void main(String[] args) { + for (Languages l : Languages.values()) { + System.out.println(l.components().stream().map(Construct::name) + .collect(Collectors.joining(", ", "same(" + l.name() + ", ", ");"))); + } + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/LoadFromJarTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/LoadFromJarTestCase.java new file mode 100644 index 0000000000..2c092d966e --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/LoadFromJarTestCase.java @@ -0,0 +1,24 @@ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; + +class LoadFromJarTestCase extends TestBase { + + @Test + void shouldLoadWithFileName() throws OWLOntologyCreationException { + OWLOntology loadOntology = m.loadOntology(IRI.create("jar:!/koala.owl")); + assertEquals(70, loadOntology.getAxiomCount()); + } + + @Test + void shouldLoadWithRelativeFileName() throws OWLOntologyCreationException { + OWLOntology loadOntology = m.loadOntology(IRI.create("jar:!koala.owl")); + assertEquals(70, loadOntology.getAxiomCount()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ManSyntaxTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ManSyntaxTestCase.java new file mode 100644 index 0000000000..0ea47a3b08 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ManSyntaxTestCase.java @@ -0,0 +1,117 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import java.util.ArrayList; +import java.util.Collection; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; + +class ManSyntaxTestCase extends TestBase { + + static Collection getData() { + Collection toReturn = new ArrayList<>(); + Builder b = new Builder(); + toReturn.add(new Object[] {b.ann()}); + toReturn.add(new Object[] {b.asymm()}); + toReturn.add(new Object[] {b.annDom()}); + toReturn.add(new Object[] {b.annRange()}); + toReturn.add(new Object[] {b.ass()}); + toReturn.add(new Object[] {b.assAnd()}); + toReturn.add(new Object[] {b.assOr()}); + toReturn.add(new Object[] {b.dRangeAnd()}); + toReturn.add(new Object[] {b.dRangeOr()}); + toReturn.add(new Object[] {b.assNot()}); + toReturn.add(new Object[] {b.assNotAnon()}); + toReturn.add(new Object[] {b.assSome()}); + toReturn.add(new Object[] {b.assAll()}); + toReturn.add(new Object[] {b.assHas()}); + toReturn.add(new Object[] {b.assMin()}); + toReturn.add(new Object[] {b.assMax()}); + toReturn.add(new Object[] {b.assEq()}); + toReturn.add(new Object[] {b.assHasSelf()}); + toReturn.add(new Object[] {b.assOneOf()}); + toReturn.add(new Object[] {b.assDSome()}); + toReturn.add(new Object[] {b.assDAll()}); + toReturn.add(new Object[] {b.assDHas()}); + toReturn.add(new Object[] {b.assDMin()}); + toReturn.add(new Object[] {b.assDMax()}); + toReturn.add(new Object[] {b.assDEq()}); + toReturn.add(new Object[] {b.dOneOf()}); + toReturn.add(new Object[] {b.dNot()}); + toReturn.add(new Object[] {b.dRangeRestrict()}); + toReturn.add(new Object[] {b.assD()}); + toReturn.add(new Object[] {b.assDPlain()}); + toReturn.add(new Object[] {b.dDom()}); + toReturn.add(new Object[] {b.dRange()}); + toReturn.add(new Object[] {b.dDef()}); + toReturn.add(new Object[] {b.decC()}); + toReturn.add(new Object[] {b.decOp()}); + toReturn.add(new Object[] {b.decDp()}); + toReturn.add(new Object[] {b.decDt()}); + toReturn.add(new Object[] {b.decAp()}); + toReturn.add(new Object[] {b.decI()}); + toReturn.add(new Object[] {b.assDi()}); + toReturn.add(new Object[] {b.dc()}); + toReturn.add(new Object[] {b.dDp()}); + toReturn.add(new Object[] {b.dOp()}); + toReturn.add(new Object[] {b.du()}); + toReturn.add(new Object[] {b.ec()}); + toReturn.add(new Object[] {b.eDp()}); + toReturn.add(new Object[] {b.eOp()}); + toReturn.add(new Object[] {b.fdp()}); + toReturn.add(new Object[] {b.fop()}); + toReturn.add(new Object[] {b.ifp()}); + toReturn.add(new Object[] {b.iop()}); + toReturn.add(new Object[] {b.irr()}); + toReturn.add(new Object[] {b.ndp()}); + toReturn.add(new Object[] {b.nop()}); + toReturn.add(new Object[] {b.opa()}); + toReturn.add(new Object[] {b.opaInv()}); + toReturn.add(new Object[] {b.opaInvj()}); + toReturn.add(new Object[] {b.oDom()}); + toReturn.add(new Object[] {b.oRange()}); + toReturn.add(new Object[] {b.chain()}); + toReturn.add(new Object[] {b.ref()}); + toReturn.add(new Object[] {b.same()}); + toReturn.add(new Object[] {b.subAnn()}); + toReturn.add(new Object[] {b.subClass()}); + toReturn.add(new Object[] {b.subData()}); + toReturn.add(new Object[] {b.subObject()}); + toReturn.add(new Object[] {b.rule()}); + toReturn.add(new Object[] {b.symm()}); + toReturn.add(new Object[] {b.trans()}); + toReturn.add(new Object[] {b.hasKey()}); + toReturn.add(new Object[] {b.bigRule()}); + return toReturn; + } + + @ParameterizedTest + @MethodSource("getData") + void testAssertion(OWLAxiom object) + throws OWLOntologyCreationException, OWLOntologyStorageException { + OWLOntology o = setupManager().createOntology(iri("urn:test:", "manchester")); + o.addAxiom(object); + StringDocumentTarget s = saveOntology(o, new ManchesterSyntaxDocumentFormat()); + loadOntologyFromString(s, new ManchesterSyntaxDocumentFormat()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/MaximumModalDepthFinderTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/MaximumModalDepthFinderTestCase.java new file mode 100644 index 0000000000..ae1a81c4de --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/MaximumModalDepthFinderTestCase.java @@ -0,0 +1,118 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.util.MaximumModalDepthFinder; + +class MaximumModalDepthFinderTestCase { + + static Collection getData() { + Builder b = new Builder(); + Map map = new LinkedHashMap<>(); + Integer zero = Integer.valueOf(0); + Integer one = Integer.valueOf(1); + map.put(b.ann(), zero); + map.put(b.asymm(), zero); + map.put(b.annDom(), zero); + map.put(b.annRange(), zero); + map.put(b.ass(), zero); + map.put(b.assAnd(), zero); + map.put(b.assOr(), zero); + map.put(b.dRangeAnd(), zero); + map.put(b.dRangeOr(), zero); + map.put(b.assNot(), zero); + map.put(b.assNotAnon(), zero); + map.put(b.assSome(), one); + map.put(b.assAll(), one); + map.put(b.assHas(), zero); + map.put(b.assMin(), one); + map.put(b.assMax(), one); + map.put(b.assEq(), one); + map.put(b.assHasSelf(), one); + map.put(b.assOneOf(), zero); + map.put(b.assDSome(), one); + map.put(b.assDAll(), one); + map.put(b.assDHas(), one); + map.put(b.assDMin(), one); + map.put(b.assDMax(), one); + map.put(b.assDEq(), one); + map.put(b.dOneOf(), zero); + map.put(b.dNot(), zero); + map.put(b.dRangeRestrict(), zero); + map.put(b.assD(), zero); + map.put(b.assDPlain(), zero); + map.put(b.dDom(), zero); + map.put(b.dRange(), zero); + map.put(b.dDef(), zero); + map.put(b.decC(), zero); + map.put(b.decOp(), zero); + map.put(b.decDp(), zero); + map.put(b.decDt(), zero); + map.put(b.decAp(), zero); + map.put(b.decI(), zero); + map.put(b.assDi(), zero); + map.put(b.dc(), zero); + map.put(b.dDp(), zero); + map.put(b.dOp(), zero); + map.put(b.du(), zero); + map.put(b.ec(), zero); + map.put(b.eDp(), zero); + map.put(b.eOp(), zero); + map.put(b.fdp(), zero); + map.put(b.fop(), zero); + map.put(b.ifp(), zero); + map.put(b.iop(), zero); + map.put(b.irr(), zero); + map.put(b.ndp(), zero); + map.put(b.nop(), zero); + map.put(b.opa(), zero); + map.put(b.opaInv(), zero); + map.put(b.opaInvj(), zero); + map.put(b.oDom(), zero); + map.put(b.oRange(), zero); + map.put(b.chain(), zero); + map.put(b.ref(), zero); + map.put(b.same(), zero); + map.put(b.subAnn(), zero); + map.put(b.subClass(), zero); + map.put(b.subData(), zero); + map.put(b.subObject(), zero); + map.put(b.rule(), zero); + map.put(b.symm(), zero); + map.put(b.trans(), zero); + map.put(b.hasKey(), zero); + map.put(b.bigRule(), zero); + map.put(b.onto(), zero); + Collection toReturn = new ArrayList<>(); + map.forEach((k, v) -> toReturn.add(new Object[] {k, v})); + return toReturn; + } + + @ParameterizedTest + @MethodSource("getData") + void testAssertion(OWLObject object, Integer expected) { + MaximumModalDepthFinder testsubject = new MaximumModalDepthFinder(); + Integer i = object.accept(testsubject); + assertEquals(expected, i); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/NNFTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/NNFTestCase.java new file mode 100644 index 0000000000..187b165f75 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/NNFTestCase.java @@ -0,0 +1,97 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.util.NNF; + +class NNFTestCase { + + static Stream getData() { + Builder b = new Builder(); + return Stream.of(Arguments.of(b.dRange(), TestFiles.nnfdRange), + Arguments.of(b.dDef(), TestFiles.nnfdDef), Arguments.of(b.decC(), TestFiles.nnfdecC), + Arguments.of(b.decOp(), TestFiles.nnfdecOp), + Arguments.of(b.decDp(), TestFiles.nnfdecDp), + Arguments.of(b.decDt(), TestFiles.nnfdecDt), + Arguments.of(b.decAp(), TestFiles.nnfdecAp), Arguments.of(b.decI(), TestFiles.nnfdecI), + Arguments.of(b.assDi(), TestFiles.nnfassDi), Arguments.of(b.dc(), TestFiles.nnfdc), + Arguments.of(b.dDp(), TestFiles.nnfdDp), Arguments.of(b.dOp(), TestFiles.nnfdOp), + Arguments.of(b.du(), TestFiles.nnfdu), Arguments.of(b.ec(), TestFiles.nnfec), + Arguments.of(b.eDp(), TestFiles.nnfeDp), Arguments.of(b.eOp(), TestFiles.nnfeOp), + Arguments.of(b.fdp(), TestFiles.nnffdp), Arguments.of(b.fop(), TestFiles.nnffop), + Arguments.of(b.ifp(), TestFiles.nnfifp), Arguments.of(b.iop(), TestFiles.nnfiop), + Arguments.of(b.irr(), TestFiles.nnfirr), Arguments.of(b.ndp(), TestFiles.nnfndp), + Arguments.of(b.nop(), TestFiles.nnfnop), Arguments.of(b.opa(), TestFiles.nnfopa), + Arguments.of(b.opaInv(), TestFiles.nnfopaInv), + Arguments.of(b.opaInvj(), TestFiles.nnfopaInvj), + Arguments.of(b.oDom(), TestFiles.nnfoDom), + Arguments.of(b.oRange(), TestFiles.nnfoRange), + Arguments.of(b.chain(), TestFiles.nnfchain), Arguments.of(b.ref(), TestFiles.nnfref), + Arguments.of(b.same(), TestFiles.nnfsame), + Arguments.of(b.subAnn(), TestFiles.nnfsubAnn), + Arguments.of(b.subClass(), TestFiles.nnfsubClass), + Arguments.of(b.subData(), TestFiles.nnfsubData), + Arguments.of(b.subObject(), TestFiles.nnfsubObject), + Arguments.of(b.rule(), TestFiles.nnfrule), Arguments.of(b.symm(), TestFiles.nnfsymm), + Arguments.of(b.trans(), TestFiles.nnftrans), + Arguments.of(b.hasKey(), TestFiles.nnfhasKey), + Arguments.of(b.bigRule(), TestFiles.nnfbigRule), + Arguments.of(b.ann(), TestFiles.nnfann), Arguments.of(b.asymm(), TestFiles.nnfasymm), + Arguments.of(b.annDom(), TestFiles.nnfannDom), + Arguments.of(b.annRange(), TestFiles.nnfannRange), + Arguments.of(b.ass(), TestFiles.nnfass), Arguments.of(b.assAnd(), TestFiles.nnfassAnd), + Arguments.of(b.assOr(), TestFiles.nnfassOr), + Arguments.of(b.dRangeAnd(), TestFiles.nnfdRangeAnd), + Arguments.of(b.dRangeOr(), TestFiles.nnfdRangeOr), + Arguments.of(b.assNot(), TestFiles.nnfassNot), + Arguments.of(b.assNotAnon(), TestFiles.nnfassNotAnon), + Arguments.of(b.assSome(), TestFiles.nnfassSome), + Arguments.of(b.assAll(), TestFiles.nnfassAll), + Arguments.of(b.assHas(), TestFiles.nnfassHas), + Arguments.of(b.assMin(), TestFiles.nnfassMin), + Arguments.of(b.assMax(), TestFiles.nnfassMax), + Arguments.of(b.assEq(), TestFiles.nnfassEq), + Arguments.of(b.assHasSelf(), TestFiles.nnfassHasSelf), + Arguments.of(b.assOneOf(), TestFiles.nnfassOneOf), + Arguments.of(b.assDSome(), TestFiles.nnfassDSome), + Arguments.of(b.assDAll(), TestFiles.nnfassDAll), + Arguments.of(b.assDHas(), TestFiles.nnfassDHas), + Arguments.of(b.assDMin(), TestFiles.nnfassDMin), + Arguments.of(b.assDMax(), TestFiles.nnfassDMax), + Arguments.of(b.assDEq(), TestFiles.nnfassDEq), + Arguments.of(b.dOneOf(), TestFiles.nnfdOneOf), + Arguments.of(b.dNot(), TestFiles.nnfdNot), + Arguments.of(b.dRangeRestrict(), TestFiles.nnfdRangeRestrict), + Arguments.of(b.assD(), TestFiles.nnfassD), + Arguments.of(b.assDPlain(), TestFiles.nnfassDPlain), + Arguments.of(b.dDom(), TestFiles.nnfdDom)); + } + + @ParameterizedTest + @MethodSource("getData") + void testAssertion(OWLAxiom object, String expected) { + NNF testsubject = new NNF(OWLManager.getOWLDataFactory()); + String result = object.accept(testsubject).toString(); + assertEquals(expected, result); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/NamespacesTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/NamespacesTestCase.java new file mode 100644 index 0000000000..5c7c8705d1 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/NamespacesTestCase.java @@ -0,0 +1,92 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.EnumSet; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; +import org.semanticweb.owlapi.vocab.Namespaces; +import org.semanticweb.owlapi.vocab.OWL2Datatype; +import org.semanticweb.owlapi.vocab.XSDVocabulary; + +class NamespacesTestCase extends TestBase { + + static final String NS = "http://test.owl/test#"; + + @Test + void shouldFindInNamespace() { + EnumSet reserved = + EnumSet.of(Namespaces.OWL, Namespaces.RDF, Namespaces.RDFS, Namespaces.XSD); + for (Namespaces n : Namespaces.values()) { + IRI iri = iri(n.getPrefixIRI(), "test"); + boolean reservedVocabulary = iri.isReservedVocabulary(); + assertTrue(reservedVocabulary == reserved.contains(n), iri + " reserved? Should be " + + reserved.contains(n) + " but is " + reservedVocabulary); + } + } + + @Test + void shouldParseXSDSTRING() { + // given + String s = "xsd:string"; + // when + XSDVocabulary v = XSDVocabulary.parseShortName(s); + // then + assertEquals(XSDVocabulary.STRING, v); + assertEquals(OWL2Datatype.XSD_STRING.getDatatype(df), df.getOWLDatatype(v)); + } + + @Test + void shouldFailToParseInvalidString() { + // given + String s = "xsd:st"; + // when + assertThrows(IllegalArgumentException.class, () -> XSDVocabulary.parseShortName(s)); + // then + // an exception should have been thrown + } + + @Test + void shouldSetPrefix() throws OWLOntologyCreationException, OWLOntologyStorageException { + OWLClass item = df.getOWLClass(NS, "item"); + OWLDeclarationAxiom declaration = df.getOWLDeclarationAxiom(item); + OWLOntology o1 = m.createOntology(); + FunctionalSyntaxDocumentFormat pm1 = new FunctionalSyntaxDocumentFormat(); + pm1.setPrefix(":", NS); + m.setOntologyFormat(o1, pm1); + o1.addAxiom(declaration); + StringDocumentTarget t1 = new StringDocumentTarget(); + o1.saveOntology(t1); + OWLOntology o2 = m1.createOntology(); + FunctionalSyntaxDocumentFormat pm2 = new FunctionalSyntaxDocumentFormat(); + pm2.setPrefix(":", NS); + o2.addAxiom(declaration); + StringDocumentTarget t2 = new StringDocumentTarget(); + o1.saveOntology(pm2, t2); + assertTrue(t2.toString().contains("Declaration(Class(:item))")); + assertEquals(t1.toString(), t2.toString()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/OWL2DatatypePrefixedNameTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/OWL2DatatypePrefixedNameTestCase.java new file mode 100644 index 0000000000..b43c8d6650 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/OWL2DatatypePrefixedNameTestCase.java @@ -0,0 +1,53 @@ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group, Date: + * 04/04/2014 + */ +class OWL2DatatypePrefixedNameTestCase { + + @Test + void shouldReturnCorrectPrefixName() { + assertEquals("rdf:XMLLiteral", OWL2Datatype.RDF_XML_LITERAL.getPrefixedName()); + assertEquals("rdfs:Literal", OWL2Datatype.RDFS_LITERAL.getPrefixedName()); + assertEquals("rdf:PlainLiteral", OWL2Datatype.RDF_PLAIN_LITERAL.getPrefixedName()); + assertEquals("owl:real", OWL2Datatype.OWL_REAL.getPrefixedName()); + assertEquals("owl:rational", OWL2Datatype.OWL_RATIONAL.getPrefixedName()); + assertEquals("xsd:string", OWL2Datatype.XSD_STRING.getPrefixedName()); + assertEquals("xsd:normalizedString", OWL2Datatype.XSD_NORMALIZED_STRING.getPrefixedName()); + assertEquals("xsd:token", OWL2Datatype.XSD_TOKEN.getPrefixedName()); + assertEquals("xsd:language", OWL2Datatype.XSD_LANGUAGE.getPrefixedName()); + assertEquals("xsd:Name", OWL2Datatype.XSD_NAME.getPrefixedName()); + assertEquals("xsd:NCName", OWL2Datatype.XSD_NCNAME.getPrefixedName()); + assertEquals("xsd:NMTOKEN", OWL2Datatype.XSD_NMTOKEN.getPrefixedName()); + assertEquals("xsd:decimal", OWL2Datatype.XSD_DECIMAL.getPrefixedName()); + assertEquals("xsd:integer", OWL2Datatype.XSD_INTEGER.getPrefixedName()); + assertEquals("xsd:nonNegativeInteger", + OWL2Datatype.XSD_NON_NEGATIVE_INTEGER.getPrefixedName()); + assertEquals("xsd:nonPositiveInteger", + OWL2Datatype.XSD_NON_POSITIVE_INTEGER.getPrefixedName()); + assertEquals("xsd:positiveInteger", OWL2Datatype.XSD_POSITIVE_INTEGER.getPrefixedName()); + assertEquals("xsd:negativeInteger", OWL2Datatype.XSD_NEGATIVE_INTEGER.getPrefixedName()); + assertEquals("xsd:long", OWL2Datatype.XSD_LONG.getPrefixedName()); + assertEquals("xsd:int", OWL2Datatype.XSD_INT.getPrefixedName()); + assertEquals("xsd:short", OWL2Datatype.XSD_SHORT.getPrefixedName()); + assertEquals("xsd:byte", OWL2Datatype.XSD_BYTE.getPrefixedName()); + assertEquals("xsd:unsignedLong", OWL2Datatype.XSD_UNSIGNED_LONG.getPrefixedName()); + assertEquals("xsd:unsignedInt", OWL2Datatype.XSD_UNSIGNED_INT.getPrefixedName()); + assertEquals("xsd:unsignedShort", OWL2Datatype.XSD_UNSIGNED_SHORT.getPrefixedName()); + assertEquals("xsd:unsignedByte", OWL2Datatype.XSD_UNSIGNED_BYTE.getPrefixedName()); + assertEquals("xsd:double", OWL2Datatype.XSD_DOUBLE.getPrefixedName()); + assertEquals("xsd:float", OWL2Datatype.XSD_FLOAT.getPrefixedName()); + assertEquals("xsd:boolean", OWL2Datatype.XSD_BOOLEAN.getPrefixedName()); + assertEquals("xsd:hexBinary", OWL2Datatype.XSD_HEX_BINARY.getPrefixedName()); + assertEquals("xsd:base64Binary", OWL2Datatype.XSD_BASE_64_BINARY.getPrefixedName()); + assertEquals("xsd:anyURI", OWL2Datatype.XSD_ANY_URI.getPrefixedName()); + assertEquals("xsd:dateTime", OWL2Datatype.XSD_DATE_TIME.getPrefixedName()); + assertEquals("xsd:dateTimeStamp", OWL2Datatype.XSD_DATE_TIME_STAMP.getPrefixedName()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/OWL2DatatypeShortFormTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/OWL2DatatypeShortFormTestCase.java new file mode 100644 index 0000000000..386ec96bc7 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/OWL2DatatypeShortFormTestCase.java @@ -0,0 +1,51 @@ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group, Date: + * 04/04/2014 + */ +class OWL2DatatypeShortFormTestCase { + + @Test + void shouldReturnCorrectShortForm() { + assertEquals("XMLLiteral", OWL2Datatype.RDF_XML_LITERAL.getShortForm()); + assertEquals("Literal", OWL2Datatype.RDFS_LITERAL.getShortForm()); + assertEquals("PlainLiteral", OWL2Datatype.RDF_PLAIN_LITERAL.getShortForm()); + assertEquals("real", OWL2Datatype.OWL_REAL.getShortForm()); + assertEquals("rational", OWL2Datatype.OWL_RATIONAL.getShortForm()); + assertEquals("string", OWL2Datatype.XSD_STRING.getShortForm()); + assertEquals("normalizedString", OWL2Datatype.XSD_NORMALIZED_STRING.getShortForm()); + assertEquals("token", OWL2Datatype.XSD_TOKEN.getShortForm()); + assertEquals("language", OWL2Datatype.XSD_LANGUAGE.getShortForm()); + assertEquals("Name", OWL2Datatype.XSD_NAME.getShortForm()); + assertEquals("NCName", OWL2Datatype.XSD_NCNAME.getShortForm()); + assertEquals("NMTOKEN", OWL2Datatype.XSD_NMTOKEN.getShortForm()); + assertEquals("decimal", OWL2Datatype.XSD_DECIMAL.getShortForm()); + assertEquals("integer", OWL2Datatype.XSD_INTEGER.getShortForm()); + assertEquals("nonNegativeInteger", OWL2Datatype.XSD_NON_NEGATIVE_INTEGER.getShortForm()); + assertEquals("nonPositiveInteger", OWL2Datatype.XSD_NON_POSITIVE_INTEGER.getShortForm()); + assertEquals("positiveInteger", OWL2Datatype.XSD_POSITIVE_INTEGER.getShortForm()); + assertEquals("negativeInteger", OWL2Datatype.XSD_NEGATIVE_INTEGER.getShortForm()); + assertEquals("long", OWL2Datatype.XSD_LONG.getShortForm()); + assertEquals("int", OWL2Datatype.XSD_INT.getShortForm()); + assertEquals("short", OWL2Datatype.XSD_SHORT.getShortForm()); + assertEquals("byte", OWL2Datatype.XSD_BYTE.getShortForm()); + assertEquals("unsignedLong", OWL2Datatype.XSD_UNSIGNED_LONG.getShortForm()); + assertEquals("unsignedInt", OWL2Datatype.XSD_UNSIGNED_INT.getShortForm()); + assertEquals("unsignedShort", OWL2Datatype.XSD_UNSIGNED_SHORT.getShortForm()); + assertEquals("unsignedByte", OWL2Datatype.XSD_UNSIGNED_BYTE.getShortForm()); + assertEquals("double", OWL2Datatype.XSD_DOUBLE.getShortForm()); + assertEquals("float", OWL2Datatype.XSD_FLOAT.getShortForm()); + assertEquals("boolean", OWL2Datatype.XSD_BOOLEAN.getShortForm()); + assertEquals("hexBinary", OWL2Datatype.XSD_HEX_BINARY.getShortForm()); + assertEquals("base64Binary", OWL2Datatype.XSD_BASE_64_BINARY.getShortForm()); + assertEquals("anyURI", OWL2Datatype.XSD_ANY_URI.getShortForm()); + assertEquals("dateTime", OWL2Datatype.XSD_DATE_TIME.getShortForm()); + assertEquals("dateTimeStamp", OWL2Datatype.XSD_DATE_TIME_STAMP.getShortForm()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/OWLClassExpressionCollectorTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/OWLClassExpressionCollectorTestCase.java new file mode 100644 index 0000000000..d0494bd96c --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/OWLClassExpressionCollectorTestCase.java @@ -0,0 +1,154 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.util.OWLClassExpressionCollector; + +class OWLClassExpressionCollectorTestCase { + + private static final String CI = ""; + private static final String IRII = ""; + private static final String AND = "ObjectIntersectionOf( )"; + private static final String OR = "ObjectUnionOf( )"; + private static final String NOT = "ObjectComplementOf()"; + private static final String SOME = "ObjectSomeValuesFrom( )"; + private static final String ALL = "ObjectAllValuesFrom( )"; + private static final String HAS = "ObjectHasValue( )"; + private static final String OMIN = + "ObjectMinCardinality(1 )"; + private static final String MAX = + "ObjectMaxCardinality(1 )"; + private static final String OEQ = + "ObjectExactCardinality(1 )"; + private static final String SELF = "ObjectHasSelf()"; + private static final String ONE = "ObjectOneOf()"; + private static final String DSOME = + "DataSomeValuesFrom( )"; + private static final String DALL = + "DataAllValuesFrom( )"; + private static final String DHAS = "DataHasValue( \"false\"^^xsd:boolean)"; + private static final String DMIN = + "DataMinCardinality(1 )"; + private static final String DMAX = + "DataMaxCardinality(1 )"; + private static final String DEQ = + "DataExactCardinality(1 )"; + private static final String THING = "owl:Thing"; + + static Collection getData() { + Builder b = new Builder(); + Map> map = new LinkedHashMap<>(); + Set empty = Collections.emptySet(); + Set ci = Collections.singleton(CI); + Set ciIrii = new HashSet<>(Arrays.asList(CI, IRII)); + map.put(b.dRange(), empty); + map.put(b.dDef(), empty); + map.put(b.decC(), ci); + map.put(b.decOp(), empty); + map.put(b.decDp(), empty); + map.put(b.decDt(), empty); + map.put(b.decAp(), empty); + map.put(b.decI(), empty); + map.put(b.assDi(), empty); + map.put(b.dc(), ciIrii); + map.put(b.dDp(), empty); + map.put(b.dOp(), empty); + map.put(b.du(), ciIrii); + map.put(b.ec(), ciIrii); + map.put(b.eDp(), empty); + map.put(b.eOp(), empty); + map.put(b.fdp(), empty); + map.put(b.fop(), empty); + map.put(b.ifp(), empty); + map.put(b.iop(), empty); + map.put(b.irr(), empty); + map.put(b.ndp(), empty); + map.put(b.nop(), empty); + map.put(b.opa(), empty); + map.put(b.opaInv(), empty); + map.put(b.opaInvj(), empty); + map.put(b.oDom(), ci); + map.put(b.oRange(), ci); + map.put(b.chain(), empty); + map.put(b.ref(), empty); + map.put(b.same(), empty); + map.put(b.subAnn(), empty); + map.put(b.subClass(), new HashSet<>(Arrays.asList(THING, CI))); + map.put(b.subData(), empty); + map.put(b.subObject(), empty); + map.put(b.rule(), empty); + map.put(b.symm(), empty); + map.put(b.trans(), empty); + map.put(b.hasKey(), ci); + map.put(b.ann(), empty); + map.put(b.asymm(), empty); + map.put(b.annDom(), empty); + map.put(b.annRange(), empty); + map.put(b.ass(), ci); + map.put(b.assAnd(), new HashSet<>(Arrays.asList(CI, IRII, AND))); + map.put(b.assOr(), new HashSet<>(Arrays.asList(CI, IRII, OR))); + map.put(b.dRangeAnd(), empty); + map.put(b.dRangeOr(), empty); + map.put(b.assNot(), new HashSet<>(Arrays.asList(CI, NOT))); + map.put(b.assNotAnon(), new HashSet<>(Arrays.asList(CI, NOT))); + map.put(b.assSome(), new HashSet<>(Arrays.asList(CI, SOME))); + map.put(b.assAll(), new HashSet<>(Arrays.asList(CI, ALL))); + map.put(b.assHas(), Collections.singleton(HAS)); + map.put(b.assMin(), new HashSet<>(Arrays.asList(CI, OMIN))); + map.put(b.assMax(), new HashSet<>(Arrays.asList(CI, MAX))); + map.put(b.assEq(), new HashSet<>(Arrays.asList(CI, OEQ))); + map.put(b.assHasSelf(), Collections.singleton(SELF)); + map.put(b.assOneOf(), Collections.singleton(ONE)); + map.put(b.assDSome(), Collections.singleton(DSOME)); + map.put(b.assDAll(), Collections.singleton(DALL)); + map.put(b.assDHas(), Collections.singleton(DHAS)); + map.put(b.assDMin(), Collections.singleton(DMIN)); + map.put(b.assDMax(), Collections.singleton(DMAX)); + map.put(b.assDEq(), Collections.singleton(DEQ)); + map.put(b.dOneOf(), empty); + map.put(b.dNot(), empty); + map.put(b.dRangeRestrict(), empty); + map.put(b.assD(), empty); + map.put(b.assDPlain(), empty); + map.put(b.dDom(), ci); + map.put(b.bigRule(), ci); + Collection toReturn = new ArrayList<>(); + map.forEach((k, v) -> toReturn.add(new Object[] {k, v})); + return toReturn; + } + + @ParameterizedTest + @MethodSource("getData") + void testAssertion(OWLAxiom object, Set expected) { + OWLClassExpressionCollector testsubject = new OWLClassExpressionCollector(); + Collection components = object.accept(testsubject); + Set strings = asUnorderedSet(components.stream().map(Object::toString)); + assertEquals(expected, strings); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/OWLDataFactoryImplTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/OWLDataFactoryImplTestCase.java new file mode 100644 index 0000000000..15792d69ea --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/OWLDataFactoryImplTestCase.java @@ -0,0 +1,477 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.semanticweb.owlapi.vocab.OWLFacet.MAX_EXCLUSIVE; +import static org.semanticweb.owlapi.vocab.OWLFacet.MIN_INCLUSIVE; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Supplier; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.SWRLClassAtom; +import org.semanticweb.owlapi.model.SWRLVariable; + +import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl; + +/** + * A test case to ensure that the reference implementation data factories do not create duplicate + * objects for distinguished values (e.g. owl:Thing, rdfs:Literal etc.) + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.2.0 + */ +class OWLDataFactoryImplTestCase { + private static final String LANG = "LANG"; + private static final String TEST = "TEST"; + private static final String URN_TEST = "urn:test#"; + + private static void assertEqualsFromSupplier(Supplier s) { + Object s1 = s.get(); + Object s2 = s.get(); + assertEquals(s1, s2); + assertEquals(s1.hashCode(), s2.hashCode()); + } + + private static void assertEqualsFromSuppliers(Supplier sa, Supplier sb) { + Object s1 = sa.get(); + Object s2 = sb.get(); + assertEquals(s1, s2); + assertEquals(s1.hashCode(), s2.hashCode()); + } + + private static void assertNotEqualsFromSupplier(Supplier s) { + Object s1 = s.get(); + Object s2 = s.get(); + assertNotEquals(s1, s2); + assertNotEquals(s1.hashCode(), s2.hashCode()); + } + + private static void assertNotEqualsFromSuppliers(Supplier sa, Supplier sb) { + Object s1 = sa.get(); + Object s2 = sb.get(); + assertNotEquals(s1, s2); + assertNotEquals(s1.hashCode(), s2.hashCode()); + } + + private static void assertSameFromSupplier(Supplier s) { + assertSame(s.get(), s.get()); + } + + int cardinality = 3; + private final OWLDataFactory testSubject = new OWLDataFactoryImpl(); + private final AtomicInteger counter = new AtomicInteger(1); + OWLClassExpression a = C(IRI()); + OWLIndividual a1 = I(); + OWLLiteral a2 = Literal(); + OWLObjectProperty a3 = OP(IRI()); + OWLDataProperty a4 = DP(IRI()); + OWLClassExpression b = C(IRI()); + OWLIndividual b1 = I(); + OWLLiteral b2 = Literal(); + OWLObjectProperty b3 = OP(IRI()); + OWLDataProperty b4 = DP(IRI()); + OWLClassExpression c = C(IRI()); + OWLIndividual c1 = I(); + OWLLiteral c2 = Literal(); + OWLObjectProperty c3 = OP(IRI()); + OWLDataProperty c4 = DP(IRI()); + OWLDatatype dt = D(IRI()); + IRI iri = IRI(); + OWLDataProperty left = DP(IRI()); + OWLIndividual o1 = I(); + OWLLiteral o2 = Literal(); + OWLObjectProperty p3 = OP(IRI()); + OWLDataProperty prop = DP(IRI()); + OWLObjectProperty prop2 = OP(IRI()); + OWLClass right = C(IRI()); + OWLIndividual s1 = I(); + OWLClassExpression[] classExpressions = {C(IRI()), C(IRI())}; + OWLDataPropertyExpression[] properties = {a4, b4}; + OWLClassExpression operand = C(IRI()); + OWLLiteral filler1 = Literal(); + OWLIndividual filler = I(); + OWLLiteral facetValue = testSubject.getOWLLiteral("3", D(IRI())); + OWLClass clsA = testSubject.getOWLClass(URN_TEST, "A"); + OWLClass clsB = testSubject.getOWLClass(URN_TEST, "B"); + OWLClass clsC = testSubject.getOWLClass(URN_TEST, "C"); + OWLClass clsD = testSubject.getOWLClass(URN_TEST, "D"); + OWLClassExpression operandA = C(IRI()); + OWLClassExpression operandB = C(IRI()); + + private OWLClass C(IRI i) { + return testSubject.getOWLClass(i); + } + + private OWLDatatype D(IRI i) { + return testSubject.getOWLDatatype(i); + } + + private OWLDataProperty DP(IRI i) { + return testSubject.getOWLDataProperty(i); + } + + private OWLIndividual I() { + return testSubject.getOWLNamedIndividual(IRI()); + } + + private static IRI IRI() { + return IRI.getNextDocumentIRI("urn:test#A"); + } + + private OWLLiteral Literal() { + return testSubject.getOWLLiteral("A" + counter.getAndIncrement()); + } + + private OWLObjectProperty OP(IRI i) { + return testSubject.getOWLObjectProperty(i); + } + + @Test + void shouldFindInternalisedSame() { + assertSameFromSupplier(testSubject::getRDFPlainLiteral); + assertSameFromSupplier(testSubject::getTopDatatype); + assertSameFromSupplier(testSubject::getBooleanOWLDatatype); + assertSameFromSupplier(testSubject::getDoubleOWLDatatype); + assertSameFromSupplier(testSubject::getFloatOWLDatatype); + assertSameFromSupplier(testSubject::getRDFSLabel); + assertSameFromSupplier(testSubject::getRDFSSeeAlso); + assertSameFromSupplier(testSubject::getRDFSIsDefinedBy); + assertSameFromSupplier(testSubject::getOWLVersionInfo); + assertSameFromSupplier(testSubject::getOWLBackwardCompatibleWith); + assertSameFromSupplier(testSubject::getOWLIncompatibleWith); + assertSameFromSupplier(testSubject::getOWLDeprecated); + assertSameFromSupplier(testSubject::getOWLThing); + assertSameFromSupplier(testSubject::getOWLNothing); + assertSameFromSupplier(testSubject::getOWLTopObjectProperty); + assertSameFromSupplier(testSubject::getOWLBottomObjectProperty); + assertSameFromSupplier(testSubject::getOWLTopDataProperty); + assertSameFromSupplier(testSubject::getOWLBottomDataProperty); + } + + @Test + void shouldHaveSWRLRulesEqual() { + SWRLVariable var = testSubject.getSWRLVariable(URN_TEST, "x"); + List body1 = Arrays.asList(testSubject.getSWRLClassAtom(clsA, var), + testSubject.getSWRLClassAtom(clsC, var)); + List head1 = Arrays.asList(testSubject.getSWRLClassAtom(clsB, var), + testSubject.getSWRLClassAtom(clsD, var)); + List body2 = Arrays.asList(testSubject.getSWRLClassAtom(clsC, var), + testSubject.getSWRLClassAtom(clsA, var)); + List head2 = Arrays.asList(testSubject.getSWRLClassAtom(clsD, var), + testSubject.getSWRLClassAtom(clsB, var)); + assertEqualsFromSuppliers(() -> testSubject.getSWRLRule(body1, head1), + () -> testSubject.getSWRLRule(body2, head2)); + } + + @Test + void shouldHaveSWRLRulesWithAnnotationsEqual() { + Collection ann1 = + Arrays.asList(testSubject.getRDFSComment("test1"), testSubject.getRDFSLabel("test2")); + Collection ann2 = + Arrays.asList(testSubject.getRDFSLabel("test2"), testSubject.getRDFSComment("test1")); + SWRLVariable var = testSubject.getSWRLVariable(URN_TEST, "x"); + List body1 = Arrays.asList(testSubject.getSWRLClassAtom(clsA, var), + testSubject.getSWRLClassAtom(clsC, var)); + List head1 = Arrays.asList(testSubject.getSWRLClassAtom(clsB, var), + testSubject.getSWRLClassAtom(clsD, var)); + List body2 = Arrays.asList(testSubject.getSWRLClassAtom(clsC, var), + testSubject.getSWRLClassAtom(clsA, var)); + List head2 = Arrays.asList(testSubject.getSWRLClassAtom(clsD, var), + testSubject.getSWRLClassAtom(clsB, var)); + assertEqualsFromSuppliers(() -> testSubject.getSWRLRule(body1, head1, ann1), + () -> testSubject.getSWRLRule(body2, head2, ann2)); + } + + @Test + void testAsSubAxiomsEquivalentClasses() { + assertEqualsFromSupplier(() -> C(iri)); + assertEqualsFromSupplier(() -> D(iri)); + assertEqualsFromSupplier(() -> DP(iri)); + assertEqualsFromSupplier(() -> OP(iri)); + assertEqualsFromSupplier(() -> testSubject.getOWLAnnotationProperty(iri)); + assertEqualsFromSupplier(() -> testSubject.getOWLAsymmetricObjectPropertyAxiom(prop2)); + assertEqualsFromSupplier(() -> testSubject.getOWLClassAssertionAxiom(right, a1)); + assertEqualsFromSupplier(() -> testSubject.getOWLDataAllValuesFrom(prop, dt)); + assertEqualsFromSupplier(() -> testSubject.getOWLDataComplementOf(dt)); + assertEqualsFromSupplier( + () -> testSubject.getOWLDataExactCardinality(cardinality, prop, dt)); + assertEqualsFromSupplier(() -> testSubject.getOWLDataExactCardinality(cardinality, prop, + testSubject.getTopDatatype())); + assertEqualsFromSupplier(() -> testSubject.getOWLDataHasValue(prop, filler1)); + assertEqualsFromSupplier(() -> testSubject.getOWLDataMaxCardinality(cardinality, prop, dt)); + assertEqualsFromSupplier(() -> testSubject.getOWLDataMaxCardinality(cardinality, prop, + testSubject.getTopDatatype())); + assertEqualsFromSupplier(() -> testSubject.getOWLDataMinCardinality(cardinality, prop, dt)); + assertEqualsFromSupplier(() -> testSubject.getOWLDataMinCardinality(cardinality, prop, + testSubject.getTopDatatype())); + assertEqualsFromSupplier(() -> testSubject.getOWLDataOneOf(a2, b2, c2)); + assertEqualsFromSupplier(() -> testSubject.getOWLDataPropertyAssertionAxiom(prop, s1, o2)); + assertEqualsFromSupplier(() -> testSubject.getOWLDataPropertyDomainAxiom(left, right)); + assertEqualsFromSupplier(() -> testSubject.getOWLDataPropertyRangeAxiom(left, dt)); + assertEqualsFromSupplier(() -> testSubject.getOWLDataSomeValuesFrom(prop, dt)); + assertEqualsFromSupplier(() -> testSubject.getOWLDatatypeRestriction(dt, + testSubject.getOWLFacetRestriction(MAX_EXCLUSIVE, facetValue))); + assertEqualsFromSupplier(() -> testSubject.getOWLDifferentIndividualsAxiom(a1, b1, c1)); + assertEqualsFromSupplier(() -> testSubject.getOWLDisjointClassesAxiom(a, b, c)); + assertEqualsFromSupplier(() -> testSubject.getOWLDisjointDataPropertiesAxiom(a4, b4, c4)); + assertEqualsFromSupplier(() -> testSubject.getOWLDisjointObjectPropertiesAxiom(a3, b3, c3)); + assertEqualsFromSupplier(() -> testSubject.getOWLEquivalentClassesAxiom(a, b, c)); + assertEqualsFromSupplier(() -> testSubject.getOWLEquivalentClassesAxiom(classExpressions)); + assertEqualsFromSupplier(() -> testSubject.getOWLEquivalentDataPropertiesAxiom(a4, b4, c4)); + assertEqualsFromSupplier(() -> testSubject.getOWLEquivalentDataPropertiesAxiom(properties)); + assertEqualsFromSupplier( + () -> testSubject.getOWLEquivalentObjectPropertiesAxiom(a3, b3, c3)); + assertEqualsFromSupplier(() -> testSubject.getOWLFunctionalDataPropertyAxiom(prop)); + assertEqualsFromSupplier(() -> testSubject.getOWLFunctionalObjectPropertyAxiom(prop2)); + assertEqualsFromSupplier( + () -> testSubject.getOWLInverseFunctionalObjectPropertyAxiom(prop2)); + assertEqualsFromSupplier(() -> testSubject.getOWLIrreflexiveObjectPropertyAxiom(prop2)); + assertEqualsFromSupplier(() -> testSubject.getOWLLiteral("3", dt)); + assertEqualsFromSupplier(() -> testSubject.getOWLLiteral(TEST, LANG)); + assertEqualsFromSupplier(() -> testSubject.getOWLNamedIndividual(iri)); + assertEqualsFromSupplier( + () -> testSubject.getOWLNegativeDataPropertyAssertionAxiom(prop, s1, o2)); + assertEqualsFromSupplier( + () -> testSubject.getOWLNegativeObjectPropertyAssertionAxiom(p3, s1, o1)); + assertEqualsFromSupplier(() -> testSubject.getOWLObjectAllValuesFrom(prop2, a)); + assertEqualsFromSupplier(() -> testSubject.getOWLObjectComplementOf(operand)); + assertEqualsFromSupplier( + () -> testSubject.getOWLObjectExactCardinality(cardinality, prop2, a)); + assertEqualsFromSupplier(() -> testSubject.getOWLObjectExactCardinality(cardinality, prop2, + testSubject.getOWLThing())); + assertEqualsFromSupplier(() -> testSubject.getOWLObjectHasSelf(prop2)); + assertEqualsFromSupplier(() -> testSubject.getOWLObjectHasValue(prop2, filler)); + assertEqualsFromSupplier(() -> testSubject.getOWLObjectIntersectionOf(a, b, c)); + assertEqualsFromSupplier( + () -> testSubject.getOWLObjectMaxCardinality(cardinality, prop2, a)); + assertEqualsFromSupplier(() -> testSubject.getOWLObjectMaxCardinality(cardinality, prop2, + testSubject.getOWLThing())); + assertEqualsFromSupplier( + () -> testSubject.getOWLObjectMinCardinality(cardinality, prop2, a)); + assertEqualsFromSupplier(() -> testSubject.getOWLObjectMinCardinality(cardinality, prop2, + testSubject.getOWLThing())); + assertEqualsFromSupplier(() -> testSubject.getOWLObjectOneOf(a1, b1, c1)); + assertEqualsFromSupplier(() -> testSubject.getOWLObjectPropertyAssertionAxiom(p3, s1, o1)); + assertEqualsFromSupplier(() -> testSubject.getOWLObjectPropertyDomainAxiom(p3, right)); + assertEqualsFromSupplier(() -> testSubject.getOWLObjectPropertyRangeAxiom(p3, right)); + assertEqualsFromSupplier(() -> testSubject.getOWLObjectSomeValuesFrom(prop2, a)); + assertEqualsFromSupplier(() -> testSubject.getOWLObjectUnionOf(a, b, c)); + assertEqualsFromSupplier(() -> testSubject.getOWLReflexiveObjectPropertyAxiom(prop2)); + assertEqualsFromSupplier(() -> testSubject.getOWLSameIndividualAxiom(a1, b1, c1)); + assertEqualsFromSupplier(() -> testSubject.getOWLSubDataPropertyOfAxiom(left, prop)); + assertEqualsFromSupplier(() -> testSubject.getOWLSubObjectPropertyOfAxiom(p3, prop2)); + assertEqualsFromSupplier(() -> testSubject.getOWLSymmetricObjectPropertyAxiom(prop2)); + assertEqualsFromSupplier(() -> testSubject.getOWLTransitiveObjectPropertyAxiom(prop2)); + assertNotEqualsFromSupplier(() -> C(IRI())); + assertNotEqualsFromSupplier(() -> D(IRI())); + assertNotEqualsFromSupplier(() -> DP(IRI())); + assertNotEqualsFromSupplier(() -> OP(IRI())); + assertNotEqualsFromSupplier(() -> testSubject.getOWLAnnotationProperty(IRI())); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLAsymmetricObjectPropertyAxiom(OP(IRI()))); + assertNotEqualsFromSupplier(() -> testSubject.getOWLClassAssertionAxiom(C(IRI()), a1)); + assertNotEqualsFromSupplier(() -> testSubject.getOWLClassAssertionAxiom(right, I())); + assertNotEqualsFromSupplier(() -> testSubject.getOWLDataAllValuesFrom(DP(IRI()), dt)); + assertNotEqualsFromSupplier(() -> testSubject.getOWLDataAllValuesFrom(prop, D(IRI()))); + assertNotEqualsFromSupplier(() -> testSubject.getOWLDataComplementOf(D(IRI()))); + assertNotEqualsFromSupplier(() -> testSubject.getOWLDataExactCardinality(3, DP(IRI()), + testSubject.getTopDatatype())); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLDataExactCardinality(3, prop, D(IRI()))); + assertNotEqualsFromSupplier(() -> testSubject.getOWLDataHasValue(DP(IRI()), filler1)); + assertNotEqualsFromSupplier(() -> testSubject.getOWLDataHasValue(prop, Literal())); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLDataMaxCardinality(3, DP(IRI()), testSubject.getTopDatatype())); + assertNotEqualsFromSupplier(() -> testSubject.getOWLDataMaxCardinality(3, prop, D(IRI()))); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLDataMinCardinality(3, DP(IRI()), testSubject.getTopDatatype())); + assertNotEqualsFromSupplier(() -> testSubject.getOWLDataMinCardinality(3, prop, D(IRI()))); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLDataPropertyAssertionAxiom(DP(IRI()), s1, o2)); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLDataPropertyAssertionAxiom(prop, I(), o2)); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLDataPropertyAssertionAxiom(prop, s1, Literal())); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLDataPropertyDomainAxiom(DP(IRI()), right)); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLDataPropertyDomainAxiom(left, C(IRI()))); + assertNotEqualsFromSupplier(() -> testSubject.getOWLDataPropertyRangeAxiom(DP(IRI()), dt)); + assertNotEqualsFromSupplier(() -> testSubject.getOWLDataPropertyRangeAxiom(left, D(IRI()))); + assertNotEqualsFromSupplier(() -> testSubject.getOWLFunctionalDataPropertyAxiom(DP(IRI()))); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLFunctionalObjectPropertyAxiom(OP(IRI()))); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLInverseFunctionalObjectPropertyAxiom(OP(IRI()))); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLIrreflexiveObjectPropertyAxiom(OP(IRI()))); + assertNotEqualsFromSupplier(() -> testSubject.getOWLLiteral("3", D(IRI()))); + assertNotEqualsFromSupplier(() -> testSubject.getOWLNamedIndividual(IRI())); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLNegativeDataPropertyAssertionAxiom(DP(IRI()), s1, o2)); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLNegativeDataPropertyAssertionAxiom(prop, I(), o2)); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLNegativeDataPropertyAssertionAxiom(prop, s1, Literal())); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLNegativeObjectPropertyAssertionAxiom(OP(IRI()), s1, o1)); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLNegativeObjectPropertyAssertionAxiom(p3, I(), o1)); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLNegativeObjectPropertyAssertionAxiom(p3, s1, I())); + assertNotEqualsFromSupplier(() -> testSubject.getOWLObjectAllValuesFrom(OP(IRI()), a)); + assertNotEqualsFromSupplier(() -> testSubject.getOWLObjectAllValuesFrom(prop2, C(IRI()))); + assertNotEqualsFromSupplier(() -> testSubject.getOWLObjectExactCardinality(3, OP(IRI()), + testSubject.getOWLThing())); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLObjectExactCardinality(3, prop2, C(IRI()))); + assertNotEqualsFromSupplier(() -> testSubject.getOWLObjectHasSelf(OP(IRI()))); + assertNotEqualsFromSupplier(() -> testSubject.getOWLObjectHasValue(OP(IRI()), filler)); + assertNotEqualsFromSupplier(() -> testSubject.getOWLObjectHasValue(prop2, I())); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLObjectMaxCardinality(3, OP(IRI()), testSubject.getOWLThing())); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLObjectMaxCardinality(3, prop2, C(IRI()))); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLObjectMinCardinality(3, OP(IRI()), testSubject.getOWLThing())); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLObjectMinCardinality(3, prop2, C(IRI()))); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLObjectPropertyAssertionAxiom(OP(IRI()), s1, o1)); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLObjectPropertyAssertionAxiom(p3, I(), o1)); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLObjectPropertyAssertionAxiom(p3, s1, I())); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLObjectPropertyDomainAxiom(OP(IRI()), right)); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLObjectPropertyDomainAxiom(p3, C(IRI()))); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLObjectPropertyRangeAxiom(OP(IRI()), right)); + assertNotEqualsFromSupplier(() -> testSubject.getOWLObjectPropertyRangeAxiom(p3, C(IRI()))); + assertNotEqualsFromSupplier(() -> testSubject.getOWLObjectSomeValuesFrom(OP(IRI()), a)); + assertNotEqualsFromSupplier(() -> testSubject.getOWLObjectSomeValuesFrom(prop2, C(IRI()))); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLReflexiveObjectPropertyAxiom(OP(IRI()))); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLSubDataPropertyOfAxiom(DP(IRI()), prop)); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLSubDataPropertyOfAxiom(left, DP(IRI()))); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLSubObjectPropertyOfAxiom(OP(IRI()), prop2)); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLSubObjectPropertyOfAxiom(p3, OP(IRI()))); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLSymmetricObjectPropertyAxiom(OP(IRI()))); + assertNotEqualsFromSupplier( + () -> testSubject.getOWLTransitiveObjectPropertyAxiom(OP(IRI()))); + assertNotEqualsFromSuppliers( + () -> testSubject.getOWLDataExactCardinality(3, prop, testSubject.getTopDatatype()), + () -> testSubject.getOWLDataExactCardinality(4, prop, testSubject.getTopDatatype())); + assertNotEqualsFromSuppliers( + () -> testSubject.getOWLDataMaxCardinality(3, prop, testSubject.getTopDatatype()), + () -> testSubject.getOWLDataMaxCardinality(4, prop, testSubject.getTopDatatype())); + assertNotEqualsFromSuppliers( + () -> testSubject.getOWLDataMinCardinality(3, prop, testSubject.getTopDatatype()), + () -> testSubject.getOWLDataMinCardinality(4, prop, testSubject.getTopDatatype())); + assertNotEqualsFromSuppliers(() -> testSubject.getOWLDataOneOf(a2, b2), + () -> testSubject.getOWLDataOneOf(a2, b2, c2)); + assertNotEqualsFromSuppliers(() -> testSubject.getOWLDataSomeValuesFrom(DP(IRI()), dt), + () -> testSubject.getOWLDataSomeValuesFrom(DP(IRI()), dt)); + assertNotEqualsFromSuppliers(() -> testSubject.getOWLDataSomeValuesFrom(prop, D(IRI())), + () -> testSubject.getOWLDataSomeValuesFrom(prop, D(IRI()))); + assertNotEqualsFromSuppliers( + () -> testSubject.getOWLDatatypeRestriction(dt, + testSubject.getOWLFacetRestriction(MAX_EXCLUSIVE, facetValue)), + () -> testSubject.getOWLDatatypeRestriction(dt, + testSubject.getOWLFacetRestriction(MIN_INCLUSIVE, facetValue))); + assertNotEqualsFromSuppliers(() -> testSubject.getOWLDifferentIndividualsAxiom(a1, b1), + () -> testSubject.getOWLDifferentIndividualsAxiom(a1, b1, c1)); + assertNotEqualsFromSuppliers(() -> testSubject.getOWLDisjointClassesAxiom(a, b), + () -> testSubject.getOWLDisjointClassesAxiom(a, b, c)); + assertNotEqualsFromSuppliers( + () -> testSubject.getOWLDisjointDataPropertiesAxiom(a4, b4, c4), + () -> testSubject.getOWLDisjointDataPropertiesAxiom(a4, b4)); + assertNotEqualsFromSuppliers( + () -> testSubject.getOWLDisjointObjectPropertiesAxiom(a3, b3, c3), + () -> testSubject.getOWLDisjointObjectPropertiesAxiom(a3, b3)); + assertNotEqualsFromSuppliers(() -> testSubject.getOWLEquivalentClassesAxiom(a, b), + () -> testSubject.getOWLEquivalentClassesAxiom(a, b, c)); + assertNotEqualsFromSuppliers(() -> testSubject.getOWLEquivalentDataPropertiesAxiom(a4, b4), + () -> testSubject.getOWLEquivalentDataPropertiesAxiom(a4, b4, c4)); + assertNotEqualsFromSuppliers( + () -> testSubject.getOWLEquivalentObjectPropertiesAxiom(a3, b3, c3), + () -> testSubject.getOWLEquivalentObjectPropertiesAxiom(a3, b3)); + assertNotEqualsFromSuppliers(() -> testSubject.getOWLLiteral("3", dt), + () -> testSubject.getOWLLiteral("4", dt)); + assertNotEqualsFromSuppliers(() -> testSubject.getOWLLiteral(TEST, LANG), + () -> testSubject.getOWLLiteral("OTHER", LANG)); + assertNotEqualsFromSuppliers(() -> testSubject.getOWLLiteral(TEST, LANG), + () -> testSubject.getOWLLiteral(TEST, "OTHER_LANG")); + assertNotEqualsFromSuppliers(() -> testSubject.getOWLObjectComplementOf(operandA), + () -> testSubject.getOWLObjectComplementOf(operandB)); + assertNotEqualsFromSuppliers( + () -> testSubject.getOWLObjectExactCardinality(3, prop2, testSubject.getOWLThing()), + () -> testSubject.getOWLObjectExactCardinality(4, prop2, testSubject.getOWLThing())); + assertNotEqualsFromSuppliers(() -> testSubject.getOWLObjectIntersectionOf(a, b), + () -> testSubject.getOWLObjectIntersectionOf(a, b, c)); + assertNotEqualsFromSuppliers( + () -> testSubject.getOWLObjectMaxCardinality(3, prop2, testSubject.getOWLThing()), + () -> testSubject.getOWLObjectMaxCardinality(4, prop2, testSubject.getOWLThing())); + assertNotEqualsFromSuppliers( + () -> testSubject.getOWLObjectMinCardinality(3, prop2, testSubject.getOWLThing()), + () -> testSubject.getOWLObjectMinCardinality(4, prop2, testSubject.getOWLThing())); + assertNotEqualsFromSuppliers(() -> testSubject.getOWLObjectOneOf(a1, b1), + () -> testSubject.getOWLObjectOneOf(a1, b1, c1)); + assertNotEqualsFromSuppliers(() -> testSubject.getOWLObjectUnionOf(a, b, c), + () -> testSubject.getOWLObjectUnionOf(a, b)); + assertNotEqualsFromSuppliers(() -> testSubject.getOWLSameIndividualAxiom(a1, b1), + () -> testSubject.getOWLSameIndividualAxiom(a1, b1, c1)); + assertSameFromSupplier(testSubject::getBooleanOWLDatatype); + assertSameFromSupplier(testSubject::getDoubleOWLDatatype); + assertSameFromSupplier(testSubject::getFloatOWLDatatype); + assertSameFromSupplier(testSubject::getOWLBackwardCompatibleWith); + assertSameFromSupplier(testSubject::getOWLBottomDataProperty); + assertSameFromSupplier(testSubject::getOWLBottomObjectProperty); + assertSameFromSupplier(testSubject::getOWLDeprecated); + assertSameFromSupplier(testSubject::getOWLIncompatibleWith); + assertSameFromSupplier(testSubject::getOWLNothing); + assertSameFromSupplier(testSubject::getOWLThing); + assertSameFromSupplier(testSubject::getOWLTopDataProperty); + assertSameFromSupplier(testSubject::getOWLTopObjectProperty); + assertSameFromSupplier(testSubject::getOWLVersionInfo); + assertSameFromSupplier(testSubject::getRDFPlainLiteral); + assertSameFromSupplier(testSubject::getRDFSIsDefinedBy); + assertSameFromSupplier(testSubject::getRDFSLabel); + assertSameFromSupplier(testSubject::getRDFSSeeAlso); + assertSameFromSupplier(testSubject::getTopDatatype); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/OWLEntityCollectorTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/OWLEntityCollectorTestCase.java new file mode 100644 index 0000000000..009c22c896 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/OWLEntityCollectorTestCase.java @@ -0,0 +1,143 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.util.OWLEntityCollector; + +class OWLEntityCollectorTestCase { + + static Collection getData() { + Builder b = new Builder(); + Map map = new LinkedHashMap<>(); + String ann = ""; + String string = "http://www.w3.org/2001/XMLSchema#string"; + String datatype = ""; + String dp = ""; + String iri = ""; + String doubl = "http://www.w3.org/2001/XMLSchema#double"; + String c = ""; + String op = ""; + String bool = "http://www.w3.org/2001/XMLSchema#boolean"; + String i = ""; + String j = ""; + String label = "rdfs:label"; + String thing = "owl:Thing"; + String topData = "owl:topDataProperty"; + String topObject = "owl:topObjectProperty"; + String diff = "owl:differentFrom"; + String same = "owl:sameAs"; + String lang = "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"; + + + map.put(b.dRange(), new String[] {ann, string, datatype, dp}); + map.put(b.dDef(), new String[] {ann, string, doubl, datatype}); + map.put(b.decC(), new String[] {ann, string, c}); + map.put(b.decOp(), new String[] {ann, op, string}); + map.put(b.decDp(), new String[] {ann, string, dp}); + map.put(b.decDt(), new String[] {ann, string, datatype}); + map.put(b.decAp(), new String[] {ann, string}); + map.put(b.decI(), new String[] {i, ann, string}); + map.put(b.assDi(), new String[] {i, iri}); + map.put(b.dc(), new String[] {c, iri}); + map.put(b.dDp(), new String[] {ann, string, iri, dp}); + map.put(b.dOp(), new String[] {ann, iri, op, string}); + map.put(b.du(), new String[] {ann, string, c, iri}); + map.put(b.ec(), new String[] {ann, string, c, iri}); + map.put(b.eDp(), new String[] {ann, string, iri, dp}); + map.put(b.eOp(), new String[] {ann, iri, op, string}); + map.put(b.fdp(), new String[] {ann, string, dp}); + map.put(b.fop(), new String[] {ann, op, string}); + map.put(b.ifp(), new String[] {ann, op, string}); + map.put(b.iop(), new String[] {ann, op, string}); + map.put(b.irr(), new String[] {ann, op, string}); + map.put(b.ndp(), new String[] {i, ann, bool, string, dp}); + map.put(b.nop(), new String[] {i, ann, op, string}); + map.put(b.opa(), new String[] {i, ann, op, string}); + map.put(b.opaInv(), new String[] {i, ann, op, string}); + map.put(b.opaInvj(), new String[] {j, i, ann, op, string}); + map.put(b.oDom(), new String[] {ann, op, string, c}); + map.put(b.oRange(), new String[] {ann, op, string, c}); + map.put(b.chain(), new String[] {ann, iri, op, string}); + map.put(b.ref(), new String[] {ann, op, string}); + map.put(b.same(), new String[] {i, ann, string, iri}); + map.put(b.subAnn(), new String[] {ann, string, label}); + map.put(b.subClass(), new String[] {ann, thing, string, c}); + map.put(b.subData(), new String[] {topData, dp}); + map.put(b.subObject(), new String[] {ann, op, string, topObject}); + map.put(b.rule(), new String[] {""}); + map.put(b.symm(), new String[] {ann, op, string}); + map.put(b.trans(), new String[] {ann, op, string}); + map.put(b.hasKey(), new String[] {ann, iri, op, string, c, dp}); + map.put(b.bigRule(), + new String[] {i, ann, diff, bool, op, string, c, datatype, iri, same, dp}); + map.put(b.ann(), new String[] {ann, bool, string}); + map.put(b.asymm(), new String[] {ann, op, string}); + map.put(b.annDom(), new String[] {ann, string}); + map.put(b.annRange(), new String[] {ann, string}); + map.put(b.ass(), new String[] {i, ann, string, c}); + map.put(b.assAnd(), new String[] {i, ann, string, c, iri}); + map.put(b.assOr(), new String[] {i, ann, string, c, iri}); + map.put(b.dRangeAnd(), new String[] {ann, bool, string, datatype, dp}); + map.put(b.dRangeOr(), new String[] {ann, bool, string, datatype, dp}); + map.put(b.assNot(), new String[] {i, ann, string, c}); + map.put(b.assNotAnon(), new String[] {ann, string, c}); + map.put(b.assSome(), new String[] {i, ann, op, string, c}); + map.put(b.assAll(), new String[] {i, ann, op, string, c}); + map.put(b.assHas(), new String[] {i, ann, op, string}); + map.put(b.assMin(), new String[] {i, ann, op, string, c}); + map.put(b.assMax(), new String[] {i, ann, op, string, c}); + map.put(b.assEq(), new String[] {i, ann, op, string, c}); + map.put(b.assHasSelf(), new String[] {i, ann, op, string}); + map.put(b.assOneOf(), new String[] {i, ann, string}); + map.put(b.assDSome(), new String[] {i, ann, string, datatype, dp}); + map.put(b.assDAll(), new String[] {i, ann, string, datatype, dp}); + map.put(b.assDHas(), new String[] {i, ann, bool, string, dp}); + map.put(b.assDMin(), new String[] {i, ann, string, datatype, dp}); + map.put(b.assDMax(), new String[] {i, ann, string, datatype, dp}); + map.put(b.assDEq(), new String[] {i, ann, string, datatype, dp}); + map.put(b.dOneOf(), new String[] {ann, bool, string, dp}); + map.put(b.dNot(), new String[] {ann, bool, string, dp}); + map.put(b.dRangeRestrict(), new String[] {ann, string, doubl, dp}); + map.put(b.assD(), new String[] {i, ann, bool, string, dp}); + map.put(b.assDPlain(), new String[] {i, ann, lang, string, dp}); + map.put(b.dDom(), new String[] {ann, string, c, dp}); + Collection toReturn = new ArrayList<>(); + map.forEach((k, v) -> toReturn.add(new Object[] {k, v})); + return toReturn; + } + + @ParameterizedTest + @MethodSource("getData") + void testAssertion(OWLAxiom object, String[] expected) { + List sig = new ArrayList<>(); + OWLEntityCollector testsubject = new OWLEntityCollector(sig); + object.accept(testsubject); + Stream result = sig.stream().map(p -> p.toString()).distinct().sorted(); + assertEquals(Stream.of(expected).distinct().sorted().collect(Collectors.joining(", ")), + result.collect(Collectors.joining(", "))); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/OWLManagerTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/OWLManagerTestCase.java new file mode 100644 index 0000000000..fdd8117ef4 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/OWLManagerTestCase.java @@ -0,0 +1,54 @@ +package org.semanticweb.owlapi.api.test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.lang.reflect.Field; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; + +import uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl; +import uk.ac.manchester.cs.owl.owlapi.concurrent.ConcurrentOWLOntologyImpl; + +/** + * Matthew Horridge Stanford Center for Biomedical Informatics Research 10/04/15 + */ +class OWLManagerTestCase { + + private OWLOntologyManager manager; + private OWLOntology ontology; + + @BeforeEach + void setUp() throws Exception { + manager = OWLManager.createOWLOntologyManager(); + ontology = manager.createOntology(); + } + + @Test + void shouldCreateOntologyWithCorrectManager() { + assertThat(ontology.getOWLOntologyManager(), is(manager)); + } + + @Test + void shouldCreateConcurrentOntologyByDefault() { + assertThat(ontology, is(instanceOf(ConcurrentOWLOntologyImpl.class))); + } + + @Test + void shouldShareReadWriteLockOnConcurrentManager() throws Exception { + // Nasty, but not sure of another way to do this without exposing it in + // the interface + manager = OWLManager.createConcurrentOWLOntologyManager(); + ontology = manager.createOntology(); + Field ontologyLockField = ConcurrentOWLOntologyImpl.class.getDeclaredField("lock"); + ontologyLockField.setAccessible(true); + Field ontologyManagerField = OWLOntologyManagerImpl.class.getDeclaredField("lock"); + ontologyManagerField.setAccessible(true); + assertThat(ontologyLockField.get(ontology), is(ontologyManagerField.get(manager))); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/OWLObjectComponentCollectorTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/OWLObjectComponentCollectorTestCase.java new file mode 100644 index 0000000000..79fd71856d --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/OWLObjectComponentCollectorTestCase.java @@ -0,0 +1,268 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.apitest.TestFiles.AANN; +import static org.semanticweb.owlapi.apitest.TestFiles.ACALL; +import static org.semanticweb.owlapi.apitest.TestFiles.ACHAS; +import static org.semanticweb.owlapi.apitest.TestFiles.ACL; +import static org.semanticweb.owlapi.apitest.TestFiles.ACLAND; +import static org.semanticweb.owlapi.apitest.TestFiles.ACLOR; +import static org.semanticweb.owlapi.apitest.TestFiles.ACNOT; +import static org.semanticweb.owlapi.apitest.TestFiles.ACSOME; +import static org.semanticweb.owlapi.apitest.TestFiles.ADALL; +import static org.semanticweb.owlapi.apitest.TestFiles.ADEQ; +import static org.semanticweb.owlapi.apitest.TestFiles.ADHAS; +import static org.semanticweb.owlapi.apitest.TestFiles.ADMAX; +import static org.semanticweb.owlapi.apitest.TestFiles.ADMIN; +import static org.semanticweb.owlapi.apitest.TestFiles.ADONEOF; +import static org.semanticweb.owlapi.apitest.TestFiles.ADSOME; +import static org.semanticweb.owlapi.apitest.TestFiles.ALL; +import static org.semanticweb.owlapi.apitest.TestFiles.AND; +import static org.semanticweb.owlapi.apitest.TestFiles.ANDP; +import static org.semanticweb.owlapi.apitest.TestFiles.ANNI; +import static org.semanticweb.owlapi.apitest.TestFiles.ANNSHORT; +import static org.semanticweb.owlapi.apitest.TestFiles.ANOP; +import static org.semanticweb.owlapi.apitest.TestFiles.AOEQ; +import static org.semanticweb.owlapi.apitest.TestFiles.AOINV; +import static org.semanticweb.owlapi.apitest.TestFiles.AOMAX; +import static org.semanticweb.owlapi.apitest.TestFiles.AOMIN; +import static org.semanticweb.owlapi.apitest.TestFiles.AONE; +import static org.semanticweb.owlapi.apitest.TestFiles.AOP; +import static org.semanticweb.owlapi.apitest.TestFiles.AOPJ; +import static org.semanticweb.owlapi.apitest.TestFiles.APD; +import static org.semanticweb.owlapi.apitest.TestFiles.APR; +import static org.semanticweb.owlapi.apitest.TestFiles.ASELF; +import static org.semanticweb.owlapi.apitest.TestFiles.BLN; +import static org.semanticweb.owlapi.apitest.TestFiles.C; +import static org.semanticweb.owlapi.apitest.TestFiles.CI; +import static org.semanticweb.owlapi.apitest.TestFiles.CNOT; +import static org.semanticweb.owlapi.apitest.TestFiles.DALL; +import static org.semanticweb.owlapi.apitest.TestFiles.DAND; +import static org.semanticweb.owlapi.apitest.TestFiles.DANN; +import static org.semanticweb.owlapi.apitest.TestFiles.DB; +import static org.semanticweb.owlapi.apitest.TestFiles.DC; +import static org.semanticweb.owlapi.apitest.TestFiles.DD; +import static org.semanticweb.owlapi.apitest.TestFiles.DDP; +import static org.semanticweb.owlapi.apitest.TestFiles.DEQ; +import static org.semanticweb.owlapi.apitest.TestFiles.DHAS; +import static org.semanticweb.owlapi.apitest.TestFiles.DIFF; +import static org.semanticweb.owlapi.apitest.TestFiles.DIND; +import static org.semanticweb.owlapi.apitest.TestFiles.DISJDP; +import static org.semanticweb.owlapi.apitest.TestFiles.DMAX; +import static org.semanticweb.owlapi.apitest.TestFiles.DMIN; +import static org.semanticweb.owlapi.apitest.TestFiles.DNOT; +import static org.semanticweb.owlapi.apitest.TestFiles.DONEOF; +import static org.semanticweb.owlapi.apitest.TestFiles.DOP; +import static org.semanticweb.owlapi.apitest.TestFiles.DOR; +import static org.semanticweb.owlapi.apitest.TestFiles.DP; +import static org.semanticweb.owlapi.apitest.TestFiles.DPI; +import static org.semanticweb.owlapi.apitest.TestFiles.DPR; +import static org.semanticweb.owlapi.apitest.TestFiles.DPRAND; +import static org.semanticweb.owlapi.apitest.TestFiles.DPRNOT; +import static org.semanticweb.owlapi.apitest.TestFiles.DPROR; +import static org.semanticweb.owlapi.apitest.TestFiles.DRA; +import static org.semanticweb.owlapi.apitest.TestFiles.DSJC; +import static org.semanticweb.owlapi.apitest.TestFiles.DSJOP; +import static org.semanticweb.owlapi.apitest.TestFiles.DSOME; +import static org.semanticweb.owlapi.apitest.TestFiles.DT; +import static org.semanticweb.owlapi.apitest.TestFiles.DTD; +import static org.semanticweb.owlapi.apitest.TestFiles.DTI; +import static org.semanticweb.owlapi.apitest.TestFiles.DU; +import static org.semanticweb.owlapi.apitest.TestFiles.EQC; +import static org.semanticweb.owlapi.apitest.TestFiles.EQDP; +import static org.semanticweb.owlapi.apitest.TestFiles.EQOP; +import static org.semanticweb.owlapi.apitest.TestFiles.FDP; +import static org.semanticweb.owlapi.apitest.TestFiles.FOP; +import static org.semanticweb.owlapi.apitest.TestFiles.HAS; +import static org.semanticweb.owlapi.apitest.TestFiles.HASKEY; +import static org.semanticweb.owlapi.apitest.TestFiles.I; +import static org.semanticweb.owlapi.apitest.TestFiles.IFP; +import static org.semanticweb.owlapi.apitest.TestFiles.II; +import static org.semanticweb.owlapi.apitest.TestFiles.INVERSE; +import static org.semanticweb.owlapi.apitest.TestFiles.IOP; +import static org.semanticweb.owlapi.apitest.TestFiles.IRI; +import static org.semanticweb.owlapi.apitest.TestFiles.IRII; +import static org.semanticweb.owlapi.apitest.TestFiles.IRR; +import static org.semanticweb.owlapi.apitest.TestFiles.MAX; +import static org.semanticweb.owlapi.apitest.TestFiles.MAXSIX; +import static org.semanticweb.owlapi.apitest.TestFiles.MIN5; +import static org.semanticweb.owlapi.apitest.TestFiles.MINMAX; +import static org.semanticweb.owlapi.apitest.TestFiles.MINMXSIX; +import static org.semanticweb.owlapi.apitest.TestFiles.NOT; +import static org.semanticweb.owlapi.apitest.TestFiles.OEQ; +import static org.semanticweb.owlapi.apitest.TestFiles.OMIN; +import static org.semanticweb.owlapi.apitest.TestFiles.ONE; +import static org.semanticweb.owlapi.apitest.TestFiles.OP; +import static org.semanticweb.owlapi.apitest.TestFiles.OPD; +import static org.semanticweb.owlapi.apitest.TestFiles.OPI; +import static org.semanticweb.owlapi.apitest.TestFiles.OPR; +import static org.semanticweb.owlapi.apitest.TestFiles.OR; +import static org.semanticweb.owlapi.apitest.TestFiles.R; +import static org.semanticweb.owlapi.apitest.TestFiles.SAME; +import static org.semanticweb.owlapi.apitest.TestFiles.SELF; +import static org.semanticweb.owlapi.apitest.TestFiles.SHORTRULE; +import static org.semanticweb.owlapi.apitest.TestFiles.SOME; +import static org.semanticweb.owlapi.apitest.TestFiles.SUBA; +import static org.semanticweb.owlapi.apitest.TestFiles.SUBC; +import static org.semanticweb.owlapi.apitest.TestFiles.SUBD; +import static org.semanticweb.owlapi.apitest.TestFiles.SUBO; +import static org.semanticweb.owlapi.apitest.TestFiles.SUBOP; +import static org.semanticweb.owlapi.apitest.TestFiles.SYMM; +import static org.semanticweb.owlapi.apitest.TestFiles.T; +import static org.semanticweb.owlapi.apitest.TestFiles.VAR1; +import static org.semanticweb.owlapi.apitest.TestFiles.adp; +import static org.semanticweb.owlapi.apitest.TestFiles.asymmetric; +import static org.semanticweb.owlapi.apitest.TestFiles.classvar2; +import static org.semanticweb.owlapi.apitest.TestFiles.diffvar2; +import static org.semanticweb.owlapi.apitest.TestFiles.dlsaferule; +import static org.semanticweb.owlapi.apitest.TestFiles.dpafalse; +import static org.semanticweb.owlapi.apitest.TestFiles.dpdomain; +import static org.semanticweb.owlapi.apitest.TestFiles.dpvar2; +import static org.semanticweb.owlapi.apitest.TestFiles.opavar2; +import static org.semanticweb.owlapi.apitest.TestFiles.plain; +import static org.semanticweb.owlapi.apitest.TestFiles.v1; +import static org.semanticweb.owlapi.apitest.TestFiles.v2; +import static org.semanticweb.owlapi.apitest.TestFiles.v3; +import static org.semanticweb.owlapi.apitest.TestFiles.v34; +import static org.semanticweb.owlapi.apitest.TestFiles.var2; +import static org.semanticweb.owlapi.apitest.TestFiles.var236; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.util.OWLObjectComponentCollector; + +class OWLObjectComponentCollectorTestCase { + + private static final String FALSE = "\"false\"^^xsd:boolean"; + static final String FIVE = "\"5.0\"^^xsd:double"; + static final String SIX = "\"6.0\"^^xsd:double"; + static final String LABEL = "http://www.w3.org/2000/01/rdf-schema#label"; + static final String LAB = "rdfs:label"; + static final String TOP = "http://www.w3.org/2002/07/owl#Thing"; + static final String THING = "owl:Thing"; + static final String TOPDT = "http://www.w3.org/2002/07/owl#topDataProperty"; + static final String TDT = "owl:topDataProperty"; + static final String TOPOP = "http://www.w3.org/2002/07/owl#topObjectProperty"; + static final String TOPO = "owl:topObjectProperty"; + static final String var6 = "Variable()"; + static final String var5 = "Variable()"; + static final String v4 = "Variable()"; + + static Collection getData() { + Builder b = new Builder(); + Map map = new LinkedHashMap<>(); + map.put(b.assDPlain(), new String[] {plain, DP, I, DPI, II, adp, plain, "\"string\"@en"}); + map.put(b.dRange(), new String[] {DT, DP, DPI, DPR, DTI}); + map.put(b.dDef(), new String[] {DB, DT, DTD, DB, DTI}); + map.put(b.decC(), new String[] {C, CI, DC}); + map.put(b.decOp(), new String[] {OP, OPI, DOP}); + map.put(b.decDp(), new String[] {DP, DPI, DDP}); + map.put(b.decDt(), new String[] {DT, DD, DTI}); + map.put(b.decAp(), new String[] {ANNSHORT, ANNI, DANN}); + map.put(b.decI(), new String[] {I, II, DIND}); + map.put(b.assDi(), new String[] {I, IRI, II, IRII, DIFF}); + map.put(b.dc(), new String[] {C, IRI, CI, IRII, DSJC}); + map.put(b.dDp(), new String[] {DP, IRI, DPI, IRII, DISJDP}); + map.put(b.dOp(), new String[] {IRI, OP, IRII, OPI, DSJOP}); + map.put(b.du(), new String[] {C, IRI, CI, IRII, DU}); + map.put(b.ec(), new String[] {C, IRI, CI, IRII, EQC}); + map.put(b.eDp(), new String[] {DP, IRI, DPI, IRII, EQDP}); + map.put(b.eOp(), new String[] {IRI, OP, IRII, OPI, EQOP}); + map.put(b.fdp(), new String[] {DP, DPI, FDP}); + map.put(b.fop(), new String[] {OP, OPI, FOP}); + map.put(b.ifp(), new String[] {OP, OPI, IFP}); + map.put(b.iop(), new String[] {OP, OPI, IOP}); + map.put(b.irr(), new String[] {OP, OPI, IRR}); + map.put(b.ndp(), new String[] {BLN, DP, I, DPI, II, ANDP, FALSE, BLN}); + map.put(b.nop(), new String[] {I, OP, OPI, II, ANOP}); + map.put(b.opa(), new String[] {I, OP, OPI, II, AOP}); + map.put(b.opaInv(), new String[] {I, OP, OPI, INVERSE, II, AOINV}); + map.put(b.opaInvj(), + new String[] {I, "urn:test:test#j", OP, OPI, INVERSE, II, "", AOPJ}); + map.put(b.oDom(), new String[] {C, OP, CI, OPI, OPD}); + map.put(b.oRange(), new String[] {C, OP, CI, OPI, OPR}); + map.put(b.chain(), new String[] {IRI, OP, IRII, OPI, SUBO}); + map.put(b.ref(), new String[] {OP, OPI, R}); + map.put(b.same(), new String[] {I, IRI, II, IRII, SAME}); + map.put(b.subAnn(), new String[] {LABEL, ANNSHORT, LAB, ANNI, SUBA}); + map.put(b.subClass(), new String[] {TOP, C, THING, CI, SUBC}); + map.put(b.subData(), new String[] {TOPDT, DP, TDT, DPI, SUBD}); + map.put(b.subObject(), new String[] {TOPOP, OP, TOPO, OPI, SUBOP}); + map.put(b.rule(), new String[] {SHORTRULE, v34, var236, v3, v4, var5, var6}); + map.put(b.symm(), new String[] {OP, OPI, SYMM}); + map.put(b.trans(), new String[] {OP, OPI, T}); + map.put(b.hasKey(), new String[] {C, DP, IRI, OP, CI, IRII, OPI, DPI, HASKEY}); + map.put(b.ann(), new String[] {IRI, AANN}); + map.put(b.asymm(), new String[] {OP, OPI, asymmetric}); + map.put(b.annDom(), new String[] {ANNSHORT, IRI, ANNI, APD}); + map.put(b.annRange(), new String[] {ANNSHORT, IRI, ANNI, APR}); + map.put(b.ass(), new String[] {C, I, CI, II, ACL}); + map.put(b.assAnd(), new String[] {C, I, IRI, CI, IRII, II, ACLAND, AND}); + map.put(b.assOr(), new String[] {C, I, IRI, CI, IRII, II, ACLOR, OR}); + map.put(b.dRangeAnd(), + new String[] {BLN, DT, DP, DPI, DPRAND, DTI, DONEOF, DAND, FALSE, BLN}); + map.put(b.dRangeOr(), new String[] {BLN, DT, DP, DPI, DOR, DPROR, DTI, DONEOF, FALSE, BLN}); + map.put(b.assNot(), new String[] {C, I, CI, II, CNOT, NOT}); + map.put(b.assNotAnon(), new String[] {C, CI, "_:id", ACNOT, NOT}); + map.put(b.assSome(), new String[] {C, I, OP, CI, OPI, II, ACSOME, SOME}); + map.put(b.assAll(), new String[] {C, I, OP, CI, OPI, II, ACALL, ALL}); + map.put(b.assHas(), new String[] {I, OP, OPI, II, ACHAS, HAS}); + map.put(b.assMin(), new String[] {C, I, OP, CI, OPI, II, AOMIN, OMIN}); + map.put(b.assMax(), new String[] {C, I, OP, CI, OPI, II, AOMAX, MAX}); + map.put(b.assEq(), new String[] {C, I, OP, CI, OPI, II, AOEQ, OEQ}); + map.put(b.assHasSelf(), new String[] {I, OP, OPI, II, ASELF, SELF}); + map.put(b.assOneOf(), new String[] {I, II, AONE, ONE}); + map.put(b.assDSome(), new String[] {DP, I, DPI, II, ADSOME, DSOME}); + map.put(b.assDAll(), new String[] {DP, I, DPI, II, ADALL, DALL}); + map.put(b.assDHas(), new String[] {DP, I, DPI, II, ADHAS, DHAS}); + map.put(b.assDMin(), new String[] {DP, I, DPI, II, ADMIN, DMIN}); + map.put(b.assDMax(), new String[] {DP, I, DPI, II, ADMAX, DMAX}); + map.put(b.assDEq(), new String[] {DP, I, DPI, II, ADEQ, DEQ}); + map.put(b.dOneOf(), new String[] {BLN, DP, DPI, ADONEOF, FALSE, BLN, DONEOF}); + map.put(b.dNot(), new String[] {BLN, DP, DPI, DPRNOT, DNOT, FALSE, BLN, DONEOF}); + map.put(b.dRangeRestrict(), + new String[] {DB, DP, DPI, MINMAX, MINMXSIX, MIN5, MAXSIX, FIVE, SIX, DB}); + map.put(b.assD(), new String[] {BLN, DP, I, DPI, II, dpafalse, FALSE, BLN}); + map.put(b.assDPlain(), new String[] {plain, DP, I, DPI, II, adp, plain, "\"string\"@en"}); + map.put(b.dDom(), new String[] {DP, DPI, dpdomain}); + map.put(b.bigRule(), + new String[] {FALSE, var6, var5, v1, v4, v34, v3, v2, var2, OPI, var236, FALSE, + diffvar2, DP, VAR1, CI, DT, BLN, IRII, opavar2, DRA, II, BLN, dpvar2, OP, C, IRI, + classvar2, IRII, I, dlsaferule, DTI, II, DPI}); + Collection toReturn = new ArrayList<>(); + map.forEach((k, v) -> toReturn.add(new Object[] {k, v})); + return toReturn; + } + + @ParameterizedTest + @MethodSource("getData") + void testAssertion(OWLAxiom object, String[] expected) { + OWLObjectComponentCollector testsubject = new OWLObjectComponentCollector(); + Collection components = testsubject.getComponents(object); + Set strings = asUnorderedSet(components.stream().map(Object::toString)); + assertEquals(new HashSet<>(Arrays.asList(expected)), strings); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/OWLObjectTypeIndexProviderTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/OWLObjectTypeIndexProviderTestCase.java new file mode 100644 index 0000000000..7ec46b675b --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/OWLObjectTypeIndexProviderTestCase.java @@ -0,0 +1,98 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +class OWLObjectTypeIndexProviderTestCase { + + Builder b = new Builder(); + + @Test + void testAssertions() { + assertEquals(2034, b.ann().typeIndex()); + assertEquals(2018, b.asymm().typeIndex()); + assertEquals(2037, b.annDom().typeIndex()); + assertEquals(2036, b.annRange().typeIndex()); + assertEquals(2005, b.ass().typeIndex()); + assertEquals(2005, b.assAnd().typeIndex()); + assertEquals(2005, b.assOr().typeIndex()); + assertEquals(2030, b.dRangeAnd().typeIndex()); + assertEquals(2030, b.dRangeOr().typeIndex()); + assertEquals(2005, b.assNot().typeIndex()); + assertEquals(2005, b.assNotAnon().typeIndex()); + assertEquals(2005, b.assSome().typeIndex()); + assertEquals(2005, b.assAll().typeIndex()); + assertEquals(2005, b.assHas().typeIndex()); + assertEquals(2005, b.assMin().typeIndex()); + assertEquals(2005, b.assMax().typeIndex()); + assertEquals(2005, b.assEq().typeIndex()); + assertEquals(2005, b.assHasSelf().typeIndex()); + assertEquals(2005, b.assOneOf().typeIndex()); + assertEquals(2005, b.assDSome().typeIndex()); + assertEquals(2005, b.assDAll().typeIndex()); + assertEquals(2005, b.assDHas().typeIndex()); + assertEquals(2005, b.assDMin().typeIndex()); + assertEquals(2005, b.assDMax().typeIndex()); + assertEquals(2005, b.assDEq().typeIndex()); + assertEquals(2030, b.dOneOf().typeIndex()); + assertEquals(2030, b.dNot().typeIndex()); + assertEquals(2030, b.dRangeRestrict().typeIndex()); + assertEquals(2010, b.assD().typeIndex()); + assertEquals(2010, b.assDPlain().typeIndex()); + assertEquals(2029, b.dDom().typeIndex()); + assertEquals(2030, b.dRange().typeIndex()); + assertEquals(2038, b.dDef().typeIndex()); + assertEquals(2000, b.decC().typeIndex()); + assertEquals(2000, b.decOp().typeIndex()); + assertEquals(2000, b.decDp().typeIndex()); + assertEquals(2000, b.decDt().typeIndex()); + assertEquals(2000, b.decAp().typeIndex()); + assertEquals(2000, b.decI().typeIndex()); + assertEquals(2007, b.assDi().typeIndex()); + assertEquals(2003, b.dc().typeIndex()); + assertEquals(2031, b.dDp().typeIndex()); + assertEquals(2024, b.dOp().typeIndex()); + assertEquals(2004, b.du().typeIndex()); + assertEquals(2001, b.ec().typeIndex()); + assertEquals(2026, b.eDp().typeIndex()); + assertEquals(2012, b.eOp().typeIndex()); + assertEquals(2028, b.fdp().typeIndex()); + assertEquals(2015, b.fop().typeIndex()); + assertEquals(2016, b.ifp().typeIndex()); + assertEquals(2014, b.iop().typeIndex()); + assertEquals(2021, b.irr().typeIndex()); + assertEquals(2011, b.ndp().typeIndex()); + assertEquals(2009, b.nop().typeIndex()); + assertEquals(2008, b.opa().typeIndex()); + assertEquals(2008, b.opaInv().typeIndex()); + assertEquals(2008, b.opaInvj().typeIndex()); + assertEquals(2022, b.oDom().typeIndex()); + assertEquals(2023, b.oRange().typeIndex()); + assertEquals(2025, b.chain().typeIndex()); + assertEquals(2020, b.ref().typeIndex()); + assertEquals(2006, b.same().typeIndex()); + assertEquals(2035, b.subAnn().typeIndex()); + assertEquals(2002, b.subClass().typeIndex()); + assertEquals(2027, b.subData().typeIndex()); + assertEquals(2013, b.subObject().typeIndex()); + assertEquals(2033, b.rule().typeIndex()); + assertEquals(2017, b.symm().typeIndex()); + assertEquals(2019, b.trans().typeIndex()); + assertEquals(2032, b.hasKey().typeIndex()); + assertEquals(2033, b.bigRule().typeIndex()); + assertEquals(1, b.onto().typeIndex()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ObjectPropertyTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ObjectPropertyTestCase.java new file mode 100644 index 0000000000..a8e719ee08 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ObjectPropertyTestCase.java @@ -0,0 +1,81 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.InverseObjectProperties; +import static org.semanticweb.owlapi.search.Searcher.inverse; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.contains; + +import java.util.Arrays; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; + +/** + * @author Matthew Horridge, The University Of Manchester, Information Management Group + * @since 2.2.0 + */ +class ObjectPropertyTestCase extends TestBase { + + @Test + void testInverseInverseSimplification() { + OWLObjectPropertyExpression inv = P.getInverseProperty(); + OWLObjectPropertyExpression inv2 = inv.getInverseProperty(); + assertEquals(P, inv2); + } + + @Test + void testInverseInverseInverseSimplification() { + OWLObjectPropertyExpression inv = P.getInverseProperty(); + OWLObjectPropertyExpression inv2 = inv.getInverseProperty(); + OWLObjectPropertyExpression inv3 = inv2.getInverseProperty(); + assertEquals(inv, inv3); + } + + @Test + void testInverse() { + OWLOntology ont = getOWLOntology(); + OWLAxiom ax = InverseObjectProperties(P, Q); + ont.addAxiom(ax); + assertTrue(contains(inverse(ont.inverseObjectPropertyAxioms(P), P), Q)); + assertFalse(contains(inverse(ont.inverseObjectPropertyAxioms(P), P), P)); + } + + @Test + void testInverseSelf() { + OWLOntology ont = getOWLOntology(); + OWLAxiom ax = InverseObjectProperties(P, P); + ont.addAxiom(ax); + assertTrue(contains(inverse(ont.inverseObjectPropertyAxioms(P), P), P)); + } + + @Test + void testCompareRoleChains() { + OWLObjectPropertyExpression p = df.getOWLObjectProperty("_:", "p"); + OWLObjectPropertyExpression q = df.getOWLObjectProperty("_:", "q"); + OWLObjectPropertyExpression r = df.getOWLObjectProperty("_:", "r"); + OWLSubPropertyChainOfAxiom ax1 = df.getOWLSubPropertyChainOfAxiom(Arrays.asList(p, q), r); + OWLSubPropertyChainOfAxiom ax2 = df.getOWLSubPropertyChainOfAxiom(Arrays.asList(p, p), r); + assertNotEquals(ax1, ax2, "role chains should not be equal"); + int comparisonResult = ax1.compareTo(ax2); + assertNotEquals(0, comparisonResult); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ParsersStorersTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ParsersStorersTestCase.java new file mode 100644 index 0000000000..41fa2527cd --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ParsersStorersTestCase.java @@ -0,0 +1,204 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.Collection; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.dlsyntax.parser.DLSyntaxOWLParserFactory; +import org.semanticweb.owlapi.dlsyntax.renderer.DLSyntaxStorerFactory; +import org.semanticweb.owlapi.formats.DLSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.KRSS2DocumentFormat; +import org.semanticweb.owlapi.formats.KRSSDocumentFormat; +import org.semanticweb.owlapi.formats.LatexDocumentFormat; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.functional.parser.OWLFunctionalSyntaxOWLParserFactory; +import org.semanticweb.owlapi.functional.renderer.FunctionalSyntaxStorerFactory; +import org.semanticweb.owlapi.io.OWLParserException; +import org.semanticweb.owlapi.io.OWLParserFactory; +import org.semanticweb.owlapi.io.StringDocumentSource; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.krss1.parser.KRSSOWLParserFactory; +import org.semanticweb.owlapi.krss2.parser.KRSS2OWLParserFactory; +import org.semanticweb.owlapi.krss2.renderer.KRSS2OWLSyntaxStorerFactory; +import org.semanticweb.owlapi.krss2.renderer.KRSSSyntaxStorerFactory; +import org.semanticweb.owlapi.latex.renderer.LatexStorerFactory; +import org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxOntologyParserFactory; +import org.semanticweb.owlapi.manchestersyntax.renderer.ManchesterSyntaxStorerFactory; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration; +import org.semanticweb.owlapi.model.OWLStorerFactory; +import org.semanticweb.owlapi.model.parameters.AxiomAnnotations; +import org.semanticweb.owlapi.model.parameters.Imports; +import org.semanticweb.owlapi.owlxml.parser.OWLXMLParserFactory; +import org.semanticweb.owlapi.owlxml.renderer.OWLXMLStorerFactory; +import org.semanticweb.owlapi.rdf.rdfxml.parser.RDFXMLParserFactory; +import org.semanticweb.owlapi.rdf.rdfxml.renderer.RDFXMLStorerFactory; +import org.semanticweb.owlapi.rdf.turtle.parser.TurtleOntologyParserFactory; +import org.semanticweb.owlapi.rdf.turtle.renderer.TurtleStorerFactory; + +class ParsersStorersTestCase extends TestBase { + + static Collection getData() { + return new Builder().all(); + } + + OWLOntology ont(OWLAxiom object) { + OWLOntology o = getAnonymousOWLOntology(); + o.add(object); + return o; + } + + void test(OWLAxiom object, OWLStorerFactory s, OWLParserFactory p, + OWLDocumentFormat ontologyFormat, boolean expectParse, boolean expectRoundtrip, + boolean logfailures, boolean annotationsSupported) throws Exception { + OWLOntology ont = ont(object); + if (!annotationsSupported) { + if (!object.getAxiomType().isLogical()) { + return; + } + object = object.getAxiomWithoutAnnotations(); + ont = ont(object); + } + StringDocumentTarget target = new StringDocumentTarget(); + s.createStorer().storeOntology(ont, target, ontologyFormat); + OWLOntology o = getAnonymousOWLOntology(); + try { + p.createParser().parse(new StringDocumentSource(target), o, + new OWLOntologyLoaderConfiguration()); + } catch (OWLParserException e) { + if (logfailures) { + System.out.println("parse fail: " + ontologyFormat.getKey() + " " + object); + System.out.println(target); + } + if (expectParse) { + throw e; + } + return; + } + boolean condition = o.containsAxiom(object) + || o.containsAxiom(object, Imports.EXCLUDED, AxiomAnnotations.IGNORE_AXIOM_ANNOTATIONS) + || object instanceof OWLObjectPropertyAssertionAxiom + && o.containsAxiom(((OWLObjectPropertyAssertionAxiom) object).getSimplified()); + if (!condition) { + if (expectRoundtrip) { + // check bnodes + String axiom = object.toString().replace("_:id", ""); + for (OWLAxiom ax : asUnorderedSet(o.axioms())) { + if (!condition) { + String a = ax.toString().replaceAll("_:genid[0-9]+", ""); + condition = axiom.equals(a); + } + } + if (!condition) { + System.out.println(target.toString()); + System.out.println(ontologyFormat + " " + axiom); + for (OWLAxiom ax : asUnorderedSet(o.axioms())) { + String a = ax.toString().replaceAll("_:genid[0-9]+", ""); + System.out.println(ontologyFormat + " parsed " + a); + } + } + assertTrue(condition, object.toString() + "\t" + o); + } else { + if (logfailures) { + System.out.println("roundtrip fail: " + ontologyFormat.getKey() + " " + object); + System.out.println(target.toString()); + o.axioms().forEach(System.out::println); + System.out.println("end of roundtrip failure"); + } + } + } + } + + @ParameterizedTest + @MethodSource("getData") + void testManchesterSyntax(OWLAxiom object) throws Exception { + boolean logicalAxiom = object.isLogicalAxiom(); + test(object, new ManchesterSyntaxStorerFactory(), + new ManchesterOWLSyntaxOntologyParserFactory(), new ManchesterSyntaxDocumentFormat(), + logicalAxiom, logicalAxiom, true, true); + } + + @ParameterizedTest + @MethodSource("getData") + void testKRSS2(OWLAxiom object) throws Exception { + // XXX at some point roundtripping should be supported + test(object, new KRSS2OWLSyntaxStorerFactory(), new KRSS2OWLParserFactory(), + new KRSS2DocumentFormat(), false, false, false, false); + } + + @ParameterizedTest + @MethodSource("getData") + void testKRSS(OWLAxiom object) throws Exception { + // XXX at some point roundtripping should be supported + test(object, new KRSSSyntaxStorerFactory(), new KRSSOWLParserFactory(), + new KRSSDocumentFormat(), false, false, false, false); + } + + @ParameterizedTest + @MethodSource("getData") + void testTurtle(OWLAxiom object) throws Exception { + test(object, new TurtleStorerFactory(), new TurtleOntologyParserFactory(), + new TurtleDocumentFormat(), true, true, true, true); + } + + @ParameterizedTest + @MethodSource("getData") + void testFSS(OWLAxiom object) throws Exception { + test(object, new FunctionalSyntaxStorerFactory(), new OWLFunctionalSyntaxOWLParserFactory(), + new FunctionalSyntaxDocumentFormat(), true, true, true, true); + } + + @ParameterizedTest + @MethodSource("getData") + void testOWLXML(OWLAxiom object) throws Exception { + test(object, new OWLXMLStorerFactory(), new OWLXMLParserFactory(), + new OWLXMLDocumentFormat(), true, true, true, true); + } + + @ParameterizedTest + @MethodSource("getData") + void testRDFXML(OWLAxiom object) throws Exception { + test(object, new RDFXMLStorerFactory(), new RDFXMLParserFactory(), + new RDFXMLDocumentFormat(), true, true, true, true); + } + + @ParameterizedTest + @MethodSource("getData") + void testDLSyntax(OWLAxiom object) throws Exception { + // XXX at some point roundtripping should be supported + test(object, new DLSyntaxStorerFactory(), new DLSyntaxOWLParserFactory(), + new DLSyntaxDocumentFormat(), false, false, true, false); + } + + @ParameterizedTest + @MethodSource("getData") + void testLatex(OWLAxiom object) throws Exception { + LatexDocumentFormat ontologyFormat = new LatexDocumentFormat(); + LatexStorerFactory storer = new LatexStorerFactory(); + StringDocumentTarget target = new StringDocumentTarget(); + storer.createStorer().storeOntology(ont(object), target, ontologyFormat); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/PriorityCollectionTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/PriorityCollectionTestCase.java new file mode 100644 index 0000000000..87849f0b1a --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/PriorityCollectionTestCase.java @@ -0,0 +1,50 @@ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Arrays; +import java.util.List; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.functional.renderer.FunctionalSyntaxStorerFactory; +import org.semanticweb.owlapi.krss2.renderer.KRSS2OWLSyntaxStorerFactory; +import org.semanticweb.owlapi.latex.renderer.LatexStorerFactory; +import org.semanticweb.owlapi.manchestersyntax.renderer.ManchesterSyntaxStorerFactory; +import org.semanticweb.owlapi.model.OWLStorer; +import org.semanticweb.owlapi.model.PriorityCollectionSorting; +import org.semanticweb.owlapi.oboformat.OBOFormatStorerFactory; +import org.semanticweb.owlapi.owlxml.renderer.OWLXMLStorerFactory; +import org.semanticweb.owlapi.rdf.rdfxml.renderer.RDFXMLStorerFactory; +import org.semanticweb.owlapi.rdf.turtle.renderer.TurtleStorerFactory; +import org.semanticweb.owlapi.rio.RioBinaryRdfStorerFactory; +import org.semanticweb.owlapi.rio.RioJsonLDStorerFactory; +import org.semanticweb.owlapi.rio.RioJsonStorerFactory; +import org.semanticweb.owlapi.rio.RioN3StorerFactory; +import org.semanticweb.owlapi.rio.RioNQuadsStorerFactory; +import org.semanticweb.owlapi.rio.RioNTriplesStorerFactory; +import org.semanticweb.owlapi.rio.RioRDFXMLStorerFactory; +import org.semanticweb.owlapi.rio.RioTrigStorerFactory; +import org.semanticweb.owlapi.rio.RioTrixStorerFactory; +import org.semanticweb.owlapi.rio.RioTurtleStorerFactory; +import org.semanticweb.owlapi.util.PriorityCollection; + +class PriorityCollectionTestCase { + + @Test + void shouldStoreStorers() { + List storers = + Arrays.asList(new RioBinaryRdfStorerFactory().get(), new RioJsonLDStorerFactory().get(), + new RioJsonStorerFactory().get(), new RioN3StorerFactory().get(), + new RioNQuadsStorerFactory().get(), new RioNTriplesStorerFactory().get(), + new RioRDFXMLStorerFactory().get(), new RioTrigStorerFactory().get(), + new RioTrixStorerFactory().get(), new RioTurtleStorerFactory().get(), + new OBOFormatStorerFactory().get(), new RDFXMLStorerFactory().get(), + new OWLXMLStorerFactory().get(), new FunctionalSyntaxStorerFactory().get(), + new ManchesterSyntaxStorerFactory().get(), new KRSS2OWLSyntaxStorerFactory().get(), + new TurtleStorerFactory().get(), new LatexStorerFactory().get()); + PriorityCollection pc = + new PriorityCollection<>(PriorityCollectionSorting.ON_SET_INJECTION_ONLY); + pc.set(storers); + assertEquals(storers.size(), pc.size(), pc.toString()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/PropertyCharacteristicsAccessorsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/PropertyCharacteristicsAccessorsTestCase.java new file mode 100644 index 0000000000..071b45a7a6 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/PropertyCharacteristicsAccessorsTestCase.java @@ -0,0 +1,111 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AsymmetricObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.FunctionalDataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.FunctionalObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.InverseFunctionalObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IrreflexiveObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ReflexiveObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SymmetricObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.TransitiveObjectProperty; +import static org.semanticweb.owlapi.search.EntitySearcher.isAsymmetric; +import static org.semanticweb.owlapi.search.EntitySearcher.isFunctional; +import static org.semanticweb.owlapi.search.EntitySearcher.isInverseFunctional; +import static org.semanticweb.owlapi.search.EntitySearcher.isIrreflexive; +import static org.semanticweb.owlapi.search.EntitySearcher.isReflexive; +import static org.semanticweb.owlapi.search.EntitySearcher.isSymmetric; +import static org.semanticweb.owlapi.search.EntitySearcher.isTransitive; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +class PropertyCharacteristicsAccessorsTestCase extends TestBase { + + @Test + void testTransitive() { + OWLOntology ont = getOWLOntology(); + assertFalse(isTransitive(P, ont)); + ont.add(TransitiveObjectProperty(P)); + assertTrue(isTransitive(P, ont)); + } + + @Test + void testSymmetric() { + OWLOntology ont = getOWLOntology(); + assertFalse(isSymmetric(P, ont)); + ont.add(SymmetricObjectProperty(P)); + assertTrue(isSymmetric(P, ont)); + } + + @Test + void testAsymmetric() { + OWLOntology ont = getOWLOntology(); + assertFalse(isAsymmetric(P, ont)); + ont.add(AsymmetricObjectProperty(P)); + assertTrue(isAsymmetric(P, ont)); + } + + @Test + void testReflexive() { + OWLOntology ont = getOWLOntology(); + assertFalse(isReflexive(P, ont)); + ont.add(ReflexiveObjectProperty(P)); + assertTrue(isReflexive(P, ont)); + } + + @Test + void testIrreflexive() { + OWLOntology ont = getOWLOntology(); + assertFalse(isIrreflexive(P, ont)); + ont.add(IrreflexiveObjectProperty(P)); + assertTrue(isIrreflexive(P, ont)); + } + + @Test + void testFunctional() { + OWLOntology ont = getOWLOntology(); + assertFalse(isFunctional(P, ont)); + ont.add(FunctionalObjectProperty(P)); + assertTrue(isFunctional(P, ont)); + } + + @Test + void testInverseFunctional() { + OWLOntology ont = getOWLOntology(); + assertFalse(isInverseFunctional(P, ont)); + ont.add(InverseFunctionalObjectProperty(P)); + assertTrue(isInverseFunctional(P, ont)); + } + + @Test + void testFunctionalDataProperty() { + OWLOntology ont = getOWLOntology(); + assertFalse(isFunctional(DP, ont)); + ont.add(FunctionalDataProperty(DP)); + assertTrue(isFunctional(DP, ont)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/PunnedDeclarationsNotAddedTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/PunnedDeclarationsNotAddedTestCase.java new file mode 100644 index 0000000000..eaf2ee1f76 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/PunnedDeclarationsNotAddedTestCase.java @@ -0,0 +1,77 @@ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Arrays; +import java.util.Collection; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; + +class PunnedDeclarationsNotAddedTestCase extends TestBase { + + static Collection data() { + return Arrays.asList(new FunctionalSyntaxDocumentFormat(), new OWLXMLDocumentFormat(), + new RDFXMLDocumentFormat(), new TurtleDocumentFormat()); + } + + protected OWLOntology getOntologyWithPunnedInvalidDeclarations() { + OWLOntology o = getOWLOntology(); + OWLObjectProperty op = df.getOWLObjectProperty(iri("testProperty")); + OWLAnnotationProperty ap = df.getOWLAnnotationProperty(iri("testProperty")); + o.add(df.getOWLDeclarationAxiom(op)); + o.add(df.getOWLTransitiveObjectPropertyAxiom(op)); + OWLAnnotationAssertionAxiom assertion = df.getOWLAnnotationAssertionAxiom(iri("test"), + df.getOWLAnnotation(ap, iri("otherTest"))); + o.add(assertion); + return o; + } + + protected OWLOntology getOntologyWithMissingDeclarations() { + OWLOntology o = getOWLOntology(); + OWLObjectProperty op = df.getOWLObjectProperty(iri("testObjectProperty")); + OWLAnnotationProperty ap = df.getOWLAnnotationProperty(iri("testAnnotationProperty")); + o.add(df.getOWLTransitiveObjectPropertyAxiom(op)); + OWLAnnotationAssertionAxiom assertion = df.getOWLAnnotationAssertionAxiom(iri("test"), + df.getOWLAnnotation(ap, iri("otherTest"))); + o.add(assertion); + return o; + } + + @ParameterizedTest + @MethodSource("data") + void shouldNotAddDeclarationsForIllegalPunnings(OWLDocumentFormat format) + throws OWLOntologyCreationException, OWLOntologyStorageException { + OWLOntology o = getOntologyWithPunnedInvalidDeclarations(); + OWLOntology reloaded = roundTrip(o, format); + OWLAnnotationProperty ap = df.getOWLAnnotationProperty(iri("testProperty")); + OWLDeclarationAxiom ax = df.getOWLDeclarationAxiom(ap); + assertFalse(reloaded.containsAxiom(ax), "Property should not have been declared"); + } + + @ParameterizedTest + @MethodSource("data") + void shouldDeclareMissingEntities(OWLDocumentFormat format) + throws OWLOntologyCreationException, OWLOntologyStorageException { + OWLOntology o = getOntologyWithMissingDeclarations(); + OWLOntology reloaded = roundTrip(o, format); + OWLObjectProperty op = df.getOWLObjectProperty(iri("testObjectProperty")); + OWLAnnotationProperty ap = df.getOWLAnnotationProperty(iri("testAnnotationProperty")); + assertTrue(reloaded.containsAxiom(df.getOWLDeclarationAxiom(ap))); + assertTrue(reloaded.containsAxiom(df.getOWLDeclarationAxiom(op))); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/RdfGraphComparatorTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/RdfGraphComparatorTestCase.java new file mode 100644 index 0000000000..ab07cda97b --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/RdfGraphComparatorTestCase.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.io.RDFResourceIRI; +import org.semanticweb.owlapi.io.RDFTriple; + +class RdfGraphComparatorTestCase extends TestBase { + + @Test + void shouldSort() { + RDFResourceIRI iri1 = new RDFResourceIRI(iri("urn:test#", "a1")); + RDFTriple first = new RDFTriple(iri1, iri1, iri1); + RDFTriple second = new RDFTriple(iri1, iri1, iri1); + assertEquals(0, first.compareTo(second)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/SerializationTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/SerializationTestCase.java new file mode 100644 index 0000000000..7f1c7da450 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/SerializationTestCase.java @@ -0,0 +1,188 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.net.URISyntaxException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.AddImport; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationSubject; +import org.semanticweb.owlapi.model.OWLAnnotationValue; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLPropertyExpression; +import org.semanticweb.owlapi.model.PrefixManager; +import org.semanticweb.owlapi.util.AutoIRIMapper; +import org.semanticweb.owlapi.util.DefaultPrefixManager; +import org.semanticweb.owlapi.vocab.OWL2Datatype; +import org.semanticweb.owlapi.vocab.OWLFacet; + +class SerializationTestCase extends TestBase { + + private static final String NS = "urn:test#"; + private final OWL2Datatype owl2datatype = OWL2Datatype.XSD_INT; + private final OWLDataProperty dp = df.getOWLDataProperty(NS, "dp"); + private final OWLDataProperty dp1 = df.getOWLDataProperty(NS, "dp1"); + private final OWLDataProperty dp2 = df.getOWLDataProperty(NS, "dp2"); + private final OWLObjectProperty op = df.getOWLObjectProperty(NS, "op"); + private final OWLObjectProperty op1 = df.getOWLObjectProperty(NS, "op1"); + private final OWLObjectProperty op2 = df.getOWLObjectProperty(NS, "op2"); + private final IRI iri = iri(NS, "iri"); + private final OWLLiteral owlliteral = df.getOWLLiteral(true); + private final OWLAnnotationSubject as = iri(NS, "i"); + private final OWLDatatype owldatatype = df.getOWLDatatype(owl2datatype); + private final OWLDataRange dr = df.getOWLDatatypeRestriction(owldatatype); + private final OWLAnnotationProperty ap = df.getOWLAnnotationProperty(NS, "ap"); + private final OWLFacet owlfacet = OWLFacet.MIN_EXCLUSIVE; + private final String string = "testString"; + private final OWLClassExpression c = df.getOWLClass(NS, "classexpression"); + private final PrefixManager prefixmanager = new DefaultPrefixManager(); + private final OWLIndividual ai = df.getOWLAnonymousIndividual(); + private final OWLIndividual i1 = df.getOWLNamedIndividual(NS, "i1"); + private final OWLIndividual i2 = df.getOWLNamedIndividual(NS, "i2"); + private final OWLAnnotationValue owlannotationvalue = owlliteral; + private final List setop = Arrays.asList(op1, op2); + private final List setdp = Arrays.asList(dp1, dp2); + private final List listowlobjectproperties = Arrays.asList(op, op); + private final List setowlindividual = Arrays.asList(i1, i2); + private final Set setowlpropertyexpression = + new HashSet<>(Arrays.asList(op, op)); + protected OWLOntology o; + IRI ontologyIRI; + + @BeforeEach + void setUp() throws OWLOntologyCreationException, URISyntaxException { + m.getIRIMappers().add(new AutoIRIMapper(new File("."), false)); + o = m.loadOntologyFromOntologyDocument( + new File(getClass().getResource("/pizza.owl").toURI())); + ontologyIRI = o.getOntologyID().getOntologyIRI().get(); + } + + @Test + void testrun() throws Exception { + o.applyChange(new AddImport(o, df.getOWLImportsDeclaration(iri))); + o.add(df.getOWLDeclarationAxiom(df.getOWLClass(iri))); + o.add(sub(c, df.getOWLClass(string, prefixmanager))); + o.add(df.getOWLEquivalentClassesAxiom(df.getOWLClass(iri), c)); + o.add(df.getOWLDisjointClassesAxiom(df.getOWLClass(iri), c)); + o.add(df.getOWLSubObjectPropertyOfAxiom(op, op)); + o.add(df.getOWLSubPropertyChainOfAxiom(listowlobjectproperties, op)); + o.add(df.getOWLEquivalentObjectPropertiesAxiom(setop)); + o.add(df.getOWLDisjointObjectPropertiesAxiom(setop)); + o.add(df.getOWLInverseObjectPropertiesAxiom(op, op)); + o.add(df.getOWLObjectPropertyDomainAxiom(op, c)); + o.add(df.getOWLObjectPropertyRangeAxiom(op, c)); + o.add(df.getOWLFunctionalObjectPropertyAxiom(op)); + o.add(df.getOWLAnnotationAssertionAxiom(ap, as, owlannotationvalue)); + o.add(df.getOWLAnnotationPropertyDomainAxiom(ap, iri)); + o.add(df.getOWLAnnotationPropertyRangeAxiom(ap, iri)); + o.add(df.getOWLSubAnnotationPropertyOfAxiom(ap, ap)); + o.add(df.getOWLInverseFunctionalObjectPropertyAxiom(op)); + o.add(df.getOWLReflexiveObjectPropertyAxiom(op)); + o.add(df.getOWLIrreflexiveObjectPropertyAxiom(op)); + o.add(df.getOWLSymmetricObjectPropertyAxiom(op)); + o.add(df.getOWLAsymmetricObjectPropertyAxiom(op)); + o.add(df.getOWLTransitiveObjectPropertyAxiom(op)); + o.add(df.getOWLSubDataPropertyOfAxiom(dp, dp)); + o.add(df.getOWLEquivalentDataPropertiesAxiom(setdp)); + o.add(df.getOWLDisjointDataPropertiesAxiom(setdp)); + o.add(df.getOWLDataPropertyDomainAxiom(dp, c)); + o.add(df.getOWLDataPropertyRangeAxiom(dp, dr)); + o.add(df.getOWLFunctionalDataPropertyAxiom(dp)); + o.add(df.getOWLHasKeyAxiom(c, setowlpropertyexpression)); + o.add(df.getOWLDatatypeDefinitionAxiom(owldatatype, dr)); + o.add(df.getOWLSameIndividualAxiom(setowlindividual)); + o.add(df.getOWLDifferentIndividualsAxiom(setowlindividual)); + o.add(df.getOWLClassAssertionAxiom(c, ai)); + o.add(df.getOWLObjectPropertyAssertionAxiom(op, ai, ai)); + o.add(df.getOWLNegativeObjectPropertyAssertionAxiom(op, ai, ai)); + o.add(df.getOWLDataPropertyAssertionAxiom(dp, ai, owlliteral)); + o.add(df.getOWLNegativeDataPropertyAssertionAxiom(dp, ai, owlliteral)); + o.add(df.getOWLInverseObjectPropertiesAxiom(op, df.getOWLObjectInverseOf(op))); + o.add(sub(c, df.getOWLDataExactCardinality(1, dp))); + o.add(sub(c, df.getOWLDataMaxCardinality(1, dp))); + o.add(sub(c, df.getOWLDataMinCardinality(1, dp))); + o.add(sub(c, df.getOWLObjectExactCardinality(1, op))); + o.add(sub(c, df.getOWLObjectMaxCardinality(1, op))); + o.add(sub(c, df.getOWLObjectMinCardinality(1, op))); + o.add(df.getOWLDataPropertyRangeAxiom(dp, df.getOWLDatatype(string, prefixmanager))); + o.add(df.getOWLDataPropertyAssertionAxiom(dp, ai, df.getOWLLiteral(string, owldatatype))); + o.add(df.getOWLDataPropertyRangeAxiom(dp, df.getOWLDataOneOf(owlliteral))); + o.add(df.getOWLDataPropertyRangeAxiom(dp, df.getOWLDataUnionOf(dr))); + o.add(df.getOWLDataPropertyRangeAxiom(dp, df.getOWLDataIntersectionOf(dr))); + o.add(df.getOWLDataPropertyRangeAxiom(dp, + df.getOWLDatatypeRestriction(owldatatype, owlfacet, owlliteral))); + o.add(df.getOWLDataPropertyRangeAxiom(dp, + df.getOWLDatatypeRestriction(owldatatype, df.getOWLFacetRestriction(owlfacet, 1)))); + o.add(sub(c, df.getOWLObjectIntersectionOf(c, df.getOWLClass(string, prefixmanager)))); + o.add(sub(c, df.getOWLDataSomeValuesFrom(dp, dr))); + o.add(sub(c, df.getOWLDataAllValuesFrom(dp, dr))); + o.add(sub(c, df.getOWLDataHasValue(dp, owlliteral))); + o.add(sub(c, df.getOWLObjectComplementOf(df.getOWLClass(iri)))); + o.add(sub(c, df.getOWLObjectOneOf(df.getOWLNamedIndividual(iri)))); + o.add(sub(c, df.getOWLObjectAllValuesFrom(op, c))); + o.add(sub(c, df.getOWLObjectSomeValuesFrom(op, c))); + o.add(sub(c, df.getOWLObjectHasValue(op, ai))); + o.add(sub(c, df.getOWLObjectUnionOf(df.getOWLClass(iri)))); + o.add(df.getOWLAnnotationAssertionAxiom(iri, df.getOWLAnnotation(ap, owlannotationvalue))); + o.add(df.getOWLAnnotationAssertionAxiom(df.getOWLNamedIndividual(iri).getIRI(), + df.getOWLAnnotation(ap, owlannotationvalue))); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + ObjectOutputStream stream = new ObjectOutputStream(out); + stream.writeObject(m); + stream.flush(); + // System.out.println(out.toString()); + ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); + ObjectInputStream inStream = new ObjectInputStream(in); + OWLOntologyManager copy = (OWLOntologyManager) inStream.readObject(); + OWLOntology o1 = copy.getOntology(ontologyIRI); + assertNotNull(o1); + assertEquals(asSet(o.axioms()), asSet(o1.axioms())); + assertEquals(o.getAxiomCount(), o1.getAxiomCount()); + assertEquals(o.getLogicalAxiomCount(), o1.getLogicalAxiomCount()); + assertEquals(asSet(o.annotations()), asSet(o1.annotations())); + assertEquals(o.getOntologyID(), o1.getOntologyID()); + } + + protected OWLAxiom sub(OWLClassExpression cl, OWLClassExpression d) { + return df.getOWLSubClassOfAxiom(cl, d); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/SimpleRendererTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/SimpleRendererTestCase.java new file mode 100644 index 0000000000..562fd52549 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/SimpleRendererTestCase.java @@ -0,0 +1,31 @@ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.util.SimpleRenderer; + +class SimpleRendererTestCase extends TestBase { + + private static final String URN_TEST = "urn:test#"; + private final SimpleRenderer testSubject = new SimpleRenderer(); + + @Test + void shouldSetPrefixes() { + testSubject.setPrefix("test", URN_TEST); + assertEquals("test:t", testSubject.getShortForm(iri(URN_TEST, "t"))); + } + + @Test + void shouldCopyPrefixesFromFormat() { + RDFXMLDocumentFormat f = new RDFXMLDocumentFormat(); + OWLOntology o = getOWLOntology(); + o.getOWLOntologyManager().setOntologyFormat(o, f); + f.setPrefix("test", URN_TEST); + testSubject.setPrefixesFromOntologyFormat(o, true); + assertEquals("test:t", testSubject.getShortForm(iri(URN_TEST, "t"))); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/StructuralTransformationTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/StructuralTransformationTestCase.java new file mode 100644 index 0000000000..d820722dba --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/StructuralTransformationTestCase.java @@ -0,0 +1,101 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.util.StructuralTransformation; + +class StructuralTransformationTestCase { + public static final String strtranssame = "[]"; + + static Collection getData() { + Builder b = new Builder(); + Map map = new LinkedHashMap<>(); + map.put(b.dRange(), TestFiles.strtransdRange); + map.put(b.dDef(), TestFiles.strtransdDef); + map.put(b.decC(), TestFiles.strtransdecC); + map.put(b.decOp(), TestFiles.strtransdecOp); + map.put(b.decDp(), TestFiles.strtransdecDp); + map.put(b.decDt(), TestFiles.strtransdecDt); + map.put(b.decAp(), TestFiles.strtransdecAp); + map.put(b.decI(), TestFiles.strtransdecI); + map.put(b.dDp(), TestFiles.strtransdDp); + map.put(b.dOp(), TestFiles.strtransdOp); + map.put(b.eDp(), TestFiles.strtranseDp); + map.put(b.eOp(), TestFiles.strtranseOp); + map.put(b.fdp(), TestFiles.strtransfdp); + map.put(b.fop(), TestFiles.strtransfop); + map.put(b.ifp(), TestFiles.strtransifp); + map.put(b.iop(), TestFiles.strtransiop); + map.put(b.irr(), TestFiles.strtransirr); + map.put(b.opa(), TestFiles.strtransopa); + map.put(b.opaInv(), TestFiles.strtransopaInv); + map.put(b.opaInvj(), TestFiles.strtransopaInvj); + map.put(b.oDom(), TestFiles.strtransoDom); + map.put(b.oRange(), TestFiles.strtransoRange); + map.put(b.chain(), TestFiles.strtranschain); + map.put(b.ref(), TestFiles.strtransref); + map.put(b.same(), strtranssame); + map.put(b.subAnn(), TestFiles.strtranssubAnn); + map.put(b.subClass(), TestFiles.strtranssubClass); + map.put(b.subData(), TestFiles.strtranssubData); + map.put(b.subObject(), TestFiles.strtranssubObject); + map.put(b.rule(), TestFiles.strtransrule); + map.put(b.symm(), TestFiles.strtranssymm); + map.put(b.trans(), TestFiles.strtranstrans); + map.put(b.hasKey(), TestFiles.strtranshasKey); + map.put(b.bigRule(), TestFiles.strtransbigRule); + map.put(b.ann(), TestFiles.strtransann); + map.put(b.asymm(), TestFiles.strtransasymm); + map.put(b.annDom(), TestFiles.strtransannDom); + map.put(b.annRange(), TestFiles.strtransannRange); + map.put(b.dRangeAnd(), TestFiles.strtransdRangeAnd); + map.put(b.dRangeOr(), TestFiles.strtransdRangeOr); + map.put(b.dOneOf(), TestFiles.strtransdOneOf); + map.put(b.dNot(), TestFiles.strtransdNot); + map.put(b.dRangeRestrict(), TestFiles.strtransdRangeRestrict); + map.put(b.assD(), TestFiles.strtransassD); + map.put(b.assDPlain(), TestFiles.strtransassDPlain); + map.put(b.dDom(), TestFiles.strtransdDom); + map.put(b.dc(), TestFiles.strtransdc); + map.put(b.du(), TestFiles.strtransdu); + map.put(b.ec(), TestFiles.strtransec); + Collection toReturn = new ArrayList<>(); + map.forEach((k, v) -> toReturn.add(new Object[] {k, v})); + return toReturn; + } + + @ParameterizedTest + @MethodSource("getData") + void testAssertion(OWLAxiom object, String expected) { + StructuralTransformation testsubject = + new StructuralTransformation(OWLManager.getOWLDataFactory()); + Set singleton = Collections.singleton(object); + String result = new TreeSet<>(testsubject.getTransformedAxioms(singleton)).toString(); + assertEquals(expected.replace(",", ",\n"), result.replace(",", ",\n")); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/TripleComparatorTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/TripleComparatorTestCase.java new file mode 100644 index 0000000000..0b82703d1d --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/TripleComparatorTestCase.java @@ -0,0 +1,142 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.OWL_CLASS; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.OWL_DISJOINT_WITH; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.RDFS_SUBCLASS_OF; +import static org.semanticweb.owlapi.vocab.OWLRDFVocabulary.RDF_TYPE; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.io.RDFNode; +import org.semanticweb.owlapi.io.RDFResourceBlankNode; +import org.semanticweb.owlapi.io.RDFResourceIRI; +import org.semanticweb.owlapi.io.RDFTriple; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; + +class TripleComparatorTestCase extends TestBase { + + private final String ns = "http://www.co-ode.org/roberts/pto.owl#"; + private final RDFResourceIRI g = r(Class(IRI(ns, "MoleOfGoldAtom"))); + private final RDFResourceIRI d = r(ObjectProperty(OWL_DISJOINT_WITH.getIRI())); + private final RDFResourceIRI subtype = r(RDFS_SUBCLASS_OF.getIRI()); + + @Test + void shouldSort() { + List list = new ArrayList<>(Arrays.asList( + //@formatter:off + triple("MoleOfNiobiumAtom"), + triple("MoleOfMercuryAtom"), + triple("MoleOfHydrogenAtom"), + triple("MoleOfSodiumAtom"), + triple("MoleOfIodineAtom"), + triple(608551021), + triple(1419046060), + triple(908505087), + triple("MoleOfManganeseAtom"), + triple("MoleOfIronAtom"), + triple("MoleOfYttriumAtom"), + triple("MoleOfRadiumAtom"), + triple("MoleOfPoloniumAtom"), + triple("MoleOfPalladiumAtom"), + triple("MoleOfLeadAtom"), + triple("MoleOfTinAtom"), + triple("MoleOfIndiumAtom"), + triple(589710844), + triple("MoleOfPhosphorusAtom"), + triple(767224527), + triple("MoleOfXenonAtom"), + triple("MoleOfZirconiumAtom"), + triple("MoleOfNickelAtom"), + triple("MoleOfRhodiumAtom"), + triple("MoleOfThalliumAtom"), + triple("MoleOfHafniumAtom"), + triple(12186480), + triple(1975184526), + triple("MoleOfVanadiumAtom"), + triple(484873262), + triple("MoleOfScandiumAtom"), + triple("MoleOfRubidiumAtom"), + triple("MoleOfMolybdenumAtom"), + triple("MoleOfTelluriumAtom"), + triple(21622515), + triple("MoleOfMagnesiumAtom"), + triple("MoleOfTungstenAtom"), + triple("MoleOfPotassiumAtom"), + triple("MoleOfSulfurAtom"), + triple("MoleOfOxygenAtom"), + triple("MoleOfHeliumAtom"), + triple("MoleOfRutheniumAtom"), + triple(315300697), + triple(1711957716), + triple("MoleOfLithiumAtom"), + triple("MoleOfTitaniumAtom"), + triple("MoleOfOsmiumAtom"), + triple("MoleOfSiliconAtom"), + triple("MoleOfTantalumAtom"), + triple(624417224), + triple("MoleOfRadonAtom"), + triple(1556170233), + new RDFTriple(g, subtype, r(IRI(ns, "MoleOfAtom"))), + triple("MoleOfSeleniumAtom"), + triple("MoleOfNeonAtom"), + triple("MoleOfKryptonAtom"), + triple(RDF_TYPE, OWL_CLASS), + triple("MoleOfPlatinumAtom"), + triple("MoleOfSilverAtom"), + triple("MoleOfStrontiumAtom"), + triple(1340998166) + , triple("MoleOfIridiumAtom") + , triple("MoleOfNitrogenAtom") + , triple("MoleOfRheniumAtom") + , triple("MoleOfZincAtom") + //@formatter:on + )); + Collections.sort(list); + } + + private RDFTriple triple(String n) { + return new RDFTriple(g, d, r(IRI(ns, n))); + } + + private RDFTriple triple(OWLRDFVocabulary p, OWLRDFVocabulary n) { + return new RDFTriple(g, r(p.getIRI()), r(n.getIRI())); + } + + private RDFTriple triple(int n) { + return new RDFTriple(g, subtype, r(n)); + } + + private static RDFResourceIRI r(OWLEntity e) { + return new RDFResourceIRI(e.getIRI()); + } + + private static RDFResourceIRI r(IRI e) { + return new RDFResourceIRI(e); + } + + private static RDFNode r(int s) { + return new RDFResourceBlankNode(Integer.valueOf(s), false, false, false); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/VisitorsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/VisitorsTestCase.java new file mode 100644 index 0000000000..a2923acd47 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/VisitorsTestCase.java @@ -0,0 +1,117 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.util.SimpleRenderer; + +class VisitorsTestCase extends TestBase { + + static Collection getData() { + Builder b = new Builder(); + Map map = new LinkedHashMap<>(); + map.put(b.rule(), TestFiles.RULE); + map.put(b.bigRule(), TestFiles.BIGRULE); + map.put(b.onto(), TestFiles.ONTO); + map.put(b.ann(), TestFiles.ANN); + map.put(b.asymm(), TestFiles.ASYMM); + map.put(b.annDom(), TestFiles.ANNDOM); + map.put(b.annRange(), TestFiles.ANNRANGE); + map.put(b.ass(), TestFiles.ASS); + map.put(b.assAnd(), TestFiles.ASSAND); + map.put(b.assOr(), TestFiles.ASSOR); + map.put(b.dRangeAnd(), TestFiles.DRANGEAND); + map.put(b.dRangeOr(), TestFiles.DRANGEOR); + map.put(b.assNot(), TestFiles.ASSNOT); + map.put(b.assNotAnon(), TestFiles.ASSNOTANON); + map.put(b.assSome(), TestFiles.ASSSOME); + map.put(b.assAll(), TestFiles.ASSALL); + map.put(b.assHas(), TestFiles.ASSHAS); + map.put(b.assMin(), TestFiles.ASSMIN); + map.put(b.assMax(), TestFiles.ASSMAX); + map.put(b.assEq(), TestFiles.ASSEQ); + map.put(b.assHasSelf(), TestFiles.ASSHASSELF); + map.put(b.assOneOf(), TestFiles.ASSONEOF); + map.put(b.assDSome(), TestFiles.assDSome); + map.put(b.assDAll(), TestFiles.assDAll); + map.put(b.assDHas(), TestFiles.assDHas); + map.put(b.assDMin(), TestFiles.assDMin); + map.put(b.assDMax(), TestFiles.assDMax); + map.put(b.assDEq(), TestFiles.assDEq); + map.put(b.dOneOf(), TestFiles.dataOneOf); + map.put(b.dNot(), TestFiles.dataNot); + map.put(b.dRangeRestrict(), TestFiles.dRangeRestrict); + map.put(b.assD(), TestFiles.assD); + map.put(b.assDPlain(), TestFiles.assDPlain); + map.put(b.dDom(), TestFiles.dDom); + map.put(b.dRange(), TestFiles.dRange); + map.put(b.dDef(), TestFiles.dDef); + map.put(b.decC(), TestFiles.decC); + map.put(b.decOp(), TestFiles.decOp); + map.put(b.decDp(), TestFiles.decDp); + map.put(b.decDt(), TestFiles.decDt); + map.put(b.decAp(), TestFiles.decAp); + map.put(b.decI(), TestFiles.decI); + map.put(b.assDi(), TestFiles.assDi); + map.put(b.dc(), TestFiles.disjointClasses); + map.put(b.dDp(), TestFiles.disjointDp); + map.put(b.dOp(), TestFiles.disjointOp); + map.put(b.du(), TestFiles.disjointu); + map.put(b.ec(), TestFiles.ec); + map.put(b.eDp(), TestFiles.eDp); + map.put(b.eOp(), TestFiles.eOp); + map.put(b.fdp(), TestFiles.functionaldp); + map.put(b.fop(), TestFiles.functionalop); + map.put(b.ifp(), TestFiles.inversefp); + map.put(b.iop(), TestFiles.inverseop); + map.put(b.irr(), TestFiles.irreflexive); + map.put(b.ndp(), TestFiles.ndp); + map.put(b.nop(), TestFiles.nop); + map.put(b.opa(), TestFiles.opa); + map.put(b.opaInv(), TestFiles.OPAINV); + map.put(b.opaInvj(), TestFiles.OPAINVJ); + map.put(b.oDom(), TestFiles.ODOM); + map.put(b.oRange(), TestFiles.ORANGE); + map.put(b.chain(), TestFiles.CHAIN); + map.put(b.ref(), TestFiles.REF); + map.put(b.same(), TestFiles.SAME); + map.put(b.subAnn(), TestFiles.SUBANN); + map.put(b.subClass(), TestFiles.SUBCLASS); + map.put(b.subData(), TestFiles.SUBDATA); + map.put(b.subObject(), TestFiles.SUBOBJECT); + map.put(b.symm(), TestFiles.SYMM); + map.put(b.trans(), TestFiles.TRANS); + map.put(b.hasKey(), TestFiles.HASKEY); + Collection toReturn = new ArrayList<>(); + map.forEach((k, v) -> toReturn.add(new Object[] {k, v})); + return toReturn; + } + + @ParameterizedTest + @MethodSource("getData") + void testAssertion(OWLObject object, String expected) { + String render = new SimpleRenderer().render(object); + assertEquals(expected, render); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AddOntologyAnnotationDataTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AddOntologyAnnotationDataTestCase.java new file mode 100644 index 0000000000..c560f1a7f0 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AddOntologyAnnotationDataTestCase.java @@ -0,0 +1,90 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.annotations; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.change.AddOntologyAnnotationData; +import org.semanticweb.owlapi.formats.RioTurtleDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.model.AddOntologyAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.2.0 + */ +class AddOntologyAnnotationDataTestCase extends TestBase { + + private final OWLAnnotation mockAnnotation = mock(OWLAnnotation.class); + private final OWLOntology mockOntology = mock(OWLOntology.class); + + private AddOntologyAnnotationData createData() { + return new AddOntologyAnnotationData(mockAnnotation); + } + + @Test + void testEquals() { + AddOntologyAnnotationData data1 = createData(); + AddOntologyAnnotationData data2 = createData(); + assertEquals(data1, data2); + assertEquals(data1.hashCode(), data2.hashCode()); + } + + @Test + void testGettersReturnNotNull() { + AddOntologyAnnotationData data = createData(); + assertNotNull(data.getAnnotation()); + assertNotNull(data.createOntologyChange(mockOntology)); + } + + @Test + void testGettersEquals() { + AddOntologyAnnotationData data = createData(); + assertEquals(mockAnnotation, data.getAnnotation()); + } + + @Test + void testCreateOntologyChange() { + AddOntologyAnnotationData data = createData(); + AddOntologyAnnotation change = data.createOntologyChange(mockOntology); + assertEquals(mockOntology, change.getOntology()); + assertEquals(mockAnnotation, change.getAnnotation()); + } + + @Test + void testOntologyChangeSymmetry() { + AddOntologyAnnotationData data = createData(); + AddOntologyAnnotation change = new AddOntologyAnnotation(mockOntology, mockAnnotation); + assertEquals(change.getChangeData(), data); + } + + @Test + void testTurtleTriplesOrder() { + OWLOntology o1 = loadOntologyFromString(TestFiles.ontFirst, new TurtleDocumentFormat()); + OWLOntology o2 = loadOntologyFromString(TestFiles.labelFirst, new TurtleDocumentFormat()); + assertFalse(o1.annotationsAsList().isEmpty()); + assertEquals(o1.annotationsAsList(), o2.annotationsAsList()); + OWLOntology o3 = loadOntologyFromString(TestFiles.ontFirst, new RioTurtleDocumentFormat()); + OWLOntology o4 = + loadOntologyFromString(TestFiles.labelFirst, new RioTurtleDocumentFormat()); + assertEquals(o3.annotationsAsList(), o4.annotationsAsList()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AnnotatedPunningTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AnnotatedPunningTestCase.java new file mode 100644 index 0000000000..7270c9b5a9 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AnnotatedPunningTestCase.java @@ -0,0 +1,82 @@ +package org.semanticweb.owlapi.api.test.annotations; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; + +/** + * Created by ses on 5/13/14. + */ +class AnnotatedPunningTestCase extends TestBase { + + static OWLOntology makeOwlOntologyWithDeclarationsAndAnnotationAssertions( + OWLAnnotationProperty annotationProperty, OWLOntologyManager manager, + List entities) throws OWLOntologyCreationException { + Set axioms = new HashSet<>(); + OWLDataFactory dataFactory = manager.getOWLDataFactory(); + axioms.add(dataFactory.getOWLDeclarationAxiom(annotationProperty)); + for (OWLEntity entity : entities) { + axioms.add(dataFactory.getOWLAnnotationAssertionAxiom(annotationProperty, + entity.getIRI(), dataFactory.getOWLAnonymousIndividual())); + axioms.add(dataFactory.getOWLDeclarationAxiom(entity)); + } + return manager.createOntology(axioms); + } + + static ByteArrayInputStream saveForRereading(OWLOntology o, OWLDocumentFormat format) + throws OWLOntologyStorageException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + o.saveOntology(format, out); + return new ByteArrayInputStream(out.toByteArray()); + } + + static List allTests() { + List entities = Arrays.asList(df.getOWLClass("http://localhost#", "a"), + df.getOWLDatatype("http://localhost#", "a"), + df.getOWLAnnotationProperty("http://localhost#", "a"), + df.getOWLDataProperty("http://localhost#", "a"), + df.getOWLObjectProperty("http://localhost#", "a"), + df.getOWLNamedIndividual("http://localhost#", "a")); + return Arrays.asList(Arguments.of(new RDFXMLDocumentFormat(), entities), + Arguments.of(new TurtleDocumentFormat(), entities), + Arguments.of(new FunctionalSyntaxDocumentFormat(), entities), + Arguments.of(new ManchesterSyntaxDocumentFormat(), entities)); + } + + @ParameterizedTest + @MethodSource("allTests") + void runTestForAnnotationsOnPunnedEntitiesForFormat(OWLDocumentFormat format, + List entities) throws OWLOntologyCreationException, OWLOntologyStorageException { + OWLOntology o = makeOwlOntologyWithDeclarationsAndAnnotationAssertions(AP, m, entities); + for (int counter = 0; counter < 10; counter++) { + ByteArrayInputStream in = saveForRereading(o, format); + m.removeOntology(o); + o = m.loadOntologyFromOntologyDocument(in); + } + assertEquals(entities.size(), o.axioms(AxiomType.ANNOTATION_ASSERTION).count()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AnnotatetAnnotationsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AnnotatetAnnotationsTestCase.java new file mode 100644 index 0000000000..a1ff7f8432 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AnnotatetAnnotationsTestCase.java @@ -0,0 +1,102 @@ +package org.semanticweb.owlapi.api.test.annotations; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Annotation; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.RDFSLabel; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.Arrays; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.AddOntologyAnnotation; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationSubject; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; + +class AnnotatetAnnotationsTestCase extends TestBase { + + static final String ns = "urn:n:a#"; + + @Test + void shouldRoundtripMultipleNestedAnnotationsdebug() { + OWLObjectProperty r = df.getOWLObjectProperty(ns, "r"); + OWLNamedIndividual a = df.getOWLNamedIndividual(ns, "a"); + OWLNamedIndividual b = df.getOWLNamedIndividual(ns, "b"); + OWLLiteral _1 = df.getOWLLiteral(1); + OWLLiteral _3 = df.getOWLLiteral(3); + OWLLiteral _2 = df.getOWLLiteral(2); + OWLLiteral _4 = df.getOWLLiteral(4); + OWLAnnotation c3 = df.getRDFSComment(_3); + OWLAnnotation c4 = df.getRDFSComment(_4); + OWLAnnotation c1 = df.getOWLAnnotation(df.getRDFSLabel(), _1, c3); + OWLAnnotation c2 = df.getOWLAnnotation(df.getRDFSLabel(), _2, c4); + OWLAxiom ax = df.getOWLObjectPropertyAssertionAxiom(r, a, b, Arrays.asList(c1, c2)); + List axioms = Arrays.asList(ax); + OWLOntology ont = + loadOntologyFromString(TestFiles.nestedAnnotations, new RDFXMLDocumentFormat()); + assertEquals(axioms, asList(ont.logicalAxioms())); + } + + @Test + void shouldLoadAnnotatedannotationsCorrectly() { + IRI subject = iri("http://purl.obolibrary.org/obo/", "UBERON_0000033"); + OWLOntology testcase = + loadOntologyFromString(TestFiles.annotatedAnnotation, new RDFXMLDocumentFormat()); + long before = testcase.annotationAssertionAxioms(subject).count(); + OWLOntology result = roundTrip(testcase, new RDFXMLDocumentFormat()); + long after = result.annotationAssertionAxioms(subject).count(); + assertEquals(before, after); + } + + @Test + void shouldRecognizeAnnotationsOnAxiomsWithDifferentannotationsAsDistinct() { + OWLAnnotationProperty p = AnnotationProperty(iri("p")); + OWLAnnotationSubject i = iri("i"); + OWLLiteral v = Literal("value"); + OWLLiteral ann1 = Literal("value1"); + OWLLiteral ann2 = Literal("value2"); + OWLAnnotationAssertionAxiom ax1 = + AnnotationAssertion(p, i, v, singleton(Annotation(RDFSLabel(), ann1))); + OWLAnnotationAssertionAxiom ax2 = + AnnotationAssertion(p, i, v, singleton(Annotation(RDFSLabel(), ann2))); + Set set = new TreeSet<>(); + set.add(ax1); + set.add(ax2); + assertEquals(2, set.size()); + } + + @Test + void shouldAnnotateOntologyAnnotations() throws OWLOntologyCreationException { + IRI create = iri("urn:test:", "onto"); + OWLOntology o = m.createOntology(create); + OWLAnnotation a2 = df.getOWLAnnotation(AnnotationProperty(iri("p2")), Literal("value2"), + df.getRDFSLabel("nested ontology annotation")); + OWLAnnotation a1 = + df.getOWLAnnotation(AnnotationProperty(iri("p1")), Literal("value1"), a2); + o.applyChange(new AddOntologyAnnotation(o, a1)); + OWLAnnotation a3 = df.getOWLAnnotation(AnnotationProperty(iri("p2")), Literal("value3"), + Stream.of(df.getRDFSLabel("nested ontology annotation 1"))); + OWLAnnotation a4 = df.getOWLAnnotation(AnnotationProperty(iri("p1")), iri("p5"), a3); + o.applyChange(new AddOntologyAnnotation(o, a4)); + OWLOntology o1 = roundTrip(o, new RDFXMLDocumentFormat()); + equal(o, o1); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AnnotationAccessorsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AnnotationAccessorsTestCase.java new file mode 100644 index 0000000000..5ee14fbc6a --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AnnotationAccessorsTestCase.java @@ -0,0 +1,77 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.annotations; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnonymousIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Datatype; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NamedIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.search.EntitySearcher.getAnnotationObjects; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.contains; + +import java.util.Arrays; +import java.util.Collection; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationValue; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLPrimitive; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +class AnnotationAccessorsTestCase extends TestBase { + + static Collection getData() { + return Arrays.asList(Class(subject()), NamedIndividual(subject()), DataProperty(subject()), + ObjectProperty(subject()), Datatype(subject()), AnnotationProperty(subject()), + AnonymousIndividual()); + } + + protected static IRI subject() { + return iri("http://owlapi.sourceforge.net/ontologies/test#", "X"); + } + + private static OWLAnnotationAssertionAxiom createAnnotationAssertionAxiom() { + OWLAnnotationProperty prop = AnnotationProperty(iri("prop")); + OWLAnnotationValue value = Literal("value"); + return AnnotationAssertion(prop, subject(), value); + } + + @ParameterizedTest + @MethodSource("getData") + void testClassAccessor(OWLPrimitive e) { + OWLOntology ont = getOWLOntology(); + OWLAnnotationAssertionAxiom ax = createAnnotationAssertionAxiom(); + ont.addAxiom(ax); + assertTrue(ont.annotationAssertionAxioms(subject()).anyMatch(a -> a.equals(ax))); + if (e instanceof OWLEntity) { + assertTrue(ont.annotationAssertionAxioms(((OWLEntity) e).getIRI()) + .anyMatch(a -> a.equals(ax))); + assertTrue(contains(getAnnotationObjects((OWLEntity) e, ont), ax.getAnnotation())); + } + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AnnotationPropertyConvenienceMethodTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AnnotationPropertyConvenienceMethodTestCase.java new file mode 100644 index 0000000000..69bc8f599b --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AnnotationPropertyConvenienceMethodTestCase.java @@ -0,0 +1,70 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.annotations; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationProperty; +import static org.semanticweb.owlapi.model.parameters.Imports.EXCLUDED; +import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED; +import static org.semanticweb.owlapi.search.Filters.subAnnotationWithSuper; +import static org.semanticweb.owlapi.search.Searcher.sub; +import static org.semanticweb.owlapi.search.Searcher.sup; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.contains; + +import java.util.Collection; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.search.Filters; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.2.0 + */ +class AnnotationPropertyConvenienceMethodTestCase extends TestBase { + + @Test + void testGetSuperProperties() { + OWLOntology ont = getOWLOntology(); + OWLAnnotationProperty propP = AnnotationProperty(iri("propP")); + OWLAnnotationProperty propQ = AnnotationProperty(iri("propQ")); + OWLAnnotationProperty propR = AnnotationProperty(iri("propR")); + ont.addAxioms(df.getOWLSubAnnotationPropertyOfAxiom(propP, propQ), + df.getOWLSubAnnotationPropertyOfAxiom(propP, propR)); + Collection axioms = + asUnorderedSet(ont.axioms(Filters.subAnnotationWithSub, propP, INCLUDED)); + assertTrue(contains(sup(axioms.stream()), propQ)); + assertTrue(contains(sup(axioms.stream()), propR)); + axioms = asUnorderedSet(ont.axioms(Filters.subAnnotationWithSub, propP, EXCLUDED)); + assertTrue(contains(sup(axioms.stream()), propQ)); + assertTrue(contains(sup(axioms.stream()), propR)); + } + + @Test + void testGetSubProperties() { + OWLOntology ont = getOWLOntology(); + OWLAnnotationProperty propP = AnnotationProperty(iri("propP")); + OWLAnnotationProperty propQ = AnnotationProperty(iri("propQ")); + OWLAnnotationProperty propR = AnnotationProperty(iri("propR")); + ont.addAxioms(df.getOWLSubAnnotationPropertyOfAxiom(propP, propQ), + df.getOWLSubAnnotationPropertyOfAxiom(propP, propR)); + assertTrue(contains(sub(ont.axioms(subAnnotationWithSuper, propQ, INCLUDED)), propP)); + assertTrue(contains(sub(ont.axioms(subAnnotationWithSuper, propQ, EXCLUDED)), propP)); + assertTrue(contains(sub(ont.axioms(subAnnotationWithSuper, propR, INCLUDED)), propP)); + assertTrue(contains(sub(ont.axioms(subAnnotationWithSuper, propR, EXCLUDED)), propP)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AnnotationPropertyReferencesTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AnnotationPropertyReferencesTestCase.java new file mode 100644 index 0000000000..5ca98dad79 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AnnotationPropertyReferencesTestCase.java @@ -0,0 +1,68 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.annotations; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.model.parameters.Imports.EXCLUDED; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.AddOntologyAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationSubject; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +class AnnotationPropertyReferencesTestCase extends TestBase { + static final OWLLiteral val = Literal("Test", ""); + + @Test + void testContainsReferenceForAnnotationAssertion() { + OWLAnnotationSubject subject = A.getIRI(); + OWLAnnotationAssertionAxiom ax = AnnotationAssertion(AP, subject, val); + OWLOntology ont = getOWLOntology(); + ont.addAxiom(ax); + assertTrue(ont.containsAnnotationPropertyInSignature(AP.getIRI())); + assertTrue(ont.annotationPropertiesInSignature().anyMatch(a -> a.equals(AP))); + } + + @Test + void testContainsReferenceForAxiomAnnotation() { + OWLAnnotation anno = df.getOWLAnnotation(AP, val); + OWLSubClassOfAxiom ax = df.getOWLSubClassOfAxiom(A, B, singleton(anno)); + OWLOntology ont = getOWLOntology(); + ont.addAxiom(ax); + assertTrue(ont.containsAnnotationPropertyInSignature(anno.getProperty().getIRI())); + assertTrue( + ont.annotationPropertiesInSignature().anyMatch(a -> a.equals(anno.getProperty()))); + } + + @Test + void testContainsReferenceForOntologyAnnotation() { + OWLAnnotation anno = df.getOWLAnnotation(AP, val); + OWLOntology ont = getOWLOntology(); + ont.applyChange(new AddOntologyAnnotation(ont, anno)); + assertTrue( + ont.containsAnnotationPropertyInSignature(anno.getProperty().getIRI(), EXCLUDED)); + assertTrue(ont.annotationPropertiesInSignature(EXCLUDED) + .anyMatch(a -> a.equals(anno.getProperty()))); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AnnotationShortFormProviderTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AnnotationShortFormProviderTestCase.java new file mode 100644 index 0000000000..8e40245e86 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/AnnotationShortFormProviderTestCase.java @@ -0,0 +1,110 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.annotations; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NamedIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Ontology; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.PrefixManager; +import org.semanticweb.owlapi.util.AnnotationValueShortFormProvider; +import org.semanticweb.owlapi.util.CollectionFactory; +import org.semanticweb.owlapi.util.DefaultPrefixManager; +import org.semanticweb.owlapi.util.SimpleIRIShortFormProvider; +import org.semanticweb.owlapi.util.SimpleShortFormProvider; +import org.semanticweb.owlapi.util.StringAnnotationVisitor; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +class AnnotationShortFormProviderTestCase extends TestBase { + + private static final String IND = "ind"; + protected PrefixManager pm = + new DefaultPrefixManager(null, null, "http://org.semanticweb.owlapi/ont#"); + protected OWLAnnotationProperty prop = AnnotationProperty("prop", pm); + protected List props = Collections.singletonList(prop); + protected Map> langMap = new HashMap<>(); + + @Test + void testLiteralWithoutLanguageValue() { + OWLNamedIndividual root = NamedIndividual(IND, pm); + String shortForm = "MyLabel"; + Ontology(m, AnnotationAssertion(prop, root.getIRI(), Literal(shortForm))); + AnnotationValueShortFormProvider sfp = + new AnnotationValueShortFormProvider(props, langMap, m); + assertEquals(sfp.getShortForm(root), shortForm); + } + + @Test + void testLiteralWithLanguageValue() { + OWLNamedIndividual root = NamedIndividual(IND, pm); + String label1 = "MyLabel"; + String label2 = "OtherLabel"; + Ontology(m, AnnotationAssertion(prop, root.getIRI(), Literal(label1, "ab")), + AnnotationAssertion(prop, root.getIRI(), Literal(label2, "xy"))); + langMap.put(prop, Arrays.asList("ab", "xy")); + AnnotationValueShortFormProvider sfp = + new AnnotationValueShortFormProvider(props, langMap, m); + assertEquals(sfp.getShortForm(root), label1); + Map> langMap2 = new HashMap<>(); + langMap2.put(prop, Arrays.asList("xy", "ab")); + AnnotationValueShortFormProvider sfp2 = + new AnnotationValueShortFormProvider(props, langMap2, m); + assertEquals(sfp2.getShortForm(root), label2); + } + + @Test + void testIRIValue() { + OWLNamedIndividual root = NamedIndividual(IND, pm); + Ontology(m, AnnotationAssertion(prop, root.getIRI(), + IRI("http://org.semanticweb.owlapi/ont#", "myIRI"))); + AnnotationValueShortFormProvider sfp = + new AnnotationValueShortFormProvider(props, langMap, m); + assertEquals("myIRI", sfp.getShortForm(root)); + } + + @Test + void shouldWrapWithDoubleQuotes() { + OWLNamedIndividual root = NamedIndividual(IND, pm); + String shortForm = "MyLabel"; + Ontology(m, AnnotationAssertion(prop, root.getIRI(), Literal(shortForm))); + AnnotationValueShortFormProvider sfp = new AnnotationValueShortFormProvider(m, + new SimpleShortFormProvider(), new SimpleIRIShortFormProvider(), props, langMap); + sfp.setLiteralRenderer(new StringAnnotationVisitor() { + + @Override + public String visit(OWLLiteral literal) { + return '"' + literal.getLiteral() + '"'; + } + }); + String shortForm2 = sfp.getShortForm(root); + assertEquals(shortForm2, '"' + shortForm + '"'); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/BFOTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/BFOTestCase.java new file mode 100644 index 0000000000..249c58a824 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/BFOTestCase.java @@ -0,0 +1,16 @@ +package org.semanticweb.owlapi.api.test.annotations; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.rdf.rdfxml.parser.RDFXMLParserFactory; + +class BFOTestCase extends TestBase { + + @Test + void shouldparseBFO() { + m.getOntologyParsers().set(new RDFXMLParserFactory()); + loadOntologyFromString(TestFiles.BFO, new RDFXMLDocumentFormat()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/BlankNodeIdsAndAnnotationsRoundTripTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/BlankNodeIdsAndAnnotationsRoundTripTestCase.java new file mode 100644 index 0000000000..9e44c2984e --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/BlankNodeIdsAndAnnotationsRoundTripTestCase.java @@ -0,0 +1,127 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.annotations; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.NQuadsDocumentFormat; +import org.semanticweb.owlapi.formats.NTriplesDocumentFormat; +import org.semanticweb.owlapi.formats.RDFJsonDocumentFormat; +import org.semanticweb.owlapi.formats.RDFJsonLDDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RioRDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RioTurtleDocumentFormat; +import org.semanticweb.owlapi.formats.TrigDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; + +class BlankNodeIdsAndAnnotationsRoundTripTestCase extends TestBase { + private final OWLAnnotation ann1 = df.getRDFSComment("test for anon class in object position"); + private final OWLAnnotation ann2 = df.getRDFSComment("test for named class in object position"); + private final OWLAnnotation ann3 = + df.getRDFSComment("test for anon individual in object position"); + private final OWLAnnotation ann4 = df.getOWLAnnotation(df.getRDFSComment(), + df.getOWLLiteral("test for second anon class in object position"), + df.getRDFSLabel("nested label")); + private final OWLAnnotation ann5 = + df.getRDFSComment("test for second named class in object position"); + private final OWLAnnotation ann6 = + df.getRDFSComment("test for third anon class in object position"); + private final OWLClass c4 = df.getOWLClass("urn:test:c4"); + private final OWLClass c5 = df.getOWLClass("urn:test:c5"); + private final OWLObjectProperty op = df.getOWLObjectProperty("urn:test:op"); + private final OWLDataProperty dp = df.getOWLDataProperty("urn:test:dp"); + private final OWLAnonymousIndividual a = df.getOWLAnonymousIndividual(); + private final OWLAnonymousIndividual b = df.getOWLAnonymousIndividual(); + private final OWLAnonymousIndividual a1 = df.getOWLAnonymousIndividual(); + private final OWLAnonymousIndividual a2 = df.getOWLAnonymousIndividual(); + private final OWLClassExpression ce1 = df.getOWLObjectAllValuesFrom(op, c4); + private final OWLClassExpression ce2 = df.getOWLObjectSomeValuesFrom(op, df.getOWLThing()); + private final OWLClassExpression ce3 = df.getOWLObjectExactCardinality(1, op); + private final OWLClassExpression ce4 = + df.getOWLObjectIntersectionOf(df.getOWLObjectExactCardinality(2, op), + df.getOWLDataExactCardinality(3, dp), df.getOWLObjectComplementOf(ce3), ce3); + private final Set singleAxiomsLost = + new HashSet<>(Arrays.asList(new TrigDocumentFormat(), new RDFJsonLDDocumentFormat(), + new NTriplesDocumentFormat(), new RDFXMLDocumentFormat(), new RDFJsonDocumentFormat(), + new NQuadsDocumentFormat(), new TurtleDocumentFormat(), new RioTurtleDocumentFormat(), + new RioRDFXMLDocumentFormat())); + + protected OWLOntology blankNodeIdsAndAnnotationsRoundTripTestCase(OWLOntology ont1) { + ont1.add( + df.getOWLClassAssertionAxiom(df.getOWLObjectComplementOf(c4), a, Arrays.asList(ann1)), + df.getOWLClassAssertionAxiom(df.getOWLObjectComplementOf(c5), a, Arrays.asList(ann5)), + df.getOWLClassAssertionAxiom(ce1, a), df.getOWLClassAssertionAxiom(ce2, a), + df.getOWLClassAssertionAxiom(ce3, a), + df.getOWLClassAssertionAxiom(ce3, a, Arrays.asList(ann6)), + df.getOWLClassAssertionAxiom(ce4, a), + df.getOWLClassAssertionAxiom(ce4, a, Arrays.asList(ann4)), + df.getOWLObjectPropertyAssertionAxiom(op, a1, a2, Arrays.asList(ann3)), + df.getOWLClassAssertionAxiom(ce1, b), df.getOWLClassAssertionAxiom(ce2, b), + df.getOWLClassAssertionAxiom(c4, a), + df.getOWLClassAssertionAxiom(c4, a, Arrays.asList(ann2))); + return ont1; + } + + @Override + public boolean equal(OWLOntology ont1, OWLOntology ont2) { + // Axioms without annotations are lost if identical axioms with + // annotations exist. + // This is not a code defect, it's a consequence of the mapping specs. + // To allow roundtripping to work and help verify the rest of the axioms are accurately + // written out and parsed, this method adds the lost unannotated axioms. + if (singleAxiomsLost.contains(ont2.getFormat())) { + OWLIndividual i = ont2.axioms(AxiomType.CLASS_ASSERTION) + .filter(x -> x.annotations().anyMatch(ann2::equals)).map(x -> x.getIndividual()) + .findAny().orElse(null); + if (i != null) { + ont2.add(df.getOWLClassAssertionAxiom(ce3, i), df.getOWLClassAssertionAxiom(c4, i), + df.getOWLClassAssertionAxiom(ce4, i)); + } + } + return super.equal(ont1, ont2); + } + + @ParameterizedTest + @MethodSource("formats") + void testFormat(OWLDocumentFormat d) { + roundTripOntology(blankNodeIdsAndAnnotationsRoundTripTestCase(getOWLOntology()), d); + } + + @Test + void roundTripRDFXMLAndFunctionalShouldBeSame() { + OWLOntology o = blankNodeIdsAndAnnotationsRoundTripTestCase(getOWLOntology()); + OWLOntology o1 = roundTrip(o, new RDFXMLDocumentFormat()); + OWLOntology o2 = roundTrip(o, new FunctionalSyntaxDocumentFormat()); + equal(o, o1); + equal(o1, o2); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/DeclareAnnotatedEntitiesTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/DeclareAnnotatedEntitiesTestCase.java new file mode 100644 index 0000000000..69846e26ce --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/DeclareAnnotatedEntitiesTestCase.java @@ -0,0 +1,86 @@ +package org.semanticweb.owlapi.api.test.annotations; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Set; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RioTurtleDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * Created by vincent on 20.08.15. + */ +class DeclareAnnotatedEntitiesTestCase extends TestBase { + + @Test + void shouldDeclareAllDatatypes() throws Exception { + OWLOntology ontology = + loadOntologyFromString(TestFiles.declareDatatypes, new OWLXMLDocumentFormat()); + Set declarations = asSet(ontology.axioms(AxiomType.DECLARATION)); + Set annotationAssertionAxioms = + asSet(ontology.axioms(AxiomType.ANNOTATION_ASSERTION)); + OWLOntology ontology2 = m1.createOntology(); + ontology2.add(annotationAssertionAxioms); + OWLOntology o3 = roundTrip(ontology2, new RDFXMLDocumentFormat()); + Set reloadedDeclarations = asSet(o3.axioms(AxiomType.DECLARATION)); + assertEquals(declarations, reloadedDeclarations); + } + + private static final String in = "@prefix owl: .\n" + + "@prefix xsd: .\n" + + "@prefix rdf: .\n" + + "@prefix rdfs: .\n" + + "@prefix oio: .\n" + + "@prefix obo: .\n\n" + + "# omitting this line loses the axiom annotation in roundtrip\n" + + "oio:source rdf:type owl:AnnotationProperty .\n\n\n" + + "rdfs:comment rdf:type owl:AnnotationProperty .\n\n\n" + "obo:MONDO_0009025\n" + + " a owl:Class ;\n" + " oio:hasDbXref \"UMLS:C1415737\" .\n" + "\n" + + "[ a owl:Axiom ;\n" + " rdfs:comment \"Some comment\";\n" + + " oio:source \"MONDO:notFoundInSource\" ;\n" + + " owl:annotatedProperty oio:hasDbXref ;\n" + + " owl:annotatedSource obo:MONDO_0009025 ;\n" + + " owl:annotatedTarget \"UMLS:C1415737\"\n" + "] ."; + private static final String inNoDeclaration = + "@prefix owl: .\n" + + "@prefix xsd: .\n" + + "@prefix rdf: .\n" + + "@prefix oio: .\n" + + "@prefix obo: .\n\n" + "obo:MONDO_0009025\n" + + " a owl:Class ;\n" + " oio:hasDbXref \"UMLS:C1415737\" .\n" + "\n" + + "[ a owl:Axiom ;\n" + " rdfs:comment \"Some comment\";\n" + + " oio:source \"MONDO:notFoundInSource\" ;\n" + + " owl:annotatedProperty oio:hasDbXref ;\n" + + " owl:annotatedSource obo:MONDO_0009025 ;\n" + + " owl:annotatedTarget \"UMLS:C1415737\"\n" + "] ."; + + @Test + void shouldRoundtripUndeclaredAnnotationPropertiesTurtle() { + OWLOntology o = loadOntologyFromString(in, new TurtleDocumentFormat()); + OWLOntology o1 = loadOntologyFromString(inNoDeclaration, new TurtleDocumentFormat()); + // this declaration was excluded on purpose - add it to be able to use equal + o1.add(df.getOWLDeclarationAxiom( + df.getOWLAnnotationProperty("http://www.geneontology.org/formats/oboInOwl#source"))); + equal(o, o1); + } + + @Test + void shouldRoundtripUndeclaredAnnotationPropertiesRioTurtle() { + OWLOntology o = loadOntologyFromString(in, new RioTurtleDocumentFormat()); + OWLOntology o1 = loadOntologyFromString(inNoDeclaration, new RioTurtleDocumentFormat()); + // this declaration was excluded on purpose - add it to be able to use equal + o1.add(df.getOWLDeclarationAxiom( + df.getOWLAnnotationProperty("http://www.geneontology.org/formats/oboInOwl#source"))); + equal(o, o1); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/GetAxiomsIgnoringAnnotationsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/GetAxiomsIgnoringAnnotationsTestCase.java new file mode 100644 index 0000000000..5ed474756a --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/GetAxiomsIgnoringAnnotationsTestCase.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.annotations; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.contains; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +class GetAxiomsIgnoringAnnotationsTestCase extends TestBase { + + @Test + void testGetAxiomsIgnoringAnnoations() { + OWLLiteral annoLiteral = Literal("value"); + OWLAnnotationProperty annoProp = AnnotationProperty(iri("annoProp")); + OWLAnnotation anno = df.getOWLAnnotation(annoProp, annoLiteral); + OWLAxiom axiom = + df.getOWLSubClassOfAxiom(Class(iri("A")), Class(iri("B")), singleton(anno)); + OWLOntology ont = getOWLOntology(); + ont.addAxiom(axiom); + assertTrue(contains(ont.axiomsIgnoreAnnotations(axiom), axiom)); + OWLAxiom noAnnotations = axiom.getAxiomWithoutAnnotations(); + assertFalse(contains(ont.axiomsIgnoreAnnotations(axiom), noAnnotations)); + assertTrue(contains(ont.axiomsIgnoreAnnotations(noAnnotations), axiom)); + assertFalse(contains(ont.axiomsIgnoreAnnotations(noAnnotations), noAnnotations)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/LoadAnnotationAxiomsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/LoadAnnotationAxiomsTestCase.java new file mode 100644 index 0000000000..841bd22476 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/LoadAnnotationAxiomsTestCase.java @@ -0,0 +1,102 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.annotations; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.RDFSComment; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubClassOf; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.HashSet; +import java.util.Set; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration; +import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +class LoadAnnotationAxiomsTestCase extends TestBase { + + @Test + void testIgnoreAnnotations() { + OWLOntology ont = getOWLOntology(); + OWLSubClassOfAxiom sca = SubClassOf(A, B); + ont.add(sca); + OWLAnnotationProperty rdfsComment = RDFSComment(); + OWLLiteral lit = Literal("Hello world"); + OWLAnnotationAssertionAxiom annoAx1 = AnnotationAssertion(rdfsComment, A.getIRI(), lit); + ont.add(annoAx1); + OWLAnnotationPropertyDomainAxiom annoAx2 = + df.getOWLAnnotationPropertyDomainAxiom(rdfsComment, A.getIRI()); + ont.add(annoAx2); + OWLAnnotationPropertyRangeAxiom annoAx3 = + df.getOWLAnnotationPropertyRangeAxiom(rdfsComment, B.getIRI()); + ont.add(annoAx3); + OWLAnnotationProperty myComment = AnnotationProperty(IRI("http://ont.com#", "myComment")); + OWLSubAnnotationPropertyOfAxiom annoAx4 = + df.getOWLSubAnnotationPropertyOfAxiom(myComment, rdfsComment); + ont.add(annoAx4); + reload(ont, new RDFXMLDocumentFormat()); + reload(ont, new OWLXMLDocumentFormat()); + reload(ont, new TurtleDocumentFormat()); + reload(ont, new FunctionalSyntaxDocumentFormat()); + } + + private void reload(OWLOntology ontology, OWLDocumentFormat format) { + Set axioms = asUnorderedSet(ontology.axioms()); + Set annotationAxioms = + asUnorderedSet(axioms.stream().filter(OWLAxiom::isAnnotationAxiom)); + OWLOntologyLoaderConfiguration withAnnosConfig = new OWLOntologyLoaderConfiguration(); + OWLOntology reloadedWithAnnoAxioms = reload(ontology, format, withAnnosConfig); + equal(ontology, reloadedWithAnnoAxioms); + OWLOntologyLoaderConfiguration withoutAnnosConfig = + new OWLOntologyLoaderConfiguration().setLoadAnnotationAxioms(false); + OWLOntology reloadedWithoutAnnoAxioms = reload(ontology, format, withoutAnnosConfig); + assertFalse(axioms.equals(asUnorderedSet(reloadedWithoutAnnoAxioms.axioms()))); + Set axiomsMinusAnnotationAxioms = new HashSet<>(axioms); + axiomsMinusAnnotationAxioms.removeAll(annotationAxioms); + assertEquals(axiomsMinusAnnotationAxioms, + asUnorderedSet(reloadedWithoutAnnoAxioms.axioms())); + } + + private OWLOntology reload(OWLOntology ontology, OWLDocumentFormat format, + OWLOntologyLoaderConfiguration configuration) { + OWLOntology reloaded = + loadOntologyWithConfig(saveOntology(ontology, format), configuration); + reloaded.remove(reloaded.axioms(AxiomType.DECLARATION)); + return reloaded; + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/RelativeIRIsRoundTripTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/RelativeIRIsRoundTripTestCase.java new file mode 100644 index 0000000000..ede693d9d9 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/RelativeIRIsRoundTripTestCase.java @@ -0,0 +1,85 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.annotations; + +import java.util.Arrays; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.HasIRI; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.util.OWLEntityRenamer; + +class RelativeIRIsRoundTripTestCase extends TestBase { + private final String ns = ""; + // "urn:test:ns#"; + private final OWLDataProperty d = df.getOWLDataProperty(ns + "d"); + private final OWLObjectProperty o = df.getOWLObjectProperty(ns + "o"); + private final OWLAnnotationProperty x = df.getOWLAnnotationProperty(ns + "X"); + private final OWLAnnotationProperty y = df.getOWLAnnotationProperty(ns + "Y"); + private final OWLAnnotation ann1 = df.getOWLAnnotation(x, df.getOWLLiteral("x")); + private final OWLAnnotation ann2 = df.getOWLAnnotation(y, df.getOWLLiteral("y")); + + protected OWLOntology relativeIRIsRoundTripTestCase() { + OWLClassExpression c1 = df.getOWLDataAllValuesFrom(d, df.getBooleanOWLDatatype()); + OWLClassExpression c2 = df.getOWLObjectSomeValuesFrom(o, df.getOWLThing()); + OWLAxiom a = df.getOWLSubClassOfAxiom(c1, c2, Arrays.asList(ann1, ann2)); + OWLOntology ont1 = getOWLOntology(iri("http://www.semanticweb.org/owlapi/", "")); + ont1.add(a); + return ont1; + } + + @Override + public boolean equal(OWLOntology ont1, OWLOntology ont2) { + if (!ont2.containsDataPropertyInSignature(d.getIRI())) { + OWLEntityRenamer renamer = + new OWLEntityRenamer(ont2.getOWLOntologyManager(), Arrays.asList(ont2)); + ont2.applyChanges(renamer.changeIRI(relativise(d), d.getIRI())); + ont2.applyChanges(renamer.changeIRI(relativise(o), o.getIRI())); + ont2.applyChanges(renamer.changeIRI(relativise(x), x.getIRI())); + ont2.applyChanges(renamer.changeIRI(relativise(y), y.getIRI())); + } + return super.equal(ont1, ont2); + } + + protected IRI relativise(HasIRI e) { + return iri("http://www.semanticweb.org/owlapi/", e.getIRI().toString()); + } + + @ParameterizedTest + @MethodSource("formats") + void testFormat(OWLDocumentFormat d) { + roundTripOntology(relativeIRIsRoundTripTestCase(), d); + } + + @Test + void roundTripRDFXMLAndFunctionalShouldBeSame() { + OWLOntology ont = relativeIRIsRoundTripTestCase(); + OWLOntology o1 = roundTrip(ont, new RDFXMLDocumentFormat()); + OWLOntology o2 = roundTrip(ont, new FunctionalSyntaxDocumentFormat()); + equal(ont, o1); + equal(o1, o2); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/SWRLAnnotationTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/SWRLAnnotationTestCase.java new file mode 100644 index 0000000000..d2cf692d75 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/SWRLAnnotationTestCase.java @@ -0,0 +1,90 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.annotations; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; + +import java.util.Set; +import java.util.TreeSet; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.io.StringDocumentSource; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.SWRLAtom; +import org.semanticweb.owlapi.model.SWRLVariable; + +class SWRLAnnotationTestCase extends TestBase { + + private static final String NS = "http://protege.org/ontologies/SWRLAnnotation.owl"; + protected OWLClass a = Class(iri(NS + "#", "A")); + protected OWLClass b = Class(iri(NS + "#", "B")); + protected OWLAxiom axiom; + + @BeforeEach + void setUpAtoms() { + SWRLVariable x = df.getSWRLVariable(NS + "#", "x"); + SWRLAtom atom1 = df.getSWRLClassAtom(a, x); + SWRLAtom atom2 = df.getSWRLClassAtom(b, x); + Set consequent = new TreeSet<>(); + consequent.add(atom1); + OWLAnnotation annotation = df.getRDFSComment("Not a great rule"); + Set annotations = new TreeSet<>(); + annotations.add(annotation); + Set body = new TreeSet<>(); + body.add(atom2); + axiom = df.getSWRLRule(body, consequent, annotations); + } + + @Test + void shouldRoundTripAnnotation() { + OWLOntology ontology = createOntology(); + assertTrue(ontology.containsAxiom(axiom)); + StringDocumentTarget saveOntology = saveOntology(ontology); + ontology = loadOntologyFromString(saveOntology, ontology.getNonnullFormat()); + assertTrue(ontology.containsAxiom(axiom)); + } + + OWLOntology createOntology() { + OWLOntology ontology = getOWLOntology(); + ontology.add(axiom); + return ontology; + } + + @Test + void replicateFailure() { + String input = TestFiles.HEAD + " rdf:ID=\"test-table5-prp-inv2-rule\"" + TestFiles.TAIL; + OWLOntology ontology = loadOntologyFromString( + new StringDocumentSource(input, "test", new RDFXMLDocumentFormat(), null)); + assertTrue(ontology.axioms(AxiomType.SWRL_RULE) + .anyMatch(ax -> ax.toString().contains(TestFiles.DL_RULE))); + } + + @Test + void replicateSuccess() { + String input = TestFiles.HEAD + TestFiles.TAIL; + OWLOntology ontology = loadOntologyFromString( + new StringDocumentSource(input, "test", new RDFXMLDocumentFormat(), null)); + assertTrue(ontology.axioms(AxiomType.SWRL_RULE) + .anyMatch(ax -> ax.toString().contains(TestFiles.DL_RULE))); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/package-info.java new file mode 100644 index 0000000000..384e85009e --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/annotations/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.api.test.annotations; diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/AnonymousFunctionalRoundtripTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/AnonymousFunctionalRoundtripTestCase.java new file mode 100644 index 0000000000..c1a6cfec9d --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/AnonymousFunctionalRoundtripTestCase.java @@ -0,0 +1,61 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.anonymous; + +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnonymousIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ClassAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataPropertyAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectHasValue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubClassOf; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLOntology; + +class AnonymousFunctionalRoundtripTestCase extends TestBase { + + private static final String NS = "http://namespace.owl"; + + @Test + void shouldRoundTripFixed() { + loadOntologyFromString(TestFiles.FIXED, new FunctionalSyntaxDocumentFormat()); + } + + @Test + void shouldRoundTripBroken() throws Exception { + OWLOntology o = loadOntologyFromString(TestFiles.BROKEN, new RDFXMLDocumentFormat()); + FunctionalSyntaxDocumentFormat format = new FunctionalSyntaxDocumentFormat(); + format.setDefaultPrefix(NS + '#'); + OWLOntology o1 = roundTrip(o, format); + equal(o, o1); + } + + @Test + void shouldRoundTrip() throws Exception { + OWLIndividual i = AnonymousIndividual(); + OWLOntology ontology = getOWLOntology(); + ontology.add(SubClassOf(C, ObjectHasValue(P, i)), ClassAssertion(D, i), + DataPropertyAssertion(DP, i, Literal("hello"))); + RDFXMLDocumentFormat format = new RDFXMLDocumentFormat(); + format.setDefaultPrefix(NS + '#'); + ontology = roundTrip(ontology, format); + FunctionalSyntaxDocumentFormat format2 = new FunctionalSyntaxDocumentFormat(); + format2.setDefaultPrefix(NS + '#'); + ontology = roundTrip(ontology, format2); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/AnonymousIndividualsNormaliser.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/AnonymousIndividualsNormaliser.java new file mode 100644 index 0000000000..2181983758 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/AnonymousIndividualsNormaliser.java @@ -0,0 +1,61 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.anonymous; + +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnonymousIndividual; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; + +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.util.OWLObjectDuplicator; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +public class AnonymousIndividualsNormaliser extends OWLObjectDuplicator { + + private final Map renamingMap = new HashMap<>(); + private final AtomicInteger counter = new AtomicInteger(0); + + /** + * Creates an object duplicator that duplicates objects using the specified data factory. + * + * @param m The manager providing data factory and config to be used for the duplication. + */ + public AnonymousIndividualsNormaliser(OWLOntologyManager m) { + super(m); + } + + public Set getNormalisedAxioms(Collection axioms) { + return getNormalisedAxioms(axioms.stream()); + } + + public Set getNormalisedAxioms(Stream axioms) { + return asSet(axioms.map(this::t)); + } + + @Override + public OWLAnonymousIndividual visit(OWLAnonymousIndividual individual) { + return renamingMap.computeIfAbsent(individual, + x -> AnonymousIndividual("anon-ind-" + counter.incrementAndGet())); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/AnonymousRoundTripTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/AnonymousRoundTripTestCase.java new file mode 100644 index 0000000000..841ed7d303 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/AnonymousRoundTripTestCase.java @@ -0,0 +1,63 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.anonymous; + +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnonymousIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ClassAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectPropertyAssertion; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyID; + +class AnonymousRoundTripTestCase extends TestBase { + + @Test + void shouldNotFailOnAnonymousOntologySearch() throws OWLOntologyCreationException { + m.createOntology(new OWLOntologyID()); + assertNull(m.getOntology(new OWLOntologyID())); + } + + @Test + void testRoundTrip() { + String ns = "http://smi-protege.stanford.edu/ontologies/AnonymousIndividuals.owl"; + OWLClass a = Class(IRI(ns + "#", "A")); + OWLAnonymousIndividual h = AnonymousIndividual(); + OWLAnonymousIndividual i = AnonymousIndividual(); + OWLAnnotationProperty p = AnnotationProperty(IRI(ns + "#", "p")); + OWLObjectProperty q = ObjectProperty(IRI(ns + "#", "q")); + OWLOntology ontology = getOWLOntology(); + OWLAnnotation annotation1 = df.getOWLAnnotation(p, h); + OWLAnnotation annotation2 = df.getRDFSLabel(Literal("Second", "en")); + ontology.add(df.getOWLAnnotationAssertionAxiom(a.getIRI(), annotation1), + ClassAssertion(a, h), ObjectPropertyAssertion(q, h, i), + df.getOWLAnnotationAssertionAxiom(h, annotation2)); + OWLOntology o = roundTrip(ontology, new ManchesterSyntaxDocumentFormat()); + equal(ontology, o); + } + +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/AnonymousTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/AnonymousTestCase.java new file mode 100644 index 0000000000..0cc7192dd4 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/AnonymousTestCase.java @@ -0,0 +1,71 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.anonymous; + +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnonymousIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ClassAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataPropertyAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectHasValue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubClassOf; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLOntology; + +class AnonymousTestCase extends TestBase { + + private static final String URN_TEST = "urn:test#"; + + @Test + void shouldRoundTrip() throws Exception { + OWLClass c = Class(IRI(URN_TEST, "C")); + OWLClass d = Class(IRI(URN_TEST, "D")); + OWLObjectProperty p = ObjectProperty(IRI(URN_TEST, "p")); + OWLDataProperty q = DataProperty(IRI(URN_TEST, "q")); + OWLIndividual i = AnonymousIndividual(); + OWLOntology ontology = getOWLOntology(); + ontology.add(SubClassOf(c, ObjectHasValue(p, i)), ClassAssertion(d, i), + DataPropertyAssertion(q, i, Literal("hello"))); + OWLOntology ontologyReloaded = + loadOntologyFromString(saveOntology(ontology), ontology.getNonnullFormat()); + equal(ontology, ontologyReloaded); + } + + @Test + void testRoundTripWithAnonymousIndividuals() throws Exception { + String ns = "http://test.com/genid#"; + OWLNamedIndividual i = df.getOWLNamedIndividual(ns, "i"); + OWLObjectProperty p = df.getOWLObjectProperty(ns, "p"); + OWLDataProperty q = df.getOWLDataProperty(ns, "q"); + OWLOntology ontology = getOWLOntology(); + OWLIndividual ind = df.getOWLAnonymousIndividual(); + OWLObjectPropertyAssertionAxiom ax1 = df.getOWLObjectPropertyAssertionAxiom(p, i, ind); + OWLDataPropertyAssertionAxiom ax2 = + df.getOWLDataPropertyAssertionAxiom(q, ind, df.getOWLLiteral(5)); + ontology.add(ax1, ax2); + OWLOntology reload = roundTrip(ontology); + equal(ontology, reload); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/BlankNodeTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/BlankNodeTestCase.java new file mode 100644 index 0000000000..fc4d84286c --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/BlankNodeTestCase.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.anonymous; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +class BlankNodeTestCase extends TestBase { + + @Test + void testBlankNodes() throws OWLOntologyCreationException { + loadOntologyFromString(TestFiles.anonTurtle, new TurtleDocumentFormat()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/IsAnonymousTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/IsAnonymousTestCase.java new file mode 100644 index 0000000000..4d8b04b7c9 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/IsAnonymousTestCase.java @@ -0,0 +1,176 @@ +package org.semanticweb.owlapi.api.test.anonymous; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Arrays; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.SWRLClassAtom; +import org.semanticweb.owlapi.model.SWRLIndividualArgument; +import org.semanticweb.owlapi.model.SWRLLiteralArgument; +import org.semanticweb.owlapi.vocab.OWLFacet; + +class IsAnonymousTestCase extends TestBase { + + @Test + void shouldCheckAnonymous() throws OWLOntologyCreationException { + IRI i = iri("urn:test:", "i"); + IRI j = iri("urn:test:", "j"); + OWLClass c = df.getOWLClass(i); + OWLClass c1 = df.getOWLClass("urn:test:c1"); + OWLClass c2 = df.getOWLClass("urn:test:c2"); + OWLDataProperty dp = df.getOWLDataProperty(i); + OWLDataProperty dp1 = df.getOWLDataProperty("urn:test:dp1"); + OWLObjectProperty op = df.getOWLObjectProperty(i); + OWLObjectProperty op1 = df.getOWLObjectProperty("urn:test:op1"); + OWLObjectProperty op2 = df.getOWLObjectProperty("urn:test:op2"); + OWLNamedIndividual ind = df.getOWLNamedIndividual(i); + OWLNamedIndividual ind1 = df.getOWLNamedIndividual("urn:test:ind1"); + OWLAnnotation label = df.getRDFSLabel("label"); + OWLLiteral l = df.getOWLLiteral("literal"); + SWRLClassAtom sc = + df.getSWRLClassAtom(c, df.getSWRLIndividualArgument(df.getOWLNamedIndividual(j))); + SWRLIndividualArgument sind = df.getSWRLIndividualArgument(ind); + SWRLIndividualArgument sind1 = df.getSWRLIndividualArgument(ind1); + SWRLLiteralArgument sl = df.getSWRLLiteralArgument(l); + OWLDatatype itype = df.getIntegerOWLDatatype(); + OWLDatatype dtype = df.getDoubleOWLDatatype(); + assertFalse(new OWLOntologyID(i, i).isAnonymous()); + OWLOntology o = m.createOntology(i); + assertFalse(o.isAnonymous()); + OWLOntology o1 = m.createOntology(); + assertTrue(o1.isAnonymous()); + // entities + assertFalse(c.isAnonymous()); + assertFalse(dp.isAnonymous()); + assertFalse(op.isAnonymous()); + assertFalse(df.getOWLDatatype(i).isAnonymous()); + assertFalse(ind.isAnonymous()); + assertFalse(df.getOWLAnnotationProperty(i).isAnonymous()); + assertFalse(df.getOWLThing().isAnonymous()); + assertFalse(df.getOWLNothing().isAnonymous()); + // convenience properties + assertFalse(df.getRDFSLabel().isAnonymous()); + assertFalse(df.getRDFSComment().isAnonymous()); + assertFalse(df.getOWLTopObjectProperty().isAnonymous()); + assertFalse(df.getOWLTopDataProperty().isAnonymous()); + assertFalse(df.getTopDatatype().isAnonymous()); + assertFalse(df.getOWLBottomObjectProperty().isAnonymous()); + assertFalse(df.getOWLBottomDataProperty().isAnonymous()); + assertFalse(df.getRDFSSeeAlso().isAnonymous()); + assertFalse(df.getRDFSIsDefinedBy().isAnonymous()); + assertFalse(df.getOWLVersionInfo().isAnonymous()); + assertFalse(df.getOWLBackwardCompatibleWith().isAnonymous()); + assertFalse(df.getOWLIncompatibleWith().isAnonymous()); + assertFalse(df.getOWLDeprecated().isAnonymous()); + // convenience datatype methods + assertFalse(df.getRDFPlainLiteral().isAnonymous()); + assertFalse(itype.isAnonymous()); + assertFalse(df.getFloatOWLDatatype().isAnonymous()); + assertFalse(dtype.isAnonymous()); + assertFalse(df.getBooleanOWLDatatype().isAnonymous()); + assertFalse(df.getStringOWLDatatype().isAnonymous()); + assertTrue(i.isAnonymous()); + assertTrue(label.isAnonymous()); + assertTrue(df.getRDFSComment("comment").isAnonymous()); + assertTrue(df.getSWRLVariable("?variable").isAnonymous()); + assertTrue(df.getSWRLVariable(i).isAnonymous()); + assertTrue(new OWLOntologyID().isAnonymous()); + assertTrue(df.getOWLAnonymousIndividual().isAnonymous()); + assertTrue(l.isAnonymous()); + assertTrue(df.getDeprecatedOWLAnnotationAssertionAxiom(i).isAnonymous()); + assertTrue(df.getOWLAnnotation(df.getRDFSComment(), l).isAnonymous()); + assertTrue(sc.isAnonymous()); + assertTrue(df.getOWLDeclarationAxiom(c).isAnonymous()); + assertTrue(df.getOWLDatatypeDefinitionAxiom(itype, dtype).isAnonymous()); + assertTrue(df.getOWLDataComplementOf(itype).isAnonymous()); + assertTrue(df.getOWLDataAllValuesFrom(dp, itype).isAnonymous()); + assertTrue(df.getOWLDataSomeValuesFrom(dp, itype).isAnonymous()); + assertTrue(df.getOWLDisjointUnionAxiom(c, Arrays.asList(c1, c2)).isAnonymous()); + assertTrue(df.getOWLSubPropertyChainOfAxiom(Arrays.asList(op1, op2), op).isAnonymous()); + assertTrue(df.getSWRLRule(Arrays.asList(sc), Arrays.asList(sc)).isAnonymous()); + assertTrue(df.getSWRLDataRangeAtom(itype, sl).isAnonymous()); + assertTrue(df.getSWRLObjectPropertyAtom(op, sind, sind1).isAnonymous()); + assertTrue(df.getSWRLDataPropertyAtom(dp, sind, sl).isAnonymous()); + assertTrue(df.getSWRLBuiltInAtom(i, Arrays.asList(sl)).isAnonymous()); + assertTrue(sind.isAnonymous()); + assertTrue(sl.isAnonymous()); + assertTrue(df.getSWRLSameIndividualAtom(sind1, sind).isAnonymous()); + assertTrue(df.getSWRLDifferentIndividualsAtom(sind1, sind).isAnonymous()); + assertTrue(df.getOWLAnnotationAssertionAxiom(i, label).isAnonymous()); + assertTrue(df.getOWLClassAssertionAxiom(c, ind).isAnonymous()); + assertTrue(df.getOWLDataPropertyAssertionAxiom(dp, ind, 2D).isAnonymous()); + assertTrue(df.getOWLNegativeDataPropertyAssertionAxiom(dp, ind, l).isAnonymous()); + assertTrue(df.getOWLObjectPropertyAssertionAxiom(op, ind, ind1).isAnonymous()); + assertTrue(df.getOWLNegativeObjectPropertyAssertionAxiom(op, ind, ind1).isAnonymous()); + assertTrue(df.getOWLSameIndividualAxiom(ind, ind1).isAnonymous()); + assertTrue(df.getOWLDifferentIndividualsAxiom(ind, ind1).isAnonymous()); + assertTrue(df.getOWLDataExactCardinality(1, dp, itype).isAnonymous()); + assertTrue(df.getOWLDataMaxCardinality(1, dp).isAnonymous()); + assertTrue(df.getOWLDataMinCardinality(1, dp).isAnonymous()); + assertTrue(df.getOWLObjectExactCardinality(1, op).isAnonymous()); + assertTrue(df.getOWLObjectMinCardinality(1, op).isAnonymous()); + assertTrue(df.getOWLObjectMaxCardinality(1, op).isAnonymous()); + assertTrue(df.getOWLDisjointClassesAxiom(c, c1).isAnonymous()); + assertTrue(df.getOWLDisjointObjectPropertiesAxiom(op, op1).isAnonymous()); + assertTrue(df.getOWLDisjointDataPropertiesAxiom(dp, dp1).isAnonymous()); + assertTrue(df.getOWLEquivalentClassesAxiom(c, c1).isAnonymous()); + assertTrue(df.getOWLEquivalentObjectPropertiesAxiom(op, op1).isAnonymous()); + assertTrue(df.getOWLEquivalentDataPropertiesAxiom(dp, dp1).isAnonymous()); + assertTrue(df.getOWLFunctionalObjectPropertyAxiom(op).isAnonymous()); + assertTrue(df.getOWLInverseFunctionalObjectPropertyAxiom(op).isAnonymous()); + assertTrue(df.getOWLReflexiveObjectPropertyAxiom(op).isAnonymous()); + assertTrue(df.getOWLIrreflexiveObjectPropertyAxiom(op).isAnonymous()); + assertTrue(df.getOWLSymmetricObjectPropertyAxiom(op).isAnonymous()); + assertTrue(df.getOWLAsymmetricObjectPropertyAxiom(op).isAnonymous()); + assertTrue(df.getOWLTransitiveObjectPropertyAxiom(op).isAnonymous()); + assertTrue(df.getOWLFunctionalDataPropertyAxiom(dp).isAnonymous()); + assertTrue(df.getOWLDatatypeRestriction(itype, OWLFacet.LENGTH, l).isAnonymous()); + assertTrue(df.getOWLDatatypeMinInclusiveRestriction(2D).isAnonymous()); + assertTrue(df.getOWLDatatypeMaxInclusiveRestriction(3D).isAnonymous()); + assertTrue(df.getOWLDatatypeMinMaxInclusiveRestriction(2D, 3D).isAnonymous()); + assertTrue(df.getOWLFacetRestriction(OWLFacet.LENGTH, 1).isAnonymous()); + assertTrue(df.getOWLDatatypeMinExclusiveRestriction(1).isAnonymous()); + assertTrue(df.getOWLDatatypeMaxExclusiveRestriction(1).isAnonymous()); + assertTrue(df.getOWLDatatypeMinMaxExclusiveRestriction(1, 2).isAnonymous()); + assertTrue(df.getOWLObjectPropertyDomainAxiom(op, c).isAnonymous()); + assertTrue(df.getOWLDataPropertyDomainAxiom(dp, c).isAnonymous()); + assertTrue(df.getOWLAnnotationPropertyDomainAxiom(df.getRDFSLabel(), i).isAnonymous()); + assertTrue(df.getOWLObjectPropertyRangeAxiom(op, c).isAnonymous()); + assertTrue(df.getOWLDataPropertyRangeAxiom(dp, itype).isAnonymous()); + assertTrue(df.getOWLAnnotationPropertyRangeAxiom(df.getRDFSLabel(), i).isAnonymous()); + assertTrue(df.getOWLDataIntersectionOf(itype, dtype).isAnonymous()); + assertTrue(df.getOWLObjectIntersectionOf(c, c1).isAnonymous()); + assertTrue(df.getOWLDataUnionOf(itype, dtype).isAnonymous()); + assertTrue(df.getOWLObjectUnionOf(c, c1).isAnonymous()); + assertTrue(df.getOWLSubClassOfAxiom(c, c1).isAnonymous()); + assertTrue(df.getOWLSubObjectPropertyOfAxiom(op, op1).isAnonymous()); + assertTrue(df.getOWLSubDataPropertyOfAxiom(dp, dp1).isAnonymous()); + assertTrue(df.getOWLSubAnnotationPropertyOfAxiom(df.getRDFSLabel(), df.getRDFSLabel()) + .isAnonymous()); + assertTrue(df.getOWLObjectComplementOf(c).isAnonymous()); + assertTrue(df.getOWLDataOneOf(l).isAnonymous()); + assertTrue(df.getOWLObjectOneOf(ind).isAnonymous()); + assertTrue(df.getOWLObjectAllValuesFrom(op, c).isAnonymous()); + assertTrue(df.getOWLObjectSomeValuesFrom(op, c).isAnonymous()); + assertTrue(df.getOWLHasKeyAxiom(c, dp).isAnonymous()); + assertTrue(df.getOWLInverseObjectPropertiesAxiom(op, op).isAnonymous()); + assertTrue(df.getOWLObjectHasValue(op, ind).isAnonymous()); + assertTrue(df.getOWLDataHasValue(dp, l).isAnonymous()); + assertTrue(df.getOWLObjectInverseOf(op).isAnonymous()); + assertTrue(df.getOWLObjectHasSelf(op).isAnonymous()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/TestOWLClassExpressionsAndObjectOneOfTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/TestOWLClassExpressionsAndObjectOneOfTestCase.java new file mode 100644 index 0000000000..9749051320 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/TestOWLClassExpressionsAndObjectOneOfTestCase.java @@ -0,0 +1,29 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.anonymous; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; + +class TestOWLClassExpressionsAndObjectOneOfTestCase extends TestBase { + + @Test + void testAnonymous() { + assertNotNull( + loadOntologyFromString(TestFiles.anonOneOf, new FunctionalSyntaxDocumentFormat())); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/package-info.java new file mode 100644 index 0000000000..fea5f53a36 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/anonymous/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.api.test.anonymous; diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/axioms/BuiltInClassTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/axioms/BuiltInClassTestCase.java new file mode 100644 index 0000000000..11b57cb825 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/axioms/BuiltInClassTestCase.java @@ -0,0 +1,70 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.axioms; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.OWLNothing; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.OWLThing; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectHasSelf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.createObjectProperty; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; + +/** + * Tests that the isOWLThing and isOWLNothing methods return correct values. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +class BuiltInClassTestCase { + + @Test + void testOWLThing() { + OWLClass thing = OWLThing(); + assertTrue(thing.isOWLThing()); + assertFalse(thing.isOWLNothing()); + } + + @Test + void testOWLThingFromURI() { + OWLClassExpression desc = Class(OWLRDFVocabulary.OWL_THING.getIRI()); + assertTrue(desc.isOWLThing()); + assertFalse(desc.isOWLNothing()); + } + + @Test + void testOWLNothing() { + OWLClass nothing = OWLNothing(); + assertTrue(nothing.isOWLNothing()); + assertFalse(nothing.isOWLThing()); + } + + @Test + void testOWLNothingFromURI() { + OWLClassExpression desc = Class(OWLRDFVocabulary.OWL_NOTHING.getIRI()); + assertTrue(desc.isOWLNothing()); + assertFalse(desc.isOWLThing()); + } + + @Test + void testAnonymousClass() { + OWLClassExpression desc = ObjectHasSelf(createObjectProperty()); + assertFalse(desc.isOWLThing()); + assertFalse(desc.isOWLNothing()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/axioms/BuiltInPropertyTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/axioms/BuiltInPropertyTestCase.java new file mode 100644 index 0000000000..382d33c425 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/axioms/BuiltInPropertyTestCase.java @@ -0,0 +1,70 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.axioms; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +class BuiltInPropertyTestCase extends TestBase { + + @Test + void testTopObjectPropertyPositive() { + assertTrue(df.getOWLTopObjectProperty().isOWLTopObjectProperty()); + } + + @Test + void testBottomObjectPropertyPositive() { + assertTrue(df.getOWLBottomObjectProperty().isOWLBottomObjectProperty()); + } + + @Test + void testTopObjectPropertyNegative() { + assertFalse(PROP.isOWLTopObjectProperty()); + } + + @Test + void testBottomObjectPropertyNegative() { + assertFalse(PROP.isOWLBottomObjectProperty()); + } + + @Test + void testTopDataPropertyPositive() { + assertTrue(df.getOWLTopDataProperty().isOWLTopDataProperty()); + } + + @Test + void testBottomDataPropertyPositive() { + assertTrue(df.getOWLBottomDataProperty().isOWLBottomDataProperty()); + } + + @Test + void testTopDataPropertyNegative() { + assertFalse(DPROP.isOWLTopDataProperty()); + } + + @Test + void testBottomDataPropertyNegative() { + assertFalse(DPROP.isOWLBottomDataProperty()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/axioms/DeclarationEntityReferencesTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/axioms/DeclarationEntityReferencesTestCase.java new file mode 100644 index 0000000000..48337f4bbc --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/axioms/DeclarationEntityReferencesTestCase.java @@ -0,0 +1,77 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.axioms; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Declaration; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.createClass; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.createDataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.createIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.createObjectProperty; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.contains; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * A test case which ensures that an ontology contains entity references when that ontology only + * contains entity declaration axioms. In other words, entity declaration axioms produce the correct + * entity references. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +class DeclarationEntityReferencesTestCase extends TestBase { + + @Test + void testOWLClassDeclarationAxiom() { + OWLClass cls = createClass(); + OWLAxiom ax = Declaration(cls); + OWLOntology ont = getOWLOntology(); + ont.add(ax); + assertTrue(contains(ont.classesInSignature(), cls)); + } + + @Test + void testOWLObjectPropertyDeclarationAxiom() { + OWLObjectProperty prop = createObjectProperty(); + OWLAxiom ax = Declaration(prop); + OWLOntology ont = getOWLOntology(); + ont.add(ax); + assertTrue(contains(ont.objectPropertiesInSignature(), prop)); + } + + @Test + void testOWLDataPropertyDeclarationAxiom() { + OWLDataProperty prop = createDataProperty(); + OWLAxiom ax = Declaration(prop); + OWLOntology ont = getOWLOntology(); + ont.add(ax); + assertTrue(contains(ont.dataPropertiesInSignature(), prop)); + } + + @Test + void testOWLIndividualDeclarationAxiom() { + OWLNamedIndividual ind = createIndividual(); + OWLAxiom ax = Declaration(ind); + OWLOntology ont = getOWLOntology(); + ont.add(ax); + assertTrue(contains(ont.individualsInSignature(), ind)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/axioms/NNFTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/axioms/NNFTestCase.java new file mode 100644 index 0000000000..2dabe3181b --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/axioms/NNFTestCase.java @@ -0,0 +1,212 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.axioms; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectAllValuesFrom; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectComplementOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectHasValue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectIntersectionOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectMaxCardinality; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectMinCardinality; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectOneOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectSomeValuesFrom; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectUnionOf; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.util.NNF; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +class NNFTestCase extends TestBase { + + private static OWLClassExpression getNNF(OWLClassExpression classExpression) { + NNF nnf = new NNF(df); + return classExpression.accept(nnf.getClassVisitor()); + } + + @Test + void testPosOWLClass() { + assertEquals(A, A.getNNF()); + } + + @Test + void testNegOWLClass() { + assertEquals(notA, notA.getNNF()); + } + + @Test + void testPosAllValuesFrom() { + OWLClassExpression cls = ObjectAllValuesFrom(P, A); + assertEquals(cls.getNNF(), cls); + } + + @Test + void testNegAllValuesFrom() { + OWLClassExpression cls = ObjectAllValuesFrom(P, A).getObjectComplementOf(); + OWLClassExpression nnf = ObjectSomeValuesFrom(P, A.getObjectComplementOf()); + assertEquals(cls.getNNF(), nnf); + } + + @Test + void testPosSomeValuesFrom() { + OWLClassExpression cls = ObjectSomeValuesFrom(P, A); + assertEquals(cls.getNNF(), cls); + } + + @Test + void testNegSomeValuesFrom() { + OWLClassExpression cls = ObjectComplementOf(ObjectSomeValuesFrom(P, A)); + OWLClassExpression nnf = ObjectAllValuesFrom(P, ObjectComplementOf(A)); + assertEquals(cls.getNNF(), nnf); + } + + @Test + void testPosObjectIntersectionOf() { + OWLClassExpression cls = ObjectIntersectionOf(A, B, C); + assertEquals(cls.getNNF(), cls); + } + + @Test + void testNegObjectIntersectionOf() { + OWLClassExpression cls = ObjectComplementOf(ObjectIntersectionOf(A, B, C)); + OWLClassExpression nnf = ObjectUnionOf(notA, notB, notC); + assertEquals(cls.getNNF(), nnf); + } + + @Test + void testPosObjectUnionOf() { + OWLClassExpression cls = ObjectUnionOf(A, B, C); + assertEquals(cls.getNNF(), cls); + } + + @Test + void testNegObjectUnionOf() { + OWLClassExpression cls = ObjectComplementOf(ObjectUnionOf(A, B, C)); + OWLClassExpression nnf = ObjectIntersectionOf(notA, notB, notC); + assertEquals(cls.getNNF(), nnf); + } + + @Test + void testPosObjectMinCardinality() { + OWLClassExpression cls = ObjectMinCardinality(3, P, A); + assertEquals(cls.getNNF(), cls); + } + + @Test + void testNegObjectMinCardinality() { + OWLClassExpression cls = ObjectMinCardinality(3, P, A).getObjectComplementOf(); + OWLClassExpression nnf = ObjectMaxCardinality(2, P, A); + assertEquals(cls.getNNF(), nnf); + } + + @Test + void testPosObjectMaxCardinality() { + OWLClassExpression cls = ObjectMaxCardinality(3, P, A); + assertEquals(cls.getNNF(), cls); + } + + @Test + void testNegObjectMaxCardinality() { + OWLClassExpression cls = ObjectMaxCardinality(3, P, A).getObjectComplementOf(); + OWLClassExpression nnf = ObjectMinCardinality(4, P, A); + assertEquals(cls.getNNF(), nnf); + } + + @Test + void testNamedClass() { + assertEquals(A, getNNF(A)); + } + + @Test + void testObjectIntersectionOf() { + OWLClassExpression nnf = ObjectUnionOf(ObjectComplementOf(A), ObjectComplementOf(B)); + OWLClassExpression comp = getNNF(ObjectComplementOf(ObjectIntersectionOf(A, B))); + assertEquals(nnf, comp); + } + + @Test + void testObjectUnionOf() { + OWLClassExpression neg = ObjectComplementOf(ObjectUnionOf(A, B)); + OWLClassExpression nnf = ObjectIntersectionOf(ObjectComplementOf(A), ObjectComplementOf(B)); + assertEquals(nnf, getNNF(neg)); + } + + @Test + void testDoubleNegation() { + assertEquals(A, getNNF(ObjectComplementOf(ObjectComplementOf(A)))); + } + + @Test + void testTripleNegation() { + OWLClassExpression desc = ObjectComplementOf(ObjectComplementOf(A)); + assertEquals(ObjectComplementOf(A), getNNF(ObjectComplementOf(desc))); + } + + @Test + void testObjectSome() { + OWLClassExpression desc = ObjectSomeValuesFrom(P, A); + OWLClassExpression nnf = ObjectAllValuesFrom(P, ObjectComplementOf(A)); + assertEquals(nnf, getNNF(ObjectComplementOf(desc))); + } + + @Test + void testObjectAll() { + OWLClassExpression desc = ObjectAllValuesFrom(P, A); + OWLClassExpression nnf = ObjectSomeValuesFrom(P, ObjectComplementOf(A)); + assertEquals(nnf, getNNF(ObjectComplementOf(desc))); + } + + @Test + void testObjectHasValue() { + OWLClassExpression desc = ObjectHasValue(P, indA); + OWLClassExpression nnf = ObjectAllValuesFrom(P, ObjectComplementOf(ObjectOneOf(indA))); + assertEquals(nnf, getNNF(ObjectComplementOf(desc))); + } + + @Test + void testObjectMin() { + OWLClassExpression desc = ObjectMinCardinality(3, P, A); + OWLClassExpression nnf = ObjectMaxCardinality(2, P, A); + assertEquals(nnf, getNNF(ObjectComplementOf(desc))); + } + + @Test + void testObjectMax() { + OWLClassExpression desc = ObjectMaxCardinality(3, P, A); + OWLClassExpression nnf = ObjectMinCardinality(4, P, A); + assertEquals(nnf, getNNF(ObjectComplementOf(desc))); + } + + @Test + void testNestedA() { + OWLClassExpression opA = ObjectSomeValuesFrom(P, ObjectUnionOf(A, B)); + OWLClassExpression desc = ObjectUnionOf(opA, B); + OWLClassExpression nnf = ObjectIntersectionOf(ObjectComplementOf(B), ObjectAllValuesFrom(P, + ObjectIntersectionOf(ObjectComplementOf(A), ObjectComplementOf(B)))); + assertEquals(getNNF(ObjectComplementOf(desc)), nnf); + } + + @Test + void testNestedB() { + OWLClassExpression desc = ObjectIntersectionOf(ObjectIntersectionOf(A, B), + ObjectComplementOf(ObjectUnionOf(C, D))); + OWLClassExpression nnf = ObjectUnionOf( + ObjectUnionOf(ObjectComplementOf(A), ObjectComplementOf(B)), ObjectUnionOf(C, D)); + assertEquals(getNNF(ObjectComplementOf(desc)), nnf); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/axioms/ThreeEquivalentsRoundTripTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/axioms/ThreeEquivalentsRoundTripTestCase.java new file mode 100644 index 0000000000..ae8630c1b5 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/axioms/ThreeEquivalentsRoundTripTestCase.java @@ -0,0 +1,47 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.axioms; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentClasses; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectSomeValuesFrom; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; + +/** test for 3178902 adapted from the report Timothy provided. */ +class ThreeEquivalentsRoundTripTestCase extends TestBase { + + @Test + void shouldRoundTrip() throws Exception { + // given + OWLAxiom axiomToAdd = + EquivalentClasses(A, ObjectSomeValuesFrom(P, B), ObjectSomeValuesFrom(Q, C)); + OWLOntology ontology = getOWLOntology(); + ontology.addAxiom(axiomToAdd); + // when + ontology = roundTrip(ontology); + // then + assertTrue(ontology.containsObjectPropertyInSignature(P.getIRI())); + assertTrue(ontology.containsObjectPropertyInSignature(Q.getIRI())); + assertTrue(ontology.containsClassInSignature(B.getIRI())); + assertTrue(ontology.containsClassInSignature(C.getIRI())); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/axioms/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/axioms/package-info.java new file mode 100644 index 0000000000..986313c107 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/axioms/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.api.test.axioms; diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/AbstractRoundTrippingTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/AbstractRoundTrippingTestCase.java new file mode 100644 index 0000000000..71c91e7d90 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/AbstractRoundTrippingTestCase.java @@ -0,0 +1,1099 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.baseclasses; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Annotation; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationPropertyDomain; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationPropertyRange; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnonymousIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AsymmetricObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ClassAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataComplementOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataExactCardinality; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataIntersectionOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataMaxCardinality; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataMinCardinality; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataPropertyAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataPropertyDomain; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataPropertyRange; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataUnionOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Datatype; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DatatypeDefinition; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DatatypeRestriction; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Declaration; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DifferentIndividuals; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DisjointClasses; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DisjointDataProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DisjointObjectProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentDataProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentObjectProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.FacetRestriction; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.FunctionalDataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.FunctionalObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.HasKey; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Integer; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.InverseFunctionalObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.InverseObjectProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IrreflexiveObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NamedIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NegativeDataPropertyAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NegativeObjectPropertyAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectPropertyAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectPropertyDomain; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectPropertyRange; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectSomeValuesFrom; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.RDFSComment; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.RDFSLabel; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ReflexiveObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SameIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubAnnotationPropertyOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubClassOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubDataPropertyOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubObjectPropertyOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubPropertyChainOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SymmetricObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.TopDatatype; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.TransitiveObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.createClass; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.createIndividual; +import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.net.URISyntaxException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.ValueSource; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.DLSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.KRSS2DocumentFormat; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RDFJsonDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RioRDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RioTurtleDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.io.IRIDocumentSource; +import org.semanticweb.owlapi.io.RDFTriple; +import org.semanticweb.owlapi.io.StringDocumentSource; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.AddOntologyAnnotation; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataIntersectionOf; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.SWRLAtom; +import org.semanticweb.owlapi.model.SWRLDArgument; +import org.semanticweb.owlapi.model.SWRLIndividualArgument; +import org.semanticweb.owlapi.model.SWRLLiteralArgument; +import org.semanticweb.owlapi.model.SWRLVariable; +import org.semanticweb.owlapi.rdf.rdfxml.parser.OWLRDFXMLParserException; +import org.semanticweb.owlapi.rdf.rdfxml.parser.RDFXMLParser; +import org.semanticweb.owlapi.vocab.OWL2Datatype; +import org.semanticweb.owlapi.vocab.OWLFacet; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +class AbstractRoundTrippingTestCase extends TestBase { + private static final String ONTOLOGY_IRI_TEST_CASE = "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " ]>\n" + "\n" + + " \n" + + " \n" + + " \n" + "

    \n" + + " \n" + + "

    \n" + " \n" + ""; + + static List> literalWithEscapesNoRioRDFXMLTestCase() { + OWLClass cls = Class(IRI("http://owlapi.sourceforge.net/ontology#", "A")); + OWLAnnotationProperty prop = + AnnotationProperty(IRI("http://owlapi.sourceforge.net/ontology#", "prop")); + return Collections.singletonList(set(AnnotationAssertion(prop, cls.getIRI(), Literal("\\")), + AnnotationAssertion(prop, cls.getIRI(), Literal("Start" + "\\")), + AnnotationAssertion(prop, cls.getIRI(), Literal("\\" + "End")), + AnnotationAssertion(prop, cls.getIRI(), Literal("Start" + "\\" + "End")), + + AnnotationAssertion(prop, cls.getIRI(), Literal("\"")), + AnnotationAssertion(prop, cls.getIRI(), Literal("Start" + "\"")), + AnnotationAssertion(prop, cls.getIRI(), Literal("\"" + "End")), + AnnotationAssertion(prop, cls.getIRI(), Literal("Start" + "\"" + "End")), + + AnnotationAssertion(prop, cls.getIRI(), Literal("<")), + AnnotationAssertion(prop, cls.getIRI(), Literal("Start" + "<")), + AnnotationAssertion(prop, cls.getIRI(), Literal("<" + "End")), + AnnotationAssertion(prop, cls.getIRI(), Literal("Start" + "<" + "End")), + + AnnotationAssertion(prop, cls.getIRI(), Literal("\'")), + AnnotationAssertion(prop, cls.getIRI(), Literal("Start" + "\'")), + AnnotationAssertion(prop, cls.getIRI(), Literal("\'" + "End")), + AnnotationAssertion(prop, cls.getIRI(), Literal("Start" + "\'" + "End")), + + Declaration(cls))); + } + + @ParameterizedTest + @MethodSource("formats") + void anonymousRoundTripTestCase(OWLDocumentFormat f) { + OWLOntology ont1 = getOWLOntology(); + ont1.add(anonymousRoundTrip()); + roundTrip(ont1, f); + } + + static List anonymousRoundTrip() { + OWLDataProperty dp = df.getOWLDataProperty("urn:test:anon#D"); + OWLObjectProperty op = df.getOWLObjectProperty("urn:test:anon#O"); + OWLAnnotationProperty ap = df.getOWLAnnotationProperty("urn:test:anon#A2"); + OWLAnonymousIndividual i = df.getOWLAnonymousIndividual("_:b0"); + OWLAnnotation sub1 = df.getOWLAnnotation(df.getRDFSComment(), df.getOWLLiteral("z1")); + OWLAnnotation an1 = df.getOWLAnnotation(ap, i, Collections.singletonList(sub1)); + + OWLClassExpression c1 = df.getOWLDataAllValuesFrom(dp, df.getBooleanOWLDatatype()); + OWLClassExpression c2 = df.getOWLObjectSomeValuesFrom(op, df.getOWLThing()); + + return Collections + .singletonList(df.getOWLSubClassOfAxiom(c1, c2, Collections.singletonList(an1))); + } + + static List> xmlAndFunctional() { + return Arrays.asList(anonymousRoundTrip(), literalWithEscapes()); + } + + @Test + void roundTripRDFXMLAndFunctionalShouldBeSameAnonOntology() { + plainEqual(anonOntology(), true); + } + + @ParameterizedTest + @MethodSource("formats") + void anonymousOntologyAnnotationsTestCase(OWLDocumentFormat f) { + roundTrip(anonOntology(), f); + } + + protected OWLOntology anonOntology() { + OWLOntology ont = getAnonymousOWLOntology(); + OWLAnnotationProperty prop = AnnotationProperty( + IRI("http://www.semanticweb.org/ontologies/test/annotationont#", "prop")); + OWLAnnotation annotation = df.getOWLAnnotation(prop, Literal(33)); + ont.applyChange(new AddOntologyAnnotation(ont, annotation)); + ont.add(Declaration(prop)); + return ont; + } + + @Test + void roundTripRDFXMLAndFunctionalShouldBeSameBlankNodesTurtleDomain() + throws OWLOntologyCreationException, URISyntaxException { + plainEqual(blankNodesTurtleDomain(), true); + } + + @ParameterizedTest + @MethodSource("formats") + void fileRoudTripWithKnownInputFormatTestCase(OWLDocumentFormat f) + throws URISyntaxException, OWLOntologyCreationException { + roundTrip(blankNodesTurtleDomain(), f); + } + + protected OWLOntology blankNodesTurtleDomain() + throws URISyntaxException, OWLOntologyCreationException { + URL resource = getClass().getResource('/' + "testBlankNodesDomain.ttl"); + IRI iri = IRI.create(resource.toURI()); + return m.loadOntologyFromOntologyDocument( + new IRIDocumentSource(iri, new TurtleDocumentFormat(), null)); + } + + @Test + void roundTripRDFXMLAndFunctionalShouldBeSameXmlLiteral() { + plainEqual(loadOntology("XMLLiteral.rdf"), true); + } + + @ParameterizedTest + @MethodSource("formats") + void fileRoundTripNoRioRDFXMLTestCase(OWLDocumentFormat f) { + if (RioRDFXMLDocumentFormat.class.isInstance(f)) { + // XML literals managed differently in Rio + return; + } + roundTrip(loadOntology("XMLLiteral.rdf"), f); + } + + @ParameterizedTest + @ValueSource( + strings = {"AnonymousInverses.rdf", "TestParser08.rdf", "nodeid.rdf", "extraBlankNodes.owl", + "testBlankNodes2.ttl", "testBlankNodesAssertions.ttl", "owlxml_anonloop.owx"}) + void roundTripsRDFXMLAndFunctionalShouldBeSame(String fileName) { + plainEqual(loadOntology(fileName), false); + } + + @ParameterizedTest + @MethodSource({"axiomsRoundTrippingUsingEqualTestCase"}) + void roundTripsRDFXMLAndFunctionalShouldBeSame(List axioms) { + plainEqual(o(axioms), false); + } + + static List> axiomsRoundTrippingUsingEqualTestCase() { + return Arrays.asList(anonymousIndividualRoundtrip(), anonymousIndividuals2(), + anonymousIndividuals(), chainedAnonymousIndividuals(), + classAssertionWithAnonymousIndividual(), differentIndividualsAnonymous(), + differentIndividualsPairwiseAnonymous(), + objectPropertyAssertionWithAnonymousIndividuals(), sameIndividualsAnonymous()); + } + + private static List sameIndividualsAnonymous() { + // Can't round trip more than two in RDF! Also, same + // individuals axiom with anon individuals is not allowed + // in OWL 2, but it should at least round trip + return set(SameIndividual(AnonymousIndividual(), AnonymousIndividual())); + } + + private static List objectPropertyAssertionWithAnonymousIndividuals() { + OWLIndividual subject = AnonymousIndividual(); + OWLIndividual object = AnonymousIndividual(); + OWLObjectProperty prop = ObjectProperty(iri("prop")); + return set(ObjectPropertyAssertion(prop, subject, object), Declaration(prop)); + } + + private static List differentIndividualsPairwiseAnonymous() { + return set(DifferentIndividuals(AnonymousIndividual(), AnonymousIndividual())); + } + + private static List differentIndividualsAnonymous() { + return set(DifferentIndividuals(AnonymousIndividual(), AnonymousIndividual(), + AnonymousIndividual())); + } + + private static List classAssertionWithAnonymousIndividual() { + OWLIndividual ind = AnonymousIndividual("a"); + OWLClass cls = Class(iri("A")); + return set(ClassAssertion(A, i), Declaration(A)); + } + + private static List chainedAnonymousIndividuals() { + IRI annoPropIRI = IRI("http://owlapi.sourceforge.net/ontology#", "annoProp"); + OWLAnnotationProperty property = AnnotationProperty(annoPropIRI); + IRI subject = IRI("http://owlapi.sourceforge.net/ontology#", "subject"); + OWLAnonymousIndividual individual1 = AnonymousIndividual(); + OWLAnonymousIndividual individual2 = AnonymousIndividual(); + OWLAnonymousIndividual individual3 = AnonymousIndividual(); + OWLAnnotationAssertionAxiom annoAssertion1 = + AnnotationAssertion(property, subject, individual1); + OWLAnnotationAssertionAxiom annoAssertion2 = + AnnotationAssertion(property, individual1, individual2); + OWLAnnotationAssertionAxiom annoAssertion3 = + AnnotationAssertion(property, individual2, individual3); + return set(Declaration(NamedIndividual(subject)), annoAssertion1, annoAssertion2, + annoAssertion3); + } + + private static List anonymousIndividuals() { + OWLAnonymousIndividual ind = AnonymousIndividual(); + OWLObjectProperty p = ObjectProperty(iri("p")); + return set(ObjectPropertyAssertion(p, NamedIndividual(iri("i1")), ind), + ObjectPropertyAssertion(p, ind, NamedIndividual(iri("i2")))); + } + + private static List anonymousIndividuals2() { + // Originally submitted by Timothy Redmond + String ns = "http://another.com/ont"; + OWLClass a = Class(IRI(ns + "#", "A")); + OWLAnnotationProperty p = AnnotationProperty(IRI(ns + "#", "p")); + OWLObjectProperty q = ObjectProperty(IRI(ns + "#", "q")); + OWLAnonymousIndividual h = AnonymousIndividual(); + OWLAnonymousIndividual i = AnonymousIndividual(); + return set(AnnotationAssertion(p, a.getIRI(), h), ClassAssertion(a, h), + ObjectPropertyAssertion(q, h, i), + AnnotationAssertion(RDFSLabel(), h, Literal("Second", "en"))); + } + + private static List anonymousIndividualRoundtrip() { + OWLAnonymousIndividual ind = AnonymousIndividual(); + OWLClass cls = Class(iri("A")); + OWLAnnotationProperty prop = AnnotationProperty(iri("prop")); + OWLAnnotationAssertionAxiom ax = AnnotationAssertion(prop, cls.getIRI(), ind); + OWLObjectProperty p = ObjectProperty(iri("p")); + OWLAnonymousIndividual anon1 = AnonymousIndividual(); + OWLAnonymousIndividual anon2 = AnonymousIndividual(); + OWLNamedIndividual ind1 = NamedIndividual(iri("j")); + OWLNamedIndividual ind2 = NamedIndividual(iri("i")); + return set(ax, Declaration(cls), Declaration(p), + df.getOWLObjectPropertyAssertionAxiom(p, ind1, ind2), + df.getOWLObjectPropertyAssertionAxiom(p, anon1, anon1), + df.getOWLObjectPropertyAssertionAxiom(p, anon2, ind2), + df.getOWLObjectPropertyAssertionAxiom(p, ind2, anon2)); + } + + static final List FILE_ROUND_TRIP = Arrays.asList("AnnotatedPropertyAssertions.rdf", + "ComplexSubProperty.rdf", "DataAllValuesFrom.rdf", "cardinalitywithwhitespace.owl", + "DataComplementOf.rdf", "DataHasValue.rdf", "DataIntersectionOf.rdf", + "DataMaxCardinality.rdf", "DataMinCardinality.rdf", "DataOneOf.rdf", + "DataSomeValuesFrom.rdf", "DataUnionOf.rdf", "DatatypeRestriction.rdf", + "TestDeclarations.rdf", "Deprecated.rdf", "DisjointClasses.rdf", "HasKey.rdf", + "InverseOf.rdf", "ObjectAllValuesFrom.rdf", "ObjectCardinality.rdf", + "ObjectComplementOf.rdf", "ObjectHasSelf.rdf", "ObjectHasValue.rdf", + "ObjectIntersectionOf.rdf", "ObjectMaxCardinality.rdf", "ObjectMaxQualifiedCardinality.rdf", + "ObjectMinCardinality.rdf", "ObjectMinQualifiedCardinality.rdf", "ObjectOneOf.rdf", + "ObjectQualifiedCardinality.rdf", "ObjectSomeValuesFrom.rdf", "ObjectUnionOf.rdf", + "primer.functionalsyntax.txt", "primer.owlxml.xml", "primer.rdfxml.xml", "RDFSClass.rdf", + "koala.owl", "SubClassOf.rdf", "TestParser06.rdf", "TestParser07.rdf", "TestParser10.rdf", + "annotatedpropertychain.ttl.rdf", "UntypedSubClassOf.rdf", "SubClassOfUntypedOWLClass.rdf", + "SubClassOfUntypedSomeValuesFrom.rdf"); + + static List fileRoundTripOnly() { + return FILE_ROUND_TRIP; + } + + static List fileRoundTrip() { + List list = new ArrayList<>(); + FILE_ROUND_TRIP.forEach(file -> formats().forEach(f -> list.add(Arguments.of(file, f)))); + // use a different equal method + Arrays + .asList("extraBlankNodes.owl", "testBlankNodes2.ttl", "testBlankNodesAssertions.ttl", + "owlxml_anonloop.owx") + .forEach(file -> formats().forEach(f -> list.add(Arguments.of(file, f)))); + + return list; + } + + static List roundTrip() { + List list = new ArrayList<>(); + literalWithEscapesNoRioRDFXMLTestCase() + .forEach(axioms -> formats().forEach(f -> list.add(Arguments.of(axioms, f)))); + axiomsRoundTrippingTestCase() + .forEach(axioms -> formats().forEach(f -> list.add(Arguments.of(axioms, f)))); + axiomsRoundTrippingWithEntitiesTestCase() + .forEach(axioms -> formats().forEach(f -> list.add(Arguments.of(axioms, f)))); + relativeURITestCase() + .forEach(axioms -> formats().forEach(f -> list.add(Arguments.of(axioms, f)))); + axiomsRoundTrippingNoManchesterSyntaxTestCase() + .forEach(axioms -> formatsSkip(ManchesterSyntaxDocumentFormat.class) + .forEach(f -> list.add(Arguments.of(axioms, f)))); + return list; + } + + static List fileRoundTripNoManSyntax() { + List list = new ArrayList<>(); + Arrays.asList("AnonymousInverses.rdf", "TestParser08.rdf", "nodeid.rdf") + .forEach(file -> formatsSkip(ManchesterSyntaxDocumentFormat.class) + .forEach(f -> list.add(Arguments.of(file, f)))); + return list; + } + + @ParameterizedTest + @MethodSource({"fileRoundTrip", "fileRoundTripNoManSyntax"}) + void fileRoundTripTestCase(String fileName, OWLDocumentFormat f) { + roundTrip(loadOntology(fileName), f); + } + + @Test + void fileRoundTripSubClassOfUntypedOWLClassStrictTestCase() + throws OWLOntologyCreationException { + config = config.setStrict(true); + URL url = getClass().getResource("/SubClassOfUntypedOWLClass.rdf"); + OWLOntology ont = m.loadOntologyFromOntologyDocument( + new IRIDocumentSource(IRI.create(url), null, null), config.setReportStackTraces(true)); + assertEquals(0, ont.axioms(AxiomType.SUBCLASS_OF).count()); + OWLDocumentFormat format = ont.getFormat(); + assertTrue(format instanceof RDFXMLDocumentFormat); + RDFXMLDocumentFormat rdfxmlFormat = (RDFXMLDocumentFormat) format; + assertTrue(rdfxmlFormat.getOntologyLoaderMetaData().isPresent()); + Stream triples = + rdfxmlFormat.getOntologyLoaderMetaData().get().getUnparsedTriples(); + assertEquals(1, triples.count()); + } + + // ongoing work to use OBO as one of the roundtripping formats + // @Test + // void testOBO(OWLOntology o) throws Exception { + // createOntology.applyChange(new SetOntologyID(o, + // IRI.create("http://purl.obolibrary.org/obo/test.owl"))); + // StringDocumentTarget saveOntology = + // saveOntology(o, new FunctionalSyntaxDocumentFormat()); + // String s = saveOntology.toString() + // // + // .replace("http://www.semanticweb.org/owlapi/test#", + // "http://purl.obolibrary.org/obo/test#") + // // + // .replace("http://www.semanticweb.org/ontologies/declarations#", + // "http://purl.obolibrary.org/obo/test#") + // // + // .replace("http://www.semanticweb.org/ontologies/test/annotationont#", + // "http://purl.obolibrary.org/obo/test#"); + // createOntology = loadOntologyFromString(s, new FunctionalSyntaxDocumentFormat()); + // createOntology.removeAxioms(asList(createOntology.axioms(AxiomType.CLASS_ASSERTION) + // .filter(ax -> ax.getClassExpression().isOWLThing()))); + // OBODocumentFormat format = new OBODocumentFormat(); + // StringDocumentTarget target = saveOntology(createOntology, format); + // OWLOntology o1 = loadOntologyFromString(target, format); + // createOntology.removeAxioms(asList(createOntology.axioms(AxiomType.CLASS_ASSERTION).filter( + // ax -> ax.getClassExpression().isOWLThing() || ax.getIndividual().isAnonymous()))); + // o1.removeAxioms(asList(o1.axioms(AxiomType.CLASS_ASSERTION).filter( + // ax -> ax.getClassExpression().isOWLThing() || ax.getIndividual().isAnonymous()))); + // OWLAnnotationProperty version = df.getOWLAnnotationProperty( + // "http://www.geneontology.org/formats/oboInOwl#hasOBOFormatVersion"); + // OWLAnnotationProperty id = + // df.getOWLAnnotationProperty("http://www.geneontology.org/formats/oboInOwl#id"); + // createOntology.remove(asList(createOntology.axioms(AxiomType.ANNOTATION_ASSERTION))); + // o1.remove(asList(o1.axioms(AxiomType.ANNOTATION_ASSERTION))); + // o1.applyChanges(asList(o1.annotations().filter(a -> a.getProperty().equals(version)) + // .map(a -> new RemoveOntologyAnnotation(o1, a)))); + // createOntology.remove(asList(createOntology.axioms(AxiomType.DECLARATION))); + // o1.remove(asList(o1.axioms(AxiomType.DECLARATION))); + // System.out.println("TestBase.roundTripOntology() ont1 " + createOntology.getOntologyID()); + // createOntology.axioms().forEach(System.out::println); + // System.out.println("TestBase.roundTripOntology() \n" + target); + // System.out.println("TestBase.roundTripOntology() ont2 " + o1.getOntologyID()); + // o1.axioms().forEach(System.out::println); + // + // equal(createOntology, o1); + // } + + @ParameterizedTest + @MethodSource("roundTrip") + void roundTripFormats(List axioms, OWLDocumentFormat f) { + roundTripOntology(o(axioms), f); + } + + @ParameterizedTest + @MethodSource({"literalWithEscapesNoRioRDFXMLTestCase", + "axiomsRoundTrippingNoManchesterSyntaxTestCase", "axiomsRoundTrippingTestCase", + "axiomsRoundTrippingWithEntitiesTestCase", "relativeURITestCase", "xmlAndFunctional"}) + void roundTripRDFXMLAndFunctionalShouldBeSame(List axioms) { + plainEqual(o(axioms), true); + } + + @ParameterizedTest + @MethodSource("fileRoundTripOnly") + @ValueSource(strings = {"AnonymousInverses.rdf", "TestParser08.rdf", "nodeid.rdf"}) + void roundTripRDFXMLAndFunctionalShouldBeSame(String name) { + plainEqual(loadOntology(name), true); + } + + protected void plainEqual(OWLOntology ont, boolean compareInput) { + OWLOntology o1 = roundTrip(ont, new RDFXMLDocumentFormat()); + OWLOntology o2 = roundTrip(ont, new FunctionalSyntaxDocumentFormat()); + if (compareInput) { + equal(ont, o1); + } + equal(o1, o2); + } + + public void testKRSS2(OWLOntology o) { + roundTripOntology(o, new KRSS2DocumentFormat()); + } + + public void testKRSS(OWLOntology o) { + roundTripOntology(o, new KRSS2DocumentFormat()); + } + + public void testDLSyntax(OWLOntology o) { + roundTripOntology(o, new DLSyntaxDocumentFormat()); + } + + protected OWLOntology createOntology(String fileName, OWLDocumentFormat f) { + OWLOntology o = ontologyFromClasspathFile(fileName, f); + if (logger.isTraceEnabled()) { + logger.trace("ontology as parsed from input file:"); + o.axioms().forEach(ax -> logger.trace(ax.toString())); + } + return o; + } + + @ParameterizedTest + @MethodSource("formats") + void literalWithEscapesTestCase(OWLDocumentFormat f) { + if (RioRDFXMLDocumentFormat.class.isInstance(f)) { + // Rio normalizes literals differently, got its own test + return; + } + + List axioms = literalWithEscapes(); + OWLOntology o = getOWLOntology(); + o.add(axioms); + roundTrip(o, f); + } + + protected static List literalWithEscapes() { + OWLClass cls = Class(IRI("http://owlapi.sourceforge.net/ontology#", "A")); + OWLAnnotationProperty prop = + AnnotationProperty(IRI("http://owlapi.sourceforge.net/ontology#", "prop")); + List axioms = set(AnnotationAssertion(prop, cls.getIRI(), Literal("\\")), + AnnotationAssertion(prop, cls.getIRI(), Literal("Start" + "\\")), + AnnotationAssertion(prop, cls.getIRI(), Literal("\\" + "End")), + AnnotationAssertion(prop, cls.getIRI(), Literal("Start" + "\\" + "End")), + + AnnotationAssertion(prop, cls.getIRI(), Literal("\"")), + AnnotationAssertion(prop, cls.getIRI(), Literal("Start" + "\"")), + AnnotationAssertion(prop, cls.getIRI(), Literal("\"" + "End")), + AnnotationAssertion(prop, cls.getIRI(), Literal("Start" + "\"" + "End")), + + AnnotationAssertion(prop, cls.getIRI(), Literal("<")), + AnnotationAssertion(prop, cls.getIRI(), Literal("Start" + "<")), + AnnotationAssertion(prop, cls.getIRI(), Literal("<" + "End")), + AnnotationAssertion(prop, cls.getIRI(), Literal("Start" + "<" + "End")), + + AnnotationAssertion(prop, cls.getIRI(), Literal("\n")), + AnnotationAssertion(prop, cls.getIRI(), Literal("Start" + "\n")), + AnnotationAssertion(prop, cls.getIRI(), Literal("\n" + "End")), + AnnotationAssertion(prop, cls.getIRI(), Literal("Start" + "\n" + "End")), + + AnnotationAssertion(prop, cls.getIRI(), Literal("\'")), + AnnotationAssertion(prop, cls.getIRI(), Literal("Start" + "\'")), + AnnotationAssertion(prop, cls.getIRI(), Literal("\'" + "End")), + AnnotationAssertion(prop, cls.getIRI(), Literal("Start" + "\'" + "End")), + Declaration(cls)); + return axioms; + } + + @ParameterizedTest + @MethodSource("formats") + void ontologyAnnotationsTestCase(OWLDocumentFormat f) { + if (RDFJsonDocumentFormat.class.isInstance(f)) { + // XXX RDFJsonDocumentFormat ignored. The parser parses the annotation correctly but it + // is not + // associated to the ontology. + return; + } + roundTrip(ontologyAnnotation(), f); + } + + protected OWLOntology ontologyAnnotation() { + OWLOntology ont = getOWLOntology(); + OWLAnnotationProperty prop = AnnotationProperty( + IRI("http://www.semanticweb.org/ontologies/test/annotationont#", "prop")); + OWLLiteral value = Literal(33); + OWLAnnotation annotation = Annotation(prop, value); + OWLAnnotation builtin = Annotation(df.getOWLVersionInfo(), df.getOWLLiteral("x")); + ont.applyChange(new AddOntologyAnnotation(ont, annotation)); + ont.applyChange(new AddOntologyAnnotation(ont, builtin)); + ont.addAxiom(Declaration(prop)); + return ont; + } + + @Test + void roundTripRDFXMLAndFunctionalShouldBeSameOntologyAnnotation() { + plainEqual(ontologyAnnotation(), true); + } + + @Test + void testCorrectOntologyIRI() { + OWLOntology ont = + loadOntologyFromString(ONTOLOGY_IRI_TEST_CASE, new RDFXMLDocumentFormat()); + OWLOntologyID id = ont.getOntologyID(); + assertEquals("http://www.test.com/right.owl", id.getOntologyIRI().get().toString()); + } + + @ParameterizedTest + @MethodSource("formats") + void ontologyIRITestCase(OWLDocumentFormat f) { + roundTrip(loadOntologyFromString(ONTOLOGY_IRI_TEST_CASE, new RDFXMLDocumentFormat()), f); + } + + @Test + void roundTripRDFXMLAndFunctionalShouldBeSameOntologyIRI() { + plainEqual(loadOntologyFromString(ONTOLOGY_IRI_TEST_CASE, new RDFXMLDocumentFormat()), + true); + } + + @ParameterizedTest + @MethodSource("formats") + void ontologyVersionIRITestCase(OWLDocumentFormat f) { + roundTrip(ontologyVersion(), f); + } + + protected OWLOntology ontologyVersion() { + IRI ontIRI = IRI("http://www.semanticweb.org/owlapi/", "ontology"); + IRI versionIRI = IRI("http://www.semanticweb.org/owlapi/ontology/", "version"); + OWLOntologyID ontologyID = new OWLOntologyID(optional(ontIRI), optional(versionIRI)); + return getOWLOntology(ontologyID); + } + + @Test + void roundTripRDFXMLAndFunctionalShouldBeSameOntologyVersion() { + plainEqual(ontologyVersion(), true); + } + + @ParameterizedTest + @MethodSource("formats") + void threeLayersOfAnnotationsTestCase(OWLDocumentFormat f) { + if (ManchesterSyntaxDocumentFormat.class.isInstance(f)) { + // not supported in Manchester syntax + return; + } + roundTrip(threeLayersOfAnnotations(), f); + } + + @Test + void roundTripRDFXMLAndFunctionalShouldBeSamethreeLayersAnnotations() { + plainEqual(threeLayersOfAnnotations(), true); + } + + protected OWLOntology threeLayersOfAnnotations() { + OWLOntology o = getOWLOntology(iri("urn:nested:", "ontology")); + OWLClass dbxref = df.getOWLClass(iri("urn:obo:", "DbXref")); + OWLClass definition = df.getOWLClass(iri("urn:obo:", "Definition")); + OWLObjectProperty adjacent_to = df.getOWLObjectProperty(iri("urn:obo:", "adjacent_to")); + OWLAnnotationProperty hasDefinition = + df.getOWLAnnotationProperty(iri("urn:obo:", "hasDefinition")); + OWLAnnotationProperty hasdbxref = df.getOWLAnnotationProperty(iri("urn:obo:", "hasDbXref")); + OWLDataProperty hasuri = df.getOWLDataProperty(iri("urn:obo:", "hasURI")); + OWLAnonymousIndividual ind1 = df.getOWLAnonymousIndividual(); + o.add(df.getOWLClassAssertionAxiom(dbxref, ind1)); + o.add(df.getOWLDataPropertyAssertionAxiom(hasuri, ind1, + df.getOWLLiteral("urn:SO:SO_ke", OWL2Datatype.XSD_ANY_URI))); + OWLAnonymousIndividual ind2 = df.getOWLAnonymousIndividual(); + o.add(df.getOWLClassAssertionAxiom(definition, ind2)); + o.add(df.getOWLAnnotationAssertionAxiom(hasdbxref, ind2, ind1)); + o.add(df.getOWLAnnotationAssertionAxiom(hasDefinition, adjacent_to.getIRI(), ind2)); + return o; + } + + //@formatter:off + private static final String original = "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " comment for one\n" + + " \n" + + " \n" + + " one\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " comment for two\n" + + " \n" + + " \n" + + " two\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " comment for three\n" + + " \n" + + " \n" + + " three\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; + + //@formatter:on + @ParameterizedTest + @MethodSource("formats") + void roundTripOWLXMLToRioTurtleTestCase(OWLDocumentFormat f) { + roundTrip(loadOntologyFromString(original, new OWLXMLDocumentFormat()), f); + } + + @Test + void roundTripRDFXMLAndFunctionalShouldBeSameOWLXMLToTurtle() { + plainEqual(loadOntologyFromString(original, new OWLXMLDocumentFormat()), true); + } + + @Test + void shouldRoundTripThroughOWLXML() { + OWLOntology ontology = original(); + StringDocumentTarget targetOWLXML = saveOntology(ontology, new OWLXMLDocumentFormat()); + OWLOntology o1 = loadOntologyFromString(targetOWLXML, new OWLXMLDocumentFormat()); + equal(ontology, o1); + } + + protected OWLOntology original() { + return loadOntologyFromString(original, new OWLXMLDocumentFormat()); + } + + @Test + void shouldRoundTripThroughOWLXMLOrTurtle() { + OWLOntology ontology = original(); + OWLOntology o1 = roundTrip(ontology, new RioTurtleDocumentFormat()); + equal(ontology, o1); + OWLOntology o2 = roundTrip(o1, new OWLXMLDocumentFormat()); + equal(o2, o1); + } + + @Test + void shouldRoundTripThroughOWLXMLToTurtle() { + OWLOntology ontology = original(); + StringDocumentTarget targetTTL = saveOntology(ontology, new TurtleDocumentFormat()); + StringDocumentTarget targetTTLFromTTL = saveOntology(ontology, new TurtleDocumentFormat()); + assertEquals(targetTTL.toString(), targetTTLFromTTL.toString()); + } + + @Test + void shouldRoundTripThroughOWLXMLToRioTurtle() { + OWLOntology ontology = original(); + StringDocumentTarget target1 = saveOntology(ontology, new RioTurtleDocumentFormat()); + StringDocumentTarget target2 = saveOntology(ontology, new RioTurtleDocumentFormat()); + assertEquals(target1.toString().replaceAll("_:genid[0-9]+", "_:genid"), + target2.toString().replaceAll("_:genid[0-9]+", "_:genid")); + } + + protected OWLOntology o(OWLAxiom a) { + OWLOntology ont = getOWLOntology(); + ont.add(a); + ont.unsortedSignature().filter(e -> !e.isBuiltIn() && !ont.isDeclared(e, INCLUDED)) + .forEach(e -> ont.add(Declaration(e))); + return ont; + } + + protected OWLOntology o(Collection a) { + OWLOntology ont = getOWLOntology(); + ont.add(a); + ont.unsortedSignature().filter(e -> !e.isBuiltIn() && !ont.isDeclared(e, INCLUDED)) + .forEach(e -> ont.add(Declaration(e))); + return ont; + } + + static List> axiomsRoundTrippingNoManchesterSyntaxTestCase() { + // no valid Manchester OWL Syntax roundtrip + OWLObjectPropertyExpression p = ObjectProperty(iri("p")).getInverseProperty(); + OWLObjectPropertyExpression q = ObjectProperty(iri("q")).getInverseProperty(); + OWLClass clsA = Class(iri("A")); + return Arrays.asList(set(AsymmetricObjectProperty(p)), + set(EquivalentObjectProperties(p, q)), set(FunctionalObjectProperty(p)), + set(InverseFunctionalObjectProperty(p)), set(IrreflexiveObjectProperty(p)), + set(ObjectPropertyDomain(p, clsA)), set(ObjectPropertyRange(p, clsA)), + set(ReflexiveObjectProperty(p)), set(SubObjectPropertyOf(p, q)), + set(SymmetricObjectProperty(p)), set(TransitiveObjectProperty(p))); + } + + static List> axiomsRoundTrippingTestCase() { + String HTTP_WWW_OWLAPI = "http://www.owlapi#"; + IRI iriA = iri("A"); + OWLClass clsA = Class(iriA); + OWLClass clsB = Class(iri("B")); + OWLDataProperty dp = DataProperty(iri("p")); + OWLDataProperty dq = DataProperty(iri("q")); + OWLObjectProperty op = ObjectProperty(iri("op")); + OWLObjectProperty oq = ObjectProperty(iri("oq")); + OWLDataProperty dpA = DataProperty(iri("dpropA")); + OWLDataProperty dpB = DataProperty(iri("dpropB")); + OWLDataProperty dpC = DataProperty(iri("dpropC")); + OWLObjectProperty propA = ObjectProperty(iri("propA")); + OWLObjectProperty propB = ObjectProperty(iri("propB")); + OWLObjectProperty propC = ObjectProperty(iri("propC")); + OWLObjectProperty propD = ObjectProperty(iri("propD")); + OWLAnnotationProperty apropA = AnnotationProperty(iri("apropA")); + OWLAnnotationProperty apropB = AnnotationProperty(iri("apropB")); + OWLNamedIndividual ind = NamedIndividual(iri("i")); + OWLNamedIndividual indj = NamedIndividual(iri("j")); + OWLEntity peter = NamedIndividual(IRI("http://www.another.com/ont#", "peter")); + OWLAnnotation ann1 = Annotation(RDFSLabel(), Literal("Annotation 1")); + OWLAnnotation ann2 = Annotation(RDFSLabel(), Literal("Annotation 2")); + OWLAnnotation eAnn1 = Annotation(RDFSLabel(), Literal("EntityAnnotation 1")); + OWLAnnotation eAnn2 = Annotation(RDFSLabel(), Literal("EntityAnnotation 2")); + OWLDatatype datatype = Datatype(IRI("http://www.ont.com/myont/", "mydatatype")); + OWLAnnotation annoOuterOuter1 = Annotation(AnnotationProperty(iri("myOuterOuterLabel1")), + Literal("Outer Outer label 1")); + OWLAnnotation annoOuterOuter2 = Annotation(AnnotationProperty(iri("myOuterOuterLabel2")), + Literal("Outer Outer label 2")); + OWLDatatype dt = Datatype(IRI("file:/c/test.owlapi#", "SSN")); + OWLFacetRestriction fr = + FacetRestriction(OWLFacet.PATTERN, Literal("[0-9]{3}-[0-9]{2}-[0-9]{4}")); + OWLDataRange dr = + DatatypeRestriction(Datatype(IRI("http://www.w3.org/2001/XMLSchema#", "string")), fr); + OWLDataIntersectionOf disj1 = DataIntersectionOf(DataComplementOf(dr), dt); + OWLDataIntersectionOf disj2 = DataIntersectionOf(DataComplementOf(dt), dr); + OWLAnnotation annoOuter = Annotation(AnnotationProperty(iri("myOuterLabel")), + Literal("Outer label"), annoOuterOuter1, annoOuterOuter2); + OWLAnnotation annoInner = + Annotation(AnnotationProperty(iri("myLabel")), Literal("Label"), annoOuter); + + List> list = new ArrayList<>(); + list.add(swrlRuleAlternateNS(HTTP_WWW_OWLAPI, dp, op, ind, indj)); + list.add(swrlRule()); + list.add(set(SubPropertyChainOf(Arrays.asList(propA, propB, propC), propD))); + list.add(set(AsymmetricObjectProperty(op))); + list.add(set(DifferentIndividuals(createIndividual(), createIndividual(), + createIndividual(), createIndividual(), createIndividual(), createIndividual(), + createIndividual(), createIndividual(), createIndividual(), createIndividual()))); + list.add(set(SubClassOf(clsA, ObjectSomeValuesFrom(op, ObjectSomeValuesFrom(op, clsB))), + Declaration(clsA), Declaration(clsB))); + list.add(set(Declaration(RDFSLabel()), Declaration(peter), + AnnotationAssertion(RDFSLabel(), peter.getIRI(), Literal("X", "en"), ann1, ann2))); + list.add(set(Declaration(RDFSLabel()), Declaration(peter, eAnn1, eAnn2), + AnnotationAssertion(RDFSLabel(), peter.getIRI(), Literal("X", "en"), ann1, ann2))); + list.add(set(InverseObjectProperties(oq, op))); + list.add(set(InverseObjectProperties(op, oq))); + list.add(set(Declaration(clsA), AnnotationAssertion(apropA, clsA.getIRI(), + IRI("http://www.semanticweb.org/owlapi#", "object")))); + list.add(set(SubClassOf(clsA, clsB, singleton(annoInner)))); + list.add(set(AnnotationPropertyDomain(RDFSComment(), iriA))); + list.add(set(AnnotationPropertyRange(RDFSComment(), iriA))); + list.add(set(SubAnnotationPropertyOf(apropA, RDFSLabel()))); + list.add(set(SubClassOf(clsA, DataMaxCardinality(3, dp, Integer())))); + list.add(set(SubClassOf(clsA, DataMinCardinality(3, dp, Integer())))); + list.add(set(SubClassOf(clsA, DataExactCardinality(3, dp, Integer())))); + list.add(set(DataPropertyRange(dp, DataUnionOf(disj1, disj2)))); + list.add(set( + HasKey(singleton(Annotation(apropA, Literal("Test", ""))), clsA, propA, propB, propC), + Declaration(apropA), Declaration(propA), Declaration(propB), Declaration(propC))); + list.add( + set(DisjointClasses(asUnorderedSet(Stream.generate(() -> createClass()).limit(6000))))); + list.add(set(SubClassOf(clsB, ObjectSomeValuesFrom(op.getInverseProperty(), clsA)))); + list.add(set(SubDataPropertyOf(dp, dq))); + list.add(set(DataPropertyAssertion(dp, ind, Literal(33.3)))); + list.add(set(NegativeDataPropertyAssertion(dp, ind, Literal(33.3)), + NegativeDataPropertyAssertion(dp, ind, Literal("weasel", "")), + NegativeDataPropertyAssertion(dp, ind, Literal("weasel")))); + list.add(set(FunctionalDataProperty(dp))); + list.add(set(DataPropertyDomain(dp, Class(iri("A"))))); + list.add(set(DataPropertyRange(dp, TopDatatype()))); + list.add(set(DisjointDataProperties(dpA, dpB, dpC), Declaration(dpA), Declaration(dpB), + Declaration(dpC))); + list.add(set(DisjointDataProperties(dpA, dpB))); + list.add(set(EquivalentDataProperties(dp, dq))); + list.add(set(AsymmetricObjectProperty(op))); + list.add( + set(DatatypeDefinition(datatype, DataComplementOf(Integer())), Declaration(datatype))); + list.add(set(DifferentIndividuals(ind, indj), + DifferentIndividuals(ind, NamedIndividual(iri("k"))))); + list.add(set( + DifferentIndividuals(ind, indj, NamedIndividual(iri("k")), NamedIndividual(iri("l"))))); + list.add(set(DisjointObjectProperties(propA, propB, propC), Declaration(propA), + Declaration(propB), Declaration(propC))); + list.add(set(DisjointObjectProperties(propA, propB))); + list.add( + set(EquivalentObjectProperties(propA, propB), Declaration(propA), Declaration(propB))); + list.add(set(FunctionalObjectProperty(op))); + list.add(set(InverseFunctionalObjectProperty(op))); + list.add(set(IrreflexiveObjectProperty(op))); + list.add(set(DifferentIndividuals( + asUnorderedSet(Stream.generate(() -> createIndividual()).limit(1000))))); + list.add(set(AnnotationAssertion(apropA, clsA.getIRI(), Literal("abc", "en")), + Declaration(clsA))); + list.add(set(AnnotationAssertion(apropA, iriA, Literal("abc", "en")), + AnnotationAssertion(apropA, iriA, Literal("abcd", "")), + AnnotationAssertion(apropA, iriA, Literal("abcde")), + AnnotationAssertion(apropA, iriA, Literal("abcdef", OWL2Datatype.XSD_STRING)), + Declaration(clsA))); + list.add(set(NegativeObjectPropertyAssertion(op, ind, indj))); + list.add(set(ObjectPropertyAssertion(op, ind, indj))); + list.add(set(SubPropertyChainOf(Arrays.asList(propA, propB, propC), propD, set( + Annotation(apropA, Literal("Test", "en")), Annotation(apropB, Literal("Test", "")))))); + list.add(set(ObjectPropertyDomain(op, clsA))); + list.add(set(ObjectPropertyRange(op, clsA))); + list.add(set(Declaration(Class(IRI("http://www.test.com/ontology#", "Class%37A"))), + Declaration(ObjectProperty(IRI("http://www.test.com/ontology#", "prop%37A"))))); + list.add(set(ReflexiveObjectProperty(op))); + list.add(set(SameIndividual(ind, indj))); + list.add(set(DataPropertyAssertion(dp, ind, Literal("Test \"literal\"\nStuff")))); + list.add(set(DataPropertyAssertion(dp, ind, Literal("Test \"literal\"")), + DataPropertyAssertion(dp, ind, Literal("Test 'literal'")), + DataPropertyAssertion(dp, ind, Literal("Test \"\"\"literal\"\"\"")))); + list.add(set(SubObjectPropertyOf(op, oq))); + list.add(set(SymmetricObjectProperty(op))); + list.add(set(TransitiveObjectProperty(op))); + list.add(set(DataPropertyAssertion(dp, ind, Literal(3)), + DataPropertyAssertion(dp, ind, Literal(33.3)), + DataPropertyAssertion(dp, ind, Literal(true)), + DataPropertyAssertion(dp, ind, Literal(33.3f)), + DataPropertyAssertion(dp, ind, Literal("33.3")))); + return list; + } + + protected static List swrlRule() { + String HTTP_WWW_OWLAPI = "http://www.owlapi#"; + OWLDataProperty dp = DataProperty(iri("p")); + OWLObjectProperty op = ObjectProperty(iri("op")); + OWLNamedIndividual ind = NamedIndividual(iri("i")); + OWLNamedIndividual indj = NamedIndividual(iri("j")); + + String URN_SWRL_VAR = "urn:swrl:var#"; + SWRLVariable varX = df.getSWRLVariable(URN_SWRL_VAR, "x"); + SWRLVariable varY = df.getSWRLVariable(URN_SWRL_VAR, "y"); + SWRLVariable varZ = df.getSWRLVariable(URN_SWRL_VAR, "z"); + Set body = new HashSet<>(); + body.add(df.getSWRLClassAtom(Class(iri("A")), varX)); + SWRLIndividualArgument indIArg = df.getSWRLIndividualArgument(ind); + SWRLIndividualArgument indJArg = df.getSWRLIndividualArgument(indj); + body.add(df.getSWRLClassAtom(Class(iri("D")), indIArg)); + body.add(df.getSWRLClassAtom(Class(iri("B")), varX)); + SWRLVariable varQ = df.getSWRLVariable(URN_SWRL_VAR, "q"); + SWRLVariable varR = df.getSWRLVariable(URN_SWRL_VAR, "r"); + body.add(df.getSWRLDataPropertyAtom(dp, varX, varQ)); + OWLLiteral lit = Literal(33); + SWRLLiteralArgument litArg = df.getSWRLLiteralArgument(lit); + body.add(df.getSWRLDataPropertyAtom(dp, varY, litArg)); + Set head = new HashSet<>(); + head.add(df.getSWRLClassAtom(Class(iri("C")), varX)); + head.add(df.getSWRLObjectPropertyAtom(op, varY, varZ)); + head.add(df.getSWRLSameIndividualAtom(varX, varY)); + head.add(df.getSWRLSameIndividualAtom(indIArg, indJArg)); + head.add(df.getSWRLDifferentIndividualsAtom(varX, varZ)); + head.add(df.getSWRLDifferentIndividualsAtom(varX, varZ)); + head.add(df.getSWRLDifferentIndividualsAtom(indIArg, indJArg)); + OWLObjectSomeValuesFrom svf = ObjectSomeValuesFrom(op, Class(iri("A"))); + head.add(df.getSWRLClassAtom(svf, varX)); + List args = new ArrayList<>(); + args.add(varQ); + args.add(varR); + args.add(litArg); + head.add(df.getSWRLBuiltInAtom(IRI(HTTP_WWW_OWLAPI, "myBuiltIn"), args)); + return set(df.getSWRLRule(body, head)); + } + + protected static List swrlRuleAlternateNS(String HTTP_WWW_OWLAPI, OWLDataProperty dp, + OWLObjectProperty op, OWLNamedIndividual ind, OWLNamedIndividual indj) { + SWRLVariable varX = df.getSWRLVariable(HTTP_WWW_OWLAPI, "x"); + SWRLVariable varY = df.getSWRLVariable(HTTP_WWW_OWLAPI, "y"); + SWRLVariable varZ = df.getSWRLVariable(HTTP_WWW_OWLAPI, "z"); + Set body = new HashSet<>(); + body.add(df.getSWRLClassAtom(Class(iri("A")), varX)); + SWRLIndividualArgument indIArg = df.getSWRLIndividualArgument(ind); + SWRLIndividualArgument indJArg = df.getSWRLIndividualArgument(indj); + body.add(df.getSWRLClassAtom(Class(iri("D")), indIArg)); + body.add(df.getSWRLClassAtom(Class(iri("B")), varX)); + SWRLVariable varQ = df.getSWRLVariable(HTTP_WWW_OWLAPI, "q"); + SWRLVariable varR = df.getSWRLVariable(HTTP_WWW_OWLAPI, "r"); + body.add(df.getSWRLDataPropertyAtom(dp, varX, varQ)); + OWLLiteral lit = Literal(33); + SWRLLiteralArgument litArg = df.getSWRLLiteralArgument(lit); + body.add(df.getSWRLDataPropertyAtom(dp, varY, litArg)); + Set head = new HashSet<>(); + head.add(df.getSWRLClassAtom(Class(iri("C")), varX)); + head.add(df.getSWRLObjectPropertyAtom(op, varY, varZ)); + head.add(df.getSWRLSameIndividualAtom(varX, varY)); + head.add(df.getSWRLSameIndividualAtom(indIArg, indJArg)); + head.add(df.getSWRLDifferentIndividualsAtom(varX, varZ)); + head.add(df.getSWRLDifferentIndividualsAtom(varX, varZ)); + head.add(df.getSWRLDifferentIndividualsAtom(indIArg, indJArg)); + OWLObjectSomeValuesFrom svf = ObjectSomeValuesFrom(op, Class(iri("A"))); + head.add(df.getSWRLClassAtom(svf, varX)); + List args = new ArrayList<>(); + args.add(varQ); + args.add(varR); + args.add(litArg); + head.add(df.getSWRLBuiltInAtom(IRI(HTTP_WWW_OWLAPI, "myBuiltIn"), args)); + return set(df.getSWRLRule(body, head)); + } + + static List> axiomsRoundTrippingWithEntitiesTestCase() { + IRI iriA = iri("A"); + OWLClass clsA = Class(iriA); + OWLAnnotationProperty apropA = AnnotationProperty(iri("apropA")); + OWLAnnotationProperty apropB = AnnotationProperty(iri("apropB")); + return Collections.singletonList( + set(Declaration(clsA), AnnotationAssertion(apropA, clsA.getIRI(), Literal("value1")), + AnnotationAssertion(apropB, clsA.getIRI(), Literal("value2")))); + } + + static List> relativeURITestCase() { + return Collections.singletonList( + set(Declaration(Class(IRI(IRI.getNextDocumentIRI(uriBase) + "/", "Office"))))); + } + + @Test + void shouldThrowMeaningfulException() { + OWLOntology ontology = getOWLOntology(); + RDFXMLParser parser = new RDFXMLParser(); + // on Java 6 for Mac the following assertion does not work: the root + // exception does not have a message. + // expectedException + // .expectMessage(" reason is: Illegal character in fragment at index + // 21: http://example.com/#1#2"); + assertThrows(OWLRDFXMLParserException.class, + () -> parser.parse(new StringDocumentSource(TestFiles.rdfContentForException), ontology, + config), + "[line=1:column=378] IRI 'http://example.com/#1#2' cannot be resolved against current base IRI "); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/AnnotatedAxiomRoundTripTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/AnnotatedAxiomRoundTripTestCase.java new file mode 100644 index 0000000000..a3877381a0 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/AnnotatedAxiomRoundTripTestCase.java @@ -0,0 +1,147 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.baseclasses; + +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.*; +import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.function.Consumer; +import java.util.function.Function; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.formats.*; +import org.semanticweb.owlapi.model.*; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +class AnnotatedAxiomRoundTripTestCase extends TestBase { + + OWLOntology annotatedAxiom(Function, OWLAxiom> f) { + + OWLAnnotationProperty prop = AnnotationProperty(iri("prop")); + OWLLiteral lit = Literal("Test", ""); + OWLAnnotation anno1 = Annotation(prop, lit); + OWLAnnotationProperty prop2 = AnnotationProperty(iri("prop2")); + OWLAnnotation anno2 = Annotation(prop2, lit); + Set annos = new HashSet<>(Arrays.asList(anno1, anno2)); + Set axioms = new HashSet<>(); + OWLAxiom ax = f.apply(annos); + axioms.add(ax.getAnnotatedAxiom(annos)); + axioms.add(Declaration(prop)); + axioms.add(Declaration(prop2)); + axioms.add(ax.getAnnotatedAxiom(singleton(anno1))); + axioms.add(ax.getAnnotatedAxiom(singleton(anno2))); + OWLOntology ont = getOWLOntology(); + ont.add(axioms); + ont.unsortedSignature().filter(e -> !e.isBuiltIn() && !ont.isDeclared(e, INCLUDED)) + .forEach(e -> ont.add(Declaration(e))); + return ont; + } + + static List, OWLAxiom>> annotatedAxiomRoundtripExceptManchesterSyntaxTestCase() { + return Arrays.asList(a -> Declaration(ObjectProperty(iri("propP")), a), + a -> Declaration(Datatype(iri("DT")), a), + a -> Declaration(NamedIndividual(iri("I")), a), + a -> Declaration(DataProperty(iri("propD")), a), + a -> Declaration(AnnotationProperty(iri("propA")), a), a -> Declaration(A, a)); + } + + static List, OWLAxiom>> annotatedAxiomRoundtripExceptRDFXMLAndFunctionalTestCase() { + return Arrays.asList(a -> EquivalentClasses(a, A, B, C, D), + a -> EquivalentDataProperties(a, DP, DQ, DR), + a -> EquivalentObjectProperties(a, P, Q, R)); + } + + static List, OWLAxiom>> annotatedAxiomRountripTestCase() { + return Arrays.asList(a -> AsymmetricObjectProperty(P, a), a -> ClassAssertion(A, I, a), + a -> DataPropertyAssertion(DP, I, Literal("xyz"), a), a -> DataPropertyDomain(DP, A, a), + a -> DataPropertyRange(DP, TopDatatype(), a), a -> DisjointClasses(a, A, B), + a -> DisjointClasses(a, A, B, C, D), a -> DisjointDataProperties(a, DP, DQ), + a -> DisjointDataProperties(a, DP, DQ, DR), a -> DisjointObjectProperties(a, P, Q), + a -> DisjointObjectProperties(a, P, Q, R), a -> EquivalentClasses(a, A, B), + a -> EquivalentDataProperties(a, DP, DQ), a -> EquivalentObjectProperties(a, P, Q), + a -> FunctionalDataProperty(DP, a), a -> FunctionalObjectProperty(P, a), + a -> InverseFunctionalObjectProperty(P, a), a -> IrreflexiveObjectProperty(P, a), + a -> NegativeDataPropertyAssertion(DP, I, Literal("xyz"), a), + a -> NegativeObjectPropertyAssertion(P, I, J, a), + a -> ObjectPropertyAssertion(P, I, J, a), a -> ObjectPropertyDomain(P, A, a), + a -> ObjectPropertyRange(P, A, a), a -> ReflexiveObjectProperty(P, a), + a -> df.getOWLSubClassOfAxiom(A, B, a), a -> SubDataPropertyOf(DP, DQ, a), + a -> SubObjectPropertyOf(P, Q, a), a -> SymmetricObjectProperty(P, a), + a -> TransitiveObjectProperty(P, a), + a -> SubPropertyChainOf(Arrays.asList(P, Q), R, a), + a -> DifferentIndividuals(Arrays.asList(i, I, J), a), + a -> DifferentIndividuals(Arrays.asList(I, J), a), + a -> DifferentIndividuals(Arrays.asList(i, I, J), a), + a -> DifferentIndividuals(Arrays.asList(I, J), a)); + } + + static List, OWLAxiom>> individualsAxiomAnnotatedTestCase() { + return Arrays.asList( + a -> df.getOWLSameIndividualAxiom( + Arrays.asList(NamedIndividual(iri("A")), NamedIndividual(iri("B"))), a), + a -> df.getOWLDifferentIndividualsAxiom(Arrays.asList(NamedIndividual(iri("A")), + NamedIndividual(iri("B")), NamedIndividual(iri("C"))), a), + a -> df.getOWLSameIndividualAxiom( + Arrays.asList(NamedIndividual(iri("A")), NamedIndividual(iri("B"))), a)); + } + + static List annotatedOntologies() { + List list = new ArrayList<>(); + List formats = Arrays.asList(new RDFXMLDocumentFormat(), + new RioRDFXMLDocumentFormat(), new RDFJsonDocumentFormat(), new OWLXMLDocumentFormat(), + new FunctionalSyntaxDocumentFormat(), new TurtleDocumentFormat(), + new RioTurtleDocumentFormat(), new TrigDocumentFormat(), new RDFJsonLDDocumentFormat(), + new NTriplesDocumentFormat(), new NQuadsDocumentFormat()); + Consumer, OWLAxiom>> action = + x -> formats.forEach(f -> list.add(Arguments.of(x, f))); + annotatedAxiomRountripTestCase().forEach(action); + annotatedAxiomRoundtripExceptManchesterSyntaxTestCase().forEach(action); + annotatedAxiomRoundtripExceptRDFXMLAndFunctionalTestCase().forEach(action); + individualsAxiomAnnotatedTestCase().forEach(action); + return list; + } + + @ParameterizedTest + @MethodSource({"annotatedOntologies"}) + void testRDFXML(Function, OWLAxiom> f, OWLDocumentFormat d) { + roundTripOntology(annotatedAxiom(f), d); + } + + @ParameterizedTest + @MethodSource({"annotatedAxiomRountripTestCase", "individualsAxiomAnnotatedTestCase", + "annotatedAxiomRoundtripExceptRDFXMLAndFunctionalTestCase"}) + void testManchesterOWLSyntax(Function, OWLAxiom> f) { + roundTripOntology(annotatedAxiom(f), new ManchesterSyntaxDocumentFormat()); + } + + @ParameterizedTest + @MethodSource({"annotatedAxiomRountripTestCase", "individualsAxiomAnnotatedTestCase", + "annotatedAxiomRoundtripExceptManchesterSyntaxTestCase"}) + void roundTripRDFXMLAndFunctionalShouldBeSame(Function, OWLAxiom> f) { + OWLOntology o = annotatedAxiom(f); + OWLOntology o1 = roundTrip(o, new RDFXMLDocumentFormat()); + OWLOntology o2 = roundTrip(o, new FunctionalSyntaxDocumentFormat()); + equal(o, o1); + equal(o1, o2); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/LiteralWithStringTypeRoundTripTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/LiteralWithStringTypeRoundTripTestCase.java new file mode 100644 index 0000000000..d707952248 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/LiteralWithStringTypeRoundTripTestCase.java @@ -0,0 +1,85 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.baseclasses; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Arrays; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.3.0 + */ +class LiteralWithStringTypeRoundTripTestCase extends TestBase { + + protected OWLOntology literalWithStringTypeRoundTripTestCase() { + try { + return m.createOntology(Stream.of(df.getOWLDataPropertyAssertionAxiom( + df.getOWLDataProperty("http://owlapi.sourceforge.net/ontology#prop"), + df.getOWLNamedIndividual("http://owlapi.sourceforge.net/ontology#A"), + df.getOWLLiteral("test url")))); + } catch (OWLOntologyCreationException e) { + throw new RuntimeException(e); + } + } + + @Override + public OWLOntology roundTripOntology(OWLOntology ont, OWLDocumentFormat format) { + String string = saveOntology(ont, format).toString(); + assertTrue(format.getKey().equals("RDF/JSON") || !string.contains("^^xsd:string"), + format.getKey() + "\n" + string); + return super.roundTripOntology(ont, format); + } + + @Test + void shouldParseInputWithoutExplicitString() { + OWLDataPropertyAssertionAxiom ax = df.getOWLDataPropertyAssertionAxiom( + df.getOWLDataProperty("http://owlapi.sourceforge.net/ontology#prop"), + df.getOWLNamedIndividual("http://owlapi.sourceforge.net/ontology#A"), + df.getOWLLiteral("test url")); + Arrays + .asList(TestFiles.STRING1, TestFiles.STRING2, TestFiles.STRING3, TestFiles.STRING4, + TestFiles.STRING5, TestFiles.STRING6, TestFiles.STRING7, TestFiles.STRING8, + TestFiles.STRING9) + .forEach(s -> assertTrue(loadOntologyFromString(s).containsAxiom(ax))); + } + + @ParameterizedTest + @MethodSource("formats") + void testFormat(OWLDocumentFormat d) throws Exception { + roundTripOntology(literalWithStringTypeRoundTripTestCase(), d); + } + + @Test + void roundTripRDFXMLAndFunctionalShouldBeSame() + throws OWLOntologyCreationException, OWLOntologyStorageException { + OWLOntology o = literalWithStringTypeRoundTripTestCase(); + OWLOntology o1 = roundTrip(o, new RDFXMLDocumentFormat()); + OWLOntology o2 = roundTrip(o, new FunctionalSyntaxDocumentFormat()); + equal(o, o1); + equal(o1, o2); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/PlainLiteralTypeFoldingAxiomSet.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/PlainLiteralTypeFoldingAxiomSet.java new file mode 100644 index 0000000000..baa89f5bbd --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/PlainLiteralTypeFoldingAxiomSet.java @@ -0,0 +1,102 @@ +package org.semanticweb.owlapi.api.test.baseclasses; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAxiom; + +/** + * Created by ses on 9/30/14. + */ +public class PlainLiteralTypeFoldingAxiomSet implements Set { + + private final Set delegate = createPlainLiteralTypeFoldingSet(); + + /** + * @param axioms axioms to be used + */ + public PlainLiteralTypeFoldingAxiomSet(Collection axioms) { + delegate.addAll(axioms); + } + + static Set createPlainLiteralTypeFoldingSet() { + return new HashSet<>(); + } + + @Override + public int size() { + return delegate.size(); + } + + @Override + public boolean isEmpty() { + return delegate.isEmpty(); + } + + @Override + public boolean contains(@Nullable Object o) { + return delegate.contains(o); + } + + @Override + public Iterator iterator() { + return delegate.iterator(); + } + + @Override + public Object[] toArray() { + return delegate.toArray(); + } + + @Override + public T[] toArray(@Nullable T[] a) { + return delegate.toArray(a); + } + + @Override + public boolean add(@Nullable OWLAxiom owlAxiom) { + return delegate.add(owlAxiom); + } + + @Override + public boolean remove(@Nullable Object o) { + return delegate.remove(o); + } + + @Override + public boolean containsAll(@Nullable Collection c) { + return delegate.containsAll(c); + } + + @Override + public boolean addAll(@Nullable Collection c) { + return delegate.addAll(c); + } + + @Override + public boolean retainAll(@Nullable Collection c) { + return delegate.retainAll(c); + } + + @Override + public boolean removeAll(@Nullable Collection c) { + return delegate.removeAll(c); + } + + @Override + public void clear() { + delegate.clear(); + } + + @Override + public boolean equals(@Nullable Object o) { + return delegate.equals(o); + } + + @Override + public int hashCode() { + return delegate.hashCode(); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/ReasonerTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/ReasonerTestCase.java new file mode 100644 index 0000000000..28f46a6f88 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/ReasonerTestCase.java @@ -0,0 +1,567 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.baseclasses; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentClasses; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentObjectProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.InverseObjectProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.OWLNothing; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.OWLThing; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubClassOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubObjectPropertyOf; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.reasoner.InferenceType; +import org.semanticweb.owlapi.reasoner.Node; +import org.semanticweb.owlapi.reasoner.NodeSet; +import org.semanticweb.owlapi.reasoner.OWLReasoner; +import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; +import org.semanticweb.owlapi.reasoner.structural.StructuralReasonerFactory; + +/** + * This test case creates a small ontology and tests the getters in the reasoner interface. The test + * ontology isn't designed to test the correctness of reasoning results, rather it is designed to + * test the reasoner returns the results in the form required by the OWL API reasoner interface. + * + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +class ReasonerTestCase extends TestBase { + + private final OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory(); + private OWLReasoner reasoner; + + private OWLOntology createOntology() { + OWLOntology o = getOWLOntology(); + o.add(SubClassOf(G, OWLThing()), SubClassOf(OWLThing(), G), EquivalentClasses(A, B), + SubClassOf(C, B), SubClassOf(D, A), SubClassOf(D, F), SubClassOf(F, D), + SubClassOf(E, C), SubClassOf(K, D), EquivalentClasses(K, OWLNothing()), + EquivalentObjectProperties(P, Q), SubObjectPropertyOf(P, R), + InverseObjectProperties(R, S)); + return o; + } + + @BeforeEach + void setUpOntoAndReasoner() { + reasoner = reasonerFactory.createReasoner(createOntology()); + } + + @AfterEach + void tearDown() { + reasoner.dispose(); + } + + @Test + void testGetName() { + assertNotNull(reasoner.getReasonerName()); + } + + @Test + void testGetVersion() { + assertNotNull(reasoner.getReasonerVersion()); + } + + @Test + void testGetTopClassNode() { + Node node = reasoner.getTopClassNode(); + assertTrue(node.isTopNode()); + assertFalse(node.isBottomNode()); + assertTrue(node.contains(OWLThing())); + assertTrue(node.contains(G)); + assertEquals(2, node.getSize()); + assertEquals(2, node.entities().count()); + assertEquals(1, node.getEntitiesMinusTop().size()); + assertTrue(node.getEntitiesMinusTop().contains(G)); + } + + @Test + void testGetBottomClassNode() { + Node node = reasoner.getBottomClassNode(); + assertTrue(node.isBottomNode()); + assertFalse(node.isTopNode()); + assertTrue(node.contains(OWLNothing())); + assertTrue(node.contains(K)); + assertEquals(2, node.getSize()); + assertEquals(2, node.entities().count()); + assertEquals(1, node.getEntitiesMinusBottom().size()); + assertTrue(node.getEntitiesMinusBottom().contains(K)); + } + + @Test + void testGetEquivalentClasses() { + Node nTop = reasoner.getEquivalentClasses(OWLThing()); + assertNotNull(nTop); + assertEquals(2, nTop.getSize()); + assertTrue(nTop.contains(OWLThing())); + assertTrue(nTop.contains(G)); + Node nG = reasoner.getEquivalentClasses(G); + assertNotNull(nG); + assertEquals(2, nG.getSize()); + assertTrue(nG.contains(OWLThing())); + assertTrue(nG.contains(G)); + assertEquals(nTop, nG); + Node nA = reasoner.getEquivalentClasses(A); + assertNotNull(nA); + assertEquals(2, nA.getSize()); + assertTrue(nA.contains(A)); + assertTrue(nA.contains(B)); + Node nB = reasoner.getEquivalentClasses(B); + assertNotNull(nB); + assertEquals(2, nB.getSize()); + assertTrue(nB.contains(A)); + assertTrue(nB.contains(B)); + assertEquals(nA, nB); + Node nC = reasoner.getEquivalentClasses(C); + assertNotNull(nC); + assertEquals(1, nC.getSize()); + assertTrue(nC.contains(C)); + assertEquals(C, nC.getRepresentativeElement()); + Node nE = reasoner.getEquivalentClasses(E); + assertNotNull(nE); + assertEquals(1, nE.getSize()); + assertTrue(nE.contains(E)); + assertEquals(E, nE.getRepresentativeElement()); + Node nD = reasoner.getEquivalentClasses(D); + assertNotNull(nD); + assertEquals(2, nD.getSize()); + assertTrue(nD.contains(D)); + assertTrue(nD.contains(F)); + Node nF = reasoner.getEquivalentClasses(F); + assertNotNull(nF); + assertEquals(2, nF.getSize()); + assertTrue(nF.contains(D)); + assertTrue(nF.contains(F)); + assertEquals(nD, nF); + Node nBot = reasoner.getEquivalentClasses(OWLNothing()); + assertNotNull(nBot); + assertEquals(2, nBot.getSize()); + assertTrue(nBot.contains(OWLNothing())); + assertTrue(nBot.contains(K)); + Node nK = reasoner.getEquivalentClasses(K); + assertNotNull(nK); + assertEquals(2, nK.getSize()); + assertTrue(nBot.contains(OWLNothing())); + assertTrue(nBot.contains(K)); + assertEquals(nBot, nK); + } + + @Test + void testGetSuperClassesDirect() { + NodeSet nsSupTop = reasoner.getSuperClasses(OWLThing(), true); + assertNotNull(nsSupTop); + assertTrue(nsSupTop.isEmpty()); + NodeSet nsSupG = reasoner.getSuperClasses(G, true); + assertNotNull(nsSupG); + assertTrue(nsSupG.isEmpty()); + NodeSet nsSupA = reasoner.getSuperClasses(A, true); + assertNotNull(nsSupA); + assertFalse(nsSupA.isEmpty()); + assertEquals(1, nsSupA.nodes().count()); + assertTrue(nsSupA.containsEntity(OWLThing())); + assertTrue(nsSupA.containsEntity(G)); + assertTrue(nsSupA.isTopSingleton()); + NodeSet nsSupB = reasoner.getSuperClasses(B, true); + assertNotNull(nsSupB); + assertEquals(1, nsSupB.nodes().count()); + assertTrue(nsSupB.containsEntity(OWLThing())); + assertTrue(nsSupB.containsEntity(G)); + assertTrue(nsSupB.isTopSingleton()); + NodeSet nsSupC = reasoner.getSuperClasses(C, true); + assertNotNull(nsSupC); + assertEquals(1, nsSupC.nodes().count()); + assertTrue(nsSupC.containsEntity(A)); + assertTrue(nsSupC.containsEntity(B)); + NodeSet nsSupE = reasoner.getSuperClasses(E, true); + assertNotNull(nsSupE); + assertEquals(1, nsSupE.nodes().count()); + assertTrue(nsSupE.containsEntity(C)); + NodeSet nsSupD = reasoner.getSuperClasses(D, true); + assertNotNull(nsSupD); + assertEquals(1, nsSupD.nodes().count()); + assertTrue(nsSupD.containsEntity(A)); + assertTrue(nsSupD.containsEntity(B)); + NodeSet nsSupF = reasoner.getSuperClasses(F, true); + assertNotNull(nsSupF); + assertEquals(1, nsSupF.nodes().count()); + assertTrue(nsSupF.containsEntity(A)); + assertTrue(nsSupF.containsEntity(B)); + NodeSet nsSupK = reasoner.getSuperClasses(K, true); + assertNotNull(nsSupK); + assertEquals(2, nsSupK.nodes().count()); + assertTrue(nsSupK.containsEntity(E)); + assertTrue(nsSupK.containsEntity(D)); + assertTrue(nsSupK.containsEntity(F)); + NodeSet nsSupBot = reasoner.getSuperClasses(OWLNothing(), true); + assertNotNull(nsSupBot); + assertEquals(2, nsSupBot.nodes().count()); + assertTrue(nsSupBot.containsEntity(E)); + assertTrue(nsSupBot.containsEntity(D)); + assertTrue(nsSupBot.containsEntity(F)); + } + + @Test + void testGetSuperClasses() { + NodeSet nsSupTop = reasoner.getSuperClasses(OWLThing(), false); + assertNotNull(nsSupTop); + assertTrue(nsSupTop.isEmpty()); + NodeSet nsSupG = reasoner.getSuperClasses(G, false); + assertNotNull(nsSupG); + assertTrue(nsSupG.isEmpty()); + NodeSet nsSupA = reasoner.getSuperClasses(A, false); + assertNotNull(nsSupA); + assertFalse(nsSupA.isEmpty()); + assertEquals(1, nsSupA.nodes().count()); + assertTrue(nsSupA.containsEntity(OWLThing())); + assertTrue(nsSupA.containsEntity(G)); + assertTrue(nsSupA.isTopSingleton()); + NodeSet nsSupB = reasoner.getSuperClasses(B, false); + assertNotNull(nsSupB); + assertEquals(1, nsSupB.nodes().count()); + assertTrue(nsSupB.containsEntity(OWLThing())); + assertTrue(nsSupB.containsEntity(G)); + assertTrue(nsSupB.isTopSingleton()); + NodeSet nsSupC = reasoner.getSuperClasses(C, false); + assertNotNull(nsSupC); + assertEquals(2, nsSupC.nodes().count()); + assertTrue(nsSupC.containsEntity(OWLThing())); + assertTrue(nsSupC.containsEntity(G)); + assertTrue(nsSupC.containsEntity(A)); + assertTrue(nsSupC.containsEntity(B)); + NodeSet nsSupE = reasoner.getSuperClasses(E, false); + assertNotNull(nsSupE); + assertEquals(3, nsSupE.nodes().count()); + assertTrue(nsSupE.containsEntity(C)); + assertTrue(nsSupE.containsEntity(A)); + assertTrue(nsSupE.containsEntity(B)); + assertTrue(nsSupE.containsEntity(G)); + assertTrue(nsSupE.containsEntity(OWLThing())); + NodeSet nsSupD = reasoner.getSuperClasses(D, false); + assertNotNull(nsSupD); + assertEquals(2, nsSupD.nodes().count()); + assertTrue(nsSupD.containsEntity(A)); + assertTrue(nsSupD.containsEntity(B)); + assertTrue(nsSupD.containsEntity(G)); + assertTrue(nsSupD.containsEntity(OWLThing())); + NodeSet nsSupF = reasoner.getSuperClasses(F, false); + assertNotNull(nsSupF); + assertEquals(2, nsSupF.nodes().count()); + assertTrue(nsSupF.containsEntity(A)); + assertTrue(nsSupF.containsEntity(B)); + assertTrue(nsSupF.containsEntity(G)); + assertTrue(nsSupF.containsEntity(OWLThing())); + NodeSet nsSupK = reasoner.getSuperClasses(K, false); + assertNotNull(nsSupK); + assertEquals(5, nsSupK.nodes().count()); + assertTrue(nsSupK.containsEntity(E)); + assertTrue(nsSupK.containsEntity(D)); + assertTrue(nsSupK.containsEntity(F)); + assertTrue(nsSupK.containsEntity(C)); + assertTrue(nsSupK.containsEntity(A)); + assertTrue(nsSupK.containsEntity(B)); + assertTrue(nsSupK.containsEntity(G)); + assertTrue(nsSupK.containsEntity(OWLThing())); + NodeSet nsSupBot = reasoner.getSuperClasses(OWLNothing(), false); + assertNotNull(nsSupBot); + assertEquals(5, nsSupBot.nodes().count()); + assertTrue(nsSupBot.containsEntity(E)); + assertTrue(nsSupBot.containsEntity(D)); + assertTrue(nsSupBot.containsEntity(F)); + assertTrue(nsSupBot.containsEntity(C)); + assertTrue(nsSupBot.containsEntity(A)); + assertTrue(nsSupBot.containsEntity(B)); + assertTrue(nsSupBot.containsEntity(G)); + assertTrue(nsSupBot.containsEntity(OWLThing())); + } + + @Test + void testGetSubClassesDirect() { + NodeSet nsSubTop = reasoner.getSubClasses(OWLThing(), true); + assertNotNull(nsSubTop); + assertEquals(1, nsSubTop.nodes().count()); + assertTrue(nsSubTop.containsEntity(A)); + assertTrue(nsSubTop.containsEntity(B)); + NodeSet nsSubG = reasoner.getSubClasses(G, true); + assertNotNull(nsSubG); + assertEquals(1, nsSubG.nodes().count()); + assertTrue(nsSubG.containsEntity(A)); + assertTrue(nsSubG.containsEntity(B)); + NodeSet nsSubA = reasoner.getSubClasses(A, true); + assertNotNull(nsSubA); + assertFalse(nsSubG.isEmpty()); + assertEquals(2, nsSubA.nodes().count()); + assertTrue(nsSubA.containsEntity(C)); + assertTrue(nsSubA.containsEntity(D)); + assertTrue(nsSubA.containsEntity(F)); + NodeSet nsSubB = reasoner.getSubClasses(B, true); + assertNotNull(nsSubB); + assertEquals(2, nsSubB.nodes().count()); + assertTrue(nsSubB.containsEntity(C)); + assertTrue(nsSubB.containsEntity(D)); + assertTrue(nsSubB.containsEntity(F)); + NodeSet nsSubC = reasoner.getSubClasses(C, true); + assertNotNull(nsSubC); + assertEquals(1, nsSubC.nodes().count()); + assertTrue(nsSubC.containsEntity(E)); + NodeSet nsSubE = reasoner.getSubClasses(E, true); + assertNotNull(nsSubE); + assertEquals(1, nsSubE.nodes().count()); + assertTrue(nsSubE.containsEntity(K)); + assertTrue(nsSubE.containsEntity(OWLNothing())); + NodeSet nsSubD = reasoner.getSubClasses(D, true); + assertNotNull(nsSubD); + assertEquals(1, nsSubD.nodes().count()); + assertTrue(nsSubD.containsEntity(K)); + assertTrue(nsSubD.containsEntity(OWLNothing())); + NodeSet nsSubF = reasoner.getSubClasses(F, true); + assertNotNull(nsSubF); + assertEquals(1, nsSubF.nodes().count()); + assertTrue(nsSubF.containsEntity(K)); + assertTrue(nsSubF.containsEntity(OWLNothing())); + NodeSet nsSubK = reasoner.getSubClasses(K, true); + assertNotNull(nsSubK); + assertTrue(nsSubK.isEmpty()); + NodeSet nsSubBot = reasoner.getSubClasses(OWLNothing(), true); + assertNotNull(nsSubBot); + assertTrue(nsSubBot.isEmpty()); + } + + @Test + void testGetSubClasses() { + NodeSet nsSubTop = reasoner.getSubClasses(OWLThing(), false); + assertNotNull(nsSubTop); + assertEquals(5, nsSubTop.nodes().count()); + assertTrue(nsSubTop.containsEntity(A)); + assertTrue(nsSubTop.containsEntity(B)); + assertTrue(nsSubTop.containsEntity(C)); + assertTrue(nsSubTop.containsEntity(D)); + assertTrue(nsSubTop.containsEntity(F)); + assertTrue(nsSubTop.containsEntity(E)); + assertTrue(nsSubTop.containsEntity(K)); + assertTrue(nsSubTop.containsEntity(OWLNothing())); + NodeSet nsSubG = reasoner.getSubClasses(G, false); + assertNotNull(nsSubG); + assertEquals(5, nsSubG.nodes().count()); + assertTrue(nsSubG.containsEntity(A)); + assertTrue(nsSubG.containsEntity(B)); + assertTrue(nsSubG.containsEntity(C)); + assertTrue(nsSubG.containsEntity(D)); + assertTrue(nsSubG.containsEntity(F)); + assertTrue(nsSubG.containsEntity(E)); + assertTrue(nsSubG.containsEntity(K)); + assertTrue(nsSubG.containsEntity(OWLNothing())); + NodeSet nsSubA = reasoner.getSubClasses(A, false); + assertNotNull(nsSubA); + assertFalse(nsSubG.isEmpty()); + assertEquals(4, nsSubA.nodes().count()); + assertTrue(nsSubA.containsEntity(C)); + assertTrue(nsSubA.containsEntity(D)); + assertTrue(nsSubA.containsEntity(F)); + assertTrue(nsSubA.containsEntity(E)); + assertTrue(nsSubA.containsEntity(K)); + assertTrue(nsSubA.containsEntity(OWLNothing())); + NodeSet nsSubB = reasoner.getSubClasses(B, false); + assertNotNull(nsSubB); + assertEquals(4, nsSubB.nodes().count()); + assertTrue(nsSubB.containsEntity(C)); + assertTrue(nsSubB.containsEntity(D)); + assertTrue(nsSubB.containsEntity(F)); + assertTrue(nsSubB.containsEntity(E)); + assertTrue(nsSubB.containsEntity(K)); + assertTrue(nsSubB.containsEntity(OWLNothing())); + NodeSet nsSubC = reasoner.getSubClasses(C, false); + assertNotNull(nsSubC); + assertEquals(2, nsSubC.nodes().count()); + assertTrue(nsSubC.containsEntity(E)); + assertTrue(nsSubC.containsEntity(K)); + assertTrue(nsSubC.containsEntity(OWLNothing())); + NodeSet nsSubE = reasoner.getSubClasses(E, false); + assertNotNull(nsSubE); + assertEquals(1, nsSubE.nodes().count()); + assertTrue(nsSubE.containsEntity(K)); + assertTrue(nsSubE.containsEntity(OWLNothing())); + NodeSet nsSubD = reasoner.getSubClasses(D, false); + assertNotNull(nsSubD); + assertEquals(1, nsSubD.nodes().count()); + assertTrue(nsSubD.containsEntity(K)); + assertTrue(nsSubD.containsEntity(OWLNothing())); + NodeSet nsSubF = reasoner.getSubClasses(F, false); + assertNotNull(nsSubF); + assertEquals(1, nsSubF.nodes().count()); + assertTrue(nsSubF.containsEntity(K)); + assertTrue(nsSubF.containsEntity(OWLNothing())); + NodeSet nsSubK = reasoner.getSubClasses(K, false); + assertNotNull(nsSubK); + assertTrue(nsSubK.isEmpty()); + NodeSet nsSubBot = reasoner.getSubClasses(OWLNothing(), false); + assertNotNull(nsSubBot); + assertTrue(nsSubBot.isEmpty()); + } + + @Test + void testIsSatisfiable() { + assertTrue(reasoner.isSatisfiable(OWLThing())); + assertTrue(reasoner.isSatisfiable(G)); + assertTrue(reasoner.isSatisfiable(A)); + assertTrue(reasoner.isSatisfiable(B)); + assertTrue(reasoner.isSatisfiable(C)); + assertTrue(reasoner.isSatisfiable(D)); + assertTrue(reasoner.isSatisfiable(E)); + assertFalse(reasoner.isSatisfiable(OWLNothing())); + assertFalse(reasoner.isSatisfiable(K)); + } + + @Test + void testComputeClassHierarchy() { + reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY); + assertTrue(reasoner.isPrecomputed(InferenceType.CLASS_HIERARCHY)); + } + + @Test + void testGetTopObjectPropertyNode() { + Node node = reasoner.getTopObjectPropertyNode(); + assertNotNull(node); + assertTrue(node.isTopNode()); + } + + @Test + void testGetBottomObjectPropertyNode() { + Node node = reasoner.getBottomObjectPropertyNode(); + assertNotNull(node); + assertTrue(node.isBottomNode()); + } + + @Test + void testGetSubObjectPropertiesDirect() { + NodeSet nsSubTop = + reasoner.getSubObjectProperties(df.getOWLTopObjectProperty(), true); + assertNotNull(nsSubTop); + assertEquals(2, nsSubTop.nodes().count()); + assertTrue(nsSubTop.containsEntity(R)); + assertTrue(nsSubTop.containsEntity(S)); + assertTrue(nsSubTop.containsEntity(R.getInverseProperty())); + assertTrue(nsSubTop.containsEntity(S.getInverseProperty())); + NodeSet nsSubR = reasoner.getSubObjectProperties(R, true); + assertNotNull(nsSubR); + assertEquals(1, nsSubR.nodes().count()); + assertTrue(nsSubR.containsEntity(P)); + assertTrue(nsSubR.containsEntity(Q)); + NodeSet nsSubRMinus = + reasoner.getSubObjectProperties(R.getInverseProperty(), true); + assertNotNull(nsSubRMinus); + assertEquals(1, nsSubRMinus.nodes().count()); + assertTrue(nsSubRMinus.containsEntity(P.getInverseProperty())); + assertTrue(nsSubRMinus.containsEntity(Q.getInverseProperty())); + NodeSet nsSubSMinus = + reasoner.getSubObjectProperties(S.getInverseProperty(), true); + assertNotNull(nsSubSMinus); + assertEquals(1, nsSubSMinus.nodes().count()); + assertTrue(nsSubSMinus.containsEntity(P)); + assertTrue(nsSubSMinus.containsEntity(Q)); + NodeSet nsSubS = reasoner.getSubObjectProperties(S, true); + assertNotNull(nsSubS); + assertEquals(1, nsSubS.nodes().count()); + assertTrue(nsSubS.containsEntity(P.getInverseProperty())); + assertTrue(nsSubS.containsEntity(Q.getInverseProperty())); + NodeSet nsSubP = reasoner.getSubObjectProperties(P, true); + assertNotNull(nsSubP); + assertEquals(1, nsSubP.nodes().count()); + assertTrue(nsSubP.containsEntity(df.getOWLBottomObjectProperty())); + NodeSet nsSubQ = reasoner.getSubObjectProperties(Q, true); + assertNotNull(nsSubQ); + assertEquals(1, nsSubQ.nodes().count()); + assertTrue(nsSubQ.containsEntity(df.getOWLBottomObjectProperty())); + NodeSet nsSubPMinus = + reasoner.getSubObjectProperties(P.getInverseProperty(), true); + assertNotNull(nsSubPMinus); + assertEquals(1, nsSubPMinus.nodes().count()); + assertTrue(nsSubPMinus.containsEntity(df.getOWLBottomObjectProperty())); + NodeSet nsSubQMinus = + reasoner.getSubObjectProperties(Q.getInverseProperty(), true); + assertNotNull(nsSubQMinus); + assertEquals(1, nsSubQMinus.nodes().count()); + assertTrue(nsSubQMinus.containsEntity(df.getOWLBottomObjectProperty())); + } + + @Test + void testGetSubObjectProperties() { + NodeSet nsSubTop = + reasoner.getSubObjectProperties(df.getOWLTopObjectProperty(), false); + assertNotNull(nsSubTop); + assertEquals(5, nsSubTop.nodes().count()); + assertTrue(nsSubTop.containsEntity(R)); + assertTrue(nsSubTop.containsEntity(S)); + assertTrue(nsSubTop.containsEntity(P)); + assertTrue(nsSubTop.containsEntity(Q)); + assertTrue(nsSubTop.containsEntity(R.getInverseProperty())); + assertTrue(nsSubTop.containsEntity(R.getInverseProperty())); + assertTrue(nsSubTop.containsEntity(P.getInverseProperty())); + assertTrue(nsSubTop.containsEntity(Q.getInverseProperty())); + assertTrue(nsSubTop.containsEntity(df.getOWLBottomObjectProperty())); + NodeSet nsSubR = reasoner.getSubObjectProperties(R, false); + assertNotNull(nsSubR); + assertEquals(2, nsSubR.nodes().count()); + assertTrue(nsSubR.containsEntity(P)); + assertTrue(nsSubR.containsEntity(Q)); + assertTrue(nsSubR.containsEntity(df.getOWLBottomObjectProperty())); + NodeSet nsSubRMinus = + reasoner.getSubObjectProperties(R.getInverseProperty(), false); + assertNotNull(nsSubRMinus); + assertEquals(2, nsSubRMinus.nodes().count()); + assertTrue(nsSubRMinus.containsEntity(P.getInverseProperty())); + assertTrue(nsSubRMinus.containsEntity(Q.getInverseProperty())); + assertTrue(nsSubRMinus.containsEntity(df.getOWLBottomObjectProperty())); + NodeSet nsSubSMinus = + reasoner.getSubObjectProperties(S.getInverseProperty(), false); + assertNotNull(nsSubSMinus); + assertEquals(2, nsSubSMinus.nodes().count()); + assertTrue(nsSubRMinus.containsEntity(P.getInverseProperty())); + assertTrue(nsSubRMinus.containsEntity(Q.getInverseProperty())); + assertTrue(nsSubRMinus.containsEntity(df.getOWLBottomObjectProperty())); + NodeSet nsSubS = reasoner.getSubObjectProperties(S, false); + assertNotNull(nsSubS); + assertEquals(2, nsSubS.nodes().count()); + assertTrue(nsSubS.containsEntity(P.getInverseProperty())); + assertTrue(nsSubS.containsEntity(Q.getInverseProperty())); + assertTrue(nsSubS.containsEntity(df.getOWLBottomObjectProperty())); + NodeSet nsSubP = reasoner.getSubObjectProperties(P, false); + assertNotNull(nsSubP); + assertEquals(1, nsSubP.nodes().count()); + assertTrue(nsSubP.containsEntity(df.getOWLBottomObjectProperty())); + NodeSet nsSubQ = reasoner.getSubObjectProperties(Q, false); + assertNotNull(nsSubQ); + assertEquals(1, nsSubQ.nodes().count()); + assertTrue(nsSubQ.containsEntity(df.getOWLBottomObjectProperty())); + NodeSet nsSubPMinus = + reasoner.getSubObjectProperties(P.getInverseProperty(), false); + assertNotNull(nsSubPMinus); + assertEquals(1, nsSubPMinus.nodes().count()); + assertTrue(nsSubPMinus.containsEntity(df.getOWLBottomObjectProperty())); + NodeSet nsSubQMinus = + reasoner.getSubObjectProperties(Q.getInverseProperty(), false); + assertNotNull(nsSubQMinus); + assertEquals(1, nsSubQMinus.nodes().count()); + assertTrue(nsSubQMinus.containsEntity(df.getOWLBottomObjectProperty())); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/TestBase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/TestBase.java new file mode 100644 index 0000000000..9a4b2393ee --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/TestBase.java @@ -0,0 +1,772 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.baseclasses; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Datatype; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NamedIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectComplementOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.api.function.Executable; +import org.junit.jupiter.api.io.TempDir; +import org.semanticweb.owlapi.api.test.anonymous.AnonymousIndividualsNormaliser; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.NQuadsDocumentFormat; +import org.semanticweb.owlapi.formats.NTriplesDocumentFormat; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.formats.PrefixDocumentFormat; +import org.semanticweb.owlapi.formats.RDFJsonDocumentFormat; +import org.semanticweb.owlapi.formats.RDFJsonLDDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RioRDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RioTurtleDocumentFormat; +import org.semanticweb.owlapi.formats.TrigDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.io.IRIDocumentSource; +import org.semanticweb.owlapi.io.StreamDocumentSource; +import org.semanticweb.owlapi.io.StringDocumentSource; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OntologyConfigurator; +import org.semanticweb.owlapi.vocab.OWL2Datatype; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.2.0 + */ +@Timeout(value = 1000, unit = TimeUnit.SECONDS) +public abstract class TestBase { + + @TempDir + public File folder; + private static final String BLANK = "blank"; + protected static final Logger logger = LoggerFactory.getLogger(TestBase.class); + protected static final String uriBase = "http://www.semanticweb.org/owlapi/test"; + protected static OWLDataFactory df; + + public static final String OBO = "http://purl.obolibrary.org/obo/"; + + public static final OWLObjectProperty S = ObjectProperty(iri("s")); + public static final OWLClass K = Class(iri("K")); + public static final OWLClass G = Class(iri("G")); + public static final OWLClass F = Class(iri("F")); + public static final OWLClass E = Class(iri("E")); + public static final OWLClass D = Class(iri("D")); + public static final OWLClass C = Class(iri("C")); + + public static final OWLClass C1 = Class(iri(OBO, "TEST_1")); + public static final OWLClass C2 = Class(iri(OBO, "TEST_2")); + public static final OWLClass C3 = Class(iri(OBO, "TEST_3")); + public static final OWLClass C4 = Class(iri(OBO, "TEST_4")); + public static final OWLClass C5 = Class(iri(OBO, "TEST_5")); + + + public static final OWLDataProperty DR = DataProperty(iri("r")); + public static final OWLObjectProperty R = ObjectProperty(iri("r")); + public static final OWLClass B = Class(iri("B")); + public static final OWLClass A = Class(iri("A")); + public static final OWLDataProperty DQ = DataProperty(iri("q")); + public static final OWLDataProperty DPROP = DataProperty(iri("prop")); + public static final OWLObjectProperty PROP = ObjectProperty(iri("prop")); + public static final OWLObjectProperty Q = ObjectProperty(iri("q")); + public static final OWLDataProperty DP = DataProperty(iri("p")); + public static final OWLDataProperty DPP = DataProperty(iri("dp")); + public static final OWLObjectProperty P = ObjectProperty(iri("p")); + public static final OWLNamedIndividual J = NamedIndividual(iri("j")); + public static final OWLNamedIndividual I = NamedIndividual(iri("i")); + public static final OWLNamedIndividual indA = NamedIndividual(iri("a")); + public static final OWLObjectComplementOf notC = ObjectComplementOf(C); + public static final OWLObjectComplementOf notB = ObjectComplementOf(B); + public static final OWLObjectComplementOf notA = ObjectComplementOf(A); + public static final OWLNamedIndividual i = NamedIndividual(iri("I")); + public static final OWLAnnotationProperty AP = AnnotationProperty(iri("propA")); + public static final OWLDataProperty PD = DataProperty(iri("propD")); + public static final OWLDatatype DT = Datatype(iri("DT")); + public static final OWLAnnotationProperty areaTotal = + AnnotationProperty(IRI("http://dbpedia.org/ontology/", "areaTotal")); + public static final IRI southAfrica = IRI("http://dbpedia.org/resource/", "South_Africa"); + public static final OWLLiteral oneMillionth = Literal("1.0E-7", OWL2Datatype.XSD_DOUBLE); + + protected static OntologyConfigurator masterConfigurator; + protected final File RESOURCES = resources(); + protected OWLOntologyLoaderConfiguration config = new OWLOntologyLoaderConfiguration(); + protected OWLOntologyManager m = setupManager(); + protected OWLOntologyManager m1 = setupManager(); + + public static IRI iri(String name) { + return IRI(uriBase + '#', name); + } + + public static IRI iri(File file) { + return IRI.create(file); + } + + public static IRI iri(String p, String s) { + return IRI.create(p, s); + } + + private static final File resources() { + try { + return new File(TestBase.class.getResource("/owlapi.properties").toURI()) + .getParentFile(); + } catch (URISyntaxException e) { + throw new OWLRuntimeException("NO RESOURCE FOLDER ACCESSIBLE", e); + } + } + + public static List formats() { + return Arrays.asList(new RDFXMLDocumentFormat(), new RioRDFXMLDocumentFormat(), + new RDFJsonDocumentFormat(), new OWLXMLDocumentFormat(), + new FunctionalSyntaxDocumentFormat(), new TurtleDocumentFormat(), + new RioTurtleDocumentFormat(), new ManchesterSyntaxDocumentFormat(), + new TrigDocumentFormat(), new RDFJsonLDDocumentFormat(), new NTriplesDocumentFormat(), + new NQuadsDocumentFormat()); + } + + public static Stream formatsSkip(Class c) { + return formats().stream().filter(x -> !c.isInstance(x)); + } + + public static void assertThrowsWithMessage(String message, Class c, + Executable r) { + assertThrows(c, r, message); + } + + public static void assertThrowsWithCauseMessage(Class wrapper, Class c, + @Nullable String message, Executable r) { + assertThrowsWithCausePredicate(wrapper, c, + e -> assertTrue(message == null || e.getMessage().contains(message)), r); + } + + public static void assertThrowsWithPredicate(Class c, Consumer p, Executable r) { + try { + r.execute(); + } catch (Throwable e) { + assertEquals(c, e.getClass()); + p.accept(e); + } + } + + public static void assertThrowsWithCausePredicate(Class wrapper, Class c, + Consumer p, Executable r) { + try { + r.execute(); + } catch (Throwable e) { + assertEquals(wrapper, e.getClass()); + assertNotNull(e.getCause()); + assertEquals(c, e.getCause().getClass()); + p.accept(e.getCause()); + } + } + + public static void assertThrowsWithCause(Class wrapper, Class c, Executable r) { + assertThrowsWithCauseMessage(wrapper, c, null, r); + } + + @BeforeAll + public static void setupManagers() { + masterConfigurator = new OntologyConfigurator(); + df = OWLManager.getOWLDataFactory(); + } + + protected static OWLOntologyManager setupManager() { + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + man.setOntologyConfigurator(masterConfigurator); + return man; + } + + protected static Set singleton(S s) { + return Collections.singleton(s); + } + + protected T get(Optional t) { + return t.get(); + } + + protected OWLOntology ontologyFromClasspathFile(String fileName) { + return ontologyFromClasspathFile(fileName, config); + } + + protected OWLOntology ontologyFromClasspathFile(String fileName, + @Nullable OWLDocumentFormat format) { + return ontologyFromClasspathFile(fileName, config, format); + } + + protected OWLOntology ontologyFromClasspathFile(String fileName, + OWLOntologyLoaderConfiguration configuration) { + try (InputStream in = getClass().getResourceAsStream('/' + fileName)) { + return m1.loadOntologyFromOntologyDocument(new StreamDocumentSource(in), configuration); + } catch (OWLOntologyCreationException | IOException e) { + throw new OWLRuntimeException(e); + } + } + + protected OWLOntology ontologyFromClasspathFile(String fileName, + OWLOntologyLoaderConfiguration configuration, @Nullable OWLDocumentFormat f) { + if (f == null) { + return ontologyFromClasspathFile(fileName, configuration); + } + URL resource = getClass().getResource('/' + fileName); + try (InputStream resourceAsStream = new FileInputStream(new File(resource.toURI()))) { + return m1.loadOntologyFromOntologyDocument( + new StreamDocumentSource(resourceAsStream, IRI.create(resource), f, null), + configuration); + } catch (OWLOntologyCreationException | IOException | URISyntaxException e) { + throw new OWLRuntimeException(e); + } + } + + protected Set stripSimpleDeclarations(Collection axioms) { + Set toReturn = new HashSet<>(); + for (OWLAxiom ax : axioms) { + if (!isSimpleDeclaration(ax)) { + toReturn.add(ax); + } + } + return toReturn; + } + + protected boolean isSimpleDeclaration(OWLAxiom ax) { + return ax.isOfType(AxiomType.DECLARATION) && ax.annotationsAsList().isEmpty(); + } + + private static String str(Stream s) { + return s.map(Object::toString).map(f -> f.replace(" ", "\n ").replace("(", "(\n")) + .collect(Collectors.joining("\n")); + } + + public boolean equal(OWLOntology ont1, OWLOntology ont2) { + if (ont1.isNamed() && ont2.isNamed()) { + assertEquals(ont1.getOntologyID(), ont2.getOntologyID()); + } + if (!Objects.equals(asSet(ont1.annotations()), asSet(ont2.annotations()))) { + assertEquals(str(ont1.annotations()), str(ont2.annotations())); + } + Set axioms1; + Set axioms2; + // This isn't great - we normalise axioms by changing the ids of + // individuals. This relies on the fact that + // we iterate over objects in the same order for the same set of axioms! + axioms1 = new AnonymousIndividualsNormaliser(ont1.getOWLOntologyManager()) + .getNormalisedAxioms(ont1.axioms()); + axioms2 = new AnonymousIndividualsNormaliser(ont1.getOWLOntologyManager()) + .getNormalisedAxioms(ont2.axioms()); + OWLDocumentFormat ontologyFormat = ont2.getNonnullFormat(); + applyEquivalentsRoundtrip(axioms1, axioms2, ontologyFormat); + if (ontologyFormat instanceof ManchesterSyntaxDocumentFormat) { + // drop GCIs from the expected axioms, they won't be there + Iterator it = axioms1.iterator(); + while (it.hasNext()) { + OWLAxiom next = it.next(); + if (next instanceof OWLSubClassOfAxiom) { + OWLSubClassOfAxiom n = (OWLSubClassOfAxiom) next; + if (n.getSubClass().isAnonymous() && n.getSuperClass().isAnonymous()) { + it.remove(); + } + } + } + } + PlainLiteralTypeFoldingAxiomSet a = new PlainLiteralTypeFoldingAxiomSet(axioms1); + PlainLiteralTypeFoldingAxiomSet b = new PlainLiteralTypeFoldingAxiomSet(axioms2); + if (!a.equals(b)) { + int counter = 0; + StringBuilder sb = new StringBuilder(); + Set leftOnly = new HashSet<>(); + Set rightOnly = new HashSet<>(); + for (OWLAxiom ax : a) { + if (!b.contains(ax) && !isIgnorableAxiom(ax, false)) { + leftOnly.add(ax); + sb.append("Rem axiom: ").append(ax).append('\n'); + counter++; + } + } + for (OWLAxiom ax : b) { + if (!a.contains(ax) && !isIgnorableAxiom(ax, true)) { + rightOnly.add(ax); + sb.append("Add axiom: ").append(ax).append('\n'); + counter++; + } + } + if (counter > 0 && !rightOnly.equals(leftOnly)) { + // a test fails on OpenJDK implementations because of + // ordering + // testing here if blank node ids are the only difference + boolean fixed = !verifyErrorIsDueToBlankNodesId(leftOnly, rightOnly); + if (fixed) { + if (logger.isTraceEnabled()) { + String x = getClass().getSimpleName() + + " roundTripOntology() Failing to match axioms: \n" + sb + + topOfStackTrace(); + logger.trace(x); + } + fail(getClass().getSimpleName() + + " roundTripOntology() Failing to match axioms: \n" + sb); + return false; + } else { + return true; + } + } else { + return true; + } + } + return true; + } + + /** + * equivalent entity axioms with more than two entities are broken up by RDF syntaxes. Ensure + * they are still recognized as correct roundtripping + */ + public void applyEquivalentsRoundtrip(Set axioms1, Set axioms2, + OWLDocumentFormat destination) { + if (!axioms1.equals(axioms2)) { + // remove axioms that differ only because of n-ary equivalence + // axioms + // http://www.w3.org/TR/owl2-mapping-to-rdf/#Axioms_that_are_Translated_to_Multiple_Triples + for (OWLAxiom ax : new ArrayList<>(axioms1)) { + if (ax instanceof OWLEquivalentClassesAxiom) { + OWLEquivalentClassesAxiom ax2 = (OWLEquivalentClassesAxiom) ax; + if (ax2.getOperandsAsList().size() > 2) { + Collection pairs = ax2.splitToAnnotatedPairs(); + if (removeIfContainsAll(axioms2, pairs, destination)) { + axioms1.remove(ax); + axioms2.removeAll(pairs); + } + } + } else if (ax instanceof OWLEquivalentDataPropertiesAxiom) { + OWLEquivalentDataPropertiesAxiom ax2 = (OWLEquivalentDataPropertiesAxiom) ax; + if (ax2.getOperandsAsList().size() > 2) { + Collection pairs = + ax2.splitToAnnotatedPairs(); + if (removeIfContainsAll(axioms2, pairs, destination)) { + axioms1.remove(ax); + axioms2.removeAll(pairs); + } + } + } else if (ax instanceof OWLEquivalentObjectPropertiesAxiom) { + OWLEquivalentObjectPropertiesAxiom ax2 = + (OWLEquivalentObjectPropertiesAxiom) ax; + if (ax2.getOperandsAsList().size() > 2) { + Collection pairs = + ax2.splitToAnnotatedPairs(); + if (removeIfContainsAll(axioms2, pairs, destination)) { + axioms1.remove(ax); + axioms2.removeAll(pairs); + } + } + } + } + } + if (!axioms1.equals(axioms2) && destination instanceof RDFJsonLDDocumentFormat) { + // other axioms can have their annotations changed to string type + Set reannotated1 = new HashSet<>(); + axioms1.forEach(a -> reannotated1.add(reannotate(a))); + axioms1.clear(); + axioms1.addAll(reannotated1); + Set reannotated2 = new HashSet<>(); + axioms2.forEach(a -> reannotated2.add(reannotate(a))); + axioms2.clear(); + axioms2.addAll(reannotated2); + } + } + + private boolean removeIfContainsAll(Collection axioms, + Collection others, OWLDocumentFormat destination) { + if (axioms.containsAll(others)) { + axioms.removeAll(others); + return true; + } + // some syntaxes attach xsd:string to annotation values that did not + // have it previously + if (!(destination instanceof RDFJsonLDDocumentFormat)) { + return false; + } + Set toRemove = new HashSet<>(); + for (OWLAxiom ax : others) { + OWLAxiom reannotated = reannotate(ax); + toRemove.add(reannotated); + } + axioms.removeAll(toRemove); + return true; + } + + protected OWLAxiom reannotate(OWLAxiom ax) { + return ax.getAxiomWithoutAnnotations().getAnnotatedAxiom(reannotate(ax.annotations())); + } + + public static List set(S... s) { + return asList(Stream.of(s).distinct()); + } + + private static Set reannotate(Stream anns) { + OWLDatatype stringType = df.getOWLDatatype(OWL2Datatype.XSD_STRING); + Set toReturn = new HashSet<>(); + anns.forEach(a -> { + Optional asLiteral = a.getValue().asLiteral(); + if (asLiteral.isPresent() && asLiteral.get().isRDFPlainLiteral()) { + OWLAnnotation replacement = df.getOWLAnnotation(a.getProperty(), + df.getOWLLiteral(asLiteral.get().getLiteral(), stringType)); + toReturn.add(replacement); + } else { + toReturn.add(a); + } + }); + return toReturn; + } + + private static String topOfStackTrace() { + StackTraceElement[] elements = new RuntimeException().getStackTrace(); + return elements[1] + "\n" + elements[2] + '\n' + elements[3]; + } + + public static boolean verifyErrorIsDueToBlankNodesId(Set leftOnly, + Set rightOnly) { + Set leftOnlyStrings = new HashSet<>(); + Set rightOnlyStrings = new HashSet<>(); + for (OWLAxiom ax : leftOnly) { + leftOnlyStrings.add(ax.toString().replaceAll("_:anon-ind-[0-9]+", BLANK) + .replaceAll("_:genid[0-9]+", BLANK)); + } + for (OWLAxiom ax : rightOnly) { + rightOnlyStrings.add(ax.toString().replaceAll("_:anon-ind-[0-9]+", BLANK) + .replaceAll("_:genid[0-9]+", BLANK)); + } + return rightOnlyStrings.equals(leftOnlyStrings); + } + + /** + * ignore declarations of builtins and of named individuals - named individuals do not /need/ a + * declaration, but adding one is not an error. + * + * @param parse true if the axiom belongs to the parsed ones, false for the input + * @return true if the axiom can be ignored + */ + public boolean isIgnorableAxiom(OWLAxiom ax, boolean parse) { + if (ax instanceof OWLDeclarationAxiom) { + if (parse) { + // all extra declarations in the parsed ontology are fine + return true; + } + OWLDeclarationAxiom d = (OWLDeclarationAxiom) ax; + // declarations of builtin and named individuals can be ignored + return d.getEntity().isBuiltIn() || d.getEntity().isOWLNamedIndividual(); + } + return false; + } + + public OWLOntology getOWLOntology() { + try { + return m.createOntology(IRI.getNextDocumentIRI(uriBase)); + } catch (OWLOntologyCreationException e) { + throw new OWLRuntimeException(e); + } + } + + public OWLOntology getOWLOntology(IRI iri) { + try { + return m.createOntology(iri); + } catch (OWLOntologyCreationException e) { + throw new OWLRuntimeException(e); + } + } + + public OWLOntology getOWLOntology(OWLOntologyID iri) { + try { + return m.createOntology(iri); + } catch (OWLOntologyCreationException e) { + throw new OWLRuntimeException(e); + } + } + + public OWLOntology getAnonymousOWLOntology() { + try { + return m.createOntology(); + } catch (OWLOntologyCreationException e) { + throw new OWLRuntimeException(e); + } + } + + public OWLOntology roundTripOntology(OWLOntology ont) { + return roundTripOntology(ont, new RDFXMLDocumentFormat()); + } + + /** + * Saves the specified ontology in the specified format and reloads it. Calling this method from + * a test will cause the test to fail if the ontology could not be stored, could not be + * reloaded, or was reloaded and the reloaded version is not equal (in terms of ontology URI and + * axioms) with the original. + * + * @param ont The ontology to round trip. + * @param format The format to use when doing the round trip. + */ + public OWLOntology roundTripOntology(OWLOntology ont, OWLDocumentFormat format) { + try { + StringDocumentTarget target = new StringDocumentTarget(); + OWLDocumentFormat fromFormat = ont.getFormat(); + if (fromFormat.isPrefixOWLDocumentFormat() && format.isPrefixOWLDocumentFormat()) { + PrefixDocumentFormat fromPrefixFormat = fromFormat.asPrefixOWLDocumentFormat(); + PrefixDocumentFormat toPrefixFormat = format.asPrefixOWLDocumentFormat(); + toPrefixFormat.copyPrefixesFrom(fromPrefixFormat); + toPrefixFormat.setDefaultPrefix(null); + } + format.setAddMissingTypes(true); + if (logger.isTraceEnabled()) { + StringDocumentTarget targetForDebug = new StringDocumentTarget(); + ont.saveOntology(format, targetForDebug); + logger.trace(targetForDebug.toString()); + } + ont.saveOntology(format, target); + handleSaved(target, format); + OWLOntology ont2 = setupManager().loadOntologyFromOntologyDocument( + new StringDocumentSource(target.toString(), "string:ontology", format, null), + new OWLOntologyLoaderConfiguration().setReportStackTraces(true)); + if (logger.isTraceEnabled()) { + logger.trace("TestBase.roundTripOntology() ontology parsed"); + ont2.axioms().forEach(ax -> logger.trace(ax.toString())); + } + equal(ont, ont2); + return ont2; + } catch (OWLRuntimeException e) { + throw e; + } catch (Exception e) { + throw new OWLRuntimeException(e); + } + } + + // @Test + public void checkVerify() { + OWLDataProperty t = df.getOWLDataProperty("urn:test#", "t"); + Set ax1 = new HashSet<>(); + ax1.add(df.getOWLDataPropertyAssertionAxiom(t, df.getOWLAnonymousIndividual(), + df.getOWLLiteral("test1"))); + ax1.add(df.getOWLDataPropertyAssertionAxiom(t, df.getOWLAnonymousIndividual(), + df.getOWLLiteral("test2"))); + Set ax2 = new HashSet<>(); + ax2.add(df.getOWLDataPropertyAssertionAxiom(t, df.getOWLAnonymousIndividual(), + df.getOWLLiteral("test1"))); + ax2.add(df.getOWLDataPropertyAssertionAxiom(t, df.getOWLAnonymousIndividual(), + df.getOWLLiteral("test2"))); + assertFalse(ax1.equals(ax2)); + assertTrue(verifyErrorIsDueToBlankNodesId(ax1, ax2)); + } + + @SuppressWarnings("unused") + protected void handleSaved(StringDocumentTarget target, OWLDocumentFormat format) { + // System.out.println(target.toString()); + } + + public OWLOntology loadOntology(String fileName) { + return loadOntology(fileName, m); + } + + public OWLOntology loadOntology(String fileName, OWLOntologyManager manager) { + try { + URL url = getClass().getResource('/' + fileName); + return manager.loadOntologyFromOntologyDocument( + new IRIDocumentSource(IRI.create(url), null, null), + new OWLOntologyLoaderConfiguration().setReportStackTraces(true)); + } catch (OWLOntologyCreationException e) { + throw new OWLRuntimeException(e); + } + } + + protected OWLOntology loadOntologyFromString(String input) { + try { + return setupManager().loadOntologyFromOntologyDocument(new StringDocumentSource(input)); + } catch (OWLRuntimeException e) { + throw e; + } catch (Exception e) { + throw new OWLRuntimeException(e); + } + } + + protected OWLOntology loadOntologyFromString(String input, IRI i, OWLDocumentFormat f) { + StringDocumentSource documentSource = new StringDocumentSource(input, i, f, null); + try { + return setupManager().loadOntologyFromOntologyDocument(documentSource); + } catch (OWLOntologyCreationException e) { + throw new OWLRuntimeException(e); + } + } + + protected OWLOntology loadOntologyFromString(String input, OWLDocumentFormat f) { + StringDocumentSource documentSource = + new StringDocumentSource(input, IRI.generateDocumentIRI(), f, null); + try { + return setupManager().loadOntologyFromOntologyDocument(documentSource); + } catch (OWLOntologyCreationException e) { + throw new OWLRuntimeException(e); + } + } + + protected OWLOntology loadOntologyFromString(String input, OWLDocumentFormat f, + OWLOntologyLoaderConfiguration c) { + StringDocumentSource documentSource = + new StringDocumentSource(input, IRI.generateDocumentIRI(), f, null); + try { + return setupManager().loadOntologyFromOntologyDocument(documentSource, c); + } catch (OWLOntologyCreationException e) { + throw new OWLRuntimeException(e); + } + } + + protected OWLOntology loadOntologyFromString(StringDocumentSource input) { + try { + return setupManager().loadOntologyFromOntologyDocument(input); + } catch (OWLRuntimeException e) { + throw e; + } catch (Exception e) { + throw new OWLRuntimeException(e); + } + } + + protected OWLOntology loadOntologyFromString(StringDocumentTarget input) { + try { + return setupManager().loadOntologyFromOntologyDocument(new StringDocumentSource(input)); + } catch (OWLOntologyCreationException e) { + throw new OWLRuntimeException(e); + } + } + + protected OWLOntology loadOntologyFromString(StringDocumentTarget input, OWLDocumentFormat f) { + try { + return setupManager().loadOntologyFromOntologyDocument( + new StringDocumentSource(input.toString(), "string:ontology", f, null)); + } catch (OWLOntologyCreationException e) { + throw new OWLRuntimeException(e); + } + } + + protected OWLOntology loadOntologyStrict(StringDocumentTarget o) { + return loadOntologyWithConfig(o, new OWLOntologyLoaderConfiguration().setStrict(true)); + } + + protected OWLOntology loadOntologyStrict(String s, OWLDocumentFormat f) { + return loadOntologyWithConfig(new StringDocumentSource(s, "string:ontology", f, null), + new OWLOntologyLoaderConfiguration().setStrict(true)); + } + + protected OWLOntology loadOntologyWithConfig(StringDocumentTarget o, + OWLOntologyLoaderConfiguration c) { + return loadOntologyWithConfig(new StringDocumentSource(o), c); + } + + protected OWLOntology loadOntologyWithConfig(StringDocumentSource o, + OWLOntologyLoaderConfiguration c) { + try { + return setupManager().loadOntologyFromOntologyDocument(o, c); + } catch (OWLRuntimeException e) { + throw e; + } catch (Exception e) { + throw new OWLRuntimeException(e); + } + } + + protected StringDocumentTarget saveOntology(OWLOntology o) { + return saveOntology(o, o.getNonnullFormat()); + } + + protected StringDocumentTarget saveOntology(OWLOntology o, OWLDocumentFormat format) { + try { + StringDocumentTarget t = new StringDocumentTarget(); + o.saveOntology(format, t); + return t; + } catch (OWLRuntimeException e) { + throw e; + } catch (Exception e) { + throw new OWLRuntimeException(e); + } + } + + protected OWLOntology roundTrip(OWLOntology o, OWLDocumentFormat format) { + return loadOntologyFromString(saveOntology(o, format), format); + } + + protected OWLOntology roundTrip(OWLOntology o, OWLDocumentFormat format, + OWLOntologyLoaderConfiguration c) { + return loadOntologyWithConfig(saveOntology(o, format), c); + } + + protected OWLOntology roundTrip(OWLOntology o) { + return loadOntologyFromString(saveOntology(o)); + } + + protected interface AxiomBuilder { + List build(); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/package-info.java new file mode 100644 index 0000000000..da774bf737 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/baseclasses/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.api.test.baseclasses; diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/classexpressions/SameIndividualsThreeElementsAxiomAnnotatedRoundTripTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/classexpressions/SameIndividualsThreeElementsAxiomAnnotatedRoundTripTestCase.java new file mode 100644 index 0000000000..88c65723ce --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/classexpressions/SameIndividualsThreeElementsAxiomAnnotatedRoundTripTestCase.java @@ -0,0 +1,131 @@ +package org.semanticweb.owlapi.api.test.classexpressions; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Annotation; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Declaration; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NamedIndividual; +import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; +import java.util.function.Function; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.NQuadsDocumentFormatFactory; +import org.semanticweb.owlapi.formats.NTriplesDocumentFormatFactory; +import org.semanticweb.owlapi.formats.RDFJsonDocumentFormatFactory; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormatFactory; +import org.semanticweb.owlapi.formats.RioRDFXMLDocumentFormatFactory; +import org.semanticweb.owlapi.formats.RioTurtleDocumentFormatFactory; +import org.semanticweb.owlapi.formats.TrigDocumentFormatFactory; +import org.semanticweb.owlapi.formats.TurtleDocumentFormatFactory; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDocumentFormatFactory; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; + +class SameIndividualsThreeElementsAxiomAnnotatedRoundTripTestCase extends TestBase { + + + protected OWLOntology createOntology() { + Function, OWLAxiom> f = + a -> df.getOWLSameIndividualAxiom(Arrays.asList(NamedIndividual(iri("A")), + NamedIndividual(iri("B")), NamedIndividual(iri("C"))), a); + + OWLAnnotationProperty prop = AnnotationProperty(iri("prop")); + OWLLiteral lit = Literal("Test", ""); + OWLAnnotation anno1 = Annotation(prop, lit); + OWLAnnotationProperty prop2 = AnnotationProperty(iri("prop2")); + OWLAnnotation anno2 = Annotation(prop2, lit); + Set annos = new HashSet<>(Arrays.asList(anno1, anno2)); + Set axioms = new HashSet<>(); + OWLAxiom ax = f.apply(annos); + axioms.add(ax.getAnnotatedAxiom(annos)); + axioms.add(Declaration(prop)); + axioms.add(Declaration(prop2)); + axioms.add(ax.getAnnotatedAxiom(singleton(anno1))); + axioms.add(ax.getAnnotatedAxiom(singleton(anno2))); + OWLOntology ont = getOWLOntology(); + ont.add(axioms); + ont.unsortedSignature().filter(e -> !e.isBuiltIn() && !ont.isDeclared(e, INCLUDED)) + .forEach(e -> ont.add(Declaration(e))); + return ont; + } + + @Test + public void testRDFXML() { + // axioms with three or more elements cannot be represented as one axiom in this syntax + sameIndividualAssertion(createOntology(), new RDFXMLDocumentFormatFactory()); + } + + @Test + public void testRioRDFXML() { + // axioms with three or more elements cannot be represented as one axiom in this syntax + sameIndividualAssertion(createOntology(), new RioRDFXMLDocumentFormatFactory()); + } + + @Test + public void testTrig() { + // axioms with three or more elements cannot be represented as one axiom in this syntax + sameIndividualAssertion(createOntology(), new TrigDocumentFormatFactory()); + } + + @Test + public void testRDFJSON() { + // axioms with three or more elements cannot be represented as one axiom in this syntax + sameIndividualAssertion(createOntology(), new RDFJsonDocumentFormatFactory()); + } + + @Test + public void testNTriples() { + // axioms with three or more elements cannot be represented as one axiom in this syntax + sameIndividualAssertion(createOntology(), new NTriplesDocumentFormatFactory()); + } + + @Test + public void roundTripRDFXMLAndFunctionalShouldBeSame() { + // axioms with three or more elements cannot be represented as one axiom in this syntax + // super.roundTripRDFXMLAndFunctionalShouldBeSame(); + } + + @Test + public void testJSONLD() { + // axioms with three or more elements cannot be represented as one axiom in this syntax + sameIndividualAssertion(createOntology(), new RDFJsonDocumentFormatFactory()); + } + + @Test + public void testNQuads() { + // axioms with three or more elements cannot be represented as one axiom in this syntax + sameIndividualAssertion(createOntology(), new NQuadsDocumentFormatFactory()); + } + + @Test + public void testTurtle() { + // axioms with three or more elements cannot be represented as one axiom in this syntax + sameIndividualAssertion(createOntology(), new TurtleDocumentFormatFactory()); + } + + @Test + public void testRioTurtle() { + // axioms with three or more elements cannot be represented as one axiom in this syntax + sameIndividualAssertion(createOntology(), new RioTurtleDocumentFormatFactory()); + } + + protected void sameIndividualAssertion(OWLOntology ont, OWLDocumentFormatFactory f) { + OWLOntology o = + loadOntologyFromString(saveOntology(ont, f.createFormat()), f.createFormat()); + assertEquals(3, o.getAxiomCount(AxiomType.SAME_INDIVIDUAL)); + ont.axioms(AxiomType.SAME_INDIVIDUAL).map(OWLSameIndividualAxiom::splitToAnnotatedPairs) + .forEach(axs -> axs.forEach(a -> assertTrue(o.containsAxiom(a)))); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/AddAxiomDataTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/AddAxiomDataTestCase.java new file mode 100644 index 0000000000..ea1734a49a --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/AddAxiomDataTestCase.java @@ -0,0 +1,54 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.dataproperties; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.mock; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.change.AddAxiomData; +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.2.0 + */ +class AddAxiomDataTestCase { + + private final OWLAxiom mockAxiom = mock(OWLAxiom.class); + private final OWLOntology mockOntology = mock(OWLOntology.class); + + @Test + void testEquals() { + AddAxiomData data1 = new AddAxiomData(mockAxiom); + AddAxiomData data2 = new AddAxiomData(mockAxiom); + assertEquals(data1, data2); + } + + @Test + void testOntologyChange() { + AddAxiomData data = new AddAxiomData(mockAxiom); + AddAxiom change = data.createOntologyChange(mockOntology); + assertEquals(change.getOntology(), mockOntology); + assertEquals(change.getAxiom(), mockAxiom); + } + + @Test + void testRoundTripChange() { + AddAxiomData data = new AddAxiomData(mockAxiom); + AddAxiom change = new AddAxiom(mockOntology, mockAxiom); + assertEquals(data, change.getChangeData()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/AllDifferentTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/AllDifferentTestCase.java new file mode 100644 index 0000000000..52e64c25b8 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/AllDifferentTestCase.java @@ -0,0 +1,31 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.dataproperties; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.OWLOntology; + +class AllDifferentTestCase extends TestBase { + + @Test + void testDistinctMembers() { + OWLOntology o1 = + loadOntologyFromString(TestFiles.distinctMembers1, new RDFXMLDocumentFormat()); + OWLOntology o2 = + loadOntologyFromString(TestFiles.distinctMembers2, new RDFXMLDocumentFormat()); + equal(o2, o1); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/DisjointClassesRoundTripTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/DisjointClassesRoundTripTestCase.java new file mode 100644 index 0000000000..bb6bc610ff --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/DisjointClassesRoundTripTestCase.java @@ -0,0 +1,54 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.dataproperties; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DisjointClasses; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectUnionOf; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.equalStreams; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.PrefixDocumentFormat; +import org.semanticweb.owlapi.model.OWLOntology; + +class DisjointClassesRoundTripTestCase extends TestBase { + + static final String NS = "http://ns.owl"; + + @Test + void shouldParse() { + OWLOntology ontology = buildOntology(); + OWLOntology roundtripped = loadOntologyFromString(TestFiles.parseDisjointClasses, + new ManchesterSyntaxDocumentFormat()); + equal(ontology, roundtripped); + } + + @Test + void shouldRoundTrip() { + OWLOntology ontology = buildOntology(); + PrefixDocumentFormat format = new ManchesterSyntaxDocumentFormat(); + format.setPrefix("piz", NS + '#'); + OWLOntology roundtripped = roundTrip(ontology, format); + assertTrue(equalStreams(ontology.logicalAxioms(), roundtripped.logicalAxioms())); + } + + private OWLOntology buildOntology() { + OWLOntology ontology = getOWLOntology(iri(NS, "")); + ontology + .add(DisjointClasses(ObjectUnionOf(C, D), ObjectUnionOf(C, E), ObjectUnionOf(C, F))); + return ontology; + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/DisjointUnionTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/DisjointUnionTestCase.java new file mode 100644 index 0000000000..dd49526343 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/DisjointUnionTestCase.java @@ -0,0 +1,39 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.dataproperties; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DisjointUnion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLOntology; + +class DisjointUnionTestCase extends TestBase { + + static final String NS = "http://protege.org/protege/DisjointUnion.owl"; + static final OWLClass A = Class(IRI(NS + "#", "A")); + static final OWLClass B = Class(IRI(NS + "#", "B")); + static final OWLClass C = Class(IRI(NS + "#", "C")); + + @Test + void testDisjointUnion() { + OWLOntology ontology = getOWLOntology(); + ontology.add(DisjointUnion(A, B, C)); + assertEquals(1, ontology.disjointUnionAxioms(A).count()); + assertEquals(0, ontology.disjointUnionAxioms(B).count()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/EquivalentClassesAxiomTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/EquivalentClassesAxiomTestCase.java new file mode 100644 index 0000000000..175dcd0ab0 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/EquivalentClassesAxiomTestCase.java @@ -0,0 +1,95 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.dataproperties; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentClasses; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.OWLNothing; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.OWLThing; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectSomeValuesFrom; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubClassOf; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.Collection; +import java.util.Set; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; + +/** + * @author Matthew Horridge, The University Of Manchester, Information Management Group + * @since 2.2.0 + */ +class EquivalentClassesAxiomTestCase extends TestBase { + + @Test + void testContainsNamedClass() { + OWLClassExpression desc = ObjectSomeValuesFrom(P, B); + OWLClassExpression desc2 = ObjectSomeValuesFrom(P, A); + OWLEquivalentClassesAxiom ax = EquivalentClasses(A, desc); + assertTrue(ax.containsNamedEquivalentClass()); + OWLEquivalentClassesAxiom ax2 = EquivalentClasses(desc, desc2); + assertFalse(ax2.containsNamedEquivalentClass()); + } + + @Test + void testGetNamedClasses() { + OWLClassExpression desc = ObjectSomeValuesFrom(P, B); + OWLEquivalentClassesAxiom ax = EquivalentClasses(A, desc); + Set clses = asUnorderedSet(ax.namedClasses()); + assertEquals(1, clses.size()); + assertTrue(clses.contains(A)); + } + + @Test + void testGetNamedClassesWithNothing() { + OWLClassExpression desc = ObjectSomeValuesFrom(P, B); + OWLEquivalentClassesAxiom ax = EquivalentClasses(OWLNothing(), desc); + Set clses = asUnorderedSet(ax.namedClasses()); + assertTrue(clses.isEmpty()); + assertFalse(ax.containsOWLThing()); + assertTrue(ax.containsOWLNothing()); + } + + @Test + void testGetNamedClassesWithThing() { + OWLClassExpression desc = ObjectSomeValuesFrom(P, B); + OWLEquivalentClassesAxiom ax = EquivalentClasses(OWLThing(), desc); + Set clses = asUnorderedSet(ax.namedClasses()); + assertTrue(clses.isEmpty()); + assertFalse(ax.containsOWLNothing()); + assertTrue(ax.containsOWLThing()); + } + + @Test + void testSplit() { + OWLEquivalentClassesAxiom ax = EquivalentClasses(A, B, C); + Collection scas = ax.asOWLSubClassOfAxioms(); + assertEquals(6, scas.size()); + assertTrue(scas.contains(SubClassOf(A, B))); + assertTrue(scas.contains(SubClassOf(B, A))); + assertTrue(scas.contains(SubClassOf(A, C))); + assertTrue(scas.contains(SubClassOf(C, A))); + assertTrue(scas.contains(SubClassOf(B, C))); + assertTrue(scas.contains(SubClassOf(C, B))); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/RemoveAxiomDataTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/RemoveAxiomDataTestCase.java new file mode 100644 index 0000000000..89e79a34f3 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/RemoveAxiomDataTestCase.java @@ -0,0 +1,63 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.dataproperties; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.change.RemoveAxiomData; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.RemoveAxiom; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.2.0 + */ +class RemoveAxiomDataTestCase { + + private final OWLAxiom mockAxiom = mock(OWLAxiom.class); + private final OWLOntology mockOntology = mock(OWLOntology.class); + + @Test + void testEquals() { + RemoveAxiomData data1 = new RemoveAxiomData(mockAxiom); + RemoveAxiomData data2 = new RemoveAxiomData(mockAxiom); + assertEquals(data1, data2); + assertEquals(data1.hashCode(), data2.hashCode()); + } + + @Test + void testGettersNotNull() { + RemoveAxiomData data = new RemoveAxiomData(mockAxiom); + assertNotNull(data.getAxiom()); + } + + @Test + void testCreateOntologyChange() { + RemoveAxiomData data = new RemoveAxiomData(mockAxiom); + RemoveAxiom change = data.createOntologyChange(mockOntology); + assertNotNull(change); + assertEquals(change.getOntology(), mockOntology); + assertEquals(change.getAxiom(), mockAxiom); + } + + @Test + void testRoundTripChange() { + RemoveAxiomData data = new RemoveAxiomData(mockAxiom); + RemoveAxiom change = new RemoveAxiom(mockOntology, mockAxiom); + assertEquals(data, change.getChangeData()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/package-info.java new file mode 100644 index 0000000000..da50ff62bd --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/dataproperties/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.api.test.dataproperties; diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/fileroundtrip/FileRoundTripCorrectAxiomsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/fileroundtrip/FileRoundTripCorrectAxiomsTestCase.java new file mode 100644 index 0000000000..71fda76a76 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/fileroundtrip/FileRoundTripCorrectAxiomsTestCase.java @@ -0,0 +1,236 @@ +package org.semanticweb.owlapi.api.test.fileroundtrip; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataAllValuesFrom; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataComplementOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataHasValue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataIntersectionOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataMaxCardinality; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataMinCardinality; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataOneOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataPropertyRange; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataSomeValuesFrom; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataUnionOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Datatype; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DatatypeRestriction; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Declaration; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DisjointClasses; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.FacetRestriction; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Float; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.HasKey; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Integer; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.InverseObjectProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NamedIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.OWLThing; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectAllValuesFrom; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectComplementOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectExactCardinality; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectHasSelf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectHasValue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectIntersectionOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectMaxCardinality; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectMinCardinality; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectOneOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectPropertyAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectSomeValuesFrom; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectUnionOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubClassOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.TopDatatype; +import static org.semanticweb.owlapi.model.parameters.Imports.EXCLUDED; +import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.parameters.AxiomAnnotations; +import org.semanticweb.owlapi.reasoner.BufferingMode; +import org.semanticweb.owlapi.reasoner.SimpleConfiguration; +import org.semanticweb.owlapi.reasoner.structural.StructuralReasoner; +import org.semanticweb.owlapi.search.Searcher; +import org.semanticweb.owlapi.vocab.OWLFacet; + +class FileRoundTripCorrectAxiomsTestCase extends TestBase { + + static final OWLDataProperty DAP = DataProperty(IRI("http://example.com/", "dataProperty")); + static final OWLObjectProperty OP = + ObjectProperty(IRI("http://example.com/", "objectProperty")); + static final OWLClass PERSON = Class(IRI("http://example.com/", "Person")); + static final String DECLARATIONS = "http://www.semanticweb.org/ontologies/declarations#"; + static final OWLDeclarationAxiom DATATYPE = Declaration(Datatype(IRI(DECLARATIONS, "dt"))); + static final OWLDeclarationAxiom ANNOTATIONP = + Declaration(AnnotationProperty(IRI(DECLARATIONS, "ap"))); + static final OWLDeclarationAxiom NAMED_INDIVIDUAL = + Declaration(NamedIndividual(IRI(DECLARATIONS, "ni"))); + static final OWLDeclarationAxiom DATA_PROPERTY = + Declaration(DataProperty(IRI(DECLARATIONS, "dp"))); + static final String OWLAPI_TEST = "http://www.semanticweb.org/owlapi/test#"; + static final OWLDeclarationAxiom DECLARATION_A = + Declaration(Class(IRI("http://owlapi.sourceforge.net/ontology#", "ClsA"))); + static final OWLClass subCls = Class(IRI(OWLAPI_TEST, "A")); + static final OWLClass supCls = Class(IRI(OWLAPI_TEST, "B")); + static final OWLClass fillerCls = Class(IRI(OWLAPI_TEST, "C")); + static final OWLObjectProperty property = ObjectProperty(IRI(OWLAPI_TEST, "P")); + static final OWLDatatype DATAB = Datatype(iri("B")); + static final OWLDeclarationAxiom dpd = Declaration(DP); + static final OWLDeclarationAxiom dbb = Declaration(DATAB); + static final OWLDeclarationAxiom pd = Declaration(P); + static final OWLDeclarationAxiom cd = Declaration(Class(IRI(DECLARATIONS, "Cls"))); + static final OWLDeclarationAxiom opd = Declaration(ObjectProperty(IRI(DECLARATIONS, "op"))); + static final OWLDeclarationAxiom bd = Declaration(B); + static final IRI clsA = IRI(OWLAPI_TEST, "ClsA"); + static final IRI prop = IRI(OWLAPI_TEST, "prop"); + static final OWLNamedIndividual subject = + NamedIndividual(IRI("http://Example.com#", "myBuilding")); + static final OWLObjectProperty predicate = + ObjectProperty(IRI("http://Example.com#", "located_at")); + static final OWLNamedIndividual object = + NamedIndividual(IRI("http://Example.com#", "myLocation")); + + protected void assertEqualsSet(String ontology, Set axioms) { + assertEquals(asUnorderedSet(ontologyFromClasspathFile(ontology).axioms()), axioms); + } + + static Stream axioms() { + return Stream.of( + //@formatter:off + of("DataComplementOf.rdf", DataPropertyRange(DP, DataComplementOf(Integer())), dpd), + of("DataIntersectionOf.rdf", DataPropertyRange(DP, DataIntersectionOf(Integer(), Float())), dpd), + of("DataOneOf.rdf", DataPropertyRange(DP, DataOneOf(Literal(30), Literal(31f))), dpd), + of("DataUnionOf.rdf", DataPropertyRange(DP, DataUnionOf(Integer(), Float())), dpd), + of("DatatypeRestriction.rdf", DataPropertyRange(DP, DatatypeRestriction(Integer(), FacetRestriction(OWLFacet.MIN_INCLUSIVE, Literal(18)), FacetRestriction(OWLFacet.MAX_INCLUSIVE, Literal(30)))), dpd), + of("ComplexSubProperty.rdf", df.getOWLSubPropertyChainOfAxiom(Arrays.asList(P, Q), R)), + of("TestDeclarations.rdf", DATA_PROPERTY, NAMED_INDIVIDUAL, ANNOTATIONP, DATATYPE, cd, opd), + of("DisjointClasses.rdf", DisjointClasses(A, B, C)), + of("HasKey.rdf", HasKey(PERSON, OP, DAP), Declaration(PERSON), Declaration(DAP), Declaration(OP)), + of("InverseOf.rdf", InverseObjectProperties(P, Q)), + of("DataAllValuesFrom.rdf", SubClassOf(A, DataAllValuesFrom(DP, DATAB)), dbb, dpd), + of("DataHasValue.rdf", SubClassOf(A, DataHasValue(DP, Literal(3))), dpd, SubClassOf(A, DataHasValue(DP, Literal("A", "")))), + of("DataMaxCardinality.rdf", SubClassOf(A, DataMaxCardinality(3, DP, TopDatatype())), dpd), + of("DataMinCardinality.rdf", SubClassOf(A, DataMinCardinality(3, DP, TopDatatype())), dpd), + of("DataSomeValuesFrom.rdf", SubClassOf(A, DataSomeValuesFrom(DP, DATAB)), dbb, dpd), + of("ObjectAllValuesFrom.rdf", SubClassOf(A, ObjectAllValuesFrom(P, B)), bd, pd), + of("ObjectCardinality.rdf", SubClassOf(A, ObjectExactCardinality(3, P, OWLThing())), pd), + of("ObjectComplementOf.rdf", SubClassOf(A, ObjectComplementOf(B))), + of("ObjectHasSelf.rdf", SubClassOf(A, ObjectHasSelf(P)), pd), + of("ObjectHasValue.rdf", SubClassOf(A, ObjectHasValue(P, NamedIndividual(iri("a")))), pd), + of("ObjectIntersectionOf.rdf", SubClassOf(A, ObjectIntersectionOf(B, C))), + of("ObjectMaxCardinality.rdf", SubClassOf(A, ObjectMaxCardinality(3, P, OWLThing())), pd), + of("ObjectMaxQualifiedCardinality.rdf",SubClassOf(A, ObjectMaxCardinality(3, P, B)), pd), + of("ObjectMinCardinality.rdf", SubClassOf(A, ObjectMinCardinality(3, P, OWLThing())), pd), + of("ObjectMinQualifiedCardinality.rdf",SubClassOf(A, ObjectMinCardinality(3, P, B)), pd), + of("ObjectOneOf.rdf", SubClassOf(A, ObjectOneOf(NamedIndividual(iri("a")), NamedIndividual(iri("b"))))), + of("ObjectQualifiedCardinality.rdf", SubClassOf(A, ObjectExactCardinality(3, P, B)), pd), + of("ObjectSomeValuesFrom.rdf", SubClassOf(A, ObjectSomeValuesFrom(P, B)), bd, pd), + of("ObjectUnionOf.rdf", SubClassOf(A, ObjectUnionOf(B, C))), + of("SubClassOf.rdf", SubClassOf(A, B)), + of("UntypedSubClassOf.rdf", SubClassOf(A, B)) + //@formatter:on + ); + } + + static Arguments of(String s, OWLAxiom... axioms) { + return Arguments.of(s, new HashSet<>(Arrays.asList(axioms))); + } + + @ParameterizedTest + @MethodSource("axioms") + void testContainsComplexSubPropertyAxiom(String name, Set axioms) { + assertEqualsSet(name, axioms); + } + + @Test + void testCorrectAxiomAnnotatedPropertyAssertions() { + OWLOntology ontology = ontologyFromClasspathFile("AnnotatedPropertyAssertions.rdf"); + OWLAxiom ax = ObjectPropertyAssertion(predicate, subject, object); + assertTrue(ontology.containsAxiom(ax, EXCLUDED, AxiomAnnotations.IGNORE_AXIOM_ANNOTATIONS)); + Set axioms = asUnorderedSet(ontology.axiomsIgnoreAnnotations(ax, EXCLUDED)); + assertEquals(1, axioms.size()); + OWLAxiom theAxiom = axioms.iterator().next(); + assertTrue(theAxiom.isAnnotated()); + } + + @Test + void testDeprecatedAnnotationAssertionsPresent() { + OWLOntology ont = ontologyFromClasspathFile("Deprecated.rdf"); + Searcher.annotationObjects(ont.annotationAssertionAxioms(clsA, INCLUDED)) + .forEach(a -> a.isDeprecatedIRIAnnotation()); + Searcher.annotationObjects(ont.annotationAssertionAxioms(prop, INCLUDED)) + .forEach(a -> assertTrue(a.isDeprecatedIRIAnnotation())); + } + + @Test + void testCorrectAxiomsRDFSClass() { + OWLOntology ont = ontologyFromClasspathFile("RDFSClass.rdf"); + assertTrue(ont.containsAxiom(DECLARATION_A)); + } + + @Test + void testStructuralReasonerRecusion() { + OWLOntology ontology = ontologyFromClasspathFile("koala.owl"); + String ontName = ontology.getOntologyID().getOntologyIRI().get().toString(); + StructuralReasoner reasoner = + new StructuralReasoner(ontology, new SimpleConfiguration(), BufferingMode.BUFFERING); + OWLClass cls = Class(IRI(ontName + "#", "Koala")); + reasoner.getSubClasses(cls, false); + reasoner.getSuperClasses(cls, false); + } + + @Test + void testIsGCIMethodSubClassAxiom() { + assertFalse(SubClassOf(A, B).isGCI()); + assertTrue(SubClassOf(ObjectIntersectionOf(A, C), B).isGCI()); + } + + @Test + void testParsedAxiomsSubClassOfUntypedOWLClass() { + OWLOntology ontology = ontologyFromClasspathFile("SubClassOfUntypedOWLClass.rdf"); + List axioms = asList(ontology.axioms(AxiomType.SUBCLASS_OF)); + assertEquals(1, axioms.size()); + OWLSubClassOfAxiom ax = axioms.get(0); + assertEquals(subCls, ax.getSubClass()); + assertEquals(supCls, ax.getSuperClass()); + } + + @Test + void testParsedAxiomsSubClassOfUntypedSomeValuesFrom() { + OWLOntology ontology = ontologyFromClasspathFile("SubClassOfUntypedSomeValuesFrom.rdf"); + List axioms = asList(ontology.axioms(AxiomType.SUBCLASS_OF)); + assertEquals(1, axioms.size()); + OWLSubClassOfAxiom ax = axioms.get(0); + assertEquals(subCls, ax.getSubClass()); + assertTrue(ax.getSuperClass() instanceof OWLObjectSomeValuesFrom); + OWLObjectSomeValuesFrom someValuesFrom = (OWLObjectSomeValuesFrom) ax.getSuperClass(); + assertEquals(property, someValuesFrom.getProperty()); + assertEquals(fillerCls, someValuesFrom.getFiller()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/fileroundtrip/NonSymmetricAxiomsRoundTrippingTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/fileroundtrip/NonSymmetricAxiomsRoundTrippingTestCase.java new file mode 100644 index 0000000000..26adadbb24 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/fileroundtrip/NonSymmetricAxiomsRoundTrippingTestCase.java @@ -0,0 +1,56 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.fileroundtrip; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.*; + +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.model.*; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +class NonSymmetricAxiomsRoundTrippingTestCase extends TestBase { + + static Stream nonSymmetricAxiomsRoundTrippingTestCase() { + OWLDatatype dataD = Datatype(iri("D")); + OWLDatatype dataE = Datatype(iri("E")); + OWLObjectSomeValuesFrom d = ObjectSomeValuesFrom(P, ObjectIntersectionOf(B, C)); + OWLDataSomeValuesFrom e = DataSomeValuesFrom(DP, DataIntersectionOf(dataD, dataE)); + OWLClassExpression du = ObjectUnionOf(B, C); + OWLDataUnionOf eu = DataUnionOf(dataD, dataE); + return Stream.of( + Arguments.of(SubClassOf(A, ObjectIntersectionOf(d, d)), SubClassOf(A, d)), + Arguments.of(SubClassOf(A, ObjectUnionOf(e, e)), SubClassOf(A, e)), + Arguments.of(SubClassOf(A, ObjectIntersectionOf(du, du)), SubClassOf(A, du)), + Arguments.of(DatatypeDefinition(dataD, DataUnionOf(eu, eu)), DatatypeDefinition(dataD, eu))); + } + + @ParameterizedTest + @MethodSource("nonSymmetricAxiomsRoundTrippingTestCase") + void shouldRoundTripAReadableVersion(OWLAxiom in, OWLAxiom out) { + OWLOntology output = getOWLOntology(); + output.add(in); + OWLOntology o = roundTrip(output, new FunctionalSyntaxDocumentFormat()); + assertEquals(1, o.logicalAxioms().count()); + assertEquals(out, o.logicalAxioms().iterator().next()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/fileroundtrip/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/fileroundtrip/package-info.java new file mode 100644 index 0000000000..74fa2c65dd --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/fileroundtrip/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.api.test.fileroundtrip; diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/AddImportDataTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/AddImportDataTestCase.java new file mode 100644 index 0000000000..4a3ddf6be1 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/AddImportDataTestCase.java @@ -0,0 +1,73 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.imports; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.change.AddImportData; +import org.semanticweb.owlapi.model.AddImport; +import org.semanticweb.owlapi.model.OWLImportsDeclaration; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.2.0 + */ +class AddImportDataTestCase { + + private final OWLImportsDeclaration mockDeclaration = mock(OWLImportsDeclaration.class); + private final OWLOntology mockOntology = mock(OWLOntology.class); + + private AddImportData createData() { + return new AddImportData(mockDeclaration); + } + + @Test + void testEquals() { + AddImportData data1 = createData(); + AddImportData data2 = createData(); + assertEquals(data1, data2); + assertEquals(data1.hashCode(), data2.hashCode()); + } + + @Test + void testGettersReturnNotNull() { + AddImportData data = createData(); + assertNotNull(data.getDeclaration()); + assertNotNull(data.createOntologyChange(mockOntology)); + } + + @Test + void testGettersEquals() { + AddImportData data = createData(); + assertEquals(mockDeclaration, data.getDeclaration()); + } + + @Test + void testCreateOntologyChange() { + AddImportData data = createData(); + AddImport change = data.createOntologyChange(mockOntology); + assertEquals(mockOntology, change.getOntology()); + assertEquals(mockDeclaration, change.getImportDeclaration()); + } + + @Test + void testOntologyChangeSymmetry() { + AddImportData data = createData(); + AddImport change = new AddImport(mockOntology, mockDeclaration); + assertEquals(change.getChangeData(), data); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/AutoIRIMapperTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/AutoIRIMapperTestCase.java new file mode 100644 index 0000000000..53fead34b1 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/AutoIRIMapperTestCase.java @@ -0,0 +1,19 @@ +package org.semanticweb.owlapi.api.test.imports; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.util.AutoIRIMapper; + +class AutoIRIMapperTestCase extends TestBase { + + @Test + void shouldTestIRIMapperForOWLXML() { + AutoIRIMapper mapper = new AutoIRIMapper(RESOURCES, false); + IRI documentIRI = mapper.getDocumentIRI(iri("urn:test:", "prem")); + assert documentIRI != null; + assertTrue(documentIRI.toString().endsWith("/urntestontology.xml")); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/ImportsCacheTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/ImportsCacheTestCase.java new file mode 100644 index 0000000000..8475099292 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/ImportsCacheTestCase.java @@ -0,0 +1,59 @@ +package org.semanticweb.owlapi.api.test.imports; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.contains; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.AddImport; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLImportsDeclaration; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * Matthew Horridge Stanford Center for Biomedical Informatics Research 10 Jul 16 + */ +class ImportsCacheTestCase extends TestBase { + + private OWLOntology ontA; + private OWLOntology ontB; + private IRI ontBDocIri; + private OWLImportsDeclaration ontBDocumentIriImportsDeclaration; + + @BeforeEach + void setUpOntologies() throws Exception { + ontA = m.createOntology(iri("http://ont.com/", "ontA")); + ontB = m.createOntology(iri("http://ont.com/", "ontB")); + ontBDocIri = iri("http://docs.ont.com/ontB"); + ontBDocumentIriImportsDeclaration = df.getOWLImportsDeclaration(ontBDocIri); + } + + /** + * Retrieves the imports closure of ontA, where ontA imports ontB via its documentIRI. The + * document IRI is set BEFORE adding the imports declaration. + */ + @Test + void shouldRetrieveImportsClosureByDocumentIri() { + // Update the document IRI for ontB BEFORE we add the import + m.setOntologyDocumentIRI(ontB, ontBDocIri); + // OntA imports OntB by a document IRI rather than its ontology IRI + ontA.applyChange(new AddImport(ontA, ontBDocumentIriImportsDeclaration)); + assertTrue(contains(ontA.importsClosure(), ontA)); + assertTrue(contains(ontA.importsClosure(), ontB)); + } + + /** + * Retrieves the imports closure of ontA, where ontA imports ontB via its documentIRI. The + * document IRI is set AFTER adding the imports declaration. + */ + @Test + void shouldRetrieveImportsClosureByDocumentIriAfterDocumentIriChange() { + // OntA imports OntB by a document IRI rather than its ontology IRI + ontA.applyChange(new AddImport(ontA, ontBDocumentIriImportsDeclaration)); + // Update the document IRI for ontB (AFTER we haved added the import) + m.setOntologyDocumentIRI(ontB, ontBDocIri); + assertTrue(contains(ontA.importsClosure(), ontA)); + assertTrue(contains(ontA.importsClosure(), ontB)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/ImportsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/ImportsTestCase.java new file mode 100644 index 0000000000..5c6ada98e9 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/ImportsTestCase.java @@ -0,0 +1,315 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.imports; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ImportsDeclaration; +import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.contains; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.io.StringDocumentSource; +import org.semanticweb.owlapi.model.AddImport; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLImportsDeclaration; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLOntologyIRIMapper; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.RemoveImport; +import org.semanticweb.owlapi.model.UnloadableImportException; +import org.semanticweb.owlapi.profiles.OWLProfileReport; +import org.semanticweb.owlapi.profiles.Profiles; +import org.semanticweb.owlapi.util.AutoIRIMapper; +import org.semanticweb.owlapi.util.SimpleIRIMapper; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +class ImportsTestCase extends TestBase { + + static final String loadRight = "\n" + + "\n" + + " "; + static final String unloadableImport = "\n" + + "\n" + + " \n" + + " \n" + " \n" + + ""; + static final String remapImportRdfXml = + "\n" + "\n" + + " \n" + + " \n" + + " \n" + ""; + static final String remapImport = "\n" + + "\n" + + " http://test.org/TestPizzaImport.owl\n" + ""; + static final String IMPORTS = "imports"; + + @Test + void testImportsClosureUpdate() { + IRI aIRI = IRI("http://a.com", ""); + OWLOntology ontA = getOWLOntology(aIRI); + IRI bIRI = IRI("http://b.com", ""); + OWLOntology ontB = getOWLOntology(bIRI); + ontA.applyChange(new AddImport(ontA, df.getOWLImportsDeclaration(bIRI))); + assertEquals(2, m.importsClosure(ontA).count()); + m.removeOntology(ontB); + assertEquals(1, m.importsClosure(ontA).count()); + getOWLOntology(bIRI); + assertEquals(2, m.importsClosure(ontA).count()); + } + + @Test + void shouldLoad() throws Exception { + File importsBothNameAndVersion = new File(folder, "tempimportsNameAndVersion.owl"); + File importsBothNameAndOther = new File(folder, "tempimportsNameAndOther.owl"); + File ontologyByName = new File(folder, "tempmain.owl"); + File ontologyByVersion = new File(folder, "tempversion.owl"); + File ontologyByOtherPath = new File(folder, "tempother.owl"); + OWLOntology ontology = getOWLOntology( + new OWLOntologyID(optional(iri(ontologyByName)), optional(iri(ontologyByVersion)))); + ontology.saveOntology(iri(ontologyByName)); + ontology.saveOntology(iri(ontologyByVersion)); + ontology.saveOntology(iri(ontologyByOtherPath)); + OWLOntology ontology1 = m1.createOntology(iri(importsBothNameAndVersion)); + OWLOntology ontology2 = m1.createOntology(iri(importsBothNameAndOther)); + List changes = new ArrayList<>(); + changes.add(new AddImport(ontology1, df.getOWLImportsDeclaration(iri(ontologyByName)))); + changes.add(new AddImport(ontology1, df.getOWLImportsDeclaration(iri(ontologyByVersion)))); + changes.add(new AddImport(ontology2, df.getOWLImportsDeclaration(iri(ontologyByName)))); + changes + .add(new AddImport(ontology2, df.getOWLImportsDeclaration(iri(ontologyByOtherPath)))); + ontology1.applyChanges(changes); + ontology2.applyChanges(changes); + ontology1.saveOntology(iri(importsBothNameAndVersion)); + ontology2.saveOntology(iri(importsBothNameAndOther)); + // when + OWLOntology o1 = m.loadOntology(iri(importsBothNameAndVersion)); + OWLOntology o2 = m1.loadOntology(iri(importsBothNameAndOther)); + // then + assertNotNull(o1); + assertNotNull(o2); + } + + @Test + public void shouldNotLoadWrong() throws OWLOntologyCreationException { + m.createOntology(IRI.create("urn:test#", "test")); + StringDocumentSource documentSource = new StringDocumentSource(TestFiles.loadRight); + OWLOntology o = m.loadOntologyFromOntologyDocument(documentSource); + assertTrue(o.isAnonymous()); + assertFalse(o.getOntologyID().getDefaultDocumentIRI().isPresent()); + } + + @Test + void testManualImports() { + OWLOntology baseOnt = getOWLOntology(IRI("http://semanticweb.org/ontologies/", "base")); + IRI importedIRI = IRI("http://semanticweb.org/ontologies/", "imported"); + OWLOntology importedOnt = getOWLOntology(importedIRI); + Set preImportsClosureCache = asUnorderedSet(baseOnt.importsClosure()); + assertTrue(preImportsClosureCache.contains(baseOnt)); + assertFalse(preImportsClosureCache.contains(importedOnt)); + baseOnt.applyChange(new AddImport(baseOnt, df.getOWLImportsDeclaration(importedIRI))); + Set postImportsClosureCache = asUnorderedSet(baseOnt.importsClosure()); + assertTrue(postImportsClosureCache.contains(baseOnt)); + assertTrue(postImportsClosureCache.contains(importedOnt)); + } + + @Test + void shouldThrowExceptionWithDefaultImportsconfig() { + assertThrows(UnloadableImportException.class, + () -> loadOntologyFromString(TestFiles.unloadableImport, new RDFXMLDocumentFormat())); + } + + @Test + void testImports() throws OWLOntologyCreationException { + m.getIRIMappers().add(new AutoIRIMapper(new File(RESOURCES, IMPORTS), true)); + m.loadOntologyFromOntologyDocument(new File(RESOURCES, "/imports/D.owl")); + } + + @Test + void testCyclicImports() throws OWLOntologyCreationException { + m.getIRIMappers().add(new AutoIRIMapper(new File(RESOURCES, "importscyclic"), true)); + m.loadOntologyFromOntologyDocument(new File(RESOURCES, "/importscyclic/D.owl")); + } + + @Test + void testCyclicImports2() throws OWLOntologyCreationException { + m.getIRIMappers().add(new AutoIRIMapper(new File(RESOURCES, "importscyclic"), true)); + m.loadOntologyFromOntologyDocument(iri(new File(RESOURCES, "importscyclic/D.owl"))); + } + + @Test + void testTurtleGraphImport() throws OWLOntologyCreationException { + // document without ontology declaration should be removed and + // reimported + File ontologyDirectory = new File(RESOURCES, "importNoOntology"); + String ns = "http://www.w3.org/2013/12/FDA-TA/tests/RenalTransplantation/"; + IRI bobsOntologyName = iri(ns, "subject-bob"); + OWLNamedIndividual bobsIndividual = + df.getOWLNamedIndividual(ns + "subject-bob#", "subjectOnImmunosuppressantA2"); + m.getIRIMappers().add(new SimpleIRIMapper(iri(ns, "subject-amy"), + iri(new File(ontologyDirectory, "subject-amy.ttl")))); + m.getIRIMappers().add(new SimpleIRIMapper(bobsOntologyName, + iri(new File(ontologyDirectory, "subject-bob.ttl")))); + m.getIRIMappers().add(new SimpleIRIMapper(iri(ns, "subject-sue"), + iri(new File(ontologyDirectory, "subject-sue.ttl")))); + m.getIRIMappers().add(new SimpleIRIMapper(iri("http://www.w3.org/2013/12/FDA-TA/", "core"), + iri(new File(ontologyDirectory, "core.ttl")))); + OWLOntology topLevelImport = + m.loadOntologyFromOntologyDocument(new File(ontologyDirectory, "subjects.ttl")); + assertTrue(topLevelImport.containsEntityInSignature(bobsIndividual, INCLUDED), + "Individuals about Bob are missing..."); + } + + /** + * Tests to see if the method which obtains the imports closure behaves correctly. + */ + @Test + void testImportsClosure() { + OWLOntology ontA = getOWLOntology(); + OWLOntology ontB = getOWLOntology(); + assertTrue(contains(ontA.importsClosure(), ontA)); + OWLImportsDeclaration importsDeclaration = + ImportsDeclaration(get(ontB.getOntologyID().getOntologyIRI())); + ontA.applyChange(new AddImport(ontA, importsDeclaration)); + assertTrue(contains(ontA.importsClosure(), ontB)); + ontA.applyChange(new RemoveImport(ontA, importsDeclaration)); + assertFalse(contains(ontA.importsClosure(), ontB)); + ontA.applyChange(new AddImport(ontA, importsDeclaration)); + assertTrue(contains(ontA.importsClosure(), ontB)); + ontB.getOWLOntologyManager().removeOntology(ontB); + assertFalse(contains(ontA.importsClosure(), ontB)); + } + + @Test + void shouldRemapImport() throws OWLOntologyCreationException { + IRI testImport = iri("http://test.org/", "TestPizzaImport.owl"); + IRI remap = iri("urn:test:", "mockImport"); + OWLOntologyIRIMapper mock = mock(OWLOntologyIRIMapper.class); + when(mock.getDocumentIRI(eq(testImport))).thenReturn(remap); + m.getIRIMappers().set(mock); + m.createOntology(remap); + OWLOntology o = + m.loadOntologyFromOntologyDocument(new StringDocumentSource(TestFiles.remapImport)); + assertEquals(1, o.importsDeclarations().count()); + verify(mock).getDocumentIRI(testImport); + } + + @Test + void shouldRemapImportRdfXML() throws OWLOntologyCreationException { + IRI testImport = iri("http://test.org/", "TestPizzaImport.owl"); + IRI remap = iri("urn:test:", "mockImport"); + OWLOntologyIRIMapper mock = mock(OWLOntologyIRIMapper.class); + when(mock.getDocumentIRI(eq(testImport))).thenReturn(remap); + m.getIRIMappers().set(mock); + m.createOntology(remap); + OWLOntology o = m.loadOntologyFromOntologyDocument( + new StringDocumentSource(TestFiles.remapImportRdfXml)); + assertEquals(1, o.importsDeclarations().count()); + verify(mock).getDocumentIRI(testImport); + } + + @Test + void testImportOntologyByLocation() throws Exception { + File f = new File(folder, "a.owl"); + createOntologyFile(IRI("http://a.com", ""), f); + // have to load an ontology for it to get a document IRI + OWLOntology a = m.loadOntologyFromOntologyDocument(f); + IRI locA = m.getOntologyDocumentIRI(a); + IRI bIRI = IRI("http://b.com", ""); + OWLOntology b = getOWLOntology(bIRI); + // import from the document location of a.owl (rather than the + // ontology IRI) + b.applyChange(new AddImport(b, df.getOWLImportsDeclaration(locA))); + assertEquals(1, b.importsDeclarations().count()); + assertEquals(1, b.imports().count()); + } + + @Test + void shouldNotCreateIllegalPunning() throws OWLOntologyCreationException { + m.getIRIMappers().add(new AutoIRIMapper(new File(RESOURCES, "importscyclic"), true)); + OWLOntology o = m.loadOntologyFromOntologyDocument( + iri(new File(RESOURCES, "importscyclic/relaMath.owl"))); + OWLProfileReport checkOntology = Profiles.OWL2_DL.checkOntology(o); + assertTrue(checkOntology.isInProfile(), checkOntology.toString()); + o.directImports() + .forEach(ont -> assertEquals(0, ont.annotationPropertiesInSignature().count())); + } + + private OWLOntology createOntologyFile(IRI iri, File f) throws Exception { + OWLOntology a = m1.createOntology(iri); + try (OutputStream out = new FileOutputStream(f)) { + a.saveOntology(out); + } + return a; + } + + @Test + void testImportsWhenRemovingAndReloading() throws Exception { + OWLOntologyManager man = setupManager(); + AutoIRIMapper mapper = new AutoIRIMapper(new File(RESOURCES, IMPORTS), true); + man.getIRIMappers().add(mapper); + String name = "/imports/thesubont.omn"; + File file = new File(getClass().getResource(name).toURI()); + OWLOntology root = man.loadOntologyFromOntologyDocument(file); + assertEquals(1, root.imports().count()); + man.ontologies().forEach(o -> man.removeOntology(o)); + assertEquals(0, man.ontologies().count()); + root = man.loadOntologyFromOntologyDocument(file); + assertEquals(1, root.imports().count()); + } + + @Test + void testAutoIRIMapperShouldNotBeConfusedByPrefixes() { + AutoIRIMapper mapper = new AutoIRIMapper(new File(RESOURCES, IMPORTS), true); + assertTrue(mapper.getOntologyIRIs() + .contains(iri("http://owlapitestontologies.com/", "thesubont"))); + } + + @Test + void testAutoIRIMapperShouldRecogniseRdfAboutInOwlOntology() { + AutoIRIMapper mapper = new AutoIRIMapper(new File(RESOURCES, IMPORTS), true); + assertTrue( + mapper.getOntologyIRIs().contains(iri("http://test.org/compleximports/", "A.owl"))); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/OWLZipClosureIRIMapperTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/OWLZipClosureIRIMapperTestCase.java new file mode 100644 index 0000000000..7165138531 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/OWLZipClosureIRIMapperTestCase.java @@ -0,0 +1,48 @@ +package org.semanticweb.owlapi.api.test.imports; + +import java.io.File; +import java.io.IOException; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.util.AutoIRIMapper; +import org.semanticweb.owlapi.util.OWLZipClosureIRIMapper; + +class OWLZipClosureIRIMapperTestCase extends TestBase { + static final IRI dIRI = iri("http://test.org/complexImports/", "D.owl"); + + @ParameterizedTest + @ValueSource(strings = {"owlzipwithfolders.zip", "owlzipwithcatalog.zip", "owlzipnoindex.zip",}) + void shouldLoadClosure(String child) throws OWLOntologyCreationException, IOException { + File file2 = new File(RESOURCES, child); + m1.getIRIMappers().add(new AutoIRIMapper(imports(), true)); + OWLOntology test = m1.loadOntologyFromOntologyDocument(d()); + m.getIRIMappers().add(new OWLZipClosureIRIMapper(file2)); + OWLOntology loadOntology = m.loadOntology(dIRI); + equal(loadOntology, test); + } + + @Test + void shouldMapIRIsWithAutoIRIMapper() throws OWLOntologyCreationException { + File file2 = new File(RESOURCES, "owlzipnoindex.zip"); + m1.getIRIMappers().add(new AutoIRIMapper(imports(), true)); + OWLOntology test = m1.loadOntologyFromOntologyDocument(d()); + m.getIRIMappers().add(new AutoIRIMapper(file2, false)); + OWLOntology loadOntology = m.loadOntology(dIRI); + equal(loadOntology, test); + } + + private File imports() { + return new File(RESOURCES, "imports"); + } + + private File d() { + return new File(RESOURCES, "/imports/D.owl"); + } +} + diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/OWLZipSaverTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/OWLZipSaverTestCase.java new file mode 100644 index 0000000000..a7217b5506 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/OWLZipSaverTestCase.java @@ -0,0 +1,64 @@ +package org.semanticweb.owlapi.api.test.imports; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.Collections; +import java.util.zip.ZipEntry; +import java.util.zip.ZipException; +import java.util.zip.ZipInputStream; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.io.StringDocumentSource; +import org.semanticweb.owlapi.model.AddImport; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; +import org.semanticweb.owlapi.util.OWLZipSaver; + +class OWLZipSaverTestCase extends TestBase { + static final IRI iri1 = iri("urn:test:", "o1.owl"); + static final IRI iri2 = iri("urn:test:", "o2.owl"); + + @Test + void shouldSaveClosureWithYaml() throws ZipException, IOException, OWLOntologyCreationException, + OWLOntologyStorageException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + OWLOntology o1 = m.createOntology(iri1); + OWLOntology o2 = m.createOntology(iri2); + o1.applyChange(new AddImport(o1, df.getOWLImportsDeclaration(iri2))); + new OWLZipSaver().saveOntologies(Collections.singleton(o1), Collections.singleton(o2), out); + ZipInputStream in = new ZipInputStream(new ByteArrayInputStream(out.toByteArray())); + ZipEntry nextEntry = in.getNextEntry(); + assertEquals("owlzip.yaml", nextEntry.getName()); + String read = read(in); + assertEquals( + "ontologies:\n" + "- iri: urn:test:o1.owl\n" + " path: urn:test:o1.owl\n" + + " root: true\n" + "- iri: urn:test:o2.owl\n" + " path: urn:test:o2.owl\n", + read); + nextEntry = in.getNextEntry(); + String read1 = read(in); + nextEntry = in.getNextEntry(); + String read2 = read(in); + OWLOntology o2read = m1.loadOntologyFromOntologyDocument(new StringDocumentSource(read2)); + OWLOntology o1read = m1.loadOntologyFromOntologyDocument(new StringDocumentSource(read1)); + equal(o1, o1read); + equal(o2, o2read); + } + + protected String read(ZipInputStream in) throws IOException { + StringBuilder b = new StringBuilder(); + while (in.available() > 0) { + int read = in.read(); + if (read > 0) { + b.append((char) read); + } + } + return b.toString(); + } +} + diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/RemoveImportDataTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/RemoveImportDataTestCase.java new file mode 100644 index 0000000000..95b1d6a3fa --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/RemoveImportDataTestCase.java @@ -0,0 +1,73 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.imports; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.change.RemoveImportData; +import org.semanticweb.owlapi.model.OWLImportsDeclaration; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.RemoveImport; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.2.0 + */ +class RemoveImportDataTestCase { + + private final OWLImportsDeclaration mockDeclaration = mock(OWLImportsDeclaration.class); + private final OWLOntology mockOntology = mock(OWLOntology.class); + + private RemoveImportData createData() { + return new RemoveImportData(mockDeclaration); + } + + @Test + void testEquals() { + RemoveImportData data1 = createData(); + RemoveImportData data2 = createData(); + assertEquals(data1, data2); + assertEquals(data1.hashCode(), data2.hashCode()); + } + + @Test + void testGettersReturnNotNull() { + RemoveImportData data = createData(); + assertNotNull(data.getDeclaration()); + assertNotNull(data.createOntologyChange(mockOntology)); + } + + @Test + void testGettersEquals() { + RemoveImportData data = createData(); + assertEquals(mockDeclaration, data.getDeclaration()); + } + + @Test + void testCreateOntologyChange() { + RemoveImportData data = createData(); + RemoveImport change = data.createOntologyChange(mockOntology); + assertEquals(mockOntology, change.getOntology()); + assertEquals(mockDeclaration, change.getImportDeclaration()); + } + + @Test + void testOntologyChangeSymmetry() { + RemoveImportData data = createData(); + RemoveImport change = new RemoveImport(mockOntology, mockDeclaration); + assertEquals(change.getChangeData(), data); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/package-info.java new file mode 100644 index 0000000000..8ca9ec70c6 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/imports/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.api.test.imports; diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/individuals/NoQNameRoundTripTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/individuals/NoQNameRoundTripTestCase.java new file mode 100644 index 0000000000..d76fbfb6eb --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/individuals/NoQNameRoundTripTestCase.java @@ -0,0 +1,108 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.individuals; + +import static org.junit.jupiter.api.Assertions.fail; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Declaration; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NamedIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectPropertyAssertion; +import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED; + +import java.util.Arrays; +import java.util.List; + +import org.eclipse.rdf4j.rio.RDFHandlerException; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.NQuadsDocumentFormat; +import org.semanticweb.owlapi.formats.NTriplesDocumentFormat; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RDFJsonDocumentFormat; +import org.semanticweb.owlapi.formats.RDFJsonLDDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RioRDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RioTurtleDocumentFormat; +import org.semanticweb.owlapi.formats.TrigDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.rdf.rdfxml.renderer.IllegalElementNameException; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +class NoQNameRoundTripTestCase extends TestBase { + + OWLOntology noQNameRoundTripTestCase() { + OWLOntology ont = getOWLOntology(); + ont.add(ObjectPropertyAssertion(ObjectProperty(IRI("http://example.com/place/123", "")), + NamedIndividual( + IRI("http://example.com/place/112013e2-df48-4a34-8a9d-99ef572a395A", "")), + NamedIndividual( + IRI("http://example.com/place/112013e2-df48-4a34-8a9d-99ef572a395B", "")))); + ont.unsortedSignature().filter(e -> !e.isBuiltIn() && !ont.isDeclared(e, INCLUDED)) + .forEach(e -> ont.add(Declaration(e))); + return ont; + } + + @Test + void testRDFXML() { + try { + roundTripOntology(noQNameRoundTripTestCase(), new RDFXMLDocumentFormat()); + fail("Expected an exception specifying that a QName could not be generated"); + } catch (OWLRuntimeException e) { + if (!(e.getCause().getCause() instanceof IllegalElementNameException)) { + throw e; + } + } + } + + @Test + void testRioRDFXML() { + try { + roundTripOntology(noQNameRoundTripTestCase(), new RioRDFXMLDocumentFormat()); + fail("Expected an exception specifying that a QName could not be generated"); + } catch (OWLRuntimeException e) { + Throwable ex = e.getCause(); + while (ex != null && !(ex instanceof RDFHandlerException)) { + ex = ex.getCause(); + } + if (ex == null || !ex.getMessage().contains("http://example.com/place/123")) { + throw e; + } + } + } + + static List noQNameFormats() { + return Arrays.asList(new RDFJsonDocumentFormat(), new OWLXMLDocumentFormat(), + new FunctionalSyntaxDocumentFormat(), new TurtleDocumentFormat(), + new RioTurtleDocumentFormat(), new ManchesterSyntaxDocumentFormat(), + new TrigDocumentFormat(), new RDFJsonLDDocumentFormat(), new NTriplesDocumentFormat(), + new NQuadsDocumentFormat()); + } + + @ParameterizedTest + @MethodSource("noQNameFormats") + void testFormat(OWLDocumentFormat d) { + roundTripOntology(noQNameRoundTripTestCase(), d); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/individuals/SameIndividualsQuadrupletRoundTripTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/individuals/SameIndividualsQuadrupletRoundTripTestCase.java new file mode 100644 index 0000000000..2dacaeec15 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/individuals/SameIndividualsQuadrupletRoundTripTestCase.java @@ -0,0 +1,133 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.individuals; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Declaration; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentClasses; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentDataProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentObjectProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NamedIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SameIndividual; +import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED; + +import java.util.Arrays; +import java.util.Collection; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +class SameIndividualsQuadrupletRoundTripTestCase extends TestBase { + + private static final OWLClass a = Class(iri("a")); + private static final OWLClass b = Class(iri("b")); + private static final OWLClass c = Class(iri("c")); + private static final OWLClass d = Class(iri("d")); + + private static final OWLDataProperty p = DataProperty(iri("p")); + private static final OWLDataProperty q = DataProperty(iri("q")); + private static final OWLDataProperty r = DataProperty(iri("r")); + private static final OWLDataProperty s = DataProperty(iri("s")); + + private static final OWLObjectProperty t = ObjectProperty(iri("t")); + private static final OWLObjectProperty u = ObjectProperty(iri("u")); + private static final OWLObjectProperty w = ObjectProperty(iri("w")); + private static final OWLObjectProperty z = ObjectProperty(iri("z")); + + private static final OWLNamedIndividual i = NamedIndividual(iri("i")); + private static final OWLNamedIndividual j = NamedIndividual(iri("j")); + private static final OWLNamedIndividual k = NamedIndividual(iri("k")); + private static final OWLNamedIndividual l = NamedIndividual(iri("l")); + private static final OWLSameIndividualAxiom axiom1 = SameIndividual(i, j, k, l); + private static final OWLEquivalentClassesAxiom axiom2 = EquivalentClasses(a, b, c, d); + private static final OWLEquivalentObjectPropertiesAxiom axiom3 = + EquivalentObjectProperties(t, u, w, z); + private static final OWLEquivalentDataPropertiesAxiom axiom4 = + EquivalentDataProperties(p, q, r, s); + + protected OWLOntology o(Collection axioms) { + OWLOntology ont = getOWLOntology(); + ont.add(axioms); + ont.unsortedSignature().filter(e -> !e.isBuiltIn() && !ont.isDeclared(e, INCLUDED)) + .forEach(e -> ont.add(Declaration(e))); + return ont; + } + + OWLOntology sameIndividualsQuadrupletRoundTripTestCase() { + return o(Arrays.asList(axiom1, axiom2, axiom3, axiom4)); + } + + @Override + public boolean equal(OWLOntology ont1, OWLOntology ont2) { + // More than two individuals in a sameAs cannot be roundtripped traditionally in RDF based + // languages + assertTrue(ont1.containsAxiom(axiom1)); + assertTrue(ont1.containsAxiom(axiom2)); + assertTrue(ont1.containsAxiom(axiom3)); + assertTrue(ont1.containsAxiom(axiom4)); + if (!ont2.containsAxiom(axiom1)) { + axiom1.splitToAnnotatedPairs().forEach(ax -> assertAxiomContained(ax, ont2)); + } + if (!ont2.containsAxiom(axiom2)) { + axiom2.splitToAnnotatedPairs().forEach(ax -> assertAxiomContained(ax, ont2)); + } + if (!ont2.containsAxiom(axiom3)) { + axiom3.splitToAnnotatedPairs().forEach(ax -> assertAxiomContained(ax, ont2)); + } + if (!ont2.containsAxiom(axiom4)) { + axiom4.splitToAnnotatedPairs().forEach(ax -> assertAxiomContained(ax, ont2)); + } + return true; + } + + protected void assertAxiomContained(OWLAxiom ax, OWLOntology ont2) { + assertTrue(ont2.containsAxiom(ax), ax + "\t" + ont2.toString()); + } + + @ParameterizedTest + @MethodSource("formats") + void testFormat(OWLDocumentFormat df) { + roundTripOntology(sameIndividualsQuadrupletRoundTripTestCase(), df); + } + + @Test + void roundTripRDFXMLAndFunctionalShouldBeSame() { + OWLOntology o = sameIndividualsQuadrupletRoundTripTestCase(); + OWLOntology o1 = roundTrip(o, new RDFXMLDocumentFormat()); + OWLOntology o2 = roundTrip(o, new FunctionalSyntaxDocumentFormat()); + equal(o, o1); + equal(o2, o1); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/individuals/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/individuals/package-info.java new file mode 100644 index 0000000000..7622cc90df --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/individuals/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.api.test.individuals; diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/literals/LiteralTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/literals/LiteralTestCase.java new file mode 100644 index 0000000000..86a46ff0e6 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/literals/LiteralTestCase.java @@ -0,0 +1,187 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.literals; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.PlainLiteral; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.createIndividual; + +import java.util.Collections; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; +import org.semanticweb.owlapi.vocab.OWL2Datatype; +import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +class LiteralTestCase extends TestBase { + + private static final String ABC = "abc"; + + @Test + void testHasLangMethod() { + OWLLiteral literalWithLang = Literal(ABC, "en"); + assertTrue(literalWithLang.hasLang()); + OWLLiteral literalWithoutLang = Literal(ABC, ""); + assertFalse(literalWithoutLang.hasLang()); + } + + @Test + void testGetLangMethod() { + OWLLiteral literalWithLang = Literal(ABC, "en"); + assertEquals("en", literalWithLang.getLang()); + OWLLiteral literalWithoutLang = Literal(ABC, ""); + assertEquals("", literalWithoutLang.getLang()); + } + + @Test + void testNormalisation() { + OWLLiteral literalWithLang = Literal(ABC, "EN"); + assertEquals("en", literalWithLang.getLang()); + assertTrue(literalWithLang.hasLang("EN")); + } + + @Test + void testPlainLiteralWithLang() { + OWLLiteral literalWithLang = Literal(ABC, "en"); + assertFalse(literalWithLang.getDatatype().getIRI().isPlainLiteral()); + assertFalse(literalWithLang.isRDFPlainLiteral()); + assertTrue(literalWithLang.hasLang()); + assertEquals("en", literalWithLang.getLang()); + assertEquals(literalWithLang.getDatatype(), OWL2Datatype.RDF_LANG_STRING.getDatatype(df)); + } + + @Test + void testPlainLiteralWithEmbeddedLang() { + OWLLiteral literal = Literal("abc@en", PlainLiteral()); + assertTrue(literal.hasLang()); + assertFalse(literal.isRDFPlainLiteral()); + assertEquals("en", literal.getLang()); + assertEquals(ABC, literal.getLiteral()); + assertEquals(literal.getDatatype(), OWL2Datatype.RDF_LANG_STRING.getDatatype(df)); + } + + @Test + void tesPlainLiteralWithEmbeddedEmptyLang() { + OWLLiteral literal = Literal("abc@", PlainLiteral()); + assertFalse(literal.hasLang()); + assertFalse(literal.isRDFPlainLiteral()); + assertEquals("", literal.getLang()); + assertEquals(ABC, literal.getLiteral()); + assertEquals(literal.getDatatype(), OWL2Datatype.RDF_LANG_STRING.getDatatype(df)); + } + + @Test + void tesPlainLiteralWithDoubleSep() { + OWLLiteral literal = Literal("abc@@en", PlainLiteral()); + assertTrue(literal.hasLang()); + assertFalse(literal.isRDFPlainLiteral()); + assertEquals("en", literal.getLang()); + assertEquals("abc@", literal.getLiteral()); + assertEquals(literal.getDatatype(), OWL2Datatype.RDF_LANG_STRING.getDatatype(df)); + } + + @Test + void testBoolean() { + OWLLiteral literal = Literal(true); + assertTrue(literal.isBoolean()); + assertTrue(literal.parseBoolean()); + OWLLiteral trueLiteral = Literal("true", OWL2Datatype.XSD_BOOLEAN); + assertTrue(trueLiteral.isBoolean()); + assertTrue(trueLiteral.parseBoolean()); + OWLLiteral falseLiteral = Literal("false", OWL2Datatype.XSD_BOOLEAN); + assertTrue(falseLiteral.isBoolean()); + assertFalse(falseLiteral.parseBoolean()); + OWLLiteral oneLiteral = Literal("1", OWL2Datatype.XSD_BOOLEAN); + assertTrue(oneLiteral.isBoolean()); + assertTrue(oneLiteral.parseBoolean()); + OWLLiteral zeroLiteral = Literal("0", OWL2Datatype.XSD_BOOLEAN); + assertTrue(zeroLiteral.isBoolean()); + assertFalse(zeroLiteral.parseBoolean()); + } + + @Test + void testBuiltInDatatypes() { + OWL2Datatype dt = OWL2Datatype.getDatatype(OWLRDFVocabulary.RDF_PLAIN_LITERAL); + assertNotNull(dt); + dt = OWL2Datatype.getDatatype(OWLRDFVocabulary.RDFS_LITERAL); + assertNotNull(dt); + OWLDatatype datatype = df.getOWLDatatype(OWLRDFVocabulary.RDFS_LITERAL); + assertNotNull(datatype); + OWL2Datatype test = datatype.getBuiltInDatatype(); + assertEquals(test, dt); + } + + @Test + void testFailure() { + for (IRI type : OWL2Datatype.getDatatypeIRIs()) { + OWLDatatype datatype = df.getOWLDatatype(type); + if (datatype.isBuiltIn()) { + OWL2Datatype builtInDatatype = datatype.getBuiltInDatatype(); + assertNotNull(builtInDatatype); + } + } + } + + @Test + void shouldStoreTagsCorrectly() throws OWLOntologyStorageException { + String in = "See more at abc"; + OWLOntology o = getOWLOntology(); + OWLAnnotationAssertionAxiom ax = + df.getOWLAnnotationAssertionAxiom(createIndividual().getIRI(), df.getRDFSComment(in)); + o.add(ax); + OWLOntology o1 = roundTrip(o, new RDFXMLDocumentFormat()); + assertTrue(o1.containsAxiom(ax)); + equal(o, o1); + } + + @Test + void shouldFindReferencingAxiomsForIntLiteral() throws OWLOntologyCreationException { + OWLLiteral x = df.getOWLLiteral(32); + OWLClass c = df.getOWLClass("C"); + OWLAxiom a = df.getOWLSubClassOfAxiom(c, df.getOWLThing(), + Collections.singleton(df.getRDFSLabel("x", Stream.of(df.getRDFSComment(x))))); + OWLOntology o = m.createOntology(); + o.add(a); + assertEquals(1, o.referencingAxioms(x).count()); + } + + @Test + void shouldFindReferencingAxiomsForBooleanLiteral() throws OWLOntologyCreationException { + OWLLiteral x = df.getOWLLiteral(true); + OWLClass c = df.getOWLClass("C"); + OWLAxiom a = + df.getOWLSubClassOfAxiom(c, df.getOWLDataHasValue(df.getOWLDataProperty("P"), x)); + OWLOntology o = m.createOntology(); + o.add(a); + assertEquals(1, o.referencingAxioms(x).count()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/literals/OWL2DatatypeTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/literals/OWL2DatatypeTestCase.java new file mode 100644 index 0000000000..e8d32c7775 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/literals/OWL2DatatypeTestCase.java @@ -0,0 +1,263 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.literals; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; +import static org.semanticweb.owlapi.vocab.OWL2Datatype.RDFS_LITERAL; +import static org.semanticweb.owlapi.vocab.OWL2Datatype.RDF_PLAIN_LITERAL; +import static org.semanticweb.owlapi.vocab.OWL2Datatype.XSD_BOOLEAN; +import static org.semanticweb.owlapi.vocab.OWL2Datatype.XSD_BYTE; +import static org.semanticweb.owlapi.vocab.OWL2Datatype.XSD_DOUBLE; +import static org.semanticweb.owlapi.vocab.OWL2Datatype.XSD_FLOAT; +import static org.semanticweb.owlapi.vocab.OWL2Datatype.XSD_INTEGER; +import static org.semanticweb.owlapi.vocab.OWL2Datatype.XSD_STRING; + +import java.util.HashSet; +import java.util.Set; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.DataRangeType; +import org.semanticweb.owlapi.model.EntityType; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDatatype; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.2.0 + */ +class OWL2DatatypeTestCase extends TestBase { + + private OWLDatatype plainLiteral; + + @BeforeEach + void setUpLiteral() { + plainLiteral = RDF_PLAIN_LITERAL.getDatatype(df); + } + + @Test + void getBuiltInDatatype() { + assertEquals(RDF_PLAIN_LITERAL, plainLiteral.getBuiltInDatatype()); + } + + @Test + void isString() { + assertFalse(plainLiteral.isString()); + assertTrue(XSD_STRING.getDatatype(df).isString()); + } + + @Test + void isInteger() { + assertFalse(plainLiteral.isInteger()); + assertTrue(XSD_INTEGER.getDatatype(df).isInteger()); + } + + @Test + void isFloat() { + assertFalse(plainLiteral.isFloat()); + assertTrue(XSD_FLOAT.getDatatype(df).isFloat()); + } + + @Test + void isDouble() { + assertFalse(plainLiteral.isDouble()); + assertTrue(XSD_DOUBLE.getDatatype(df).isDouble()); + } + + @Test + void isBoolean() { + assertFalse(plainLiteral.isBoolean()); + assertTrue(XSD_BOOLEAN.getDatatype(df).isBoolean()); + } + + @Test + void isRDFPlainLiteral() { + assertTrue(plainLiteral.isRDFPlainLiteral()); + assertFalse(XSD_STRING.getDatatype(df).isRDFPlainLiteral()); + } + + @Test + void isDatatype() { + assertTrue(plainLiteral.isOWLDatatype()); + } + + @Test + void asOWLDatatype() { + assertEquals(plainLiteral, plainLiteral.asOWLDatatype()); + } + + @Test + void isTopDatatype() { + assertTrue(RDFS_LITERAL.getDatatype(df).isTopDatatype()); + assertFalse(plainLiteral.isTopDatatype()); + } + + @Test + void getDataRangeType() { + assertEquals(DataRangeType.DATATYPE, plainLiteral.getDataRangeType()); + } + + @Test + void getEntityType() { + assertEquals(EntityType.DATATYPE, plainLiteral.getEntityType()); + } + + @Test + void isType() { + assertTrue(plainLiteral.isType(EntityType.DATATYPE)); + assertFalse(plainLiteral.isType(EntityType.CLASS)); + assertFalse(plainLiteral.isType(EntityType.OBJECT_PROPERTY)); + assertFalse(plainLiteral.isType(EntityType.DATA_PROPERTY)); + assertFalse(plainLiteral.isType(EntityType.ANNOTATION_PROPERTY)); + assertFalse(plainLiteral.isType(EntityType.NAMED_INDIVIDUAL)); + } + + @Test + void isBuiltIn() { + assertTrue(plainLiteral.isBuiltIn()); + } + + @Test + void isOWLClass() { + assertFalse(plainLiteral.isOWLClass()); + } + + @Test + void asOWLClass() { + assertThrows(RuntimeException.class, plainLiteral::asOWLClass); + } + + @Test + void isOWLObjectProperty() { + assertFalse(plainLiteral.isOWLObjectProperty()); + } + + @Test + void asOWLObjectProperty() { + assertThrows(RuntimeException.class, plainLiteral::asOWLObjectProperty); + } + + @Test + void isOWLDataProperty() { + assertFalse(plainLiteral.isOWLDataProperty()); + } + + @Test + void asOWLDataProperty() { + assertThrows(RuntimeException.class, plainLiteral::asOWLDataProperty); + } + + @Test + void isOWLAnnotationProperty() { + assertFalse(plainLiteral.isOWLAnnotationProperty()); + } + + @Test + void asOWLAnnotationProperty() { + assertThrows(RuntimeException.class, plainLiteral::asOWLAnnotationProperty); + } + + @Test + void isOWLNamedIndividual() { + assertFalse(plainLiteral.isOWLNamedIndividual()); + } + + @Test + void asOWLNamedIndividual() { + assertThrows(RuntimeException.class, plainLiteral::asOWLNamedIndividual); + } + + @Test + void toStringID() { + assertNotNull(plainLiteral.toStringID()); + assertEquals(RDF_PLAIN_LITERAL.getIRI().toString(), plainLiteral.toStringID()); + } + + @Test + void getIRI() { + assertNotNull(plainLiteral.getIRI()); + assertEquals(RDF_PLAIN_LITERAL.getIRI(), plainLiteral.getIRI()); + } + + @Test + void shouldEquals() { + assertEquals(plainLiteral, plainLiteral); + assertEquals(plainLiteral, RDF_PLAIN_LITERAL.getDatatype(df)); + assertNotSame(plainLiteral, XSD_STRING.getDatatype(df)); + } + + @Test + void getSignature() { + assertEquals(asUnorderedSet(plainLiteral.signature()), singleton(plainLiteral)); + } + + @Test + void getAnonymousIndividuals() { + assertEquals(0L, plainLiteral.anonymousIndividuals().count()); + } + + @Test + void getClassesInSignature() { + assertEquals(0L, plainLiteral.classesInSignature().count()); + } + + @Test + void getObjectPropertiesInSignature() { + assertEquals(0L, plainLiteral.objectPropertiesInSignature().count()); + } + + @Test + void getDataPropertiesInSignature() { + assertEquals(0L, plainLiteral.dataPropertiesInSignature().count()); + } + + @Test + void getIndividualsInSignature() { + assertEquals(0L, plainLiteral.individualsInSignature().count()); + } + + @Test + void getNestedClassExpressions() { + assertEquals(0L, plainLiteral.nestedClassExpressions().count()); + } + + @Test + void isTopEntity() { + assertTrue(RDFS_LITERAL.getDatatype(df).isTopDatatype()); + assertFalse(RDF_PLAIN_LITERAL.getDatatype(df).isTopDatatype()); + } + + @Test + void isBottomEntity() { + assertFalse(plainLiteral.isBottomEntity()); + } + + @Test + void contains() { + IRI iri = XSD_BYTE.getIRI(); + Set datatypes = new HashSet<>(); + OWLDatatype dtImpl = df.getOWLDatatype(iri); + OWLDatatype dt2Impl = XSD_BYTE.getDatatype(df); + assertEquals(dtImpl, dt2Impl); + datatypes.add(dt2Impl); + assertTrue(datatypes.contains(dtImpl)); + assertEquals(dt2Impl.hashCode(), dtImpl.hashCode()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/literals/OWLLiteralCorruptionTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/literals/OWLLiteralCorruptionTestCase.java new file mode 100644 index 0000000000..504c214805 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/literals/OWLLiteralCorruptionTestCase.java @@ -0,0 +1,117 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.literals; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.io.StringDocumentSource; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +class OWLLiteralCorruptionTestCase extends TestBase { + + static final String URN_TEST = "urn:test#"; + static final OWLLiteral ONESHORT = + df.getOWLLiteral("1", OWL2Datatype.XSD_SHORT.getDatatype(df)); + static final OWLLiteral ZERO_ONE = df.getOWLLiteral("01", df.getIntegerOWLDatatype()); + static final OWLLiteral ONE = df.getOWLLiteral("1", df.getIntegerOWLDatatype()); + + @Test + void shouldroundTripLiteral() { + String testString; + StringBuilder sb = new StringBuilder(1000); + int count = 17; + while (count-- > 0) { + sb.append("200 \u00B5Liters + character above U+0FFFF = "); + sb.appendCodePoint(0x10192); // happens to be "ROMAN SEMUNCIA SIGN" + sb.append('\n'); + } + testString = sb.toString(); + OWLLiteral literal = Literal(testString); + assertEquals(literal.getLiteral(), testString, "Out = in ? false"); + } + + @Test + void shouldRoundTripXMLLiteral() { + OWLOntology o = getOWLOntology(); + OWLDataProperty p = df.getOWLDataProperty(iri(URN_TEST, "p")); + OWLLiteral l = df.getOWLLiteral(TestFiles.literalXMl, OWL2Datatype.RDF_XML_LITERAL); + OWLNamedIndividual i = df.getOWLNamedIndividual(iri(URN_TEST, "i")); + o.add(df.getOWLDataPropertyAssertionAxiom(p, i, l)); + String string = saveOntology(o).toString(); + assertTrue(string.contains(TestFiles.literalXMl)); + } + + @Test + void shouldFailOnMalformedXMLLiteral() throws OWLOntologyCreationException { + OWLOntology o = m.createOntology(); + OWLDataProperty p = df.getOWLDataProperty(iri(URN_TEST, "p")); + OWLLiteral l = + df.getOWLLiteral(TestFiles.literalMalformedXML, OWL2Datatype.RDF_XML_LITERAL); + OWLNamedIndividual i = df.getOWLNamedIndividual(iri(URN_TEST, "i")); + o.add(df.getOWLDataPropertyAssertionAxiom(p, i, l)); + assertThrowsWithCauseMessage(OWLRuntimeException.class, OWLOntologyStorageException.class, + "XML literal is not self contained", () -> saveOntology(o)); + } + + @Test + void shouldAcceptXMLLiteralWithDatatype() { + // A bug in OWLAPI means some incorrect XMLLiterals might have been + // produced. + // They should be understood in input and saved correctly on roundtrip + String input = TestFiles.preamble + TestFiles.wrong + TestFiles.closure; + OWLOntology o = + loadOntologyFromString(input, IRI.generateDocumentIRI(), new RDFXMLDocumentFormat()); + OWLOntology o1 = + loadOntologyFromString(TestFiles.preamble + TestFiles.correct + TestFiles.closure, + IRI.generateDocumentIRI(), new RDFXMLDocumentFormat()); + equal(o, o1); + assertTrue( + saveOntology(o, new RDFXMLDocumentFormat()).toString().contains(TestFiles.correct)); + } + + @Test + void shouldRoundtripPaddedLiterals() { + OWLOntology o = + loadOntologyFromString(new StringDocumentSource(TestFiles.roundtripPaddedLiterals, + iri(URN_TEST, "test"), new FunctionalSyntaxDocumentFormat(), null)); + OWLOntology o2 = roundTrip(o, new FunctionalSyntaxDocumentFormat()); + equal(o, o2); + OWLNamedIndividual i = + df.getOWLNamedIndividual(iri("http://www.semanticweb.org/owlapi/test#", "c")); + assertTrue(o.containsAxiom(df.getOWLDataPropertyAssertionAxiom(DP, i, ZERO_ONE))); + assertTrue(o.containsAxiom(df.getOWLDataPropertyAssertionAxiom(DP, i, ONE))); + assertTrue(o.containsAxiom(df.getOWLDataPropertyAssertionAxiom(DP, i, ONESHORT))); + } + + @Test + void shouldNotFindPaddedLiteralsEqualToNonPadded() { + assertNotEquals(ZERO_ONE, ONE); + assertNotEquals(ONE, ZERO_ONE); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/literals/TestCornerCasesTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/literals/TestCornerCasesTestCase.java new file mode 100644 index 0000000000..ec8816aa41 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/literals/TestCornerCasesTestCase.java @@ -0,0 +1,114 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.literals; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Set; +import java.util.TreeSet; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; + +class TestCornerCasesTestCase extends TestBase { + + @Test + void testFloatZeros() { + // +0 and -0 are not equal + OWLDatatype type = df.getFloatOWLDatatype(); + OWLLiteral lit1 = df.getOWLLiteral("0.0", type); + OWLLiteral lit2 = df.getOWLLiteral("-0.0", type); + assertFalse(lit1.equals(lit2)); + } + + @Test + void testIntegerRange() { + String expected = "2147483648"; + OWLDatatype type = df.getIntegerOWLDatatype(); + OWLLiteral lit = df.getOWLLiteral(expected, type); + assertEquals(expected, lit.getLiteral()); + } + + @Test + void testIntegerWithBlank() { + String expected = ""; + OWLDatatype type = df.getIntegerOWLDatatype(); + OWLLiteral lit = df.getOWLLiteral(expected, type); + assertEquals(expected, lit.getLiteral()); + } + + @Test + void testEnumInt() { + OWLDatatype type = df.getIntegerOWLDatatype(); + df.getOWLLiteral("1000000000000000000000000000000000000000", type); + } + + @Test + void testGetDataPropertyValues() { + OWLDatatype type = df.getIntegerOWLDatatype(); + OWLLiteral lit1 = df.getOWLLiteral("01", type); + OWLLiteral lit2 = df.getOWLLiteral("1", type); + assertFalse(lit1.equals(lit2)); + } + + @Test + void testWebOnt() { + Set expected = new TreeSet<>(); + expected.add( + "DataPropertyRange( DataOneOf(\"1\"^^xsd:integer \"2\"^^xsd:integer \"3\"^^xsd:integer \"4\"^^xsd:integer))"); + expected + .add("Declaration(DataProperty())"); + expected + .add("ClassAssertion(owl:Thing )"); + expected.add( + "DataPropertyRange( DataOneOf(\"4\"^^xsd:integer \"5\"^^xsd:integer \"6\"^^xsd:integer))"); + expected.add( + "ClassAssertion(DataMinCardinality(1 rdfs:Literal) )"); + OWLOntology o = loadOntologyFromString(TestFiles.webOnt, new RDFXMLDocumentFormat()); + Set result = new TreeSet<>(); + o.axioms().forEach(ax -> result.add(ax.toString())); + if (!result.equals(expected)) { + Set intersection = new TreeSet<>(result); + intersection.retainAll(expected); + Set s1 = new TreeSet<>(result); + s1.removeAll(intersection); + Set s2 = new TreeSet<>(expected); + s2.removeAll(intersection); + } + assertEquals(expected, result); + } + + @Test + void testMinusInf() throws Exception { + OWLOntology o = + loadOntologyFromString(TestFiles.minusInf, new FunctionalSyntaxDocumentFormat()); + assertTrue(saveOntology(o).toString().contains("-INF")); + equal(o, roundTrip(o)); + } + + @Test + void testLargeInteger() throws Exception { + OWLOntology o = + loadOntologyFromString(TestFiles.largeInteger, new FunctionalSyntaxDocumentFormat()); + assertTrue(saveOntology(o).toString().contains("-INF")); + equal(o, roundTrip(o)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/literals/TestPlainLiteralTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/literals/TestPlainLiteralTestCase.java new file mode 100644 index 0000000000..a3d5f83b93 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/literals/TestPlainLiteralTestCase.java @@ -0,0 +1,111 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.literals; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.RDFSComment; + +import java.io.ByteArrayOutputStream; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.AddOntologyAnnotation; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +class TestPlainLiteralTestCase extends TestBase { + + static final String URN_TEST = "urn:test#"; + static final String TEST = "test"; + + @Test + void testPlainLiteral() { + IRI iri = IRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "PlainLiteral"); + assertTrue(iri.isPlainLiteral()); + assertNotNull(df.getRDFPlainLiteral()); + assertNotNull(OWL2Datatype.getDatatype(iri)); + } + + @Test + void shouldParsePlainLiteral() { + OWLOntology o = + loadOntologyFromString(TestFiles.parsePlainLiteral, new RDFXMLDocumentFormat()); + IRI i = IRI(URN_TEST, "ind"); + assertEquals(o.annotationAssertionAxioms(i).iterator().next(), + AnnotationAssertion(RDFSComment(), i, Literal(TEST, OWL2Datatype.RDF_PLAIN_LITERAL))); + } + + @Test + void testPlainLiteralFromEvren() { + OWLDatatype node = df.getRDFPlainLiteral(); + assertTrue(node.isBuiltIn()); + assertNotNull(node.getBuiltInDatatype()); + } + + @Test + void testPlainLiteralSerialization() throws Exception { + OWLOntology o = getOWLOntology(); + OWLDataProperty p = df.getOWLDataProperty(URN_TEST, "p"); + OWLIndividual i = df.getOWLNamedIndividual(URN_TEST, "ind"); + OWLLiteral l = df.getOWLLiteral(TEST, OWL2Datatype.RDF_PLAIN_LITERAL); + o.add(df.getOWLDataPropertyAssertionAxiom(p, i, l)); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + o.saveOntology(out); + String expectedStart = " replacements = new HashMap<>(); + replacements.put(Literal(true), Literal(false)); + replacements.put(Literal(3), Literal(4)); + List results = replacer.changeLiterals(replacements); + assertResults(o, results); + } + + protected void assertResults(OWLOntology o, List r) { + assertTrue(r.contains(new AddAxiom(o, DataPropertyAssertion(DP, ind, Literal(4))))); + assertTrue(r.contains(new AddAxiom(o, DataPropertyAssertion(DP, ind, Literal(false))))); + assertTrue(r.contains(new RemoveAxiom(o, DataPropertyAssertion(DP, ind, Literal(3))))); + assertTrue(r.contains(new RemoveAxiom(o, DataPropertyAssertion(DP, ind, Literal(true))))); + assertEquals(4, r.size()); + } + + @Test + void shouldReplaceLiteralsWithTransformer() throws OWLOntologyCreationException { + OWLOntology o = createAxioms(); + final Map replacements = new HashMap<>(); + replacements.put(Literal(true), Literal(false)); + replacements.put(Literal(3), Literal(4)); + OWLObjectTransformer replacer = + new OWLObjectTransformer<>((x) -> true, (input) -> { + OWLLiteral l = replacements.get(input); + if (l == null) { + return input; + } + return l; + }, df, OWLLiteral.class); + List results = replacer.change(o); + assertResults(o, results); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/literals/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/literals/package-info.java new file mode 100644 index 0000000000..910c768b8e --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/literals/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.api.test.literals; diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/multithread/OwlOntologyMultipleThreadsTest.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/multithread/OwlOntologyMultipleThreadsTest.java new file mode 100644 index 0000000000..b5046c956a --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/multithread/OwlOntologyMultipleThreadsTest.java @@ -0,0 +1,340 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.semanticweb.owlapi.api.test.multithread; + +import static org.semanticweb.owlapi.model.parameters.AxiomAnnotations.IGNORE_AXIOM_ANNOTATIONS; +import static org.semanticweb.owlapi.model.parameters.Imports.EXCLUDED; +import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicLong; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationSubject; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; + +class OwlOntologyMultipleThreadsTest extends TestBase { + + private static class TestCallback implements Runnable { + + private final OWLOntology o1; + private final OWLOntology o2; + + TestCallback(OWLOntology o1, OWLOntology o2) { + this.o1 = o1; + this.o2 = o2; + } + + void consume(@SuppressWarnings("unused") Object o) {} + + @Override + public void run() { + for (int index = 0; index < 100; index++) { + o1.isEmpty(); + o1.annotationsAsList().forEach(this::consume); + o1.signature(INCLUDED).forEach(this::consume); + o1.signature(EXCLUDED).forEach(this::consume); + o1.getOWLOntologyManager(); + o1.getOntologyID(); + o1.isAnonymous(); + o1.directImportsDocuments().forEach(this::consume); + o1.directImports().forEach(this::consume); + o1.imports().forEach(this::consume); + o1.importsClosure().forEach(this::consume); + o1.importsDeclarations().forEach(this::consume); + o1.axioms().forEach(this::consume); + o1.getAxiomCount(); + List classes = asList(o1.classesInSignature()); + o1.classesInSignature(INCLUDED).forEach(this::consume); + o1.classesInSignature(EXCLUDED).forEach(this::consume); + List objectProperties = + asList(o1.objectPropertiesInSignature(INCLUDED)); + o1.objectPropertiesInSignature(EXCLUDED).forEach(this::consume); + o1.objectPropertiesInSignature().forEach(this::consume); + List dataProperties = asList(o1.dataPropertiesInSignature()); + o1.dataPropertiesInSignature(INCLUDED).forEach(this::consume); + o1.dataPropertiesInSignature(EXCLUDED).forEach(this::consume); + List individuals = asList(o1.individualsInSignature()); + o1.individualsInSignature(INCLUDED).forEach(this::consume); + o1.individualsInSignature(EXCLUDED).forEach(this::consume); + List anonIndividuals = + asList(o1.referencedAnonymousIndividuals(EXCLUDED)); + o1.datatypesInSignature().forEach(this::consume); + o1.datatypesInSignature(INCLUDED).forEach(this::consume); + o1.datatypesInSignature(EXCLUDED).forEach(this::consume); + o1.annotationPropertiesInSignature(EXCLUDED).forEach(this::consume); + for (OWLObjectProperty o : objectProperties) { + o1.axioms(o, EXCLUDED).forEach(this::consume); + o1.containsObjectPropertyInSignature(o.getIRI(), EXCLUDED); + o1.containsObjectPropertyInSignature(o.getIRI(), INCLUDED); + o1.containsObjectPropertyInSignature(o.getIRI(), EXCLUDED); + o1.objectSubPropertyAxiomsForSubProperty(o).forEach(this::consume); + o1.objectSubPropertyAxiomsForSuperProperty(o).forEach(this::consume); + o1.objectPropertyDomainAxioms(o).forEach(this::consume); + o1.objectPropertyRangeAxioms(o).forEach(this::consume); + o1.inverseObjectPropertyAxioms(o).forEach(this::consume); + o1.equivalentObjectPropertiesAxioms(o).forEach(this::consume); + o1.disjointObjectPropertiesAxioms(o).forEach(this::consume); + o1.functionalObjectPropertyAxioms(o).forEach(this::consume); + o1.inverseFunctionalObjectPropertyAxioms(o).forEach(this::consume); + o1.symmetricObjectPropertyAxioms(o).forEach(this::consume); + o1.asymmetricObjectPropertyAxioms(o).forEach(this::consume); + o1.reflexiveObjectPropertyAxioms(o).forEach(this::consume); + o1.irreflexiveObjectPropertyAxioms(o).forEach(this::consume); + o1.transitiveObjectPropertyAxioms(o).forEach(this::consume); + } + for (OWLClass c : classes) { + o1.axioms(c, EXCLUDED).forEach(this::consume); + o1.containsClassInSignature(c.getIRI(), EXCLUDED); + o1.containsClassInSignature(c.getIRI(), INCLUDED); + o1.containsClassInSignature(c.getIRI(), EXCLUDED); + o1.subClassAxiomsForSubClass(c).forEach(this::consume); + o1.subClassAxiomsForSuperClass(c).forEach(this::consume); + o1.equivalentClassesAxioms(c).forEach(this::consume); + o1.disjointClassesAxioms(c).forEach(this::consume); + o1.disjointUnionAxioms(c).forEach(this::consume); + o1.hasKeyAxioms(c).forEach(this::consume); + o1.classAssertionAxioms(c).forEach(this::consume); + } + for (OWLDataProperty p : dataProperties) { + o1.axioms(p, EXCLUDED).forEach(this::consume); + o1.containsDataPropertyInSignature(p.getIRI(), EXCLUDED); + o1.containsDataPropertyInSignature(p.getIRI(), INCLUDED); + o1.containsDataPropertyInSignature(p.getIRI(), EXCLUDED); + o1.dataSubPropertyAxiomsForSubProperty(p).forEach(this::consume); + o1.dataSubPropertyAxiomsForSuperProperty(p).forEach(this::consume); + o1.dataPropertyDomainAxioms(p).forEach(this::consume); + o1.dataPropertyRangeAxioms(p).forEach(this::consume); + o1.equivalentDataPropertiesAxioms(p).forEach(this::consume); + o1.disjointDataPropertiesAxioms(p).forEach(this::consume); + o1.functionalDataPropertyAxioms(p).forEach(this::consume); + } + for (OWLNamedIndividual i : individuals) { + o1.axioms(i, EXCLUDED).forEach(this::consume); + o1.containsIndividualInSignature(i.getIRI(), EXCLUDED); + o1.containsIndividualInSignature(i.getIRI(), INCLUDED); + o1.containsIndividualInSignature(i.getIRI(), EXCLUDED); + o1.classAssertionAxioms(i).forEach(this::consume); + o1.dataPropertyAssertionAxioms(i).forEach(this::consume); + o1.objectPropertyAssertionAxioms(i).forEach(this::consume); + o1.negativeObjectPropertyAssertionAxioms(i).forEach(this::consume); + o1.negativeDataPropertyAssertionAxioms(i).forEach(this::consume); + o1.sameIndividualAxioms(i).forEach(this::consume); + o1.differentIndividualAxioms(i).forEach(this::consume); + } + for (OWLAnonymousIndividual i : anonIndividuals) { + assert i != null; + o1.axioms(i, EXCLUDED).forEach(this::consume); + } + for (AxiomType ax : AxiomType.AXIOM_TYPES) { + assert ax != null; + o1.axioms(ax).forEach(this::consume); + o1.axioms(ax, INCLUDED).forEach(this::consume); + o1.axioms(ax, EXCLUDED).forEach(this::consume); + } + for (OWLDatatype t : asList(o1.datatypesInSignature())) { + o1.axioms(t, EXCLUDED).forEach(this::consume); + o1.containsDatatypeInSignature(t.getIRI(), EXCLUDED); + o1.containsDatatypeInSignature(t.getIRI(), INCLUDED); + o1.containsDatatypeInSignature(t.getIRI(), EXCLUDED); + o1.datatypeDefinitions(t).forEach(this::consume); + } + for (OWLAnnotationProperty p : asList( + o1.annotationPropertiesInSignature(EXCLUDED))) { + assert p != null; + o1.axioms(p, EXCLUDED).forEach(this::consume); + o1.containsAnnotationPropertyInSignature(p.getIRI(), EXCLUDED); + o1.containsAnnotationPropertyInSignature(p.getIRI(), INCLUDED); + o1.containsAnnotationPropertyInSignature(p.getIRI(), EXCLUDED); + o1.subAnnotationPropertyOfAxioms(p).forEach(this::consume); + o1.annotationPropertyDomainAxioms(p).forEach(this::consume); + o1.annotationPropertyRangeAxioms(p).forEach(this::consume); + } + for (AxiomType ax : AxiomType.AXIOM_TYPES) { + assert ax != null; + o1.getAxiomCount(ax); + o1.getAxiomCount(ax, INCLUDED); + o1.getAxiomCount(ax, EXCLUDED); + } + o1.logicalAxioms().forEach(this::consume); + o1.getLogicalAxiomCount(); + for (OWLAxiom ax : asList(o1.logicalAxioms())) { + assert ax != null; + o1.containsAxiom(ax); + o1.containsAxiom(ax, INCLUDED, IGNORE_AXIOM_ANNOTATIONS); + o1.containsAxiom(ax, EXCLUDED, IGNORE_AXIOM_ANNOTATIONS); + } + for (OWLAxiom ax : asList(o1.logicalAxioms())) { + assert ax != null; + o1.containsAxiom(ax, EXCLUDED, IGNORE_AXIOM_ANNOTATIONS); + o1.containsAxiom(ax, INCLUDED, IGNORE_AXIOM_ANNOTATIONS); + o1.containsAxiom(ax, EXCLUDED, IGNORE_AXIOM_ANNOTATIONS); + } + for (OWLAxiom ax : asList(o1.logicalAxioms())) { + assert ax != null; + o1.axiomsIgnoreAnnotations(ax, EXCLUDED).forEach(this::consume); + o1.axiomsIgnoreAnnotations(ax, INCLUDED).forEach(this::consume); + o1.axiomsIgnoreAnnotations(ax, EXCLUDED).forEach(this::consume); + } + o1.generalClassAxioms().forEach(this::consume); + anonIndividuals + .forEach(i -> o1.referencingAxioms(i, EXCLUDED).forEach(this::consume)); + o1.signature().forEach(e -> { + assert e != null; + o1.referencingAxioms(e, EXCLUDED).forEach(this::consume); + o1.referencingAxioms(e, INCLUDED).forEach(this::consume); + o1.referencingAxioms(e, EXCLUDED).forEach(this::consume); + o1.declarationAxioms(e).forEach(this::consume); + o1.containsEntityInSignature(e, INCLUDED); + o1.containsEntityInSignature(e, EXCLUDED); + o1.containsEntityInSignature(e); + o1.containsEntityInSignature(e.getIRI(), EXCLUDED); + o1.containsEntityInSignature(e.getIRI(), INCLUDED); + o1.entitiesInSignature(e.getIRI()).forEach(this::consume); + o1.entitiesInSignature(e.getIRI(), EXCLUDED).forEach(this::consume); + o1.entitiesInSignature(e.getIRI(), INCLUDED).forEach(this::consume); + o1.isDeclared(e); + o1.isDeclared(e, INCLUDED); + o1.isDeclared(e, EXCLUDED); + if (e instanceof OWLAnnotationSubject) { + o1.annotationAssertionAxioms((OWLAnnotationSubject) e) + .forEach(this::consume); + } + }); + List axioms = asList(o1.axioms()); + for (OWLAxiom ax : axioms) { + o1.add(ax); + o2.remove(ax); + } + } + } + } + + @Test + public void testLockingOwlOntologyImpl() throws OWLOntologyCreationException { + OWLOntology o = loadOntologyFromString(TestFiles.KOALA, new RDFXMLDocumentFormat()); + MultiThreadChecker checker = new MultiThreadChecker(5); + checker.check(new TestCallback(o, m.createOntology())); + String trace = checker.getTrace(); + System.out.println(trace); + } + + static class MultiThreadChecker { + + public static final int defaultRep = 10; + protected int rep = defaultRep; + protected final PrintStream p; + private final ByteArrayOutputStream out = new ByteArrayOutputStream(); + private boolean successful = false; + + public MultiThreadChecker(int i) { + this(); + if (i > 0) { + rep = i; + } + } + + public MultiThreadChecker() { + p = new PrintStream(out); + } + + public void check(Runnable cb) { + AtomicLong counter = new AtomicLong(0); + final long start = System.currentTimeMillis(); + ExecutorService service = Executors.newFixedThreadPool(rep); + List> list = new ArrayList<>(); + for (int i = 0; i < rep * rep; i++) { + list.add(() -> { + try { + cb.run(); + counter.incrementAndGet(); + } catch (Throwable e) { + e.printStackTrace(p); + printout(start, counter); + } + return null; + }); + } + long end = System.currentTimeMillis(); + try { + service.invokeAll(list); + end = System.currentTimeMillis() - end; + } catch (InterruptedException e) { + e.printStackTrace(); + } + printout(end, counter); + } + + protected void printout(long end, AtomicLong counter) { + long expected = rep * rep; + p.println("elapsed time (ms): " + end + "\nSuccessful threads: " + counter.get() + + "\t expected: " + expected); + successful = counter.get() == expected; + } + + public boolean isSuccessful() { + return successful; + } + + public String getTrace() { + p.flush(); + return out.toString(); + } + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/multithread/RaceTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/multithread/RaceTestCase.java new file mode 100644 index 0000000000..0f52eb1c4e --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/multithread/RaceTestCase.java @@ -0,0 +1,192 @@ +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.semanticweb.owlapi.api.test.multithread; + +import static org.junit.jupiter.api.Assertions.fail; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.contains; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; + +class RaceTestCase { + + @Test + void testSubClassLHS() throws Exception { + final int totalRepetitions = 200; + int repetitions = 0; + RaceTestCaseRunner r; + do { + repetitions++; + r = new RaceTestCaseRunner(); + r.racing(); + } while (!r.callback.failed() && repetitions < totalRepetitions); + if (r.callback.failed()) { + r.callback.diagnose(); + fail("Failed after " + repetitions + " repetition(s)."); + } + } + + static interface RaceCallback { + + void add(); + + boolean failed(); + + void diagnose(); + + void race(); + } + + static class RaceTestCaseRunner { + + static final String NS = "http://www.race.org#"; + protected RaceCallback callback; + final AtomicBoolean done = new AtomicBoolean(false); + ExecutorService exec = Executors.newFixedThreadPool(5); + private final Runnable writer = () -> { + while (!done.get()) { + callback.add(); + } + callback.add(); + }; + + RaceTestCaseRunner() throws OWLOntologyCreationException { + callback = new SubClassLHSCallback(); + } + + void racing() throws InterruptedException { + exec.submit(writer); + callback.race(); + done.set(true); + exec.shutdown(); + exec.awaitTermination(5, TimeUnit.SECONDS); + } + + static class SubClassLHSCallback implements RaceCallback { + + private final AtomicInteger counter = new AtomicInteger(); + OWLDataFactory factory; + OWLOntologyManager manager; + OWLOntology ontology; + OWLClass x; + OWLClass y; + + SubClassLHSCallback() throws OWLOntologyCreationException { + manager = OWLManager.createConcurrentOWLOntologyManager(); + factory = manager.getOWLDataFactory(); + ontology = manager.createOntology(); + x = factory.getOWLClass(NS, "X"); + y = factory.getOWLClass(NS, "Y"); + } + + @Override + public void add() { + OWLClass middle = createMiddleClass(counter.getAndIncrement()); + Set axioms = computeChanges(middle); + ontology.add(axioms); + } + + @Override + public boolean failed() { + long size = computeSize(); + return size < counter.get(); + } + + public long computeSize() { + return ontology.subClassAxiomsForSubClass(x).count(); + } + + public Set computeChanges(OWLClass middle) { + OWLAxiom axiom1 = factory.getOWLSubClassOfAxiom(x, middle); + OWLAxiom axiom2 = factory.getOWLSubClassOfAxiom(middle, y); + Set axioms = new HashSet<>(); + axioms.add(axiom1); + axioms.add(axiom2); + return axioms; + } + + @Override + public void diagnose() { + List axiomsFound = + asList(ontology.subClassAxiomsForSubClass(x)); + System.out.println("Expected getSubClassAxiomsForSubClass to return " + counter + + " axioms but it only found " + axiomsFound.size()); + for (int i = 0; i < counter.get(); i++) { + OWLAxiom checkMe = factory.getOWLSubClassOfAxiom(x, createMiddleClass(i)); + if (!contains(ontology.subClassAxiomsForSubClass(x), checkMe) + && ontology.containsAxiom(checkMe)) { + System.out.println(checkMe.toString() + + " is an axiom in the ontology that is not found by getSubClassAxiomsForSubClass"); + return; + } + } + } + + @Override + public void race() { + ontology.subClassAxiomsForSubClass(factory.getOWLClass("http://www.race.org#", "testclass")).forEach(this::lose); + } + + private void lose(@SuppressWarnings("unused") Object o) { + // no op + } + + public OWLClass createMiddleClass(int i) { + return factory.getOWLClass(NS, "P" + i); + } + } + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/AnnotationStreamTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/AnnotationStreamTestCase.java new file mode 100644 index 0000000000..1c68153ca6 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/AnnotationStreamTestCase.java @@ -0,0 +1,20 @@ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.model.OWLOntology; + +class AnnotationStreamTestCase extends TestBase { + + @Test + void shouldFindUniqueProperties() { + OWLOntology ontology = + loadOntologyFromString(TestFiles.uniquePropertiesTurtle, new TurtleDocumentFormat()); + assertEquals(ontology.annotationPropertiesInSignature().distinct().count(), + ontology.annotationPropertiesInSignature().count()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/ChangeOntologyURITestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/ChangeOntologyURITestCase.java new file mode 100644 index 0000000000..073072c421 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/ChangeOntologyURITestCase.java @@ -0,0 +1,68 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.AddImport; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.util.OWLOntologyIRIChanger; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +class ChangeOntologyURITestCase extends TestBase { + + @Test + void testChangeURI() throws OWLOntologyCreationException { + IRI oldIRI = iri("http://www.semanticweb.org/ontologies/", "ontA"); + IRI newIRI = iri("http://www.semanticweb.org/ontologies/", "ontB"); + OWLOntology ont = m.createOntology(oldIRI); + OWLOntology importingOnt = + m.createOntology(iri("http://www.semanticweb.org/ontologies/", "ontC")); + importingOnt.applyChange(new AddImport(importingOnt, + df.getOWLImportsDeclaration(get(ont.getOntologyID().getOntologyIRI())))); + assertTrue(m.contains(oldIRI)); + OWLOntologyIRIChanger changer = new OWLOntologyIRIChanger(m); + m.applyChanges(changer.getChanges(ont, newIRI)); + assertFalse(m.contains(oldIRI)); + assertTrue(m.contains(newIRI)); + assertTrue(m.ontologies().anyMatch(o -> o.equals(ont))); + assertTrue(m.directImports(importingOnt).anyMatch(o -> o.equals(ont))); + OWLOntology ontology = m.getOntology(newIRI); + assertNotNull(ontology); + assertEquals(ontology, ont); + assertEquals(ontology.getOntologyID().getOntologyIRI().get(), newIRI); + assertTrue(m.importsClosure(importingOnt).anyMatch(o -> o.equals(ont))); + assertNotNull(m.getOntologyDocumentIRI(ont)); + // Document IRI will still be the same (in this case the old ont URI) + assertEquals(m.getOntologyDocumentIRI(ont), oldIRI); + assertNotNull(ont.getFormat()); + } + + @Test + void shouldCheckContents() throws OWLOntologyCreationException { + m.createOntology(iri("http://www.test.com/", "123")); + OWLOntologyID anonymousId = m1.createOntology().getOntologyID(); + m.contains(anonymousId); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/DifferentPhysicalURISameOntologyIRITestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/DifferentPhysicalURISameOntologyIRITestCase.java new file mode 100644 index 0000000000..cab166598c --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/DifferentPhysicalURISameOntologyIRITestCase.java @@ -0,0 +1,41 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntologyAlreadyExistsException; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +class DifferentPhysicalURISameOntologyIRITestCase extends TestBase { + + private static final String ONTOLOGY_A = "ImportsTestOntologyA.owl"; + private static final String ONTOLOGY_A_EMPTY = "ImportsTestOntologyAEmpty.owl"; + + @Test + void testDifferentPhysicalURISameOntologyIRI() throws Exception { + IRI ontologyADocumentIRI = IRI.create(DifferentPhysicalURISameOntologyIRITestCase.class + .getResource('/' + ONTOLOGY_A).toURI()); + IRI ontologyADocumentIRIB = IRI.create(DifferentPhysicalURISameOntologyIRITestCase.class + .getResource('/' + ONTOLOGY_A_EMPTY).toURI()); + m.loadOntologyFromOntologyDocument(ontologyADocumentIRI); + assertThrows(OWLOntologyAlreadyExistsException.class, + () -> m.loadOntologyFromOntologyDocument(ontologyADocumentIRIB)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/DublinCoreTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/DublinCoreTestCase.java new file mode 100644 index 0000000000..93031b9b26 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/DublinCoreTestCase.java @@ -0,0 +1,38 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.model.parameters.Imports.EXCLUDED; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.vocab.DublinCoreVocabulary; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +class DublinCoreTestCase extends TestBase { + + @Test + void testAnnotationProperties() { + OWLOntology ontology = ontologyFromClasspathFile("dublincore.rdf"); + for (DublinCoreVocabulary vocabulary : DublinCoreVocabulary.values()) { + assertTrue( + ontology.containsAnnotationPropertyInSignature(vocabulary.getIRI(), EXCLUDED), + vocabulary.getIRI().toString()); + } + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/ExistingOutputStreamTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/ExistingOutputStreamTestCase.java new file mode 100644 index 0000000000..84ee2d7cff --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/ExistingOutputStreamTestCase.java @@ -0,0 +1,62 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import java.io.BufferedOutputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLRuntimeException; + +/** + * API writers/storers/renderers should not close streams if they didn't open them. + * + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.2.3 + */ +class ExistingOutputStreamTestCase extends TestBase { + + @Test + void testOutputStreamRemainsOpen() { + OWLOntology ontology = getOWLOntology(); + saveOntology(ontology, new RDFXMLDocumentFormat()); + saveOntology(ontology, new OWLXMLDocumentFormat()); + saveOntology(ontology, new TurtleDocumentFormat()); + saveOntology(ontology, new FunctionalSyntaxDocumentFormat()); + saveOntology(ontology, new ManchesterSyntaxDocumentFormat()); + } + + // test that the stream is not closed by adding a comment at the end + @Override + protected StringDocumentTarget saveOntology(OWLOntology o, OWLDocumentFormat format) { + try (BufferedOutputStream os = new BufferedOutputStream(new ByteArrayOutputStream()); + OutputStreamWriter w = new OutputStreamWriter(os)) { + o.saveOntology(format, os); + os.flush(); + w.write(""); + } catch (Exception e) { + throw new OWLRuntimeException(e); + } + return new StringDocumentTarget(); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/HashCodeTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/HashCodeTestCase.java new file mode 100644 index 0000000000..e37a6ed785 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/HashCodeTestCase.java @@ -0,0 +1,136 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.HashSet; +import java.util.Set; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.SetOntologyID; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +import uk.ac.manchester.cs.owl.owlapi.OWLLiteralImplBoolean; +import uk.ac.manchester.cs.owl.owlapi.OWLLiteralImplDouble; +import uk.ac.manchester.cs.owl.owlapi.OWLLiteralImplFloat; +import uk.ac.manchester.cs.owl.owlapi.OWLLiteralImplInteger; +import uk.ac.manchester.cs.owl.owlapi.OWLLiteralImplLong; +import uk.ac.manchester.cs.owl.owlapi.OWLLiteralImplNoCompression; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.2.0 + */ +class HashCodeTestCase extends TestBase { + + private static final String THREE = "3.0"; + + @Test + void testSetContainsLong() { + OWLDatatype datatype = df.getOWLDatatype(OWL2Datatype.XSD_LONG.getIRI()); + OWLLiteral litNoComp = new OWLLiteralImplNoCompression("3", null, datatype); + OWLLiteral litNoComp2 = new OWLLiteralImplNoCompression("3", null, datatype); + OWLLiteral litLongImpl = new OWLLiteralImplLong(3); + assertEquals(litNoComp.getLiteral(), litLongImpl.getLiteral()); + assertTrue(litLongImpl.equals(litNoComp)); + assertTrue(litNoComp.equals(litLongImpl)); + assertEquals(litNoComp, litLongImpl); + Set lncset = new HashSet<>(); + lncset.add(litNoComp); + assertTrue(lncset.contains(litNoComp2)); + assertTrue(lncset.contains(litLongImpl)); + } + + @Test + void testSetContainsInt() { + OWLDatatype datatype = df.getOWLDatatype(OWL2Datatype.XSD_INTEGER.getIRI()); + OWLLiteral litNoComp = new OWLLiteralImplNoCompression("3", null, datatype); + OWLLiteral litNoComp2 = new OWLLiteralImplNoCompression("3", null, datatype); + OWLLiteral litIntImpl = new OWLLiteralImplInteger(3); + assertEquals(litNoComp.getLiteral(), litIntImpl.getLiteral()); + Set lncset = new HashSet<>(); + lncset.add(litNoComp); + assertTrue(lncset.contains(litNoComp2)); + assertTrue(lncset.contains(litIntImpl)); + } + + @Test + void testSetContainsDouble() { + OWLDatatype datatype = df.getOWLDatatype(OWL2Datatype.XSD_DOUBLE.getIRI()); + OWLLiteral litNoComp = new OWLLiteralImplNoCompression(THREE, null, datatype); + OWLLiteral litNoComp2 = new OWLLiteralImplNoCompression(THREE, null, datatype); + OWLLiteral litIntImpl = new OWLLiteralImplDouble(3.0D); + assertEquals(litNoComp.getLiteral(), litIntImpl.getLiteral()); + Set lncset = new HashSet<>(); + lncset.add(litNoComp); + assertTrue(lncset.contains(litNoComp2)); + assertTrue(lncset.contains(litIntImpl)); + } + + @Test + void testSetContainsFloat() { + OWLDatatype datatype = df.getOWLDatatype(OWL2Datatype.XSD_FLOAT.getIRI()); + OWLLiteral litNoComp = new OWLLiteralImplNoCompression(THREE, null, datatype); + OWLLiteral litNoComp2 = new OWLLiteralImplNoCompression(THREE, null, datatype); + OWLLiteral litIntImpl = new OWLLiteralImplFloat(3.0F); + assertEquals(litNoComp.getLiteral(), litIntImpl.getLiteral()); + Set lncset = new HashSet<>(); + lncset.add(litNoComp); + assertTrue(lncset.contains(litNoComp2)); + assertTrue(lncset.contains(litIntImpl)); + } + + @Test + void testSetContainsBoolean() { + OWLDatatype datatype = df.getOWLDatatype(OWL2Datatype.XSD_BOOLEAN.getIRI()); + OWLLiteral litNoComp = new OWLLiteralImplNoCompression("true", null, datatype); + OWLLiteral litNoComp2 = new OWLLiteralImplNoCompression("true", null, datatype); + OWLLiteral litIntImpl = new OWLLiteralImplBoolean(true); + assertEquals(litNoComp.getLiteral(), litIntImpl.getLiteral()); + Set lncset = new HashSet<>(); + lncset.add(litNoComp); + assertTrue(lncset.contains(litNoComp2)); + assertTrue(lncset.contains(litIntImpl)); + } + + @Test + void shouldHaveSameHashCodeForOntologies() throws OWLOntologyCreationException { + final OWLOntology ontology = m.createOntology(); + int hash = ontology.hashCode(); + IRI iri = iri("urn:test:", "ontology"); + ontology.applyChange(new SetOntologyID(ontology, iri)); + int otherHash = ontology.hashCode(); + assertNotEquals(hash, otherHash); + assertNotNull(m.getOntology(iri)); + assertNotNull(m.getOntology(ontology.getOntologyID())); + } + + @Test + void shouldHaveSameHashCodeForOntologies1() { + OWLOntologyID id1 = new OWLOntologyID(IRI.create("http://purl.org/dc/elements/1.1/")); + OWLOntologyID id2 = new OWLOntologyID(IRI.create("http://purl.org/dc/elements/1.1/")); + assertEquals(id1, id2); + assertEquals(id1.hashCode(), id2.hashCode()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/IRICharSequenceTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/IRICharSequenceTestCase.java new file mode 100644 index 0000000000..ddb8cce0b9 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/IRICharSequenceTestCase.java @@ -0,0 +1,78 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.model.IRI; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.3.0 + */ +class IRICharSequenceTestCase { + + static final String abcString = "http://owlapi.sourceforge.net#ABC"; + static final IRI abc = IRI("http://owlapi.sourceforge.net#", "ABC"); + + @Test + void testCharAt() { + for (int i = 0; i < abcString.length(); i++) { + assertEquals(abcString.charAt(i), abc.charAt(i)); + } + } + + @Test + void testCharAtNoRemainder() { + String str = "http://owlapi.sourceforge.net"; + IRI iri = IRI(str, ""); + for (int i = 0; i < str.length(); i++) { + assertEquals(str.charAt(i), iri.charAt(i)); + } + } + + @Test + void testCharAtNoPrefix() { + String str = "#ABC"; + IRI iri = IRI("#", "ABC"); + for (int i = 0; i < str.length(); i++) { + assertEquals(str.charAt(i), iri.charAt(i)); + } + } + + @Test + void testSubSequence() { + for (int i = 0; i < abcString.length(); i++) { + for (int j = i; j < abcString.length(); j++) { + assertEquals(abcString.subSequence(i, j), abc.subSequence(i, j)); + } + } + } + + @Test + void testLength() { + assertEquals(33, abc.length()); + } + + @Test + void testLengthNoRemainder() { + assertEquals(29, IRI("http://owlapi.sourceforge.net", "").length()); + } + + @Test + void testLengthNoPrefix() { + assertEquals(4, IRI("#", "ABC").length()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/MapperlessOntologyManagerTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/MapperlessOntologyManagerTestCase.java new file mode 100644 index 0000000000..b3233ad32c --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/MapperlessOntologyManagerTestCase.java @@ -0,0 +1,87 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.util.HashSet; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLOntologyManager; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.2.3 + */ +class MapperlessOntologyManagerTestCase extends TestBase { + + private static final IRI ONTOLOGY_IRI = IRI("http://test.com/", "ont"); + + private OWLOntologyManager createManager() { + m.getIRIMappers().clear(); + return m; + } + + @Test + void testCreateOntologyWithIRI() throws OWLOntologyCreationException { + OWLOntologyManager manager = createManager(); + OWLOntology ontology = manager.createOntology(ONTOLOGY_IRI); + assertEquals(ONTOLOGY_IRI, ontology.getOntologyID().getOntologyIRI().get()); + assertEquals(ONTOLOGY_IRI, manager.getOntologyDocumentIRI(ontology)); + } + + @Test + void testCreateOntologyWithAxioms() throws OWLOntologyCreationException { + OWLOntologyManager manager = createManager(); + OWLOntology ontology = manager.createOntology(new HashSet()); + assertNotNull(manager.getOntologyDocumentIRI(ontology)); + } + + @Test + void testCreateOntologyWithAxiomsAndIRI() throws OWLOntologyCreationException { + OWLOntologyManager manager = createManager(); + OWLOntology ontology = manager.createOntology(new HashSet(), ONTOLOGY_IRI); + assertEquals(ONTOLOGY_IRI, ontology.getOntologyID().getOntologyIRI().get()); + assertEquals(ONTOLOGY_IRI, manager.getOntologyDocumentIRI(ontology)); + } + + @Test + void testCreateOntologyWithIdWithVersionIRI() throws OWLOntologyCreationException { + OWLOntologyManager manager = createManager(); + IRI versionIRI = IRI("http://version/1", ""); + OWLOntologyID id = new OWLOntologyID(optional(ONTOLOGY_IRI), optional(versionIRI)); + OWLOntology ontology = manager.createOntology(id); + assertEquals(ONTOLOGY_IRI, ontology.getOntologyID().getOntologyIRI().get()); + assertEquals(versionIRI, ontology.getOntologyID().getVersionIRI().get()); + assertEquals(versionIRI, manager.getOntologyDocumentIRI(ontology)); + } + + @Test + void testCreateOntologyWithId() throws OWLOntologyCreationException { + OWLOntologyManager manager = createManager(); + OWLOntologyID id = new OWLOntologyID(optional(ONTOLOGY_IRI), emptyOptional(IRI.class)); + OWLOntology ontology = manager.createOntology(id); + assertEquals(ONTOLOGY_IRI, ontology.getOntologyID().getOntologyIRI().get()); + assertEquals(ONTOLOGY_IRI, manager.getOntologyDocumentIRI(ontology)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/MissingDeclarationRoundTripTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/MissingDeclarationRoundTripTestCase.java new file mode 100644 index 0000000000..af7f27eea2 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/MissingDeclarationRoundTripTestCase.java @@ -0,0 +1,48 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; + +class MissingDeclarationRoundTripTestCase extends TestBase { + + @Test + void shouldFindOneAxiom() throws Exception { + OWLOntology ontology = createOntology(AP); + assertTrue(ontology.containsAnnotationPropertyInSignature(AP.getIRI())); + assertEquals(1, ontology.getAxiomCount()); + RDFXMLDocumentFormat format = new RDFXMLDocumentFormat(); + format.setAddMissingTypes(false); + ontology = loadOntologyStrict(saveOntology(ontology, format).toString(), format); + assertFalse(ontology.containsAnnotationPropertyInSignature(AP.getIRI())); + assertEquals(0, ontology.getAxiomCount()); + } + + private OWLOntology createOntology(OWLAnnotationProperty p) { + OWLOntology ontology = getOWLOntology(); + OWLAxiom axiom = AnnotationAssertion(p, A.getIRI(), Literal("Hello")); + ontology.add(axiom); + return ontology; + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/MoveOntologyTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/MoveOntologyTestCase.java new file mode 100644 index 0000000000..d5339eaef0 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/MoveOntologyTestCase.java @@ -0,0 +1,82 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.io.StringDocumentSource; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.parameters.OntologyCopy; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +class MoveOntologyTestCase extends TestBase { + + @BeforeEach + void setUp() throws OWLOntologyCreationException { + m.createOntology(iri("urn:test#", "test")); + } + + @Test + void testMove() throws OWLOntologyCreationException { + OWLOntology o = + m.loadOntologyFromOntologyDocument(new StringDocumentSource(TestFiles.moveTest)); + OWLOntology copy = m1.copyOntology(o, OntologyCopy.MOVE); + assertSame(o, copy); + assertEquals(m1, copy.getOWLOntologyManager()); + assertFalse(m.contains(o)); + assertTrue(m1.contains(copy)); + assertEquals(asSet(o.annotations()), asSet(copy.annotations())); + assertNull(m.getOntologyFormat(o)); + } + + @Test + void testShallow() throws OWLOntologyCreationException { + OWLOntology o = + m.loadOntologyFromOntologyDocument(new StringDocumentSource(TestFiles.moveTest)); + OWLOntology copy = m1.copyOntology(o, OntologyCopy.SHALLOW); + assertEquals(m1, copy.getOWLOntologyManager()); + assertTrue(m.contains(o)); + assertTrue(m1.contains(copy)); + assertNotNull(m.getOntologyFormat(o)); + assertEquals(asSet(o.annotations()), asSet(copy.annotations())); + assertEquals(asSet(o.importsDeclarations()), asSet(copy.importsDeclarations())); + } + + @Test + void testDeep() throws OWLOntologyCreationException { + OWLOntology o = + m.loadOntologyFromOntologyDocument(new StringDocumentSource(TestFiles.moveTest)); + OWLOntology copy = m1.copyOntology(o, OntologyCopy.DEEP); + assertEquals(m1, copy.getOWLOntologyManager()); + assertTrue(m.contains(o)); + assertTrue(m1.contains(copy)); + assertNotNull(m.getOntologyFormat(o)); + assertNotNull(m1.getOntologyFormat(o)); + assertEquals(asSet(o.annotations()), asSet(copy.annotations())); + assertEquals(asSet(o.importsDeclarations()), asSet(copy.importsDeclarations())); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/MultipleOntologyDeclarationsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/MultipleOntologyDeclarationsTestCase.java new file mode 100644 index 0000000000..20ff2463ef --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/MultipleOntologyDeclarationsTestCase.java @@ -0,0 +1,52 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.RioTurtleDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.io.StringDocumentSource; +import org.semanticweb.owlapi.io.UnparsableOntologyException; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration; + +/** + * @author Peter Ansell p_ansell@yahoo.com + */ +class MultipleOntologyDeclarationsTestCase extends TestBase { + + @Test + void shouldLoadFirstOfMultipleOntologyDeclarationsRdfXml() throws Exception { + OWLOntology o = + m.loadOntologyFromOntologyDocument(new StringDocumentSource(TestFiles.doubleOntology, + "urn:test:t1", new TurtleDocumentFormat(), null)); + assertEquals(o.getOntologyID(), new OWLOntologyID(IRI.create("urn:test:Ontology1"), + IRI.create("urn:test:Ontology1Version1"))); + } + + @Test + void shouldNotLoadMultipleOntologyDeclarationsRioRdfXml() throws Exception { + assertThrows(UnparsableOntologyException.class, + () -> m.loadOntologyFromOntologyDocument( + new StringDocumentSource(TestFiles.doubleOntology, "urn:test:t1", + new RioTurtleDocumentFormat(), null), + new OWLOntologyLoaderConfiguration().setStrict(true))); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/MultipleOntologyLoadsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/MultipleOntologyLoadsTestCase.java new file mode 100644 index 0000000000..2d7d8557e9 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/MultipleOntologyLoadsTestCase.java @@ -0,0 +1,154 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.util.Optional; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.io.OWLParser; +import org.semanticweb.owlapi.io.StringDocumentSource; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyAlreadyExistsException; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.rdf.rdfxml.parser.RDFXMLParser; + +/** + * @author Peter Ansell p_ansell@yahoo.com + */ +class MultipleOntologyLoadsTestCase extends TestBase { + + private final Optional v2 = + optional(IRI.getNextDocumentIRI("http://test.example.org/ontology/0139/version:2")); + private final Optional v1 = + optional(IRI.getNextDocumentIRI("http://test.example.org/ontology/0139/version:1")); + private final Optional i139 = + optional(IRI.getNextDocumentIRI("http://test.example.org/ontology/0139")); + private final String INPUT = "\n" + "\n" + " \n" + + " \n" + + " \n" + + " \n" + ""; + + @Test + public void testMultipleVersionLoadChangeIRI() { + OWLOntologyID initialUniqueOWLOntologyID = new OWLOntologyID(i139, v2); + OWLOntology initialOntology = getOWLOntology(initialUniqueOWLOntologyID); + OWLParser initialParser = new RDFXMLParser(); + initialParser.parse(new StringDocumentSource(INPUT), initialOntology, config); + OWLOntologyID secondUniqueOWLOntologyID = new OWLOntologyID(i139, v2); + try { + getOWLOntology(secondUniqueOWLOntologyID); + fail("Did not receive expected OWLOntologyDocumentAlreadyExistsException"); + } catch (OWLRuntimeException e) { + assertEquals(new OWLOntologyID(i139, v2), + ((OWLOntologyAlreadyExistsException) e.getCause()).getOntologyID()); + } + } + + @Test + public void testMultipleVersionLoadNoChange() { + OWLOntologyID initialUniqueOWLOntologyID = new OWLOntologyID(i139, v1); + OWLOntology initialOntology = getOWLOntology(initialUniqueOWLOntologyID); + OWLParser parser = new RDFXMLParser(); + parser.parse(new StringDocumentSource(INPUT), initialOntology, config); + OWLOntologyID secondUniqueOWLOntologyID = new OWLOntologyID(i139, v1); + try { + getOWLOntology(secondUniqueOWLOntologyID); + fail("Did not receive expected OWLOntologyAlreadyExistsException"); + } catch (OWLRuntimeException e) { + assertEquals(new OWLOntologyID(i139, v1), + ((OWLOntologyAlreadyExistsException) e.getCause()).getOntologyID()); + } + } + + @Test + public void testMultipleVersionLoadsExplicitOntologyIDs() { + OWLOntologyID initialUniqueOWLOntologyID = new OWLOntologyID(i139, v1); + OWLOntology initialOntology = getOWLOntology(initialUniqueOWLOntologyID); + OWLParser parser = new RDFXMLParser(); + parser.parse(new StringDocumentSource(INPUT), initialOntology, config); + assertEquals(i139, initialOntology.getOntologyID().getOntologyIRI()); + assertEquals(v1, initialOntology.getOntologyID().getVersionIRI()); + OWLOntologyID secondUniqueOWLOntologyID = new OWLOntologyID(i139, v2); + OWLOntology secondOntology = getOWLOntology(secondUniqueOWLOntologyID); + OWLParser secondParser = new RDFXMLParser(); + secondParser.parse(new StringDocumentSource(INPUT), secondOntology, config); + assertEquals(i139, secondOntology.getOntologyID().getOntologyIRI()); + assertEquals(v2, secondOntology.getOntologyID().getVersionIRI()); + } + + @Test + public void testMultipleVersionLoadsNoOntologyIDFirstTime() { + OWLOntology initialOntology = getAnonymousOWLOntology(); + OWLParser parser = new RDFXMLParser(); + parser.parse(new StringDocumentSource(INPUT), initialOntology, config); + assertEquals(i139, initialOntology.getOntologyID().getOntologyIRI()); + assertEquals(v1, initialOntology.getOntologyID().getVersionIRI()); + OWLOntologyID secondUniqueOWLOntologyID = new OWLOntologyID(i139, v2); + OWLOntology secondOntology = getOWLOntology(secondUniqueOWLOntologyID); + OWLParser secondParser = new RDFXMLParser(); + secondParser.parse(new StringDocumentSource(INPUT), secondOntology, config); + assertEquals(i139, secondOntology.getOntologyID().getOntologyIRI()); + assertEquals(v2, secondOntology.getOntologyID().getVersionIRI()); + } + + @Test + public void testMultipleVersionLoadsNoOntologyVersionIRIFirstTime() { + Optional empty = emptyOptional(IRI.class); + OWLOntologyID initialUniqueOWLOntologyID = new OWLOntologyID(i139, empty); + OWLOntology initialOntology = getOWLOntology(initialUniqueOWLOntologyID); + OWLParser parser = new RDFXMLParser(); + parser.parse(new StringDocumentSource(INPUT), initialOntology, config); + assertEquals(i139, initialOntology.getOntologyID().getOntologyIRI()); + assertEquals(v1, initialOntology.getOntologyID().getVersionIRI()); + OWLOntologyID secondUniqueOWLOntologyID = new OWLOntologyID(i139, v2); + OWLOntology secondOntology = getOWLOntology(secondUniqueOWLOntologyID); + OWLParser secondParser = new RDFXMLParser(); + secondParser.parse(new StringDocumentSource(INPUT), secondOntology, config); + assertEquals(i139, secondOntology.getOntologyID().getOntologyIRI()); + assertEquals(v2, secondOntology.getOntologyID().getVersionIRI()); + } + + @Test + public void testSingleVersionLoadChangeIRI() { + OWLOntologyID secondUniqueOWLOntologyID = new OWLOntologyID(i139, v2); + OWLOntology secondOntology = getOWLOntology(secondUniqueOWLOntologyID); + OWLParser secondParser = new RDFXMLParser(); + // the following throws the exception + secondParser.parse(new StringDocumentSource(INPUT), secondOntology, config); + assertEquals(i139, secondOntology.getOntologyID().getOntologyIRI()); + assertEquals(v2, secondOntology.getOntologyID().getVersionIRI()); + } + + @Test + public void testSingleVersionLoadNoChange() { + OWLOntologyID initialUniqueOWLOntologyID = new OWLOntologyID(i139, v1); + OWLOntology initialOntology = getOWLOntology(initialUniqueOWLOntologyID); + OWLParser parser = new RDFXMLParser(); + parser.parse(new StringDocumentSource(INPUT), initialOntology, config); + assertEquals(i139, initialOntology.getOntologyID().getOntologyIRI()); + assertEquals(v1, initialOntology.getOntologyID().getVersionIRI()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OWLOntologyAccessorsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OWLOntologyAccessorsTestCase.java new file mode 100644 index 0000000000..eeea674623 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OWLOntologyAccessorsTestCase.java @@ -0,0 +1,419 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.*; +import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED; +import static org.semanticweb.owlapi.search.EntitySearcher.*; +import static org.semanticweb.owlapi.search.Filters.subClassWithSub; +import static org.semanticweb.owlapi.search.Filters.subClassWithSuper; +import static org.semanticweb.owlapi.search.Searcher.*; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.contains; + +import java.util.Collection; +import java.util.Collections; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.*; + +/** + * @author Matthew Horridge, The University Of Manchester, Information Management Group + * @since 2.2.0 + */ +class OWLOntologyAccessorsTestCase extends TestBase { + + static final OWLNamedIndividual indA = NamedIndividual(iri("indA")); + static final OWLNamedIndividual indB = NamedIndividual(iri("indB")); + static final OWLNamedIndividual indC = NamedIndividual(iri("indC")); + + private static void performAxiomTests(OWLOntology ont, OWLAxiom... axioms) { + assertEquals(ont.getAxiomCount(), axioms.length); + for (OWLAxiom ax : axioms) { + assertTrue(contains(ont.axioms(), ax)); + if (ax.isLogicalAxiom()) { + assertTrue(contains(ont.logicalAxioms(), ax)); + } + assertEquals(ont.getLogicalAxiomCount(), axioms.length); + AxiomType axiomType = ax.getAxiomType(); + assertTrue(contains(ont.axioms(axiomType), ax)); + assertTrue(contains(ont.axioms(axiomType, INCLUDED), ax)); + assertEquals(ont.getAxiomCount(axiomType), axioms.length); + assertEquals(ont.getAxiomCount(axiomType, INCLUDED), axioms.length); + ax.signature().forEach(e -> { + assertTrue(contains(ont.referencingAxioms(e), ax)); + assertTrue(contains(ont.signature(), e)); + }); + } + } + + @Test + void shouldFindExpectedIRIOccurrences() { + OWLOntology o = getOWLOntology(); + IRI query = iri("urn:test:", "someIRI"); + OWLAnnotationProperty ap1 = df.getOWLAnnotationProperty("urn:test:AP1"); + OWLAnnotationProperty ap2 = df.getOWLAnnotationProperty("urn:test:AP2"); + o.add(df.getOWLAnnotationPropertyDomainAxiom(ap1, query)); + OWLAnnotation a = df.getOWLAnnotation(ap2, query); + OWLClass c = df.getOWLClass("urn:test:C"); + o.add(df.getOWLSubClassOfAxiom(c, df.getOWLThing(), Collections.singletonList(a))); + o.add(df.getOWLAnnotationAssertionAxiom(iri("urn:test:", "otherIRI"), a)); + long count = o.referencingAxioms(query).count(); + assertEquals(3, o.getAxiomCount()); + assertEquals(3, count); + } + + @Test + void testSubClassOfAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLSubClassOfAxiom ax = SubClassOf(A, B); + ont.addAxiom(ax); + OWLSubClassOfAxiom ax2 = SubClassOf(A, ObjectSomeValuesFrom(P, B)); + ont.addAxiom(ax2); + performAxiomTests(ont, ax, ax2); + assertTrue(contains(ont.subClassAxiomsForSubClass(A), ax)); + assertTrue(contains(ont.subClassAxiomsForSuperClass(B), ax)); + assertTrue(contains(ont.axioms(A), ax)); + assertTrue(contains(sup(ont.axioms(subClassWithSub, A, INCLUDED)), B)); + assertTrue(contains(sub(ont.axioms(subClassWithSuper, B, INCLUDED)), A)); + } + + @Test + void testEquivalentClassesAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLEquivalentClassesAxiom ax = EquivalentClasses(A, B, C, ObjectSomeValuesFrom(P, D)); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.equivalentClassesAxioms(A), ax)); + assertTrue(contains(ont.equivalentClassesAxioms(B), ax)); + assertTrue(contains(ont.equivalentClassesAxioms(C), ax)); + assertTrue(contains(ont.axioms(A), ax)); + assertTrue(contains(ont.axioms(B), ax)); + assertTrue(contains(ont.axioms(C), ax)); + } + + @Test + void testDisjointClassesAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLDisjointClassesAxiom ax = DisjointClasses(A, B, C, ObjectSomeValuesFrom(P, D)); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.disjointClassesAxioms(A), ax)); + assertTrue(contains(ont.disjointClassesAxioms(B), ax)); + assertTrue(contains(ont.disjointClassesAxioms(C), ax)); + assertTrue(contains(ont.axioms(A), ax)); + assertTrue(contains(ont.axioms(B), ax)); + assertTrue(contains(ont.axioms(C), ax)); + } + + @Test + void testSubObjectPropertyOfAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLSubObjectPropertyOfAxiom ax = SubObjectPropertyOf(P, Q); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.objectSubPropertyAxiomsForSubProperty(P), ax)); + assertTrue(contains(ont.objectSubPropertyAxiomsForSuperProperty(Q), ax)); + assertTrue(contains(ont.axioms(P), ax)); + } + + @Test + void testEquivalentObjectPropertiesAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLEquivalentObjectPropertiesAxiom ax = EquivalentObjectProperties(P, Q, R); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.equivalentObjectPropertiesAxioms(P), ax)); + assertTrue(contains(ont.equivalentObjectPropertiesAxioms(Q), ax)); + assertTrue(contains(ont.equivalentObjectPropertiesAxioms(R), ax)); + assertTrue(contains(ont.axioms(P), ax)); + assertTrue(contains(ont.axioms(Q), ax)); + assertTrue(contains(ont.axioms(R), ax)); + } + + @Test + void testDisjointObjectPropertiesAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLDisjointObjectPropertiesAxiom ax = DisjointObjectProperties(P, Q, R); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.disjointObjectPropertiesAxioms(P), ax)); + assertTrue(contains(ont.disjointObjectPropertiesAxioms(Q), ax)); + assertTrue(contains(ont.disjointObjectPropertiesAxioms(R), ax)); + assertTrue(contains(ont.axioms(P), ax)); + assertTrue(contains(ont.axioms(Q), ax)); + assertTrue(contains(ont.axioms(R), ax)); + } + + @Test + void testObjectPropertyDomainAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLObjectPropertyDomainAxiom ax = ObjectPropertyDomain(P, A); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.objectPropertyDomainAxioms(P), ax)); + assertTrue(contains(ont.axioms(P), ax)); + assertTrue(contains(domain(ont.objectPropertyDomainAxioms(P)), A)); + } + + @Test + void testObjectPropertyRangeAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLObjectPropertyRangeAxiom ax = ObjectPropertyRange(P, A); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.objectPropertyRangeAxioms(P), ax)); + assertTrue(contains(ont.axioms(P), ax)); + assertTrue(contains(range(ont.objectPropertyRangeAxioms(P)), A)); + } + + @Test + void testFunctionalObjectPropertyAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLFunctionalObjectPropertyAxiom ax = FunctionalObjectProperty(P); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.functionalObjectPropertyAxioms(P), ax)); + assertTrue(contains(ont.axioms(P), ax)); + assertTrue(isFunctional(P, ont)); + } + + @Test + void testInverseFunctionalObjectPropertyAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLInverseFunctionalObjectPropertyAxiom ax = InverseFunctionalObjectProperty(P); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.inverseFunctionalObjectPropertyAxioms(P), ax)); + assertTrue(contains(ont.axioms(P), ax)); + assertTrue(isInverseFunctional(P, ont)); + } + + @Test + void testTransitiveObjectPropertyAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLTransitiveObjectPropertyAxiom ax = TransitiveObjectProperty(P); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.transitiveObjectPropertyAxioms(P), ax)); + assertTrue(contains(ont.axioms(P), ax)); + assertTrue(isTransitive(P, ont)); + } + + @Test + void testSymmetricObjectPropertyAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLSymmetricObjectPropertyAxiom ax = SymmetricObjectProperty(P); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.symmetricObjectPropertyAxioms(P), ax)); + assertTrue(contains(ont.axioms(P), ax)); + assertTrue(isSymmetric(P, ont)); + } + + @Test + void testAsymmetricObjectPropertyAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLAsymmetricObjectPropertyAxiom ax = AsymmetricObjectProperty(P); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.asymmetricObjectPropertyAxioms(P), ax)); + assertTrue(contains(ont.axioms(P), ax)); + assertTrue(isAsymmetric(P, ont)); + } + + @Test + void testReflexiveObjectPropertyAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLReflexiveObjectPropertyAxiom ax = ReflexiveObjectProperty(P); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.reflexiveObjectPropertyAxioms(P), ax)); + assertTrue(contains(ont.axioms(P), ax)); + assertTrue(isReflexive(P, ont)); + } + + @Test + void testIrreflexiveObjectPropertyAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLIrreflexiveObjectPropertyAxiom ax = IrreflexiveObjectProperty(P); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.irreflexiveObjectPropertyAxioms(P), ax)); + assertTrue(contains(ont.axioms(P), ax)); + assertTrue(isIrreflexive(P, ont)); + } + + @Test + void testSubDataPropertyOfAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLSubDataPropertyOfAxiom ax = SubDataPropertyOf(DP, DQ); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.dataSubPropertyAxiomsForSubProperty(DP), ax)); + assertTrue(contains(ont.dataSubPropertyAxiomsForSuperProperty(DQ), ax)); + assertTrue(contains(ont.axioms(DP), ax)); + } + + @Test + void testEquivalentDataPropertiesAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLEquivalentDataPropertiesAxiom ax = EquivalentDataProperties(DP, DQ, DR); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.equivalentDataPropertiesAxioms(DP), ax)); + assertTrue(contains(ont.equivalentDataPropertiesAxioms(DQ), ax)); + assertTrue(contains(ont.equivalentDataPropertiesAxioms(DR), ax)); + assertTrue(contains(ont.axioms(DP), ax)); + assertTrue(contains(ont.axioms(DQ), ax)); + assertTrue(contains(ont.axioms(DR), ax)); + } + + @Test + void testDisjointDataPropertiesAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLDisjointDataPropertiesAxiom ax = DisjointDataProperties(DP, DQ, DR); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.disjointDataPropertiesAxioms(DP), ax)); + assertTrue(contains(ont.disjointDataPropertiesAxioms(DQ), ax)); + assertTrue(contains(ont.disjointDataPropertiesAxioms(DR), ax)); + assertTrue(contains(ont.axioms(DP), ax)); + assertTrue(contains(ont.axioms(DQ), ax)); + assertTrue(contains(ont.axioms(DR), ax)); + } + + @Test + void testDataPropertyDomainAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLDataPropertyDomainAxiom ax = DataPropertyDomain(DP, A); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.dataPropertyDomainAxioms(DP), ax)); + assertTrue(contains(ont.axioms(DP), ax)); + assertTrue(contains(domain(ont.dataPropertyDomainAxioms(DP)), A)); + } + + @Test + void testDataPropertyRangeAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLDatatype dt = Datatype(iri("dt")); + OWLDataPropertyRangeAxiom ax = DataPropertyRange(DP, dt); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.dataPropertyRangeAxioms(DP), ax)); + assertTrue(contains(ont.axioms(DP), ax)); + assertTrue(contains(range(ont.dataPropertyRangeAxioms(DP)), dt)); + } + + @Test + void testFunctionalDataPropertyAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLFunctionalDataPropertyAxiom ax = FunctionalDataProperty(DP); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.functionalDataPropertyAxioms(DP), ax)); + assertTrue(contains(ont.axioms(DP), ax)); + assertTrue(isFunctional(DP, ont)); + } + + @Test + void testClassAssertionAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLClassAssertionAxiom ax = ClassAssertion(A, indA); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.classAssertionAxioms(indA), ax)); + assertTrue(contains(ont.classAssertionAxioms(A), ax)); + assertTrue(contains(ont.axioms(indA), ax)); + assertTrue(contains(instances(ont.classAssertionAxioms(indA)), indA)); + assertTrue(contains(types(ont.classAssertionAxioms(indA)), A)); + } + + @Test + void testObjectPropertyAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLObjectPropertyAssertionAxiom ax = ObjectPropertyAssertion(P, indA, indB); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.objectPropertyAssertionAxioms(indA), ax)); + assertTrue(contains(ont.axioms(indA), ax)); + } + + @Test + void testNegativeObjectPropertyAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLNegativeObjectPropertyAssertionAxiom ax = NegativeObjectPropertyAssertion(P, indA, indB); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.negativeObjectPropertyAssertionAxioms(indA), ax)); + assertTrue(contains(ont.axioms(indA), ax)); + } + + @Test + void testDataPropertyAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLLiteral lit = Literal(3); + OWLDataPropertyAssertionAxiom ax = DataPropertyAssertion(DP, indA, lit); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.dataPropertyAssertionAxioms(indA), ax)); + assertTrue(contains(ont.axioms(indA), ax)); + } + + @Test + void testNegativeDataPropertyAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLLiteral lit = Literal(3); + OWLNegativeDataPropertyAssertionAxiom ax = NegativeDataPropertyAssertion(DP, indA, lit); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.negativeDataPropertyAssertionAxioms(indA), ax)); + assertTrue(contains(ont.axioms(indA), ax)); + } + + @Test + void testSameIndividualAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLSameIndividualAxiom ax = SameIndividual(indA, indB, indC); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.sameIndividualAxioms(indA), ax)); + assertTrue(contains(ont.sameIndividualAxioms(indB), ax)); + assertTrue(contains(ont.sameIndividualAxioms(indC), ax)); + assertTrue(contains(ont.axioms(indA), ax)); + Collection equivalent = + asUnorderedSet(equivalent(ont.sameIndividualAxioms(indA))); + assertTrue(equivalent.contains(indB)); + assertTrue(equivalent.contains(indC)); + } + + @Test + void testDifferentIndividualsAxiomAccessors() { + OWLOntology ont = getOWLOntology(); + OWLDifferentIndividualsAxiom ax = DifferentIndividuals(indA, indB, indC); + ont.addAxiom(ax); + performAxiomTests(ont, ax); + assertTrue(contains(ont.differentIndividualAxioms(indA), ax)); + assertTrue(contains(ont.differentIndividualAxioms(indB), ax)); + assertTrue(contains(ont.differentIndividualAxioms(indC), ax)); + assertTrue(contains(ont.axioms(indA), ax)); + Collection different = + asUnorderedSet(different(ont.differentIndividualAxioms(indA))); + assertTrue(different.contains(indB)); + assertTrue(different.contains(indC)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OWLOntologyChangeRecordTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OWLOntologyChangeRecordTestCase.java new file mode 100644 index 0000000000..9e26f31801 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OWLOntologyChangeRecordTestCase.java @@ -0,0 +1,85 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.mock; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.change.AddAxiomData; +import org.semanticweb.owlapi.change.OWLOntologyChangeData; +import org.semanticweb.owlapi.change.OWLOntologyChangeRecord; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.UnknownOWLOntologyException; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.2.0 + */ +class OWLOntologyChangeRecordTestCase extends TestBase { + + private final OWLOntologyID mockOntologyID = new OWLOntologyID(); + private final OWLOntologyChangeData mockChangeData = mock(OWLOntologyChangeData.class); + private final OWLAxiom mockAxiom = mock(OWLAxiom.class); + + @Test + void testEquals() { + OWLOntologyChangeRecord record1 = + new OWLOntologyChangeRecord(mockOntologyID, mockChangeData); + OWLOntologyChangeRecord record2 = + new OWLOntologyChangeRecord(mockOntologyID, mockChangeData); + assertEquals(record1, record2); + } + + @Test + void testGettersNotNull() { + OWLOntologyChangeRecord record = + new OWLOntologyChangeRecord(mockOntologyID, mockChangeData); + assertNotNull(record.getOntologyID()); + } + + @Test + void testGetterEqual() { + OWLOntologyChangeRecord record = + new OWLOntologyChangeRecord(mockOntologyID, mockChangeData); + assertEquals(mockOntologyID, record.getOntologyID()); + assertEquals(mockChangeData, record.getData()); + } + + @Test + void testCreateOntologyChange() { + OWLOntologyChangeRecord changeRecord = + new OWLOntologyChangeRecord(mockOntologyID, mockChangeData); + assertThrows(UnknownOWLOntologyException.class, () -> changeRecord.createOntologyChange(m)); + } + + @Test + void testCreateOntologyChangeEquals() throws OWLOntologyCreationException { + OWLOntology ontology = m.createOntology(); + OWLOntologyID ontologyID = ontology.getOntologyID(); + AddAxiomData addAxiomData = new AddAxiomData(mockAxiom); + OWLOntologyChangeRecord changeRecord = + new OWLOntologyChangeRecord(ontologyID, addAxiomData); + OWLOntologyChange change = changeRecord.createOntologyChange(m); + assertNotNull(change); + assertEquals(change.getOntology().getOntologyID(), ontologyID); + assertEquals(mockAxiom, change.getAxiom()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OWLOntologyManagerImplTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OWLOntologyManagerImplTestCase.java new file mode 100644 index 0000000000..519c352ded --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OWLOntologyManagerImplTestCase.java @@ -0,0 +1,116 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.contains; + +import java.util.Set; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.AddImport; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLException; +import org.semanticweb.owlapi.model.OWLImportsDeclaration; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; + +import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl; +import uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl; +import uk.ac.manchester.cs.owl.owlapi.OWLOntologyImpl; +import uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +class OWLOntologyManagerImplTestCase extends TestBase { + + @BeforeEach + void setUpManager() { + m = new OWLOntologyManagerImpl(new OWLDataFactoryImpl(), new ReentrantReadWriteLock()); + m.getOntologyFactories() + .add(new OWLOntologyFactoryImpl((om, id) -> new OWLOntologyImpl(om, id))); + } + + @Test + void testContains() throws OWLOntologyCreationException { + OWLOntology ont = m.createOntology(nextOntology()); + assertTrue(m.contains(ont.getOntologyID())); + assertNotNull(m.getOntology(ont.getOntologyID())); + assertTrue(contains(m.ontologies(), ont)); + assertNotNull(m.getOntologyDocumentIRI(ont)); + m.removeOntology(ont); + assertFalse(m.contains(ont.getOntologyID())); + } + + protected IRI nextOntology() { + return IRI.getNextDocumentIRI("urn:testontology"); + } + + @Test + void testImports() throws OWLOntologyCreationException { + OWLOntology ontA = m.createOntology(nextOntology()); + OWLOntology ontB = m.createOntology(nextOntology()); + OWLImportsDeclaration decl = m.getOWLDataFactory() + .getOWLImportsDeclaration(get(ontB.getOntologyID().getOntologyIRI())); + ontA.applyChange(new AddImport(ontA, decl)); + assertTrue(contains(m.directImports(ontA), ontB)); + m.removeOntology(ontB); + assertFalse(contains(m.directImports(ontA), ontB)); + } + + @Test + void testImportsClosure() throws OWLException { + // OntA -> OntB -> OntC (-> means imports) + OWLOntology ontA = m.createOntology(nextOntology()); + OWLOntology ontB = m.createOntology(nextOntology()); + OWLOntology ontC = m.createOntology(nextOntology()); + OWLImportsDeclaration declA = m.getOWLDataFactory() + .getOWLImportsDeclaration(get(ontB.getOntologyID().getOntologyIRI())); + OWLImportsDeclaration declB = m.getOWLDataFactory() + .getOWLImportsDeclaration(get(ontC.getOntologyID().getOntologyIRI())); + ontA.applyChanges(new AddImport(ontA, declA)); + ontB.applyChanges(new AddImport(ontB, declB)); + assertTrue(contains(m.importsClosure(ontA), ontA)); + assertTrue(contains(m.importsClosure(ontA), ontB)); + assertTrue(contains(m.importsClosure(ontA), ontC)); + assertTrue(contains(m.importsClosure(ontB), ontB)); + assertTrue(contains(m.importsClosure(ontB), ontC)); + } + + @Test + void testImportsLoad() throws OWLException { + OWLOntology ontA = m.createOntology(iri("urn:test:", "a")); + assertEquals(0L, ontA.directImports().count()); + IRI b = iri("urn:test:", "b"); + OWLImportsDeclaration declB = m.getOWLDataFactory().getOWLImportsDeclaration(b); + ontA.applyChange(new AddImport(ontA, declB)); + Set directImportsDocuments = asUnorderedSet(ontA.directImportsDocuments()); + assertEquals(1, directImportsDocuments.size()); + assertTrue(directImportsDocuments.contains(b)); + OWLOntology ontB = m.createOntology(b); + directImportsDocuments = asUnorderedSet(ontA.directImportsDocuments()); + assertEquals(1, directImportsDocuments.size()); + assertTrue(directImportsDocuments.contains(b)); + assertEquals(1, ontA.directImports().count()); + assertTrue(contains(ontA.directImports(), ontB)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OWLOntologyManagerRemoveAxiomsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OWLOntologyManagerRemoveAxiomsTestCase.java new file mode 100644 index 0000000000..8c41bb68c5 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OWLOntologyManagerRemoveAxiomsTestCase.java @@ -0,0 +1,30 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLOntology; + +class OWLOntologyManagerRemoveAxiomsTestCase extends TestBase { + + @Test + void testRemove() { + OWLOntology o = + loadOntologyFromString(TestFiles.premiseOntology, new FunctionalSyntaxDocumentFormat()); + o.remove(o.axioms(AxiomType.DECLARATION)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OWLOntologyManagerTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OWLOntologyManagerTestCase.java new file mode 100644 index 0000000000..f7fc714218 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OWLOntologyManagerTestCase.java @@ -0,0 +1,142 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyAlreadyExistsException; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyDocumentAlreadyExistsException; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.util.SimpleIRIMapper; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +class OWLOntologyManagerTestCase extends TestBase { + + private static final String NS = "http://www.semanticweb.org/ontologies/ontology"; + + static final IRI next(String n) { + return IRI.getNextDocumentIRI(n); + } + + @Test + void testCreateAnonymousOntology() { + OWLOntology ontology = getAnonymousOWLOntology(); + assertNotNull(ontology); + assertNotNull(ontology.getOntologyID()); + assertFalse(ontology.getOntologyID().getDefaultDocumentIRI().isPresent()); + assertFalse(ontology.getOntologyID().getOntologyIRI().isPresent()); + assertFalse(ontology.getOntologyID().getVersionIRI().isPresent()); + assertNotNull(m.getOntologyDocumentIRI(ontology)); + } + + @Test + void testCreateOntologyWithIRI() { + IRI ontologyIRI = next(NS); + OWLOntology ontology = getOWLOntology(ontologyIRI); + assertNotNull(ontology); + assertNotNull(ontology.getOntologyID()); + assertEquals(ontologyIRI, ontology.getOntologyID().getDefaultDocumentIRI().get()); + assertEquals(ontologyIRI, ontology.getOntologyID().getOntologyIRI().get()); + assertFalse(ontology.getOntologyID().getVersionIRI().isPresent()); + assertEquals(ontologyIRI, m.getOntologyDocumentIRI(ontology)); + } + + @Test + void testCreateOntologyWithIRIAndVersionIRI() { + IRI ontologyIRI = next(NS); + IRI versionIRI = next(NS + "/version"); + OWLOntology ontology = + getOWLOntology(new OWLOntologyID(optional(ontologyIRI), optional(versionIRI))); + assertNotNull(ontology); + assertNotNull(ontology.getOntologyID()); + assertEquals(versionIRI, ontology.getOntologyID().getDefaultDocumentIRI().get()); + assertEquals(ontologyIRI, ontology.getOntologyID().getOntologyIRI().get()); + assertEquals(versionIRI, ontology.getOntologyID().getVersionIRI().get()); + assertEquals(versionIRI, m.getOntologyDocumentIRI(ontology)); + } + + @Test + void testCreateOntologyWithIRIWithMapper() { + IRI ontologyIRI = next(NS); + IRI documentIRI = next("file:documentIRI"); + SimpleIRIMapper mapper = new SimpleIRIMapper(ontologyIRI, documentIRI); + m.getIRIMappers().add(mapper); + OWLOntology ontology = getOWLOntology(ontologyIRI); + assertNotNull(ontology); + assertNotNull(ontology.getOntologyID()); + assertEquals(ontologyIRI, ontology.getOntologyID().getDefaultDocumentIRI().get()); + assertEquals(ontologyIRI, ontology.getOntologyID().getOntologyIRI().get()); + assertFalse(ontology.getOntologyID().getVersionIRI().isPresent()); + assertEquals(documentIRI, m.getOntologyDocumentIRI(ontology)); + } + + @Test + void testCreateOntologyWithIRIAndVersionIRIWithMapper() { + IRI ontologyIRI = next(NS); + IRI versionIRI = next(NS + "/version"); + IRI documentIRI = next("file:documentIRI"); + SimpleIRIMapper mapper = new SimpleIRIMapper(versionIRI, documentIRI); + m.getIRIMappers().add(mapper); + OWLOntology ontology = + getOWLOntology(new OWLOntologyID(optional(ontologyIRI), optional(versionIRI))); + assertNotNull(ontology); + assertNotNull(ontology.getOntologyID()); + assertEquals(versionIRI, ontology.getOntologyID().getDefaultDocumentIRI().get()); + assertEquals(ontologyIRI, ontology.getOntologyID().getOntologyIRI().get()); + assertEquals(versionIRI, ontology.getOntologyID().getVersionIRI().get()); + assertEquals(documentIRI, m.getOntologyDocumentIRI(ontology)); + } + + @Test + void testCreateDuplicateOntologyWithIRI() { + IRI ontologyIRI = next(NS); + getOWLOntology(ontologyIRI); + assertThrowsWithCause(OWLRuntimeException.class, OWLOntologyAlreadyExistsException.class, + () -> getOWLOntology(ontologyIRI)); + } + + @Test + void testCreateDuplicateOntologyWithIRIAndVersionIRI() { + IRI ontologyIRI = next(NS); + IRI versionIRI = next(NS); + getOWLOntology(new OWLOntologyID(optional(ontologyIRI), optional(versionIRI))); + assertThrowsWithCause(OWLRuntimeException.class, OWLOntologyAlreadyExistsException.class, + () -> getOWLOntology(new OWLOntologyID(optional(ontologyIRI), optional(versionIRI)))); + } + + @Test + void testCreateDuplicatedDocumentIRI() throws OWLOntologyCreationException { + IRI ontologyIRI = next(NS); + IRI ontologyIRI2 = next(NS + "2"); + IRI documentIRI = next("file:documentIRI"); + m.getIRIMappers().add(new SimpleIRIMapper(ontologyIRI, documentIRI)); + m.getIRIMappers().add(new SimpleIRIMapper(ontologyIRI2, documentIRI)); + getOWLOntology(new OWLOntologyID(optional(ontologyIRI), optional((IRI) null))); + assertThrowsWithCause(OWLRuntimeException.class, + OWLOntologyDocumentAlreadyExistsException.class, + () -> getOWLOntology(new OWLOntologyID(optional(ontologyIRI2), optional((IRI) null)))); + + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OntologyChangeListenerTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OntologyChangeListenerTestCase.java new file mode 100644 index 0000000000..53abe401ca --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OntologyChangeListenerTestCase.java @@ -0,0 +1,75 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubClassOf; + +import java.util.HashSet; +import java.util.Set; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +class OntologyChangeListenerTestCase extends TestBase { + + @Test + void testOntologyChangeListener() { + OWLOntology ont = getOWLOntology(); + OWLSubClassOfAxiom ax = SubClassOf(A, B); + final Set impendingAdditions = new HashSet<>(); + final Set impendingRemovals = new HashSet<>(); + final Set additions = new HashSet<>(); + final Set removals = new HashSet<>(); + ont.getOWLOntologyManager().addImpendingOntologyChangeListener(impendingChanges -> { + for (OWLOntologyChange change : impendingChanges) { + if (change.isAddAxiom()) { + impendingAdditions.add(change.getAxiom()); + } else if (change.isRemoveAxiom()) { + impendingRemovals.add(change.getAxiom()); + } + } + }); + ont.getOWLOntologyManager().addOntologyChangeListener(changes -> { + for (OWLOntologyChange change : changes) { + if (change.isAddAxiom()) { + additions.add(change.getAxiom()); + } else if (change.isRemoveAxiom()) { + removals.add(change.getAxiom()); + } + } + }); + ont.addAxiom(ax); + assertTrue(additions.contains(ax)); + assertTrue(impendingAdditions.contains(ax)); + ont.remove(ax); + assertTrue(removals.contains(ax)); + assertTrue(impendingRemovals.contains(ax)); + // test that no op changes are not broadcasted + removals.clear(); + ont.remove(ax); + assertFalse(removals.contains(ax)); + assertTrue(impendingRemovals.contains(ax)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OntologyContainsAxiomTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OntologyContainsAxiomTestCase.java new file mode 100644 index 0000000000..b159df8691 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OntologyContainsAxiomTestCase.java @@ -0,0 +1,266 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Annotation; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Declaration; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ImportsDeclaration; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubClassOf; +import static org.semanticweb.owlapi.model.parameters.AxiomAnnotations.CONSIDER_AXIOM_ANNOTATIONS; +import static org.semanticweb.owlapi.model.parameters.AxiomAnnotations.IGNORE_AXIOM_ANNOTATIONS; +import static org.semanticweb.owlapi.model.parameters.Imports.EXCLUDED; +import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED; + +import java.io.File; +import java.io.FileOutputStream; + +import javax.annotation.Nonnull; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.io.StreamDocumentTarget; +import org.semanticweb.owlapi.model.AddImport; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLImportsDeclaration; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +class OntologyContainsAxiomTestCase extends TestBase { + + private static RDFXMLDocumentFormat createRDFXMLFormat() { + RDFXMLDocumentFormat format = new RDFXMLDocumentFormat(); + // This test case relies on certain declarations being in certain + // ontologies. The default + // behaviour is to add missing declarations. Therefore, this needs to be + // turned off. + format.setAddMissingTypes(false); + return format; + } + + private static TurtleDocumentFormat createTurtleOntologyFormat() { + TurtleDocumentFormat format = new TurtleDocumentFormat(); + format.setAddMissingTypes(false); + return format; + } + + @Test + void testOntologyContainsPlainAxiom() { + OWLAxiom axiom = SubClassOf(A, B); + OWLOntology ont = getOWLOntology(); + ont.addAxiom(axiom); + assertTrue(ont.containsAxiom(axiom)); + assertTrue(ont.containsAxiom(axiom, EXCLUDED, IGNORE_AXIOM_ANNOTATIONS)); + } + + @Test + void testOntologyContainsAnnotatedAxiom() { + OWLLiteral annoLiteral = Literal("value"); + OWLAnnotationProperty annoProp = AnnotationProperty(iri("annoProp")); + OWLAnnotation anno = Annotation(annoProp, annoLiteral); + OWLAxiom axiom = SubClassOf(A, B, singleton(anno)); + OWLOntology ont = getOWLOntology(); + ont.addAxiom(axiom); + assertTrue(ont.containsAxiom(axiom)); + assertTrue(ont.containsAxiom(axiom, EXCLUDED, IGNORE_AXIOM_ANNOTATIONS)); + assertFalse(ont.containsAxiom(axiom.getAxiomWithoutAnnotations())); + assertTrue(ont.containsAxiom(axiom.getAxiomWithoutAnnotations(), EXCLUDED, + IGNORE_AXIOM_ANNOTATIONS)); + } + + @Test + void testOntologyContainsAxiomsForRDFXML1() throws Exception { + RDFXMLDocumentFormat format = createRDFXMLFormat(); + runTestOntologyContainsAxioms1(format); + } + + @Test + void testOntologyContainsAxiomsForOWLXML1() throws Exception { + runTestOntologyContainsAxioms1(new OWLXMLDocumentFormat()); + } + + @Test + void testOntologyContainsAxiomsForOWLFunctionalSyntax1() throws Exception { + runTestOntologyContainsAxioms1(new FunctionalSyntaxDocumentFormat()); + } + + @Test + void testOntologyContainsAxiomsForTurtleSyntax1() throws Exception { + TurtleDocumentFormat format = createTurtleOntologyFormat(); + runTestOntologyContainsAxioms1(format); + } + + @SuppressWarnings("resource") + private void runTestOntologyContainsAxioms1(OWLDocumentFormat format) throws Exception { + OWLOntology ont1 = getOWLOntology(); + IRI ont1iri = get(ont1.getOntologyID().getOntologyIRI()); + OWLOntology ont2 = getOWLOntology(); + IRI ont2iri = get(ont2.getOntologyID().getOntologyIRI()); + OWLImportsDeclaration ont2import = ImportsDeclaration(ont1iri); + ont1.applyChange(new AddImport(ont2, ont2import)); + OWLAxiom axannoPropdecl = Declaration(AP); + ont1.addAxiom(axannoPropdecl); + OWLAnnotation inont1anno = Annotation(AP, ont1iri); + OWLAnnotation inont2anno = Annotation(AP, ont2iri); + OWLAxiom axAdecl = Declaration(A, singleton(inont1anno)); + ont1.addAxiom(axAdecl); + OWLAxiom axBdecl = Declaration(B, singleton(inont2anno)); + ont2.addAxiom(axBdecl); + OWLAxiom axAsubB = SubClassOf(A, B, singleton(inont2anno)); + ont2.addAxiom(axAsubB); + // annoProp is in ont1 and in the import closure of ont2 + assertTrue(containsConsiderEx(ont1, axannoPropdecl)); + assertFalse(containsConsiderEx(ont2, axannoPropdecl)); + assertTrue(containsConsider(ont2, axannoPropdecl)); + // A is in ont1 and in the import closure of ont2 + assertTrue(containsConsiderEx(ont1, axAdecl)); + assertFalse(containsConsiderEx(ont2, axAdecl)); + assertTrue(containsConsider(ont2, axAdecl)); + // B is in only in ont2 + assertFalse(containsConsider(ont1, axBdecl)); + assertTrue(containsConsiderEx(ont2, axBdecl)); + assertTrue(containsConsider(ont2, axBdecl)); + // A is a subclass of B is in only in ont2 + assertFalse(containsConsider(ont1, axAsubB)); + assertTrue(containsConsiderEx(ont2, axAsubB)); + assertTrue(containsConsider(ont2, axAsubB)); + File savedLocation1 = new File(folder, "testont1A.owl"); + try (FileOutputStream out1 = new FileOutputStream(savedLocation1)) { + StreamDocumentTarget writer1 = new StreamDocumentTarget(out1); + ont1.saveOntology(format, writer1); + } + File savedLocation2 = new File(folder, "testont2A.owl"); + try (FileOutputStream out2 = new FileOutputStream(savedLocation2)) { + StreamDocumentTarget writer2 = new StreamDocumentTarget(out2); + ont2.saveOntology(format, writer2); + } + OWLOntologyManager man = setupManager(); + OWLOntology ont1L = man.loadOntologyFromOntologyDocument(savedLocation1); + OWLOntology ont2L = man.loadOntologyFromOntologyDocument(savedLocation2); + // annoProp is in ont1 and in the import closure of ont2 + assertTrue(containsConsiderEx(ont1L, axannoPropdecl)); + assertFalse(containsConsiderEx(ont2L, axannoPropdecl)); + assertTrue(containsConsider(ont2L, axannoPropdecl)); + // A is in ont1 and in the import closure of ont2 + assertTrue(containsConsiderEx(ont1L, axAdecl)); + assertFalse(containsConsiderEx(ont2L, axAdecl)); + assertTrue(containsConsider(ont2L, axAdecl)); + // B is in only in ont2 + assertFalse(containsConsider(ont1L, axBdecl)); + assertTrue(containsConsiderEx(ont2L, axBdecl)); + assertTrue(containsConsider(ont2L, axBdecl)); + // A is a subclass of B is in only in ont2 + assertFalse(containsConsider(ont1L, axAsubB)); + assertTrue(containsConsiderEx(ont2L, axAsubB)); + assertTrue(containsConsider(ont2L, axAsubB)); + } + + boolean containsConsider(OWLOntology o, OWLAxiom ax) { + return o.containsAxiom(ax, INCLUDED, CONSIDER_AXIOM_ANNOTATIONS); + } + + boolean containsConsiderEx(OWLOntology o, OWLAxiom ax) { + return o.containsAxiom(ax, EXCLUDED, CONSIDER_AXIOM_ANNOTATIONS); + } + + @Test + void testOntologyContainsAxiomsForRDFXML2() throws Exception { + runTestOntologyContainsAxioms2(createRDFXMLFormat()); + } + + @Test + void testOntologyContainsAxiomsForOWLXML2() throws Exception { + runTestOntologyContainsAxioms2(new OWLXMLDocumentFormat()); + } + + @Test + void testOntologyContainsAxiomsForOWLFunctionalSyntax2() throws Exception { + runTestOntologyContainsAxioms2(new FunctionalSyntaxDocumentFormat()); + } + + @Test + void testOntologyContainsAxiomsForTurtleSyntax2() throws Exception { + runTestOntologyContainsAxioms2(createTurtleOntologyFormat()); + } + + @SuppressWarnings("resource") + private void runTestOntologyContainsAxioms2(OWLDocumentFormat format) throws Exception { + OWLOntology ont1 = getOWLOntology(); + IRI ont1iri = get(ont1.getOntologyID().getOntologyIRI()); + OWLOntology ont2 = getOWLOntology(); + IRI ont2iri = get(ont2.getOntologyID().getOntologyIRI()); + OWLImportsDeclaration ont2import = ImportsDeclaration(ont1iri); + ont2.applyChange(new AddImport(ont2, ont2import)); + OWLAxiom axAnnoPropDecl = Declaration(AP); + ont1.addAxiom(axAnnoPropDecl); + OWLAnnotation inOnt1Anno = Annotation(AP, ont1iri); + OWLAnnotation inOnt2Anno = Annotation(AP, ont2iri); + OWLAxiom axADecl = Declaration(A, singleton(inOnt1Anno)); + ont1.addAxiom(axADecl); + OWLAxiom axBDecl = Declaration(B, singleton(inOnt2Anno)); + ont2.addAxiom(axBDecl); + OWLAxiom axAsubB = SubClassOf(A, B, singleton(inOnt2Anno)); + ont2.addAxiom(axAsubB); + // annoProp is in ont1 and in the import closure of ont2 + assertTrue(containsConsiderEx(ont1, axAnnoPropDecl)); + assertFalse(containsConsiderEx(ont2, axAnnoPropDecl)); + assertTrue(containsConsider(ont2, axAnnoPropDecl)); + // A is in ont1 and in the import closure of ont2 + assertTrue(containsConsiderEx(ont1, axADecl)); + assertFalse(containsConsiderEx(ont2, axADecl)); + assertTrue(containsConsider(ont2, axADecl)); + // B is in only in ont2 + assertFalse(containsConsider(ont1, axBDecl)); + assertTrue(containsConsiderEx(ont2, axBDecl)); + assertTrue(containsConsider(ont2, axBDecl)); + // A is a subclass of B is in only in ont2 + assertFalse(containsConsider(ont1, axAsubB)); + assertTrue(containsConsiderEx(ont2, axAsubB)); + assertTrue(containsConsider(ont2, axAsubB)); + File savedLocation1 = new File(folder, "testont1B.owl"); + try (FileOutputStream out1 = new FileOutputStream(savedLocation1)) { + StreamDocumentTarget writer1 = new StreamDocumentTarget(out1); + ont1.saveOntology(format, writer1); + } + File savedLocation2 = new File(folder, "testont2B.owl"); + try (FileOutputStream out2 = new FileOutputStream(savedLocation2)) { + StreamDocumentTarget writer2 = new StreamDocumentTarget(out2); + ont2.saveOntology(format, writer2); + } + OWLOntologyManager man = setupManager(); + man.loadOntologyFromOntologyDocument(savedLocation1); + OWLOntology ont2L = man.loadOntologyFromOntologyDocument(savedLocation2); + ont2L.imports().forEach(o -> o.axioms().forEach(ax -> { + assertTrue(containsConsiderEx(o, ax)); + assertFalse(containsConsiderEx(ont2L, ax)); + })); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OntologyIDTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OntologyIDTestCase.java new file mode 100644 index 0000000000..12215aa8d6 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OntologyIDTestCase.java @@ -0,0 +1,94 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntologyID; + +class OntologyIDTestCase extends TestBase { + + static final String TEST_ONTOLOGY_IRI_STRING = "http://test.it/check1"; + IRI iri1 = iri(); + IRI iri2 = iri(); + + @Test + void shouldFindSameHashCode() { + assertEquals(iri1.hashCode(), iri2.hashCode()); + assertEquals(iri1, iri2); + } + + @Test + void shouldFindSameHashCodeForIDs() { + assertEquals(iri1.hashCode(), iri2.hashCode()); + OWLOntologyID id1 = new OWLOntologyID(optional(iri1), emptyOptional(IRI.class)); + OWLOntologyID id2 = new OWLOntologyID(optional(iri2), emptyOptional(IRI.class)); + assertEquals(id1.hashCode(), id2.hashCode()); + } + + @Test + void shouldFindSameHashCodeForIDs2() { + assertEquals(iri1.hashCode(), iri2.hashCode()); + OWLOntologyID id1 = new OWLOntologyID(optional(iri1), emptyOptional(IRI.class)); + OWLOntologyID id2 = new OWLOntologyID(optional(iri2), emptyOptional(IRI.class)); + assertEquals(id1.hashCode(), id2.hashCode()); + assertEquals(id1, id2); + } + + @Test + void testUnequalIdsUnequal() { + OWLOntologyID id1 = + new OWLOntologyID(optional(IRI("http://www.w3.org/", "foo")), emptyOptional(IRI.class)); + OWLOntologyID id2 = + new OWLOntologyID(optional(IRI("http://www.w3.org/", "bar")), emptyOptional(IRI.class)); + assertNotEquals(id1.hashCode(), id2.hashCode()); + assertNotEquals(id1, id2); + } + + // this is an experiment, if the manager were to keep all versions of an + // ontology together in a multimap or something + @Test + void testVersionedIDComparisons() { + assertEquals(iri1.hashCode(), iri2.hashCode()); + assertEquals(iri1, iri2); + OWLOntologyID unversionedID = new OWLOntologyID(optional(iri1), emptyOptional(IRI.class)); + IRI version1IRI = IRI(TEST_ONTOLOGY_IRI_STRING + "/", "version1"); + OWLOntologyID version1ID = new OWLOntologyID(optional(iri2), optional(version1IRI)); + assertEquals(unversionedID.getOntologyIRI(), version1ID.getOntologyIRI()); + assertNotEquals(unversionedID.getVersionIRI(), version1ID.getVersionIRI()); + assertNotEquals(unversionedID.hashCode(), version1ID.hashCode()); + assertNotEquals(unversionedID, version1ID); + OWLOntologyID duplicateVersion1ID = + new OWLOntologyID(optional(IRI(TEST_ONTOLOGY_IRI_STRING, "")), optional(version1IRI)); + assertEquals(version1ID, duplicateVersion1ID); + OWLOntologyID differentBasedVersion1ID = new OWLOntologyID( + optional(IRI(TEST_ONTOLOGY_IRI_STRING + "-of-doom", "")), optional(version1IRI)); + assertNotEquals(version1ID, differentBasedVersion1ID); + IRI version2IRI = IRI(TEST_ONTOLOGY_IRI_STRING + "/", "version2"); + IRI iri3 = iri(); + OWLOntologyID version2ID = new OWLOntologyID(optional(iri3), optional(version2IRI)); + assertNotEquals(version1ID.hashCode(), version2ID.hashCode()); + assertNotEquals(version1ID, version2ID); + } + + protected IRI iri() { + return IRI(TEST_ONTOLOGY_IRI_STRING, ""); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OntologyMutationTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OntologyMutationTestCase.java new file mode 100644 index 0000000000..23d0ba0b1d --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OntologyMutationTestCase.java @@ -0,0 +1,78 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.OWLThing; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubClassOf; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; + +/** + * @author Matthew Horridge, The University Of Manchester, Information Management Group + * @since 2.2.0 + */ +class OntologyMutationTestCase extends TestBase { + + static OWLAxiom ax = SubClassOf(A, OWLThing()); + + @Test + void testAddAxiom() { + OWLOntology ont = getOWLOntology(); + List chgs = new ArrayList<>(); + ont.getOWLOntologyManager().addOntologyChangeListener(changes -> chgs.addAll(changes)); + ont.add(ax); + assertEquals(1, chgs.size()); + assertTrue(chgs.contains(new AddAxiom(ont, ax))); + } + + @Test + void testAddAxioms() { + OWLOntology ont = getOWLOntology(); + List chgs = new ArrayList<>(); + ont.getOWLOntologyManager().addOntologyChangeListener(changes -> chgs.addAll(changes)); + ont.add(ax); + assertEquals(1, chgs.size()); + assertTrue(chgs.contains(new AddAxiom(ont, ax))); + } + + @Test + void testApplyChange() { + OWLOntology ont = getOWLOntology(); + List chgs = new ArrayList<>(); + ont.getOWLOntologyManager().addOntologyChangeListener(changes -> chgs.addAll(changes)); + ont.applyChange(new AddAxiom(ont, ax)); + assertEquals(1, chgs.size()); + assertTrue(chgs.contains(new AddAxiom(ont, ax))); + } + + @Test + void testApplyChanges() { + OWLOntology ont = getOWLOntology(); + List chgs = new ArrayList<>(); + ont.getOWLOntologyManager().addOntologyChangeListener(changes -> chgs.addAll(changes)); + ont.applyChange(new AddAxiom(ont, ax)); + assertEquals(1, chgs.size()); + assertTrue(chgs.contains(new AddAxiom(ont, ax))); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OntologyURITestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OntologyURITestCase.java new file mode 100644 index 0000000000..1260133a8a --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/OntologyURITestCase.java @@ -0,0 +1,118 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.contains; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyAlreadyExistsException; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.model.SetOntologyID; + +/** + * @author Matthew Horridge, The University Of Manchester, Information Management Group + * @since 2.2.0 + */ +class OntologyURITestCase extends TestBase { + + private static final String ANOTHER_COM_ONT = "http://www.another.com/ont"; + + protected IRI nextOnt() { + return IRI.getNextDocumentIRI("http://www.another.com/ont"); + } + + static final IRI version = IRI("http://www.another.com/ont/", "version"); + static final IRI onto = IRI("http://www.another.com/", "ont"); + + @Test + void testNamedOntologyToString() throws OWLOntologyCreationException { + IRI ontIRI = IRI("http://owlapi.sourceforge.net/", "ont"); + OWLOntology ont = m.createOntology(ontIRI); + String s = ont.toString(); + String expected = "Ontology(" + ont.getOntologyID() + ") [Axioms: " + ont.getAxiomCount() + + " Logical Axioms: " + ont.getLogicalAxiomCount() + "] First 20 axioms: {}"; + assertEquals(expected, s); + } + + @Test + void testOntologyID() { + OWLOntologyID ontIDBoth = new OWLOntologyID(optional(onto), optional(version)); + OWLOntologyID ontIDBoth2 = new OWLOntologyID(optional(onto), optional(version)); + assertEquals(ontIDBoth, ontIDBoth2); + OWLOntologyID ontIDURIOnly = new OWLOntologyID(optional(onto), emptyOptional(IRI.class)); + assertFalse(ontIDBoth.equals(ontIDURIOnly)); + OWLOntologyID ontIDNoneA = new OWLOntologyID(); + OWLOntologyID ontIDNoneB = new OWLOntologyID(); + assertFalse(ontIDNoneA.equals(ontIDNoneB)); + } + + @Test + void testOntologyURI() { + OWLOntology ont = getOWLOntology(onto); + assertEquals(onto, ont.getOntologyID().getOntologyIRI().get()); + assertTrue(m.contains(onto)); + assertTrue(contains(m.ontologies(), ont)); + OWLOntologyID ontID = new OWLOntologyID(optional(onto), emptyOptional(IRI.class)); + assertEquals(ont.getOntologyID(), ontID); + } + + @Test + void testDuplicateOntologyURI() throws OWLOntologyCreationException { + IRI uri = nextOnt(); + getOWLOntology(uri); + assertThrowsWithCause(OWLRuntimeException.class, OWLOntologyAlreadyExistsException.class, + () -> getOWLOntology(uri)); + } + + @Test + void testSetOntologyURI() { + IRI iri = nextOnt(); + OWLOntology ont = getOWLOntology(iri); + IRI newIRI = IRI.getNextDocumentIRI("http://www.another.com/newont"); + SetOntologyID sou = + new SetOntologyID(ont, new OWLOntologyID(optional(newIRI), emptyOptional(IRI.class))); + ont.applyChange(sou); + assertFalse(m.contains(iri)); + assertTrue(m.contains(newIRI)); + assertEquals(ont.getOntologyID().getOntologyIRI().get(), newIRI); + } + + @Test + void testVersionURI() { + IRI ontIRI = nextOnt(); + IRI verIRI = IRI.getNextDocumentIRI("http://www.another.com/ont/versions/1.0.0"); + OWLOntology ont = getOWLOntology(new OWLOntologyID(optional(ontIRI), optional(verIRI))); + assertEquals(ont.getOntologyID().getOntologyIRI().get(), ontIRI); + assertEquals(ont.getOntologyID().getVersionIRI().get(), verIRI); + } + + @Test + void testNullVersionURI() { + IRI ontIRI = nextOnt(); + IRI verIRI = null; + OWLOntology ont = getOWLOntology(new OWLOntologyID(optional(ontIRI), optional(verIRI))); + assertEquals(ont.getOntologyID().getOntologyIRI().get(), ontIRI); + assertFalse(ont.getOntologyID().getVersionIRI().isPresent()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/PrefixOntologyFormatRoundTripTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/PrefixOntologyFormatRoundTripTestCase.java new file mode 100644 index 0000000000..2dc5933d1f --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/PrefixOntologyFormatRoundTripTestCase.java @@ -0,0 +1,76 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.PrefixDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.2.0 + */ +class PrefixOntologyFormatRoundTripTestCase extends TestBase { + + protected OWLOntology prefixOntologyFormatRoundTripTestCase() { + OWLOntology ont = getAnonymousOWLOntology(); + PrefixDocumentFormat format = (PrefixDocumentFormat) ont.getNonnullFormat(); + format.setDefaultPrefix("http://default.com"); + format.setPrefix("a", "http://ontology.com/a#"); + format.setPrefix("b", "http://ontology.com/b#"); + return ont; + } + + @Override + public OWLOntology roundTripOntology(OWLOntology ont, OWLDocumentFormat format) { + OWLOntology ont2 = super.roundTripOntology(ont, format); + OWLDocumentFormat ont2Format = ont2.getFormat(); + if (format instanceof PrefixDocumentFormat && ont2Format instanceof PrefixDocumentFormat) { + PrefixDocumentFormat prefixFormat = (PrefixDocumentFormat) format; + PrefixDocumentFormat prefixFormat2 = (PrefixDocumentFormat) ont2Format; + prefixFormat.prefixNames().forEach(prefixName -> { + assertTrue(prefixFormat2.containsPrefixMapping(prefixName)); + assertEquals(prefixFormat.getPrefix(prefixName), + prefixFormat2.getPrefix(prefixName)); + }); + } + return ont2; + } + + @ParameterizedTest + @MethodSource("formats") + void testFormat(OWLDocumentFormat d) throws Exception { + roundTripOntology(prefixOntologyFormatRoundTripTestCase(), d); + } + + @Test + void roundTripRDFXMLAndFunctionalShouldBeSame() + throws OWLOntologyCreationException, OWLOntologyStorageException { + OWLOntology o = prefixOntologyFormatRoundTripTestCase(); + OWLOntology o1 = roundTrip(o, new RDFXMLDocumentFormat()); + OWLOntology o2 = roundTrip(o, new FunctionalSyntaxDocumentFormat()); + equal(o, o1); + equal(o1, o2); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/RemoveOntologyAnnotationDataTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/RemoveOntologyAnnotationDataTestCase.java new file mode 100644 index 0000000000..e347db3663 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/RemoveOntologyAnnotationDataTestCase.java @@ -0,0 +1,74 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.change.RemoveOntologyAnnotationData; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.RemoveOntologyAnnotation; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.2.0 + */ +class RemoveOntologyAnnotationDataTestCase { + + private final OWLAnnotation mockAnnotation = mock(OWLAnnotation.class); + private final OWLOntology mockOntology = mock(OWLOntology.class); + + private RemoveOntologyAnnotationData createData() { + return new RemoveOntologyAnnotationData(mockAnnotation); + } + + @Test + void testEquals() { + RemoveOntologyAnnotationData data1 = createData(); + RemoveOntologyAnnotationData data2 = createData(); + assertEquals(data1, data2); + assertEquals(data1.hashCode(), data2.hashCode()); + } + + @Test + void testGettersReturnNotNull() { + RemoveOntologyAnnotationData data = createData(); + assertNotNull(data.getAnnotation()); + assertNotNull(data.createOntologyChange(mockOntology)); + } + + @Test + void testGettersEquals() { + RemoveOntologyAnnotationData data = createData(); + assertEquals(mockAnnotation, data.getAnnotation()); + } + + @Test + void testCreateOntologyChange() { + RemoveOntologyAnnotationData data = createData(); + RemoveOntologyAnnotation change = data.createOntologyChange(mockOntology); + assertEquals(mockOntology, change.getOntology()); + assertEquals(mockAnnotation, change.getAnnotation()); + } + + @Test + void testGetChangeData() { + RemoveOntologyAnnotationData data = createData(); + RemoveOntologyAnnotation change = + new RemoveOntologyAnnotation(mockOntology, mockAnnotation); + assertEquals(change.getChangeData(), data); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/RenameEntityTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/RenameEntityTestCase.java new file mode 100644 index 0000000000..024ecaf532 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/RenameEntityTestCase.java @@ -0,0 +1,328 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationPropertyDomain; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationPropertyRange; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AsymmetricObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ClassAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataComplementOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataIntersectionOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataPropertyAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataPropertyDomain; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataPropertyRange; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataUnionOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Datatype; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Declaration; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DisjointClasses; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DisjointDataProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DisjointObjectProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentClasses; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentDataProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentObjectProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.FunctionalDataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.FunctionalObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.InverseFunctionalObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IrreflexiveObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NamedIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NegativeDataPropertyAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NegativeObjectPropertyAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectPropertyAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectPropertyDomain; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectPropertyRange; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ReflexiveObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubAnnotationPropertyOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubClassOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubDataPropertyOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubObjectPropertyOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SymmetricObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.TopDatatype; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.TransitiveObjectProperty; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.equalStreams; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.util.OWLEntityRenamer; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +class RenameEntityTestCase extends TestBase { + + static final OWLLiteral X = Literal("X"); + static final OWLClass CA = Class(iri("ClsA")); + static final OWLClass CB = Class(iri("ClsB")); + static final OWLClass CC = Class(iri("ClsC")); + static final OWLClass CA1 = Class(iri("ClsA1")); + static final OWLClass CA2 = Class(iri("ClsA2")); + static final OWLObjectProperty PA = ObjectProperty(iri("propA")); + static final OWLDataProperty DPA = DataProperty(iri("propA")); + static final OWLDataProperty DPA2 = DataProperty(iri("propA2")); + static final OWLNamedIndividual A = NamedIndividual(iri("indA")); + static final OWLNamedIndividual B = NamedIndividual(iri("indB")); + static final OWLDataProperty DPB = DataProperty(iri("propB")); + static final OWLObjectProperty PA2 = ObjectProperty(iri("propA2")); + static final OWLAnnotationProperty AP = AnnotationProperty(iri("annoProp")); + static final OWLObjectProperty PB = ObjectProperty(iri("propB")); + static final OWLObjectPropertyExpression PBI = PB.getInverseProperty(); + + static final OWLDatatype DTA = Datatype(iri("DtA")); + static final OWLDatatype DTB = Datatype(iri("DtB")); + static final OWLDatatype DTC = Datatype(iri("DtC")); + + static final OWLAnnotationProperty AP2 = AnnotationProperty(iri("annoProp2")); + static final OWLAnnotationProperty APR = AnnotationProperty(iri("annoPropR")); + + @Test + void testRenameClass() { + OWLOntology ont = getOWLOntology(); + Set axioms1 = new HashSet<>(); + axioms1.add(SubClassOf(CA1, CB)); + axioms1.add(EquivalentClasses(CA1, CC)); + axioms1.add(DisjointClasses(CA1, CC)); + axioms1.add(ObjectPropertyDomain(PA, CA1)); + axioms1.add(ObjectPropertyRange(PA, CA1)); + axioms1.add(DataPropertyDomain(DPA, CA1)); + axioms1.add(ClassAssertion(CA1, A)); + axioms1.add(AnnotationAssertion(AP, CA1.getIRI(), X)); + ont.add(axioms1); + Set axioms2 = new HashSet<>(); + axioms2.add(SubClassOf(CA2, CB)); + axioms2.add(EquivalentClasses(CA2, CC)); + axioms2.add(DisjointClasses(CA2, CC)); + axioms2.add(ObjectPropertyDomain(PA, CA2)); + axioms2.add(ObjectPropertyRange(PA, CA2)); + axioms2.add(DataPropertyDomain(DPA, CA2)); + axioms2.add(ClassAssertion(CA2, A)); + axioms2.add(AnnotationAssertion(AP, CA2.getIRI(), X)); + OWLEntityRenamer entityRenamer = + new OWLEntityRenamer(ont.getOWLOntologyManager(), singleton(ont)); + List changes = entityRenamer.changeIRI(CA1, CA2.getIRI()); + ont.applyChanges(changes); + assertEquals(asUnorderedSet(ont.axioms()), axioms2); + List changes2 = entityRenamer.changeIRI(CA2.getIRI(), CA1.getIRI()); + ont.applyChanges(changes2); + assertEquals(asUnorderedSet(ont.axioms()), axioms1); + } + + @Test + void testRenameObjectProperty() { + OWLOntology ont = getOWLOntology(); + Set axioms1 = new HashSet<>(); + axioms1.add(SubObjectPropertyOf(PA, PBI)); + axioms1.add(EquivalentObjectProperties(PA, PBI)); + axioms1.add(DisjointObjectProperties(PA, PBI)); + axioms1.add(ObjectPropertyDomain(PA, CA)); + axioms1.add(ObjectPropertyRange(PA, CA)); + axioms1.add(FunctionalObjectProperty(PA)); + axioms1.add(InverseFunctionalObjectProperty(PA)); + axioms1.add(SymmetricObjectProperty(PA)); + axioms1.add(AsymmetricObjectProperty(PA)); + axioms1.add(TransitiveObjectProperty(PA)); + axioms1.add(ReflexiveObjectProperty(PA)); + axioms1.add(IrreflexiveObjectProperty(PA)); + axioms1.add(ObjectPropertyAssertion(PA, A, B)); + axioms1.add(NegativeObjectPropertyAssertion(PA, A, B)); + axioms1.add(AnnotationAssertion(AP, PA.getIRI(), X)); + ont.add(axioms1); + Set axioms2 = new HashSet<>(); + axioms2.add(SubObjectPropertyOf(PA2, PBI)); + axioms2.add(EquivalentObjectProperties(PA2, PBI)); + axioms2.add(DisjointObjectProperties(PA2, PBI)); + axioms2.add(ObjectPropertyDomain(PA2, CA)); + axioms2.add(ObjectPropertyRange(PA2, CA)); + axioms2.add(FunctionalObjectProperty(PA2)); + axioms2.add(InverseFunctionalObjectProperty(PA2)); + axioms2.add(SymmetricObjectProperty(PA2)); + axioms2.add(AsymmetricObjectProperty(PA2)); + axioms2.add(TransitiveObjectProperty(PA2)); + axioms2.add(ReflexiveObjectProperty(PA2)); + axioms2.add(IrreflexiveObjectProperty(PA2)); + axioms2.add(ObjectPropertyAssertion(PA2, A, B)); + axioms2.add(NegativeObjectPropertyAssertion(PA2, A, B)); + axioms2.add(AnnotationAssertion(AP, PA2.getIRI(), X)); + OWLEntityRenamer entityRenamer = + new OWLEntityRenamer(ont.getOWLOntologyManager(), singleton(ont)); + List changes = entityRenamer.changeIRI(PA, PA2.getIRI()); + ont.applyChanges(changes); + assertEquals(asUnorderedSet(ont.axioms()), axioms2); + List changes2 = entityRenamer.changeIRI(PA2.getIRI(), PA.getIRI()); + ont.applyChanges(changes2); + assertEquals(asUnorderedSet(ont.axioms()), axioms1); + } + + @Test + void testRenameDataProperty() { + OWLOntology ont = getOWLOntology(); + Set axioms1 = new HashSet<>(); + axioms1.add(SubDataPropertyOf(DPA, DPB)); + axioms1.add(EquivalentDataProperties(DPA, DPB)); + axioms1.add(DisjointDataProperties(DPA, DPB)); + axioms1.add(DataPropertyDomain(DPA, CA)); + axioms1.add(DataPropertyRange(DPA, TopDatatype())); + axioms1.add(FunctionalDataProperty(DPA)); + axioms1.add(dpa(A)); + axioms1.add(ndpa(A)); + axioms1.add(AnnotationAssertion(AP, DPA.getIRI(), X)); + ont.add(axioms1); + Set axioms2 = new HashSet<>(); + axioms2.add(SubDataPropertyOf(DPA2, DPB)); + axioms2.add(EquivalentDataProperties(DPA2, DPB)); + axioms2.add(DisjointDataProperties(DPA2, DPB)); + axioms2.add(DataPropertyDomain(DPA2, CA)); + axioms2.add(DataPropertyRange(DPA2, TopDatatype())); + axioms2.add(FunctionalDataProperty(DPA2)); + axioms2.add(DataPropertyAssertion(DPA2, A, Literal(33))); + axioms2.add(NegativeDataPropertyAssertion(DPA2, A, Literal(44))); + axioms2.add(AnnotationAssertion(AP, DPA2.getIRI(), X)); + OWLEntityRenamer entityRenamer = + new OWLEntityRenamer(ont.getOWLOntologyManager(), singleton(ont)); + List changes = entityRenamer.changeIRI(DPA, DPA2.getIRI()); + ont.applyChanges(changes); + assertEquals(asUnorderedSet(ont.axioms()), axioms2); + List changes2 = entityRenamer.changeIRI(DPA2.getIRI(), DPA.getIRI()); + ont.applyChanges(changes2); + assertEquals(asUnorderedSet(ont.axioms()), axioms1); + } + + @Test + void testRenameIndividual() { + OWLOntology ont = getOWLOntology(); + OWLAnnotationAssertionAxiom aX = AnnotationAssertion(AP, DPA.getIRI(), X); + ont.add(set(ca(A), dpa(A), ndpa(A), aX, opa(A, B), nopa(A, B))); + OWLEntityRenamer entityRenamer = + new OWLEntityRenamer(ont.getOWLOntologyManager(), singleton(ont)); + ont.applyChanges(entityRenamer.changeIRI(B, A.getIRI())); + assertEquals(asUnorderedSet(ont.axioms()), + new HashSet<>(set(ca(A), dpa(A), ndpa(A), aX, opa(A, A), nopa(A, A)))); + ont.applyChanges(entityRenamer.changeIRI(A, B.getIRI())); + assertEquals(asUnorderedSet(ont.axioms()), + new HashSet<>(set(ca(B), dpa(B), ndpa(B), aX, opa(B, B), nopa(B, B)))); + } + + protected OWLNegativeObjectPropertyAssertionAxiom nopa(OWLIndividual a, OWLIndividual b) { + return NegativeObjectPropertyAssertion(PB, a, b); + } + + protected OWLObjectPropertyAssertionAxiom opa(OWLIndividual a, OWLIndividual b) { + return ObjectPropertyAssertion(PB, a, b); + } + + protected OWLNegativeDataPropertyAssertionAxiom ndpa(OWLIndividual a) { + return NegativeDataPropertyAssertion(DPA, a, Literal(44)); + } + + protected OWLDataPropertyAssertionAxiom dpa(OWLIndividual a) { + return DataPropertyAssertion(DPA, a, Literal(33)); + } + + protected OWLClassAssertionAxiom ca(OWLIndividual a) { + return ClassAssertion(CA, a); + } + + @Test + void testRenameDatatype() { + OWLOntology ont = getOWLOntology(); + Set axioms1 = new TreeSet<>(); + axioms1.add(DataPropertyRange(DPA, DataIntersectionOf(DTA, DTB))); + axioms1.add(DataPropertyRange(DPA, DataUnionOf(DTA, DTB))); + axioms1.add(DataPropertyRange(DPA, DataComplementOf(DTA))); + ont.add(axioms1); + Set axioms2 = new HashSet<>(); + axioms2.add(DataPropertyRange(DPA, DataIntersectionOf(DTC, DTB))); + axioms2.add(DataPropertyRange(DPA, DataUnionOf(DTC, DTB))); + axioms2.add(DataPropertyRange(DPA, DataComplementOf(DTC))); + OWLEntityRenamer entityRenamer = + new OWLEntityRenamer(ont.getOWLOntologyManager(), singleton(ont)); + List changes = entityRenamer.changeIRI(DTA, DTC.getIRI()); + ont.applyChanges(changes); + assertEquals(asUnorderedSet(ont.axioms()), axioms2); + List changes2 = entityRenamer.changeIRI(DTC.getIRI(), DTA.getIRI()); + ont.applyChanges(changes2); + assertTrue(equalStreams(ont.axioms().sorted(), axioms1.stream())); + } + + @Test + void testRenameAnnotationProperty() { + OWLOntology ont = getOWLOntology(); + Set axioms1 = new HashSet<>(); + axioms1.add(Declaration(AP)); + axioms1.add(AnnotationAssertion(AP, A.getIRI(), B.getIRI())); + axioms1.add(SubAnnotationPropertyOf(AP, AP2)); + axioms1.add(AnnotationPropertyRange(AP, A.getIRI())); + axioms1.add(AnnotationPropertyDomain(AP, A.getIRI())); + ont.add(axioms1); + Set axioms2 = new HashSet<>(); + axioms2.add(Declaration(APR)); + axioms2.add(AnnotationAssertion(APR, A.getIRI(), B.getIRI())); + axioms2.add(SubAnnotationPropertyOf(APR, AP2)); + axioms2.add(AnnotationPropertyRange(APR, A.getIRI())); + axioms2.add(AnnotationPropertyDomain(APR, A.getIRI())); + OWLEntityRenamer entityRenamer = + new OWLEntityRenamer(ont.getOWLOntologyManager(), singleton(ont)); + List changes = entityRenamer.changeIRI(AP, APR.getIRI()); + ont.applyChanges(changes); + assertEquals(asUnorderedSet(ont.axioms()), axioms2); + List changes2 = entityRenamer.changeIRI(APR.getIRI(), AP.getIRI()); + ont.applyChanges(changes2); + assertEquals(asUnorderedSet(ont.axioms()), axioms1); + } + + @Test + void shouldRenameAnnotationPropertyUsages() { + OWLOntology o1 = + loadOntologyFromString(TestFiles.renameApUsages, new RDFXMLDocumentFormat()); + OWLEntityRenamer renamer = + new OWLEntityRenamer(o1.getOWLOntologyManager(), Arrays.asList(o1)); + o1.annotationPropertiesInSignature() + .map(e -> renamer.changeIRI(e.getIRI(), iri("urn:test:", "attempt"))) + .forEach(list -> assertFalse(list.isEmpty())); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/RenameToExistingOntologyTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/RenameToExistingOntologyTestCase.java new file mode 100644 index 0000000000..611f736798 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/RenameToExistingOntologyTestCase.java @@ -0,0 +1,46 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLOntologyRenameException; +import org.semanticweb.owlapi.model.SetOntologyID; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +class RenameToExistingOntologyTestCase extends TestBase { + + @Test + void testRenameToExistingOntology() { + IRI ontologyAIRI = IRI("http://www.semanticweb.org/ontologies/", "ontologyA"); + OWLOntology onto = getOWLOntology(ontologyAIRI); + onto.add(df.getOWLDeclarationAxiom(Class(IRI("urn:test:", "testclass")))); + IRI ontologyBIRI = IRI("http://www.semanticweb.org/ontologies/", "ontologyB"); + OWLOntology ontologyB = getOWLOntology(ontologyBIRI); + assertThrows(OWLOntologyRenameException.class, + () -> ontologyB.applyChange(new SetOntologyID(ontologyB, + new OWLOntologyID(optional(ontologyAIRI), emptyOptional(IRI.class))))); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/SWRLRoundTripTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/SWRLRoundTripTestCase.java new file mode 100644 index 0000000000..9034175142 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/SWRLRoundTripTestCase.java @@ -0,0 +1,191 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.contains; + +import java.util.Set; +import java.util.TreeSet; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.SWRLAtom; +import org.semanticweb.owlapi.model.SWRLRule; +import org.semanticweb.owlapi.model.SWRLVariable; +import org.semanticweb.owlapi.vocab.XSDVocabulary; + +class SWRLRoundTripTestCase extends TestBase { + + static final Set LABEL_DATATYPE_DEFINITION = + singleton(df.getRDFSLabel("datatype definition")); + static final SWRLVariable vy = df.getSWRLVariable("urn:test" + "#", "Y"); + static final SWRLVariable vx = df.getSWRLVariable("urn:test" + "#", "X"); + + @Test + void shouldDoCompleteRoundtrip() throws Exception { + OWLOntology ontology = getOWLOntology(); + Set body = new TreeSet<>(); + body.add(df.getSWRLDataPropertyAtom(DP, vx, vy)); + body.add(df.getSWRLDataRangeAtom(df.getOWLDatatype(XSDVocabulary.STRING), vy)); + Set head = new TreeSet<>(); + head.add(df.getSWRLClassAtom(A, vx)); + SWRLRule rule = df.getSWRLRule(body, head); + ontology.addAxiom(rule); + ontology = roundTrip(ontology, new OWLXMLDocumentFormat()); + OWLOntology onto2 = roundTrip(ontology, new OWLXMLDocumentFormat()); + equal(ontology, onto2); + } + + @Test + void shouldDoCompleteRoundtripManchesterOWLSyntax() throws Exception { + OWLOntology ontology = getOWLOntology(); + Set body = new TreeSet<>(); + body.add(df.getSWRLDataPropertyAtom(DP, vx, vy)); + body.add(df.getSWRLDataRangeAtom(df.getOWLDatatype(XSDVocabulary.STRING), vy)); + Set head = new TreeSet<>(); + head.add(df.getSWRLClassAtom(A, vx)); + SWRLRule rule = df.getSWRLRule(body, head); + ontology.addAxiom(rule); + ontology = roundTrip(ontology, new ManchesterSyntaxDocumentFormat()); + OWLOntology onto2 = roundTrip(ontology, new ManchesterSyntaxDocumentFormat()); + equal(ontology, onto2); + } + + @Test + void shouldDoCompleteRoundtripWithAnnotationsOWLXML() throws Exception { + OWLOntology ontology = prepareOntology(); + OWLXMLDocumentFormat f = new OWLXMLDocumentFormat(); + OWLOntology ontology2 = loadOntologyFromString(saveOntology(ontology, f), f); + equal(ontology, ontology2); + assertions(ontology2); + } + + protected void assertions(OWLOntology ontology2) { + ontology2.axioms(AxiomType.SWRL_RULE).forEach(r -> assertFalse(noLabel(r))); + ontology2.axioms(AxiomType.DATATYPE_DEFINITION).forEach(r -> assertFalse(noLabel(r))); + } + + @Test + void shouldDoCompleteRoundtripWithAnnotationsTurtle() throws Exception { + OWLOntology ontology = prepareOntology(); + OWLDocumentFormat f = new TurtleDocumentFormat(); + OWLOntology ontology2 = equalRoundtrip(ontology, f); + assertions(ontology2); + } + + @Test + void shouldDoCompleteRoundtripWithAnnotationsFunctional() throws Exception { + OWLOntology ontology = prepareOntology(); + OWLDocumentFormat f = new FunctionalSyntaxDocumentFormat(); + OWLOntology ontology2 = equalRoundtrip(ontology, f); + assertions(ontology2); + } + + @Test + void shouldDoCompleteRoundtripWithAnnotationsRDFXML() throws Exception { + OWLOntology ontology = prepareOntology(); + OWLDocumentFormat f = new RDFXMLDocumentFormat(); + OWLOntology ontology2 = equalRoundtrip(ontology, f); + assertions(ontology2); + } + + @Test + void shouldDoCompleteRoundtripWithAnnotationsDatatypeRDFXML() throws Exception { + OWLOntology ontology = prepareOntology1(); + OWLDocumentFormat f = new RDFXMLDocumentFormat(); + OWLOntology ontology2 = equalRoundtrip(ontology, f); + ontology2.axioms(AxiomType.DATATYPE_DEFINITION).forEach(r -> assertFalse(noLabel(r))); + } + + protected boolean noLabel(OWLAxiom r) { + return r.annotations(df.getRDFSLabel()).count() == 0; + } + + @Disabled("man syntax does not like annotations") + @Test + void shouldDoCompleteRoundtripWithAnnotationsMan() throws Exception { + OWLOntology ontology = prepareOntology(); + OWLDocumentFormat f = new ManchesterSyntaxDocumentFormat(); + OWLOntology ontology2 = equalRoundtrip(ontology, f); + assertions(ontology2); + } + + protected OWLOntology equalRoundtrip(OWLOntology ontology, OWLDocumentFormat f) { + OWLOntology ontology2 = loadOntologyFromString(saveOntology(ontology, f), f); + equal(ontology, ontology2); + return ontology2; + } + + /** + * @return + * @throws OWLOntologyCreationException + */ + OWLOntology prepareOntology() { + OWLOntology ontology = getOWLOntology(); + Set body = new TreeSet<>(); + body.add(df.getSWRLDataPropertyAtom(DP, vx, vy)); + body.add(df.getSWRLDataRangeAtom(df.getOWLDatatype(XSDVocabulary.STRING), vy)); + Set head = new TreeSet<>(); + head.add(df.getSWRLClassAtom(A, vx)); + SWRLRule rule = df.getSWRLRule(body, head, singleton(df.getRDFSLabel("test"))); + ontology.addAxiom(rule); + OWLDatatypeDefinitionAxiom def = + df.getOWLDatatypeDefinitionAxiom(df.getOWLDatatype("urn:my#", "datatype"), + df.getOWLDatatypeMaxExclusiveRestriction(200D), LABEL_DATATYPE_DEFINITION); + ontology.addAxiom(def); + return ontology; + } + + OWLOntology prepareOntology1() { + OWLOntology ontology = getOWLOntology(); + OWLDatatypeDefinitionAxiom def = + df.getOWLDatatypeDefinitionAxiom(df.getOWLDatatype("urn:my#", "datatype"), + df.getOWLDatatypeMaxExclusiveRestriction(200D), LABEL_DATATYPE_DEFINITION); + ontology.addAxiom(def); + return ontology; + } + + @Test + void shouldParse() { + OWLOntology o = loadOntologyFromString(TestFiles.parseSWRL, new RDFXMLDocumentFormat()); + OWLDatatypeDefinitionAxiom def = + df.getOWLDatatypeDefinitionAxiom(df.getOWLDatatype("urn:my#", "datatype"), + df.getDoubleOWLDatatype(), LABEL_DATATYPE_DEFINITION); + assertTrue(contains(o.axioms(), def)); + } + + @Test + void shouldParse2() { + OWLOntology o = loadOntologyFromString(TestFiles.parseSWRL2, new RDFXMLDocumentFormat()); + OWLSubClassOfAxiom def = df.getOWLSubClassOfAxiom(df.getOWLClass("urn:test#", "myClass"), + df.getOWLClass("urn:test#", "test"), LABEL_DATATYPE_DEFINITION); + assertTrue(contains(o.axioms(), def)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/SetOntologyIDDataTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/SetOntologyIDDataTestCase.java new file mode 100644 index 0000000000..f68c3b5223 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/SetOntologyIDDataTestCase.java @@ -0,0 +1,83 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.ontology; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.change.SetOntologyIDData; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.SetOntologyID; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group + * @since 3.2.0 + */ +class SetOntologyIDDataTestCase extends TestBase { + + private final OWLOntology mockOntology = mock(OWLOntology.class); + private final OWLOntologyID mockOntologyID = new OWLOntologyID(); + + @BeforeEach + void setUp() { + when(mockOntology.getOntologyID()).thenReturn(new OWLOntologyID( + optional(iri("urn:test:", "onto1")), optional(iri("urn:test:", "onto1_1")))); + } + + private SetOntologyIDData createData() { + return new SetOntologyIDData(mockOntologyID); + } + + @Test + void testEquals() { + SetOntologyIDData data1 = createData(); + SetOntologyIDData data2 = createData(); + assertEquals(data1, data2); + assertEquals(data1.hashCode(), data2.hashCode()); + } + + @Test + void testGettersReturnNotNull() { + SetOntologyIDData data = createData(); + assertNotNull(data.getNewId()); + assertNotNull(data.createOntologyChange(mockOntology)); + } + + @Test + void testGettersEquals() { + SetOntologyIDData data = createData(); + assertEquals(mockOntologyID, data.getNewId()); + } + + @Test + void testCreateOntologyChange() { + SetOntologyIDData data = createData(); + SetOntologyID change = data.createOntologyChange(mockOntology); + assertEquals(mockOntology, change.getOntology()); + assertEquals(mockOntologyID, change.getNewOntologyID()); + } + + @Test + void testOntologyChangeSymmetry() { + SetOntologyIDData data = createData(); + SetOntologyID change = new SetOntologyID(mockOntology, mockOntologyID); + assertEquals(change.getChangeData(), data); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/package-info.java new file mode 100644 index 0000000000..1a17d5899c --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/ontology/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.api.test.ontology; diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/package-info.java new file mode 100644 index 0000000000..1c77998bf3 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.api.test; diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/reasoners/StructuralReasonerTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/reasoners/StructuralReasonerTestCase.java new file mode 100644 index 0000000000..44528c99d0 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/reasoners/StructuralReasonerTestCase.java @@ -0,0 +1,82 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.reasoners; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentClasses; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.OWLNothing; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.OWLThing; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubClassOf; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.reasoner.BufferingMode; +import org.semanticweb.owlapi.reasoner.Node; +import org.semanticweb.owlapi.reasoner.NodeSet; +import org.semanticweb.owlapi.reasoner.SimpleConfiguration; +import org.semanticweb.owlapi.reasoner.structural.StructuralReasoner; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +class StructuralReasonerTestCase extends TestBase { + + private static void testClassHierarchy(StructuralReasoner reasoner) { + NodeSet subsOfA = reasoner.getSubClasses(A, true); + assertEquals(1, subsOfA.nodes().count()); + assertTrue(subsOfA.containsEntity(B)); + NodeSet subsOfAp = reasoner.getSubClasses(D, true); + assertEquals(1, subsOfAp.nodes().count()); + assertTrue(subsOfAp.containsEntity(B)); + Node topNode = reasoner.getTopClassNode(); + NodeSet subsOfTop = + reasoner.getSubClasses(topNode.getRepresentativeElement(), true); + assertEquals(1, subsOfTop.nodes().count()); + assertTrue(subsOfTop.containsEntity(A)); + NodeSet descOfTop = + reasoner.getSubClasses(topNode.getRepresentativeElement(), false); + assertEquals(3, descOfTop.nodes().count()); + assertTrue(descOfTop.containsEntity(A)); + assertTrue(descOfTop.containsEntity(B)); + assertTrue(descOfTop.containsEntity(OWLNothing())); + NodeSet supersOfTop = reasoner.getSuperClasses(OWLThing(), false); + assertTrue(supersOfTop.isEmpty()); + NodeSet supersOfA = reasoner.getSuperClasses(A, false); + assertTrue(supersOfA.isTopSingleton()); + assertEquals(1, supersOfA.nodes().count()); + assertTrue(supersOfA.containsEntity(OWLThing())); + Node equivsOfTop = reasoner.getEquivalentClasses(OWLThing()); + assertEquals(2, equivsOfTop.entities().count()); + assertTrue(equivsOfTop.entities().anyMatch(x -> x.equals(C))); + } + + @Test + void testClassHierarchy() { + OWLOntology ont = getOWLOntology(); + ont.addAxiom(EquivalentClasses(OWLThing(), C)); + ont.addAxiom(SubClassOf(B, A)); + ont.addAxiom(EquivalentClasses(A, D)); + StructuralReasoner reasoner = + new StructuralReasoner(ont, new SimpleConfiguration(), BufferingMode.NON_BUFFERING); + testClassHierarchy(reasoner); + ont.add(SubClassOf(A, OWLThing())); + testClassHierarchy(reasoner); + ont.remove(SubClassOf(A, OWLThing())); + testClassHierarchy(reasoner); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/reasoners/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/reasoners/package-info.java new file mode 100644 index 0000000000..10b18d1131 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/reasoners/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.api.test.reasoners; diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/searcher/SearcherTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/searcher/SearcherTestCase.java new file mode 100644 index 0000000000..cb872829ef --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/searcher/SearcherTestCase.java @@ -0,0 +1,124 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.searcher; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Boolean; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataPropertyDomain; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataPropertyRange; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentDataProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentObjectProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectPropertyDomain; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectPropertyRange; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubClassOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubDataPropertyOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubObjectPropertyOf; +import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED; +import static org.semanticweb.owlapi.search.Searcher.domain; +import static org.semanticweb.owlapi.search.Searcher.equivalent; +import static org.semanticweb.owlapi.search.Searcher.range; +import static org.semanticweb.owlapi.search.Searcher.sub; +import static org.semanticweb.owlapi.search.Searcher.sup; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.contains; + +import java.util.Collection; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.search.EntitySearcher; +import org.semanticweb.owlapi.search.Filters; + +class SearcherTestCase extends TestBase { + + private static final String URN_TEST = "urn:test#"; + + @Test + void shouldSearch() { + // given + OWLOntology o = getOWLOntology(); + OWLAxiom ax = SubClassOf(C, D); + o.addAxiom(ax); + assertTrue(contains(o.axioms(AxiomType.SUBCLASS_OF), ax)); + assertTrue(contains(o.axioms(C), ax)); + } + + @Test + void shouldSearchObjectProperties() { + // given + OWLOntology o = getOWLOntology(); + OWLObjectProperty c = ObjectProperty(IRI(URN_TEST, "c")); + OWLObjectProperty d = ObjectProperty(IRI(URN_TEST, "d")); + OWLObjectProperty e = ObjectProperty(IRI(URN_TEST, "e")); + OWLObjectProperty f = ObjectProperty(IRI(URN_TEST, "f")); + OWLClass x = Class(IRI(URN_TEST, "x")); + OWLClass y = Class(IRI(URN_TEST, "Y")); + OWLAxiom ax = SubObjectPropertyOf(c, d); + OWLAxiom ax2 = ObjectPropertyDomain(c, x); + OWLAxiom ax3 = ObjectPropertyRange(c, y); + OWLAxiom ax4 = EquivalentObjectProperties(c, e); + OWLAxiom ax5 = SubObjectPropertyOf(c, df.getOWLObjectInverseOf(f)); + OWLAxiom ax6 = EquivalentObjectProperties(e, df.getOWLObjectInverseOf(f)); + o.addAxioms(ax, ax2, ax3, ax4, ax5, ax6); + assertTrue(contains(o.axioms(AxiomType.SUB_OBJECT_PROPERTY), ax)); + Collection axioms1 = + asUnorderedSet(o.axioms(Filters.subObjectPropertyWithSuper, d, INCLUDED)); + assertTrue(contains(sub(axioms1.stream()), c)); + Collection axioms2 = asUnorderedSet(o.axioms(Filters.subObjectPropertyWithSub, c, INCLUDED)); + assertTrue(contains(sup(axioms2.stream()), d)); + assertTrue(contains(domain(o.objectPropertyDomainAxioms(c)), x)); + assertTrue(contains(equivalent(o.equivalentObjectPropertiesAxioms(c)), e)); + assertTrue(contains(equivalent(o.equivalentObjectPropertiesAxioms(e)), + df.getOWLObjectInverseOf(f))); + EntitySearcher.getSuperProperties(c, o).forEach(q -> assertTrue(checkMethod(q))); + } + + protected boolean checkMethod(OWLObject q) { + return q instanceof OWLObjectPropertyExpression; + } + + @Test + void shouldSearchDataProperties() { + // given + OWLOntology o = getOWLOntology(); + OWLDataProperty c = DataProperty(IRI(URN_TEST, "c")); + OWLDataProperty d = DataProperty(IRI(URN_TEST, "d")); + OWLDataProperty e = DataProperty(IRI(URN_TEST, "e")); + OWLAxiom ax = SubDataPropertyOf(c, d); + OWLClass x = Class(IRI(URN_TEST, "x")); + OWLAxiom ax2 = DataPropertyDomain(c, x); + OWLAxiom ax3 = DataPropertyRange(c, Boolean()); + OWLAxiom ax4 = EquivalentDataProperties(c, e); + o.addAxioms(ax, ax2, ax3, ax4); + assertTrue(contains(o.axioms(AxiomType.SUB_DATA_PROPERTY), ax)); + assertTrue(contains(sub(o.axioms(Filters.subDataPropertyWithSuper, d, INCLUDED)), c)); + Collection axioms = + asUnorderedSet(o.axioms(Filters.subDataPropertyWithSub, c, INCLUDED)); + assertTrue(contains(sup(axioms.stream()), d)); + assertTrue(contains(domain(o.dataPropertyDomainAxioms(c)), x)); + assertTrue(contains(range(o.dataPropertyRangeAxioms(c)), Boolean())); + assertTrue(contains(equivalent(o.equivalentDataPropertiesAxioms(c)), e)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/searcher/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/searcher/package-info.java new file mode 100644 index 0000000000..ba93623e49 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/searcher/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.api.test.searcher; diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/swrl/SWRLAtomOrderingRoundTripTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/swrl/SWRLAtomOrderingRoundTripTestCase.java new file mode 100644 index 0000000000..1c2ae8dec1 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/swrl/SWRLAtomOrderingRoundTripTestCase.java @@ -0,0 +1,116 @@ +package org.semanticweb.owlapi.api.test.swrl; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; +import org.semanticweb.owlapi.model.PrefixManager; +import org.semanticweb.owlapi.model.SWRLAtom; +import org.semanticweb.owlapi.model.SWRLClassAtom; +import org.semanticweb.owlapi.model.SWRLRule; +import org.semanticweb.owlapi.model.SWRLVariable; +import org.semanticweb.owlapi.util.DefaultPrefixManager; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group, Date: + * 04/04/2014 + */ +class SWRLAtomOrderingRoundTripTestCase extends TestBase { + + final Set body = new LinkedHashSet<>(); + final Set head = new LinkedHashSet<>(); + SWRLRule rule; + + @BeforeEach + void setUpPrefixes() { + PrefixManager pm = new DefaultPrefixManager(null, null, "http://stuff.com/A/"); + OWLClass clsA = Class("A", pm); + OWLClass clsB = Class("B", pm); + OWLClass clsC = Class("C", pm); + OWLClass clsD = Class("D", pm); + OWLClass clsE = Class("E", pm); + SWRLVariable varA = df.getSWRLVariable("http://other.com/A/", "VarA"); + SWRLVariable varB = df.getSWRLVariable("http://other.com/A/", "VarB"); + SWRLVariable varC = df.getSWRLVariable("http://other.com/A/", "VarC"); + SWRLClassAtom t = df.getSWRLClassAtom(clsC, varA); + body.add(t); + body.add(df.getSWRLClassAtom(clsB, varB)); + body.add(df.getSWRLClassAtom(clsA, varC)); + head.add(df.getSWRLClassAtom(clsE, varA)); + head.add(df.getSWRLClassAtom(clsD, varA)); + head.add(t); + rule = df.getSWRLRule(body, head); + } + + @Test + void individualsShouldNotGetSWRLVariableTypes() throws OWLOntologyStorageException { + OWLOntology o = loadOntologyFromString(TestFiles.individualSWRLTest, + iri("urn:test#", "test"), new RDFXMLDocumentFormat()); + String string = saveOntology(o).toString(); + assertFalse( + string.contains(""), + string); + } + + @Test + void shouldPreserveOrderingInRDFXMLRoundTrip() throws Exception { + roundTrip(new RDFXMLDocumentFormat()); + } + + private void roundTrip(OWLDocumentFormat ontologyFormat) throws OWLOntologyStorageException { + OWLOntology ont = getOWLOntology(); + ont.add(rule); + StringDocumentTarget documentTarget = new StringDocumentTarget(); + ont.saveOntology(ontologyFormat, documentTarget); + OWLOntology ont2 = loadOntologyFromString(documentTarget, ontologyFormat); + Set rules = asUnorderedSet(ont2.axioms(AxiomType.SWRL_RULE)); + assertEquals(1, rules.size()); + SWRLRule parsedRule = rules.iterator().next(); + assertThat(parsedRule, is(equalTo(rule))); + List originalBody = new ArrayList<>(body); + List parsedBody = asList(parsedRule.body()); + assertThat(parsedBody, is(equalTo(originalBody))); + List originalHead = new ArrayList<>(head); + List parsedHead = asList(parsedRule.head()); + assertThat(originalHead, is(equalTo(parsedHead))); + } + + @Test + void shouldPreserveOrderingInTurtleRoundTrip() throws OWLOntologyStorageException { + roundTrip(new TurtleDocumentFormat()); + } + + @Test + void shouldPreserveOrderingInManchesterSyntaxRoundTrip() throws OWLOntologyStorageException { + roundTrip(new ManchesterSyntaxDocumentFormat()); + } + + @Test + void shouldPreserveOrderingInOWLXMLRoundTrip() throws OWLOntologyStorageException { + roundTrip(new OWLXMLDocumentFormat()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/swrl/SWRLAtomOrderingTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/swrl/SWRLAtomOrderingTestCase.java new file mode 100644 index 0000000000..bfd95dbb05 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/swrl/SWRLAtomOrderingTestCase.java @@ -0,0 +1,59 @@ +package org.semanticweb.owlapi.api.test.swrl; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.SWRLAtom; +import org.semanticweb.owlapi.model.SWRLRule; + +/** + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group, Date: + * 04/04/2014 + */ +class SWRLAtomOrderingTestCase extends TestBase { + + private final Set body = new LinkedHashSet<>(); + protected SWRLAtom atomA; + protected SWRLAtom atomB; + protected SWRLAtom atomC; + protected SWRLAtom atomD; + private SWRLRule rule; + + @BeforeEach + void setUp() { + atomA = df.getSWRLClassAtom(A, + df.getSWRLIndividualArgument(df.getOWLNamedIndividual(iri("i")))); + atomB = df.getSWRLClassAtom(A, + df.getSWRLIndividualArgument(df.getOWLNamedIndividual(iri("j")))); + atomC = df.getSWRLClassAtom(A, + df.getSWRLIndividualArgument(df.getOWLNamedIndividual(iri("k")))); + atomD = df.getSWRLClassAtom(A, + df.getSWRLIndividualArgument(df.getOWLNamedIndividual(iri("l")))); + body.add(atomC); + body.add(atomB); + body.add(atomA); + Set head = new LinkedHashSet<>(); + head.add(atomD); + rule = df.getSWRLRule(body, head, Collections.emptySet()); + } + + @Test + void shouldPreserveBodyOrdering() { + List ruleImplBody = asList(rule.body()); + List specifiedBody = new ArrayList<>(body); + assertThat(ruleImplBody, is(equalTo(specifiedBody))); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/swrl/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/swrl/package-info.java new file mode 100644 index 0000000000..77335d59b8 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/swrl/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.api.test.swrl; diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/DLSyntaxTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/DLSyntaxTestCase.java new file mode 100644 index 0000000000..c7724a304e --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/DLSyntaxTestCase.java @@ -0,0 +1,97 @@ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.dlsyntax.renderer.DLSyntaxObjectRenderer; +import org.semanticweb.owlapi.formats.DLSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.DLSyntaxHTMLDocumentFormat; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; + +class DLSyntaxTestCase extends TestBase { + + @Test + void testCommasOnDisjointThree() { + OWLAxiom ax = df.getOWLDisjointClassesAxiom(A, B, C); + DLSyntaxObjectRenderer visitor = new DLSyntaxObjectRenderer(); + String render = visitor.render(ax); + assertEquals("A ⊑ ¬ B, A ⊑ ¬ C, B ⊑ ¬ C", render); + } + + @Test + void testCommasOnDisjointTwo() { + OWLAxiom ax = df.getOWLDisjointClassesAxiom(A, B); + DLSyntaxObjectRenderer visitor = new DLSyntaxObjectRenderer(); + String render = visitor.render(ax); + assertEquals("A ⊑ ¬ B", render); + } + + @Test + void testCommasOnDisjointFour() { + OWLAxiom ax = df.getOWLDisjointClassesAxiom(A, B, C, D); + DLSyntaxObjectRenderer visitor = new DLSyntaxObjectRenderer(); + String render = visitor.render(ax); + assertEquals("A ⊑ ¬ B, A ⊑ ¬ C, A ⊑ ¬ D, B ⊑ ¬ C, B ⊑ ¬ D, C ⊑ ¬ D", render); + } + + @Test + void testCommasOnDisjointThreeOntologyHTML() throws Exception { + OWLOntology o = m.createOntology(IRI.create("urn:test:onto")); + OWLAxiom ax = df.getOWLDisjointClassesAxiom(A, B, C); + o.addAxiom(ax); + String render = saveOntology(o, new DLSyntaxHTMLDocumentFormat()).toString(); + assertEquals(TestFiles.disjointInHTML, + render.replace(System.getProperty("line.separator"), "\n")); + } + + @Test + void testCommasOnDisjointTwoOntologyHTML() throws Exception { + OWLOntology o = m.createOntology(IRI.create("urn:test:onto")); + OWLAxiom ax = df.getOWLDisjointClassesAxiom(A, B); + o.addAxiom(ax); + String render = saveOntology(o, new DLSyntaxHTMLDocumentFormat()).toString(); + assertEquals(TestFiles.disjointTwoInHTML, + render.replace(System.getProperty("line.separator"), "\n")); + } + + @Test + void testCommasOnDisjointFourOntologyHTML() throws Exception { + OWLOntology o = m.createOntology(IRI.create("urn:test:onto")); + OWLAxiom ax = df.getOWLDisjointClassesAxiom(A, B, C, D); + o.addAxiom(ax); + String render = saveOntology(o, new DLSyntaxHTMLDocumentFormat()).toString(); + assertEquals(TestFiles.disjoint4InHTML, + render.replace(System.getProperty("line.separator"), "\n")); + } + + @Test + void testCommasOnDisjointThreeOntology() throws Exception { + OWLOntology o = m.createOntology(); + OWLAxiom ax = df.getOWLDisjointClassesAxiom(A, B, C); + o.addAxiom(ax); + String render = saveOntology(o, new DLSyntaxDocumentFormat()).toString(); + assertEquals("A ⊑ ¬ B, A ⊑ ¬ C, B ⊑ ¬ C", render); + } + + @Test + void testCommasOnDisjointTwoOntology() throws Exception { + OWLOntology o = m.createOntology(); + OWLAxiom ax = df.getOWLDisjointClassesAxiom(A, B); + o.addAxiom(ax); + String render = saveOntology(o, new DLSyntaxDocumentFormat()).toString(); + assertEquals("A ⊑ ¬ B", render); + } + + @Test + void testCommasOnDisjointFourOntology() throws Exception { + OWLOntology o = m.createOntology(); + OWLAxiom ax = df.getOWLDisjointClassesAxiom(A, B, C, D); + o.addAxiom(ax); + String render = saveOntology(o, new DLSyntaxDocumentFormat()).toString(); + assertEquals("A ⊑ ¬ B, A ⊑ ¬ C, A ⊑ ¬ D, B ⊑ ¬ C, B ⊑ ¬ D, C ⊑ ¬ D", render); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/DefaultPrefixManagerTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/DefaultPrefixManagerTestCase.java new file mode 100644 index 0000000000..acd5f33a05 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/DefaultPrefixManagerTestCase.java @@ -0,0 +1,80 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.PrefixManager; +import org.semanticweb.owlapi.util.DefaultPrefixManager; +import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; + +/** + * @author Matthew Horridge, The University of Manchester, Information Management Group + * @since 3.0.0 + */ +class DefaultPrefixManagerTestCase { + + @Test + void getPrefixIRIEmpty() { + DefaultPrefixManager pm = new DefaultPrefixManager(); + pm.setPrefix("foaf:", "http://xmlns.com/foaf/0.1/"); + assertEquals("foaf:", pm.getPrefixIRI(IRI("http://xmlns.com/foaf/0.1/", ""))); + } + + @Test + void getPrefixIRIIgnoreQName() { + DefaultPrefixManager pm = new DefaultPrefixManager(); + pm.setPrefix("foaf:", "http://xmlns.com/foaf/0.1/"); + assertEquals("foaf:test:test", + pm.getPrefixIRIIgnoreQName(IRI("http://xmlns.com/foaf/0.1/test:test"))); + } + + @Test + void testContainsDefaultPrefixNames() { + PrefixManager pm = new DefaultPrefixManager(); + assertTrue(pm.containsPrefixMapping("owl:")); + assertTrue(pm.containsPrefixMapping("rdf:")); + assertTrue(pm.containsPrefixMapping("rdfs:")); + assertTrue(pm.containsPrefixMapping("xml:")); + assertTrue(pm.containsPrefixMapping("xsd:")); + assertFalse(pm.containsPrefixMapping(":")); + assertNull(pm.getDefaultPrefix()); + } + + @Test + void testPrefixIRIExpansion() { + PrefixManager pm = new DefaultPrefixManager(); + IRI iri = pm.getIRI("rdfs:comment"); + assertEquals(iri, OWLRDFVocabulary.RDFS_COMMENT.getIRI()); + } + + @Test + void testDefaultPrefixExpansion() { + String defaultPrefix = "http://www.semanticweb.org/test/ont"; + PrefixManager pm = new DefaultPrefixManager(); + pm.setDefaultPrefix(defaultPrefix); + assertTrue(pm.containsPrefixMapping(":")); + assertNotNull(pm.getDefaultPrefix()); + assertEquals(pm.getDefaultPrefix(), pm.getPrefix(":")); + String expansion = defaultPrefix + 'A'; + IRI iri = pm.getIRI(":A"); + assertEquals(iri.toString(), expansion); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/FunctionalSyntaxCommentTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/FunctionalSyntaxCommentTestCase.java new file mode 100644 index 0000000000..619a2929c7 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/FunctionalSyntaxCommentTestCase.java @@ -0,0 +1,106 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataMaxCardinality; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Datatype; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Declaration; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubClassOf; + +import java.util.Collections; +import java.util.Optional; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +class FunctionalSyntaxCommentTestCase extends TestBase { + + static final OWLDataProperty city = DataProperty(IRI("urn:test.owl#", "city")); + static final OWLClass contactInfo = Class(IRI("urn:test.owl#", "ContactInformation")); + static final OWLLiteral multiline = Literal("blah \nblah"); + static final String plainOnto = + "Prefix(:=)\nOntology(\nSubClassOf(:a :b) )"; + + @Test + void shouldParseCommentAndSkipIt() { + OWLOntology o = + loadOntologyFromString(TestFiles.parseComment, new FunctionalSyntaxDocumentFormat()); + OWLAxiom ax1 = Declaration(city); + OWLAxiom ax2 = SubClassOf(contactInfo, + DataMaxCardinality(1, city, Datatype(OWL2Datatype.XSD_STRING.getIRI()))); + OWLAxiom ax3 = Declaration(contactInfo); + assertTrue(o.containsAxiom(ax1)); + assertTrue(o.containsAxiom(ax2)); + assertTrue(o.containsAxiom(ax3)); + } + + @Test + void shouldSaveMultilineComment() throws OWLOntologyCreationException { + OWLOntology o = m.createOntology(iri("file:test.owl", "")); + o.addAxiom(df.getOWLAnnotationAssertionAxiom(IRI("urn:test.owl#", "ContactInformation"), + df.getRDFSLabel(multiline))); + o.addAxiom(Declaration(city)); + o.addAxiom(SubClassOf(contactInfo, + DataMaxCardinality(1, city, Datatype(OWL2Datatype.XSD_STRING.getIRI())))); + o.addAxiom(Declaration(Class(IRI("urn:test.owl#ContactInformation")), + Collections.singleton(df.getRDFSLabel(multiline)))); + StringDocumentTarget saveOntology = saveOntology(o, new FunctionalSyntaxDocumentFormat()); + assertEquals(TestFiles.parseMultilineComment, saveOntology.toString()); + OWLOntology loadOntologyFromString = + loadOntologyFromString(saveOntology.toString(), new FunctionalSyntaxDocumentFormat()); + equal(o, loadOntologyFromString); + } + + @Test + void shouldParseCardinalityRestrictionWithMoreThanOneDigitRange() { + OWLOntology o = loadOntologyFromString(TestFiles.cardMultipleDigits, + new FunctionalSyntaxDocumentFormat()); + assertTrue(o.containsAxiom(df.getOWLSubClassOfAxiom(A, + df.getOWLDataMinCardinality(257, DPP, OWL2Datatype.RDFS_LITERAL.getDatatype(df))))); + } + + @Test + void testConvertGetLoadedOntology() { + OWLOntology origOnt = + loadOntologyFromString(plainOnto, new FunctionalSyntaxDocumentFormat()); + assertNotNull(origOnt); + OWLOntologyManager manager = origOnt.getOWLOntologyManager(); + assertEquals(1, manager.ontologies().count()); + assertFalse(origOnt.getOntologyID().getVersionIRI().isPresent()); + assertTrue(origOnt.getAxiomCount() > 0); + Optional ontologyIRI = origOnt.getOntologyID().getOntologyIRI(); + assertTrue(ontologyIRI.isPresent()); + OWLOntology newOnt = manager.getOntology(get(ontologyIRI)); + assertNotNull(newOnt); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/FunctionalSyntaxIRIProblemTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/FunctionalSyntaxIRIProblemTestCase.java new file mode 100644 index 0000000000..1969261f2f --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/FunctionalSyntaxIRIProblemTestCase.java @@ -0,0 +1,124 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Declaration; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubClassOf; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.io.OWLOntologyDocumentTarget; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; +import org.semanticweb.owlapi.model.PrefixManager; +import org.semanticweb.owlapi.util.DefaultPrefixManager; + +class FunctionalSyntaxIRIProblemTestCase extends TestBase { + + static final String ex = "example"; + static final String NSroma = "http://www.dis.uniroma1.it/example/"; + static final String NS = "http://example.org/"; + + @Test + void testmain() throws Exception { + OWLOntology ontology = getOWLOntology(); + OWLObjectProperty p = df.getOWLObjectProperty("http://example.org/A_#", "part_of"); + OWLClass a = Class(IRI(NS, "A_A")); + OWLClass b = Class(IRI(NS, "A_B")); + ontology.add(Declaration(p), Declaration(a), Declaration(b), + SubClassOf(b, df.getOWLObjectSomeValuesFrom(p, a))); + OWLOntology loadOntology = roundTrip(ontology, new RDFXMLDocumentFormat()); + FunctionalSyntaxDocumentFormat functionalFormat = new FunctionalSyntaxDocumentFormat(); + functionalFormat.asPrefixOWLDocumentFormat().setPrefix(ex, NS); + OWLOntology loadOntology2 = roundTrip(ontology, functionalFormat); + // won't reach here if functional syntax fails - comment it out and + // uncomment this to test Manchester + ManchesterSyntaxDocumentFormat manchesterFormat = new ManchesterSyntaxDocumentFormat(); + manchesterFormat.asPrefixOWLDocumentFormat().setPrefix(ex, NS); + OWLOntology loadOntology3 = roundTrip(ontology, manchesterFormat); + assertEquals(ontology, loadOntology); + assertEquals(ontology, loadOntology2); + assertEquals(ontology, loadOntology3); + assertTrue(ontology.equalAxioms(loadOntology)); + assertTrue(ontology.equalAxioms(loadOntology2)); + assertTrue(ontology.equalAxioms(loadOntology3)); + } + + @Test + void shouldRespectDefaultPrefix() + throws OWLOntologyCreationException, OWLOntologyStorageException { + OWLOntology ontology = m.createOntology(IRI.create(NSroma)); + PrefixManager pm = new DefaultPrefixManager(); + pm.setPrefix(ex, NSroma); + OWLClass pizza = df.getOWLClass("example:pizza", pm); + OWLDeclarationAxiom declarationAxiom = df.getOWLDeclarationAxiom(pizza); + ontology.addAxiom(declarationAxiom); + FunctionalSyntaxDocumentFormat ontoFormat = new FunctionalSyntaxDocumentFormat(); + ontoFormat.copyPrefixesFrom(pm); + m.setOntologyFormat(ontology, ontoFormat); + StringDocumentTarget documentTarget = new StringDocumentTarget(); + ontology.saveOntology(documentTarget); + assertTrue(documentTarget.toString().contains("example:pizza")); + } + + @Test + void shouldConvertToFunctionalCorrectly() throws OWLOntologyStorageException { + OWLOntology o = loadOntologyFromString(TestFiles.convertToFunctional, + new ManchesterSyntaxDocumentFormat()); + OWLOntology o1 = + loadOntologyFromString(saveOntology(o, new FunctionalSyntaxDocumentFormat()), + new FunctionalSyntaxDocumentFormat()); + equal(o, o1); + } + + @Test + void shouldPreservePrefix() throws OWLOntologyCreationException, OWLOntologyStorageException { + String prefix = "http://www.dis.uniroma1.it/pizza"; + OWLOntology ontology = m.createOntology(IRI.create(prefix)); + PrefixManager pm = new DefaultPrefixManager(); + pm.setPrefix("pizza", prefix); + OWLClass pizza = df.getOWLClass("pizza:PizzaBase", pm); + assertEquals(prefix + "PizzaBase", pizza.getIRI().toString()); + OWLDeclarationAxiom declarationAxiom = df.getOWLDeclarationAxiom(pizza); + ontology.addAxiom(declarationAxiom); + FunctionalSyntaxDocumentFormat ontoFormat = new FunctionalSyntaxDocumentFormat(); + ontoFormat.setPrefix("pizza", prefix); + m.setOntologyFormat(ontology, ontoFormat); + OWLOntologyDocumentTarget stream = new StringDocumentTarget(); + ontology.saveOntology(stream); + assertTrue(stream.toString().contains("pizza:PizzaBase")); + } + + @Test + void shouldRoundtripIRIsWithQueryString() throws OWLOntologyStorageException { + OWLOntology o = + loadOntologyFromString(TestFiles.roundtripRIWithQuery, new RDFXMLDocumentFormat()); + StringDocumentTarget saveOntology = saveOntology(o, new FunctionalSyntaxDocumentFormat()); + OWLOntology o1 = loadOntologyFromString(saveOntology, new FunctionalSyntaxDocumentFormat()); + equal(o, o1); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/IRIShorteningTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/IRIShorteningTestCase.java new file mode 100644 index 0000000000..f45b1fc468 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/IRIShorteningTestCase.java @@ -0,0 +1,104 @@ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormatFactory; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormatFactory; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormatFactory; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLDocumentFormatFactory; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; +import org.semanticweb.owlapi.vocab.Namespaces; +import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; + +/** + * Created by ses on 6/23/14. + */ +class IRIShorteningTestCase extends TestBase { + + @Test + void shouldAllowColonColon() throws OWLOntologyStorageException { + OWLOntology o = ontForShortening(); + assertionOnShortening(o, new TurtleDocumentFormatFactory()); + assertionOnShortening(o, new FunctionalSyntaxDocumentFormatFactory()); + assertionOnShortening(o, new ManchesterSyntaxDocumentFormatFactory()); + } + + protected void assertionOnShortening(OWLOntology o, OWLDocumentFormatFactory f) + throws OWLOntologyStorageException { + OWLDocumentFormat turtle = f.createFormat(); + turtle.asPrefixOWLDocumentFormat().setPrefix("s", "urn:test:individual#"); + StringDocumentTarget saveOntology = saveOntology(o, turtle); + OWLOntology loadOntologyFromString = loadOntologyFromString(saveOntology, f.createFormat()); + assertEquals(asSet(o.axioms()), asSet(loadOntologyFromString.axioms())); + roundTrip(o, turtle); + } + + protected OWLOntology ontForShortening() { + OWLOntology o = getOWLOntology(iri("urn:ontology:", "testcolons")); + o.addAxiom(df.getOWLDeclarationAxiom( + df.getOWLNamedIndividual(iri("urn:test:individual#colona:", "colonb")))); + return o; + } + + @Test + void testIriEqualToPrefixNotShortenedInFSS() throws Exception { + OWLOntology o = createTestOntology(); + String output = saveOntology(o, new FunctionalSyntaxDocumentFormat()).toString(); + matchExact(output, "NamedIndividual(rdf:)", false); + matchExact(output, "NamedIndividual(rdf:type)", true); + } + + void matchExact(String output, String text, boolean expected) { + String message = "should " + (expected ? "" : "not ") + "contain" + text + " - " + output; + assertTrue(expected == output.contains(text), message); + } + + @Test + void testIriEqualToPrefixShortenedInTurtle() throws Exception { + OWLOntology o = createTestOntology(); + String output = saveOntology(o, new TurtleDocumentFormat()).toString(); + matchRegex(output, "rdf:\\s+rdf:type\\s+owl:NamedIndividual"); + matchRegex(output, "rdf:type\\s+rdf:type\\s+owl:NamedIndividual"); + } + + void matchRegex(String output, String regex) { + Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE); + Matcher matcher = pattern.matcher(output); + boolean found = matcher.find(); + assertTrue(found, "should contain " + regex + " - " + output); + } + + private OWLOntology createTestOntology() { + OWLOntology o = getOWLOntology(); + OWLNamedIndividual i = df.getOWLNamedIndividual(IRI(Namespaces.RDF.getPrefixIRI(), "")); + o.add(df.getOWLDeclarationAxiom(i)); + i = df.getOWLNamedIndividual(OWLRDFVocabulary.RDF_TYPE); + o.add(df.getOWLDeclarationAxiom(i)); + return o; + } + + @Test + void shouldOutputURNsCorrectly() + throws OWLOntologyCreationException, OWLOntologyStorageException { + OWLOntology o = m.createOntology(iri("urn:ontology:", "test")); + o.add(df.getOWLObjectPropertyAssertionAxiom(df.getOWLObjectProperty("urn:test#", "p"), + df.getOWLNamedIndividual("urn:test#", "test"), + df.getOWLNamedIndividual("urn:other:", "test"))); + equal(o, roundTrip(o)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/IRITestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/IRITestCase.java new file mode 100644 index 0000000000..8e9416fdeb --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/IRITestCase.java @@ -0,0 +1,243 @@ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.NQuadsDocumentFormat; +import org.semanticweb.owlapi.formats.NTriplesDocumentFormat; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RDFJsonDocumentFormat; +import org.semanticweb.owlapi.formats.RDFJsonLDDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RioRDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RioTurtleDocumentFormat; +import org.semanticweb.owlapi.formats.TrigDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLRuntimeException; + +class IRITestCase extends TestBase { + @Test + void shouldParseIRIAndSkipPrefixedSpaceManchesterSyntax() { + OWLDocumentFormat f = new ManchesterSyntaxDocumentFormat(); + String bad = "Prefix: owl: \n" + + "Prefix: rdf: \n" + + "Prefix: xml: \n" + + "Prefix: xsd: \n" + + "Prefix: rdfs: \n" + + "Prefix: : \n" + "Ontology: \n" + + "AnnotationProperty: < https://example.org/bad-url>"; + roundTrip(f, bad); + } + + @Test + void shouldParseIRIAndSkipPrefixedSpaceTriG() { + OWLDocumentFormat f = new TrigDocumentFormat(); + String bad = + "@prefix : .\n" + "@prefix owl: .\n" + + "@prefix rdf: .\n" + + "@prefix xml: .\n" + + "@prefix xsd: .\n" + + "@prefix rdfs: .\n" + "\n" + "{\n" + + " a owl:Ontology .\n" + + " a owl:AnnotationProperty .\n" + + " < https://example.org/bad-url> .\n" + + "}"; + loadOntologyFromString(bad, f); + } + + @Test + void shouldOutputNamedGraph() { + OWLDocumentFormat f = new TrigDocumentFormat(); + IRI iri = iri("urn:test:", "ontology"); + OWLOntology o = getOWLOntology(iri); + o.getOWLOntologyManager().getOntologyConfigurator().withNamedGraphIRIEnabled(true); + StringDocumentTarget saved = saveOntology(o, f); + assertTrue(saved.toString().contains(iri.toQuotedString() + " {")); + } + + @Test + void shouldOutputOverriddenNamedGraph() { + OWLDocumentFormat f = new TrigDocumentFormat(); + String value = "urn:test:onto"; + f.setParameter("namedGraphOverride", value); + OWLOntology o = getOWLOntology(iri("urn:test:", "ontology")); + StringDocumentTarget saved = saveOntology(o, f); + assertTrue(saved.toString().contains("<" + value + ">")); + } + + @Test + void shouldParseIRIAndSkipPrefixedSpaceRDFJSON() { + OWLDocumentFormat f = new RDFJsonDocumentFormat(); + String bad = "{\n" + " \"http://x.org\" : {\n" + + " \"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\" : [\n" + " {\n" + + " \"value\" : \"http://www.w3.org/2002/07/owl#Ontology\",\n" + + " \"type\" : \"uri\"\n" + " }\n" + " ]\n" + " },\n" + + " \"http://x.org/myobj\" : {\n" + " \"http://x.org/myprop\" : [\n" + " {\n" + + " \"value\" : \" https://example.org/bad-url\",\n" + + " \"type\" : \"uri\"\n" + " }\n" + " ]\n" + " },\n" + + " \"http://x.org/myprop\" : {\n" + + " \"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\" : [\n" + " {\n" + + " \"value\" : \"http://www.w3.org/2002/07/owl#AnnotationProperty\",\n" + + " \"type\" : \"uri\"\n" + " }\n" + " ]\n" + " }\n" + "}"; + roundTrip(f, bad); + } + + @Test + void shouldParseIRIAndSkipPrefixedSpaceNTriples() { + OWLDocumentFormat f = new NTriplesDocumentFormat(); + String bad = + " .\n" + + " .\n" + + " < https://example.org/bad-url> ."; + roundTrip(f, bad); + } + + @Test + void shouldParseIRIAndSkipPrefixedSpaceRioRDFXML() { + OWLDocumentFormat f = new RioRDFXMLDocumentFormat(); + + String bad = "\n" + "\n" + + "\n" + + " \n" + + "\n" + "\n" + + " \n" + + "\n" + "\n" + + " \n" + + "\n" + ""; + loadOntologyFromString(bad, f); + } + + @Test + void shouldParseIRIAndSkipPrefixedSpaceRioTurtle() { + OWLDocumentFormat f = new RioTurtleDocumentFormat(); + + String bad = + "@prefix : .\n" + "@prefix owl: .\n" + + "@prefix rdf: .\n" + + "@prefix xml: .\n" + + "@prefix xsd: .\n" + + "@prefix rdfs: .\n" + + " a owl:Ontology .\n" + + " a owl:AnnotationProperty .\n" + + " < https://example.org/bad-url> ."; + loadOntologyFromString(bad, f); + } + + @Test + void shouldParseIRIAndSkipPrefixedSpaceJSONLD() { + OWLDocumentFormat f = new RDFJsonLDDocumentFormat(); + + String bad = "[ {\n" + " \"@id\" : \"http://x.org\",\n" + + " \"@type\" : [ \"http://www.w3.org/2002/07/owl#Ontology\" ]\n" + "}, {\n" + + " \"@id\" : \"http://x.org/myobj\",\n" + " \"http://x.org/myprop\" : [ {\n" + + " \"@id\" : \" https://example.org/bad-url\"\n" + " } ]\n" + "}, {\n" + + " \"@id\" : \"http://x.org/myprop\",\n" + + " \"@type\" : [ \"http://www.w3.org/2002/07/owl#AnnotationProperty\" ]\n" + "} ]"; + roundTrip(f, bad); + } + + @Test + void shouldParseIRIAndSkipPrefixedSpaceNQUADS() { + OWLDocumentFormat f = new NQuadsDocumentFormat(); + String bad = + " .\n" + + " .\n" + + " < https://example.org/bad-url> ."; + roundTrip(f, bad); + } + + @Test + void shouldParseIRIAndSkipPrefixedSpaceOWLXML() { + OWLDocumentFormat f = new OWLXMLDocumentFormat(); + String bad = "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + " \n" + + " \n" + " \n" + + " \n" + " /myobj\n" + + " https://example.org/bad-url\n" + " \n" + + ""; + roundTrip(f, bad); + } + + @Test + void shouldParseIRIAndSkipPrefixedSpaceRDFXML() { + OWLDocumentFormat f = new RDFXMLDocumentFormat(); + String bad = + "\n" + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + ""; + // exception thrown by the parser + assertThrows(OWLRuntimeException.class, () -> loadOntologyFromString(bad, f)); + } + + @Test + void shouldParseIRIAndSkipPrefixedSpaceTurtle() { + OWLDocumentFormat f = new TurtleDocumentFormat(); + String bad = + "@prefix : .\n" + "@prefix owl: .\n" + + "@prefix rdf: .\n" + + "@prefix xml: .\n" + + "@prefix xsd: .\n" + + "@prefix rdfs: .\n" + + "@base .\n" + " rdf:type owl:Ontology .\n" + + " rdf:type owl:AnnotationProperty .\n" + + " < https://example.org/bad-url> ."; + // exception thrown by the parser + assertThrows(OWLRuntimeException.class, () -> loadOntologyFromString(bad, f)); + } + + @Test + void shouldParseIRIAndSkipPrefixedSpaceFunctionalSyntax() { + OWLDocumentFormat f = new FunctionalSyntaxDocumentFormat(); + String bad = "Prefix(:=)\n" + + "Prefix(owl:=)\n" + + "Prefix(rdf:=)\n" + + "Prefix(xml:=)\n" + + "Prefix(xsd:=)\n" + + "Prefix(rdfs:=)\n" + + "Ontology(\n" + + "Declaration(AnnotationProperty())\n" + + "AnnotationAssertion( < https://example.org/bad-url>)\n)"; + roundTrip(f, bad); + } + + protected void roundTrip(OWLDocumentFormat f, String bad) { + String good = bad.replace(" https://example.org/bad-url", "https://example.org/bad-url"); + OWLOntology o1 = loadOntologyFromString(bad, f); + OWLOntology o2 = loadOntologyFromString(good, f); + equal(o1, o2); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/InvalidAxiomRoundTripTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/InvalidAxiomRoundTripTestCase.java new file mode 100644 index 0000000000..cdcdca2350 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/InvalidAxiomRoundTripTestCase.java @@ -0,0 +1,238 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DifferentIndividuals; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DisjointClasses; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DisjointDataProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DisjointObjectProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentClasses; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentDataProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentObjectProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NamedIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.OWLNothing; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.OWLThing; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SameIndividual; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.Set; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; + +class InvalidAxiomRoundTripTestCase extends TestBase { + + static final IRI t3 = IRI("urn:tes#", "t3"); + static final IRI t2 = IRI("urn:tes#", "t2"); + static final IRI t1 = IRI("urn:tes#", "t1"); + OWLOntology o; + + @BeforeEach + void setUpO() { + o = getOWLOntology(); + } + + private static void assertCorrectResult(OWLAxiom wrongAxiom, OWLAxiom validAxiom, + OWLOntology reloaded) { + assertNotNull(reloaded); + assertTrue(reloaded.containsAxiom(validAxiom)); + assertFalse(reloaded.containsAxiom(wrongAxiom)); + assertEquals(1, reloaded.getLogicalAxiomCount()); + } + + private OWLOntology saveAndReload() throws OWLOntologyStorageException { + return roundTrip(o, new FunctionalSyntaxDocumentFormat()); + } + + @Test + void shouldRoundTripInvalidDifferentIndividuals() throws OWLOntologyStorageException { + // given + OWLNamedIndividual e1 = NamedIndividual(t1); + OWLNamedIndividual e2 = NamedIndividual(t2); + OWLNamedIndividual e3 = NamedIndividual(t3); + // given + OWLAxiom wrongAxiom = DifferentIndividuals(e1); + OWLAxiom validAxiom = DifferentIndividuals(e2, e3); + // when + o.add(wrongAxiom, validAxiom); + // then + assertCorrectResult(wrongAxiom, validAxiom, saveAndReload()); + } + + @Test + void shouldRoundTripInvalidDisjointObjectProperties() throws OWLOntologyStorageException { + // given + OWLObjectProperty e1 = ObjectProperty(t1); + OWLObjectProperty e2 = ObjectProperty(t2); + OWLObjectProperty e3 = ObjectProperty(t3); + // given + OWLAxiom wrongAxiom = DisjointObjectProperties(e1); + OWLAxiom validAxiom = DisjointObjectProperties(e2, e3); + // when + o.add(wrongAxiom, validAxiom); + OWLOntology reloaded = saveAndReload(); + // then + assertNotNull(reloaded); + assertTrue(reloaded.containsAxiom(validAxiom)); + assertFalse(reloaded.containsAxiom(wrongAxiom)); + assertEquals(1, reloaded.getLogicalAxiomCount()); + } + + @Test + void shouldRoundTripInvalidDisjointClasses() throws Exception { + // given + OWLClass e1 = Class(t1); + OWLClass e2 = Class(t2); + OWLClass e3 = Class(t3); + // The implementation now checks for classes that only have a single + // distinct element + // Note: we cannot distinguish between a self-disjoint axiom and an + // FSS/API etc created single element axiom. + // but this is coding around a problem in the spec. + checkSingletonDisjointFixup(e1, DisjointClasses(e1, e1)); + OWLDisjointClassesAxiom singleClassDisjointAxiom = DisjointClasses(e1); + checkSingletonDisjointFixup(e1, singleClassDisjointAxiom); + OWLAxiom validAxiom = DisjointClasses(e2, e3); + // when + o.add(singleClassDisjointAxiom, validAxiom); + OWLOntology reloaded = roundTrip(o, new FunctionalSyntaxDocumentFormat()); + // then + assertNotNull(reloaded); + assertTrue(reloaded.containsAxiom(validAxiom)); + assertTrue(reloaded.containsAxiom(singleClassDisjointAxiom)); + assertEquals(2, reloaded.getLogicalAxiomCount()); + } + + protected void checkSingletonDisjointFixup(OWLClass e1, OWLDisjointClassesAxiom wrongAxiom) { + Set classExpressions = asUnorderedSet(wrongAxiom.classExpressions()); + assertEquals(2, classExpressions.size()); + assertTrue(classExpressions.contains(e1)); + if (!e1.isOWLThing()) { + assertTrue(classExpressions.contains(OWLThing())); + } else { + assertTrue(classExpressions.contains(OWLNothing())); + } + assertTrue(wrongAxiom.isAnnotated()); + } + + @Test + void shouldRoundTripInvalidDisjointDataProperties() throws OWLOntologyStorageException { + // given + OWLDataProperty e1 = DataProperty(t1); + OWLDataProperty e2 = DataProperty(t2); + OWLDataProperty e3 = DataProperty(t3); + // given + OWLAxiom wrongAxiom = DisjointDataProperties(e1); + OWLAxiom validAxiom = DisjointDataProperties(e2, e3); + // when + o.add(wrongAxiom, validAxiom); + OWLOntology reloaded = saveAndReload(); + // then + assertNotNull(reloaded); + assertTrue(reloaded.containsAxiom(validAxiom)); + assertFalse(reloaded.containsAxiom(wrongAxiom)); + assertEquals(1, reloaded.getLogicalAxiomCount()); + } + + @Test + void shouldRoundTripInvalidSameIndividuals() throws OWLOntologyStorageException { + // given + OWLNamedIndividual e1 = NamedIndividual(t1); + OWLNamedIndividual e2 = NamedIndividual(t2); + OWLNamedIndividual e3 = NamedIndividual(t3); + // given + OWLAxiom wrongAxiom = SameIndividual(e1); + OWLAxiom validAxiom = SameIndividual(e2, e3); + // when + o.add(wrongAxiom, validAxiom); + // then + assertCorrectResult(wrongAxiom, validAxiom, saveAndReload()); + } + + @Test + void shouldRoundTripInvalidEquivalentClasses() throws OWLOntologyStorageException { + // given + OWLClass e1 = Class(t1); + OWLClass e2 = Class(t2); + OWLClass e3 = Class(t3); + // given + OWLAxiom wrongAxiom = EquivalentClasses(e1); + OWLAxiom validAxiom = EquivalentClasses(e2, e3); + // when + o.add(wrongAxiom, validAxiom); + OWLOntology reloaded = saveAndReload(); + // then + assertNotNull(reloaded); + assertTrue(reloaded.containsAxiom(validAxiom)); + assertFalse(reloaded.containsAxiom(wrongAxiom)); + assertEquals(1, reloaded.getLogicalAxiomCount()); + } + + @Test + void shouldRoundTripInvalidEquivalentObjectProperties() throws OWLOntologyStorageException { + // given + OWLObjectProperty e1 = ObjectProperty(t1); + OWLObjectProperty e2 = ObjectProperty(t2); + OWLObjectProperty e3 = ObjectProperty(t3); + // given + OWLAxiom wrongAxiom = EquivalentObjectProperties(e1); + OWLAxiom validAxiom = EquivalentObjectProperties(e2, e3); + // when + o.add(wrongAxiom, validAxiom); + OWLOntology reloaded = saveAndReload(); + // then + assertNotNull(reloaded); + assertTrue(reloaded.containsAxiom(validAxiom)); + assertFalse(reloaded.containsAxiom(wrongAxiom)); + assertEquals(1, reloaded.getLogicalAxiomCount()); + } + + @Test + void shouldRoundTripInvalidEquivalentDataProperties() throws OWLOntologyStorageException { + // given + OWLDataProperty e1 = DataProperty(t1); + OWLDataProperty e2 = DataProperty(t2); + OWLDataProperty e3 = DataProperty(t3); + // given + OWLAxiom wrongAxiom = EquivalentDataProperties(e1); + OWLAxiom validAxiom = EquivalentDataProperties(e2, e3); + // when + o.add(wrongAxiom, validAxiom); + OWLOntology reloaded = saveAndReload(); + // then + assertNotNull(reloaded); + assertTrue(reloaded.containsAxiom(validAxiom)); + assertFalse(reloaded.containsAxiom(wrongAxiom)); + assertEquals(1, reloaded.getLogicalAxiomCount()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/LatexRendererTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/LatexRendererTestCase.java new file mode 100644 index 0000000000..6e5bb230b3 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/LatexRendererTestCase.java @@ -0,0 +1,41 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.LatexDocumentFormat; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; + +class LatexRendererTestCase extends TestBase { + + @Test + void shouldRenderEscapingUnderscores() throws Exception { + OWLOntology o = + loadOntologyFromString(TestFiles.latexWithUnderscores, new LatexDocumentFormat()); + assertTrue(saveOntology(o, new LatexDocumentFormat()).toString().contains("C\\_Test")); + } + + @Test + void shouldSaveInverses() throws OWLOntologyStorageException { + OWLOntology o = + loadOntologyFromString(TestFiles.latexWithInverse, new LatexDocumentFormat()); + assertEquals(TestFiles.latexExpectedOutput, + saveOntology(o, new LatexDocumentFormat()).toString()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/ManchesterImportTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/ManchesterImportTestCase.java new file mode 100644 index 0000000000..1ad65ab76b --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/ManchesterImportTestCase.java @@ -0,0 +1,74 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; + +import java.io.File; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.util.AutoIRIMapper; + +class ManchesterImportTestCase extends TestBase { + + private final IRI str = IRI("http://owlapitestontologies.com/", "thesuperont"); + private final String superpath = "/imports/thesuperont.omn"; + + @Test + void testManualImports() throws OWLOntologyCreationException { + OWLOntologyManager manager = getManager(); + manager.loadOntologyFromOntologyDocument(new File(RESOURCES, superpath)); + assertNotNull(manager.getOntology(str)); + } + + private OWLOntologyManager getManager() { + AutoIRIMapper mapper = new AutoIRIMapper(new File(RESOURCES, "imports"), true); + m.getIRIMappers().add(mapper); + return m; + } + + @Test + void testRemoteIsParseable() throws OWLOntologyCreationException { + OWLOntologyManager manager = getManager(); + OWLOntology ontology = manager.loadOntology(str); + assertEquals(1, ontology.getAxiomCount()); + assertEquals(ontology.getOntologyID().getOntologyIRI().get(), str); + assertNotNull(manager.getOntology(str)); + } + + @Test + void testEquivalentLoading() throws OWLOntologyCreationException { + OWLOntologyManager managerStart = getManager(); + OWLOntology manualImport = + managerStart.loadOntologyFromOntologyDocument(new File(RESOURCES, superpath)); + OWLOntologyManager managerTest = getManager(); + OWLOntology iriImport = managerTest.loadOntology(str); + assertTrue(manualImport.equalAxioms(iriImport)); + assertEquals(manualImport.getOntologyID(), iriImport.getOntologyID()); + } + + @Test + void testImports() throws OWLOntologyCreationException { + OWLOntologyManager manager = getManager(); + String subpath = "/imports/thesubont.omn"; + manager.loadOntologyFromOntologyDocument(new File(RESOURCES, subpath)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/ManchesterOWLSyntaxParserErrorsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/ManchesterOWLSyntaxParserErrorsTestCase.java new file mode 100644 index 0000000000..9128388016 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/ManchesterOWLSyntaxParserErrorsTestCase.java @@ -0,0 +1,502 @@ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import javax.annotation.Nonnull; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.expression.OWLEntityChecker; +import org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxTokenizer; +import org.semanticweb.owlapi.manchestersyntax.renderer.ParserException; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.util.mansyntax.ManchesterOWLSyntaxParser; + +/** + * Some tests that ensure the correct token and token position are returned when errors are + * encountered. + * + * @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group, Date: + * 01/04/2014 + */ +class ManchesterOWLSyntaxParserErrorsTestCase extends TestBase { + + protected @Nonnull OWLEntityChecker entityChecker = mock(OWLEntityChecker.class); + private ParserWrapper parser; + + @BeforeEach + void setUp() { + OWLClass cls = mock(OWLClass.class); + when(entityChecker.getOWLClass("C")).thenReturn(cls); + OWLClass clsC1 = mock(OWLClass.class); + when(entityChecker.getOWLClass("C1")).thenReturn(clsC1); + OWLObjectProperty oP = mock(OWLObjectProperty.class); + when(oP.asOWLObjectProperty()).thenReturn(oP); + when(entityChecker.getOWLObjectProperty("oP")).thenReturn(oP); + when(entityChecker.getOWLDataProperty("dP")).thenReturn(mock(OWLDataProperty.class)); + when(entityChecker.getOWLAnnotationProperty("aP")) + .thenReturn(mock(OWLAnnotationProperty.class)); + when(entityChecker.getOWLAnnotationProperty("rdfs:comment")) + .thenReturn(df.getRDFSComment()); + OWLNamedIndividual ind = mock(OWLNamedIndividual.class); + when(entityChecker.getOWLIndividual("ind")).thenReturn(ind); + when(ind.asOWLNamedIndividual()).thenReturn(ind); + parser = new ParserWrapper(); + } + + @Test + void unknownClassNameShouldCauseException() { + checkForExceptionAt("Class: X", 7, "X"); + } + + @Test + void unknownObjectPropertyNameShouldCauseException() { + checkForExceptionAt("ObjectProperty: P", 16, "P"); + } + + @Test + void unknownDataPropertyNameShouldCauseException() { + checkForExceptionAt("DataProperty: D", 14, "D"); + } + + @Test + void unknownAnnotationPropertyNameShouldCauseException() { + checkForExceptionAt("AnnotationProperty: A", 20, "A"); + } + + @Test + void unknownNamedIndividualShouldCauseException() { + checkForExceptionAt("Individual: I", 12, "I"); + } + + @Test + void unknownDatatypeNameShouldCauseException() { + checkForExceptionAt("Datatype: D", 10, "D"); + } + + @Test + void missingLiteralTypeShouldCauseException() { + String input = "Class: C Annotations: rdfs:comment \"comment\"^^"; + checkForExceptionAtEOF(input); + } + + @Test + void prematureEOFInDeclarationShouldCauseParseException() { + checkForExceptionAtEOF("Class: "); + } + + @Test + void prematureEOFAfterClassAnnotationsShouldCauseParseException() { + checkForExceptionAtEOF("Class: C Annotations: "); + } + + @Test + void prematureEOFAfterSubClassOfShouldCauseParseException() { + String input = "Class: C SubClassOf: "; + checkForExceptionAtEOF(input); + } + + @Test + void prematureEOFAfterEquivalentToShouldCauseParseException() { + String input = "Class: C EquivalentTo: "; + checkForExceptionAtEOF(input); + } + + @Test + void prematureEOFAfterDisjointWithShouldCauseParseException() { + String input = "Class: C DisjointWith: "; + checkForExceptionAtEOF(input); + } + + @Test + void prematureEOFAfterDisjointUnionOfShouldCauseParseException() { + checkForExceptionAtEOF("Class: C DisjointUnionOf: "); + } + + @Test + void prematureEOFAfterHasKeyShouldCauseParseException() { + String input = "Class: C HasKey: "; + checkForExceptionAtEOF(input); + } + + @Test + void prematureEOFAfterClassSubClassOfAxiomAnnotationsShouldCauseParseException() { + checkForExceptionAtEOF("Class: C SubClassOf: Annotations: "); + } + + @Test + void prematureEOFAfterClassSubClassOfListShouldCauseParseException() { + checkForExceptionAtEOF("Class: C SubClassOf: C1, "); + } + + @Test + void prematureEOFAfterClassEquivalentToAxiomAnnotationsShouldCauseParseException() { + checkForExceptionAtEOF("Class: C EquivalentTo: Annotations: "); + } + + @Test + void prematureEOFAfterClassEquivalentToListShouldCauseParseException() { + checkForExceptionAtEOF("Class: C EquivalentTo: C1, "); + } + + @Test + void prematureEOFAfterClassDisjointWithAxiomAnnotationsShouldCauseParseException() { + checkForExceptionAtEOF("Class: C DisjointWith: Annotations: "); + } + + @Test + void prematureEOFAfterClassDisjointWithListShouldCauseParseException() { + checkForExceptionAtEOF("Class: C DisjointWith: C1, "); + } + + @Test + void prematureEOFAfterClassDisjointUnionOfAxiomAnnotationsShouldCauseParseException() { + checkForExceptionAtEOF("Class: C DisjointUnionOf: Annotations: "); + } + + @Test + void prematureEOFAfterClassDisjointUnionOfListShouldCauseParseException() { + checkForExceptionAtEOF("Class: C DisjointUnionOf: C1, "); + } + + @Test + void prematureEOFAfterClassHasKeyAxiomAnnotationsShouldCauseParseException() { + checkForExceptionAtEOF("Class: C HasKey: Annotations: "); + } + + @Test + void prematureEOFAfterObjectPropertyShouldCauseParseException() { + checkForExceptionAtEOF("ObjectProperty: "); + } + + @Test + void prematureEOFAfterObjectPropertyAnnotationsShouldCauseParseException() { + checkForExceptionAtEOF("ObjectProperty: oP Annotations: "); + } + + @Test + void prematureEOFAfterObjectPropertyDomainShouldCauseParseException() { + checkForExceptionAtEOF("ObjectProperty: oP Domain: "); + } + + @Test + void unrecognizedClassAfterObjectPropertyDomainShouldCauseParseException() { + checkForExceptionAt("ObjectProperty: oP Domain: X", 27, "X"); + } + + @Test + void prematureEOFAfterObjectPropertyRangeShouldCauseParseException() { + checkForExceptionAtEOF("ObjectProperty: oP Range: "); + } + + @Test + void unrecognizedClassAfterObjectPropertyRangeShouldCauseParseException() { + checkForExceptionAt("ObjectProperty: oP Range: X", 26, "X"); + } + + @Test + void prematureEOFAfterObjectPropertySubPropertyOfShouldCauseParseException() { + checkForExceptionAtEOF("ObjectProperty: oP SubPropertyOf: "); + } + + @Test + void unrecognizedPropertyAfterObjectPropertySubPropertyOfShouldCauseParseException() { + checkForExceptionAt("ObjectProperty: oP SubPropertyOf: Q", 34, "Q"); + } + + @Test + void prematureEOFAfterObjectPropertyEquivalentToShouldCauseParseException() { + checkForExceptionAtEOF("ObjectProperty: oP EquivalentTo: "); + } + + @Test + void unrecognizedPropertyAfterObjectPropertyEquivalentToShouldCauseParseException() { + checkForExceptionAt("ObjectProperty: oP EquivalentTo: Q", 33, "Q"); + } + + @Test + void prematureEOFAfterObjectPropertyDisjointWithShouldCauseParseException() { + checkForExceptionAtEOF("ObjectProperty: oP DisjointWith: "); + } + + @Test + void unrecognizedPropertyAfterObjectPropertyDisjointWithToShouldCauseParseException() { + checkForExceptionAt("ObjectProperty: oP DisjointWith: Q", 33, "Q"); + } + + @Test + void prematureEOFAfterObjectPropertyCharacteristicsShouldCauseParseException() { + checkForExceptionAtEOF("ObjectProperty: oP Characteristics: "); + } + + @Test + void unrecognizedCharacteristicAfterObjectPropertyCharacteristicsShouldCauseParseException() { + checkForExceptionAt("ObjectProperty: oP Characteristics: Q", 36, "Q"); + } + + @Test + void prematureEOFAfterObjectPropertyInverseOfShouldCauseParseException() { + checkForExceptionAtEOF("ObjectProperty: oP InverseOf: "); + } + + @Test + void unrecognizedPropertyAfterObjectPropertyInverseOfShouldCauseParseException() { + checkForExceptionAt("ObjectProperty: oP InverseOf: Q", 30, "Q"); + } + + @Test + void prematureEOFAfterObjectPropertySubPropertyChainShouldCauseParseException() { + checkForExceptionAtEOF("ObjectProperty: oP SubPropertyChain: "); + } + + @Test + void unrecognizedPropertyAfterObjectPropertySubPropertyChainOfShouldCauseParseException() { + checkForExceptionAt("ObjectProperty: oP SubPropertyChain: Q", 37, "Q"); + } + + @Test + void prematureEOFAfterDataPropertyShouldCauseParseException() { + checkForExceptionAtEOF("DataProperty: "); + } + + @Test + void prematureEOFAfterDataPropertyAnnotationsShouldCauseParseException() { + checkForExceptionAtEOF("DataProperty: dP Annotations: "); + } + + @Test + void unrecognisedAnnotationPropertyAfterDataPropertyAnnotationsShouldCauseParseException() { + checkForExceptionAt("DataProperty: dP Annotations: X", 30, "X"); + } + + @Test + void prematureEOFAfterDataPropertyDomainShouldCauseParseException() { + checkForExceptionAtEOF("DataProperty: dP Domain: "); + } + + @Test + void unrecognizedClassAfterDataPropertyDomainShouldCauseParseException() { + checkForExceptionAt("DataProperty: dP Domain: X", 25, "X"); + } + + @Test + void prematureEOFAfterDataPropertyRangeShouldCauseParseException() { + checkForExceptionAtEOF("DataProperty: dP Range: "); + } + + @Test + void unrecognizedClassAfterDataPropertyRangeShouldCauseParseException() { + checkForExceptionAt("DataProperty: dP Range: X", 24, "X"); + } + + @Test + void prematureEOFAfterDataPropertySubPropertyOfShouldCauseParseException() { + checkForExceptionAtEOF("DataProperty: dP SubPropertyOf: "); + } + + @Test + void unrecognizedPropertyAfterDataPropertySubPropertyOfShouldCauseParseException() { + checkForExceptionAt("DataProperty: dP SubPropertyOf: Q", 32, "Q"); + } + + @Test + void prematureEOFAfterDataPropertyEquivalentToShouldCauseParseException() { + checkForExceptionAtEOF("DataProperty: dP EquivalentTo: "); + } + + @Test + void unrecognizedPropertyAfterDataPropertyEquivalentToShouldCauseParseException() { + checkForExceptionAt("DataProperty: dP EquivalentTo: Q", 31, "Q"); + } + + @Test + void prematureEOFAfterDataPropertyDisjointWithShouldCauseParseException() { + checkForExceptionAtEOF("DataProperty: dP DisjointWith: "); + } + + @Test + void unrecognizedPropertyAfterDataPropertyDisjointWithToShouldCauseParseException() { + checkForExceptionAt("DataProperty: dP DisjointWith: Q", 31, "Q"); + } + + @Test + void prematureEOFAfterDataPropertyCharacteristicsShouldCauseParseException() { + checkForExceptionAtEOF("DataProperty: dP Characteristics: "); + } + + @Test + void unrecognizedCharacteristicAfterDataPropertyCharacteristicsShouldCauseParseException() { + checkForExceptionAt("DataProperty: dP Characteristics: Q", 34, "Q"); + } + + @Test + void prematureEOFAfterAnnotationPropertyShouldCauseParseException() { + checkForExceptionAtEOF("AnnotationProperty: "); + } + + @Test + void prematureEOFAfterAnnotationPropertyAnnotationsShouldCauseParseException() { + checkForExceptionAtEOF("AnnotationProperty: aP Annotations: "); + } + + @Test + void unrecognisedAnnotationPropertyAfterAnnotationPropertyAnnotationsShouldCauseParseException() { + checkForExceptionAt("AnnotationProperty: aP Annotations: X", 36, "X"); + } + + @Test + void prematureEOFAfterAnnotationPropertyDomainShouldCauseParseException() { + checkForExceptionAtEOF("AnnotationProperty: aP Domain: "); + } + + @Test + void unrecognizedClassAfterAnnotationPropertyDomainShouldCauseParseException() { + checkForExceptionAt("AnnotationProperty: aP Domain: X", 31, "X"); + } + + @Test + void prematureEOFAfterAnnotationPropertyRangeShouldCauseParseException() { + checkForExceptionAtEOF("AnnotationProperty: aP Range: "); + } + + @Test + void unrecognizedClassAfterAnnotationPropertyRangeShouldCauseParseException() { + checkForExceptionAt("AnnotationProperty: aP Range: X", 30, "X"); + } + + @Test + void prematureEOFAfterAnnotationPropertySubPropertyOfShouldCauseParseException() { + checkForExceptionAtEOF("AnnotationProperty: aP SubPropertyOf: "); + } + + @Test + void unrecognizedPropertyAfterAnnotationPropertySubPropertyOfShouldCauseParseException() { + checkForExceptionAt("AnnotationProperty: aP SubPropertyOf: Q", 38, "Q"); + } + + @Test + void prematureEOFAfterIndividualAnnotationsShouldCauseParseException() { + checkForExceptionAtEOF("Individual: ind Annotations: "); + } + + @Test + void unrecognizedAnnotationPropertyAfterIndividualAnnotationsShouldCauseParseException() { + checkForExceptionAt("Individual: ind Annotations: Q", 29, "Q"); + } + + @Test + void prematureEOFAfterIndividualTypesShouldCauseParseException() { + checkForExceptionAtEOF("Individual: ind Types: "); + } + + @Test + void unrecognizedClassAfterIndividualTypesShouldCauseParseException() { + checkForExceptionAt("Individual: ind Types: X", 23, "X"); + } + + @Test + void prematureEOFAfterIndividualFactsShouldCauseParseException() { + checkForExceptionAtEOF("Individual: ind Facts: "); + } + + @Test + void prematureEOFAfterIndividualFactsNotShouldCauseParseException() { + checkForExceptionAtEOF("Individual: ind Facts: not "); + } + + @Test + void unrecognizedPropertyAfterIndividualFactsShouldCauseParseException() { + checkForExceptionAt("Individual: ind Facts: Q", 23, "Q"); + } + + @Test + void unrecognizedPropertyAfterIndividualFactsNotShouldCauseParseException() { + checkForExceptionAt("Individual: ind Facts: not Q", 27, "Q"); + } + + @Test + void prematureEOFAfterIndividualSameAsShouldCauseParseException() { + checkForExceptionAtEOF("Individual: ind SameAs: "); + } + + @Test + void unrecognizedIndividualAfterIndividualSameAsShouldCauseParseException() { + checkForExceptionAt("Individual: ind SameAs: Q", 24, "Q"); + } + + @Test + void prematureEOFAfterIndividualDifferentFromShouldCauseParseException() { + checkForExceptionAtEOF("Individual: ind DifferentFrom: "); + } + + @Test + void unrecognizedIndividualAfterIndividualDifferentFromShouldCauseParseException() { + checkForExceptionAt("Individual: ind DifferentFrom: Q", 31, "Q"); + } + + @Test + void unclosedLiteralShouldCauseParseException() { + checkForExceptionAtEOF("Class: C Annotations: rdfs:comment \"XYZ"); + } + + @Test + void prematureEOFAfterRuleShouldCauseParseException() { + checkForExceptionAtEOF("Class: C Rule: "); + } + + @Test + void prematureEOFAfterRuleAtomShouldCauseParseException() { + checkForExceptionAtEOF("Class: C Rule: oP(?x, ?y) "); + } + + @Test + void unrecognisedPropertyAfterRuleShouldCauseParseException() { + checkForExceptionAt("Class: C Rule: X(?x, ?y) ", 15, "X"); + } + + @Test + void unmarkedVariableInRuleAtomShouldCauseParseException() { + checkForExceptionAt("Class: C Rule: oP(x, ?y)", 18, "x"); + } + + private void checkForExceptionAt(String input, int index, String currentToken) { + try { + parser.parse(input); + fail(); + } catch (ParserException e) { + assertEquals(index, e.getStartPos()); + assertEquals(currentToken, e.getCurrentToken()); + assertTrue(!e.getTokenSequence().isEmpty()); + assertEquals(currentToken, e.getTokenSequence().get(0)); + } + } + + private void checkForExceptionAtEOF(String input) { + checkForExceptionAt(input, input.length(), ManchesterOWLSyntaxTokenizer.EOFTOKEN); + String trimmedInput = input.trim(); + checkForExceptionAt(trimmedInput, trimmedInput.length(), + ManchesterOWLSyntaxTokenizer.EOFTOKEN); + } + + private class ParserWrapper { + + ParserWrapper() {} + + void parse(String input) { + ManchesterOWLSyntaxParser actualParser = OWLManager.createManchesterParser(); + actualParser.setOWLEntityChecker(entityChecker); + actualParser.setStringToParse(input); + actualParser.parseFrames(); + } + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/ManchesterOWLSyntaxParserTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/ManchesterOWLSyntaxParserTestCase.java new file mode 100644 index 0000000000..df11e098b5 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/ManchesterOWLSyntaxParserTestCase.java @@ -0,0 +1,393 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Declaration; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DisjointUnion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubClassOf; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.expression.ShortFormEntityChecker; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.manchestersyntax.renderer.ManchesterOWLSyntaxPrefixNameShortFormProvider; +import org.semanticweb.owlapi.manchestersyntax.renderer.ParserException; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.util.AnnotationValueShortFormProvider; +import org.semanticweb.owlapi.util.BidirectionalShortFormProvider; +import org.semanticweb.owlapi.util.BidirectionalShortFormProviderAdapter; +import org.semanticweb.owlapi.util.ShortFormProvider; +import org.semanticweb.owlapi.util.mansyntax.ManchesterOWLSyntaxParser; +import org.semanticweb.owlapi.vocab.OWL2Datatype; +import org.semanticweb.owlapi.vocab.OWLFacet; +import org.semanticweb.owlapi.vocab.XSDVocabulary; + +class ManchesterOWLSyntaxParserTestCase extends TestBase { + + static final String URN_TEST = "urn:test#"; + static final OWLClass MAN = Class(IRI("http://example.com/owl/families/", "Man")); + static final OWLClass PERSON = Class(IRI("http://example.com/owl/families/", "Person")); + static final OWLDatatype dateTime = df.getOWLDatatype(XSDVocabulary.DATE_TIME); + static final String opClassPunning = + "Prefix: : \n" + "Ontology: \n" + "Individual: x\n" + + "Class: creator_of\n" + "ObjectProperty: creator_of\n" + "Class: Test\n" + + " EquivalentClasses: creator_of value x, creator_of"; + static final String manSyntaxParserRuleTest = "Prefix: owl: \n" + + "Prefix: rdf: \n" + + "Prefix: xml: \n" + + "Prefix: xsd: \n" + + "Prefix: rdfs: \n" + + "Ontology: \n" + + "Datatype: xsd:decimal\n Datatype: xsd:int\n Datatype: xsd:dateTime\n" + + "DataProperty: \n Characteristics: \n Functional\n Range: \n xsd:int\n" + + "DataProperty: \n Range: \n xsd:dateTime\n" + + "Class: \n" + + "Individual: \n Types: \n \n" + + "Rule: \n xsd:decimal(?), (?, ?) -> (?)"; + + @Test + void shouldRoundtripAnnotationAssertionsWithAnnotations() throws OWLOntologyStorageException { + OWLOntology o = loadOntologyFromString(TestFiles.annotatedAnnotationMansyntax, + new ManchesterSyntaxDocumentFormat()); + OWLOntology o2 = roundTrip(o); + equal(o, o2); + } + + @Test + void shouldAcceptOPClassPunning() throws OWLOntologyStorageException { + OWLOntology o = + loadOntologyFromString(opClassPunning, new ManchesterSyntaxDocumentFormat()); + OWLOntology o2 = roundTrip(o); + equal(o, o2); + } + + @Test + void shouldRoundTrip() { + // given + OWLOntology ontology = getOWLOntology(); + ontology.add(Declaration(DP)); + // when + ontology = roundTrip(ontology); + // then + assertTrue(ontology.containsDataPropertyInSignature(DP.getIRI())); + } + + @Test + void shouldRenderCorrectly() { + // given + OWLOntology o = getOWLOntology(); + OWLObjectSomeValuesFrom r = df.getOWLObjectSomeValuesFrom(P, df.getOWLObjectUnionOf(B, C)); + OWLSubClassOfAxiom axiom = df.getOWLSubClassOfAxiom(D, r); + o.add(axiom); + StringDocumentTarget target = saveOntology(o, new ManchesterSyntaxDocumentFormat()); + assertFalse(target.toString().contains( + "((" + B.getIRI().toQuotedString() + " or " + C.getIRI().toQuotedString() + "))")); + } + + @Test + void shouldNotAddDCToPrefixes() { + OWLOntology o = + loadOntologyFromString(TestFiles.noDC, new ManchesterSyntaxDocumentFormat()); + OWLDocumentFormat f = o.getOWLOntologyManager().getOntologyFormat(o); + assertFalse(f.asPrefixOWLDocumentFormat().containsPrefixMapping("dc:")); + } + + @Test + void shouldAddDCToPrefixesWithoutDeclaration() { + // DC was added by default to the prefixes whether it was used or not. + // The behaviour was removed, but this would stop ontologies from + // loading if they relied on the prefix appearing by default + // Fix is to add it lazily if necessary + OWLOntology o = + loadOntologyFromString(TestFiles.lazyDC, new ManchesterSyntaxDocumentFormat()); + OWLDocumentFormat f = o.getOWLOntologyManager().getOntologyFormat(o); + assertTrue(f.asPrefixOWLDocumentFormat().containsPrefixMapping("dc:")); + } + + @Test + void shouldRoundtripDisjointUnion() { + OWLOntology o = getOWLOntology(); + OWLDisjointUnionAxiom axiom = DisjointUnion(A, B, C, D); + o.add(axiom); + o.add(Declaration(A), Declaration(B), Declaration(C), Declaration(D)); + OWLOntology roundtripped = roundTrip(o, new ManchesterSyntaxDocumentFormat()); + assertEquals(asUnorderedSet(o.axioms()), asUnorderedSet(roundtripped.axioms())); + } + + @Test + void testManSyntaxEditorParser() { + String expression = "yearValue some "; + OWLOntology wine = + loadOntologyFromString(TestFiles.manSyntaxParserTest, new RDFXMLDocumentFormat()); + List ontologies = asList(m.ontologies()); + ShortFormProvider sfp = + new ManchesterOWLSyntaxPrefixNameShortFormProvider(wine.getFormat()); + BidirectionalShortFormProvider shortFormProvider = + new BidirectionalShortFormProviderAdapter(ontologies, sfp); + ManchesterOWLSyntaxParser parser = OWLManager.createManchesterParser(); + parser.setStringToParse(expression); + parser.setDefaultOntology(wine); + parser.setOWLEntityChecker(new ShortFormEntityChecker(shortFormProvider)); + assertThrows(ParserException.class, () -> parser.parseClassExpression()); + } + + @Test + void shouldParseRuleInManSyntax() { + OWLOntology o = + loadOntologyFromString(manSyntaxParserRuleTest, new ManchesterSyntaxDocumentFormat()); + OWLOntology o1 = roundTrip(o, new ManchesterSyntaxDocumentFormat()); + equal(o, o1); + } + + @Test + void shouldParseRuleInManSyntaxOldNamespace() { + OWLOntology o = + loadOntologyFromString(TestFiles.manSyntaxRule, new ManchesterSyntaxDocumentFormat()); + OWLOntology o1 = roundTrip(o, new ManchesterSyntaxDocumentFormat()); + equal(o, o1); + } + + @Test + void shouldParseRuleInManSimpleSyntax() { + OWLOntology o = + loadOntologyFromString(TestFiles.manSyntaxInput, new ManchesterSyntaxDocumentFormat()); + OWLOntology o1 = roundTrip(o, new ManchesterSyntaxDocumentFormat()); + assertEquals(asUnorderedSet(o.logicalAxioms()), asUnorderedSet(o1.logicalAxioms())); + } + + @Test + void shouldAnnotateAndRoundTrip() { + OWLOntology o = + loadOntologyFromString(TestFiles.roundtripTest, new ManchesterSyntaxDocumentFormat()); + assertTrue(o.containsAxiom(Declaration(PERSON))); + assertTrue(o.containsAxiom(Declaration(MAN))); + assertTrue(o.containsAxiom(SubClassOf(MAN, PERSON))); + } + + @Test + void shouldParseCorrectly() { + // given + String text1 = + "'GWAS study' and has_publication_date some dateTime[< \"2009-01-01T00:00:00+00:00\"^^dateTime]"; + OWLClassExpression expected = df.getOWLObjectIntersectionOf(A, + df.getOWLDataSomeValuesFrom(DP, df.getOWLDatatypeRestriction(dateTime, + OWLFacet.MAX_EXCLUSIVE, df.getOWLLiteral("2009-01-01T00:00:00+00:00", dateTime)))); + // ontology creation including labels - this is the input ontology + OWLOntology o = getOWLOntology(); + o.add(df.getOWLDeclarationAxiom(A), df.getOWLDeclarationAxiom(DP), + df.getOWLDeclarationAxiom(dateTime), annotation(A, "'GWAS study'"), + annotation(DP, "has_publication_date"), annotation(dateTime, "dateTime")); + // select a short form provider that uses annotations + ShortFormProvider sfp = + new AnnotationValueShortFormProvider(Arrays.asList(df.getRDFSLabel()), + Collections.>emptyMap(), m); + BidirectionalShortFormProvider shortFormProvider = + new BidirectionalShortFormProviderAdapter(asList(m.ontologies()), sfp); + ManchesterOWLSyntaxParser parser = OWLManager.createManchesterParser(); + parser.setStringToParse(text1); + ShortFormEntityChecker owlEntityChecker = new ShortFormEntityChecker(shortFormProvider); + parser.setOWLEntityChecker(owlEntityChecker); + parser.setDefaultOntology(o); + // when + // finally parse + OWLClassExpression dsvf = parser.parseClassExpression(); + // then + assertEquals(expected, dsvf); + } + + OWLAxiom annotation(OWLEntity e, String s) { + return df.getOWLAnnotationAssertionAxiom(e.getIRI(), df.getRDFSLabel(s)); + } + + @Test + void shouldDoPrecedenceWithParentheses() { + // given + String text1 = "(a and b) or c"; + OWLClass a = Class(IRI(URN_TEST, "a")); + OWLClass b = Class(IRI(URN_TEST, "b")); + OWLClass c = Class(IRI(URN_TEST, "c")); + OWLClassExpression expected = + df.getOWLObjectUnionOf(df.getOWLObjectIntersectionOf(a, b), c); + ManchesterOWLSyntaxParser parser = setupParser(text1, expected); + // when + // finally parse + OWLClassExpression dsvf = parser.parseClassExpression(); + // then + assertEquals(expected, dsvf); + } + + @Test + void shouldParseCorrectlydecimal() { + // given + String text1 = "p some decimal[<=2.0, >= 1.0]"; + OWLDatatype decimal = df.getOWLDatatype(OWL2Datatype.XSD_DECIMAL); + OWLFacetRestriction max = + df.getOWLFacetRestriction(OWLFacet.MAX_INCLUSIVE, df.getOWLLiteral("2.0", decimal)); + OWLFacetRestriction min = + df.getOWLFacetRestriction(OWLFacet.MIN_INCLUSIVE, df.getOWLLiteral("1.0", decimal)); + OWLClassExpression expected = + df.getOWLDataSomeValuesFrom(DP, df.getOWLDatatypeRestriction(decimal, max, min)); + // ontology creation including labels - this is the input ontology + OWLOntology o = getOWLOntology(); + o.add(df.getOWLDeclarationAxiom(DP), df.getOWLDeclarationAxiom(decimal), + annotation(DP, "p")); + // select a short form provider that uses annotations + ShortFormProvider sfp = + new AnnotationValueShortFormProvider(Arrays.asList(df.getRDFSLabel()), + Collections.>emptyMap(), m); + BidirectionalShortFormProvider shortFormProvider = + new BidirectionalShortFormProviderAdapter(asList(m.ontologies()), sfp); + ManchesterOWLSyntaxParser parser = OWLManager.createManchesterParser(); + parser.setStringToParse(text1); + ShortFormEntityChecker owlEntityChecker = new ShortFormEntityChecker(shortFormProvider); + parser.setOWLEntityChecker(owlEntityChecker); + parser.setDefaultOntology(o); + // when + // finally parse + OWLClassExpression dsvf = parser.parseClassExpression(); + // then + assertEquals(expected, dsvf); + } + + @Test + void shouldParseCorrectlydecimalNotSpecified() { + // given + OWLAxiom expected = df.getOWLDataPropertyRangeAxiom(DP, + df.getOWLDataOneOf(df.getOWLLiteral("1.2", OWL2Datatype.XSD_DECIMAL))); + String input = + "Ontology:\n DataProperty: " + DP.getIRI().toQuotedString() + "\n Range: {1.2}"; + OWLOntology o = loadOntologyFromString(input, new ManchesterSyntaxDocumentFormat()); + o.logicalAxioms().forEach(ax -> assertEquals(expected, ax)); + } + + @Test + void shouldDoPrecedenceWithoutParentheses() { + // given + String text1 = "A and B or C"; + OWLClassExpression expected = + df.getOWLObjectUnionOf(df.getOWLObjectIntersectionOf(A, B), C); + ManchesterOWLSyntaxParser parser = setupParser(text1, expected); + // when + // finally parse + OWLClassExpression dsvf = parser.parseClassExpression(); + // then + assertEquals(expected, dsvf); + } + + protected ManchesterOWLSyntaxParser setupParser(String text1, OWLClassExpression expected) { + OWLOntology o = getOWLOntology(); + o.add(df.getOWLDeclarationAxiom(A), df.getOWLDeclarationAxiom(B), + df.getOWLDeclarationAxiom(C), df.getOWLDeclarationAxiom(D), + df.getOWLSubClassOfAxiom(expected, D)); + // select a short form provider that uses annotations + ShortFormProvider sfp = + new AnnotationValueShortFormProvider(Arrays.asList(df.getRDFSLabel()), + Collections.>emptyMap(), m); + BidirectionalShortFormProvider shortFormProvider = + new BidirectionalShortFormProviderAdapter(asList(m.ontologies()), sfp); + ManchesterOWLSyntaxParser parser = OWLManager.createManchesterParser(); + parser.setStringToParse(text1); + ShortFormEntityChecker owlEntityChecker = new ShortFormEntityChecker(shortFormProvider); + parser.setOWLEntityChecker(owlEntityChecker); + parser.setDefaultOntology(o); + return parser; + } + + @Test + void shouldNotFailOnAnnotations() { + OWLOntology o = loadOntologyFromString(TestFiles.annotationTestCase, + new FunctionalSyntaxDocumentFormat()); + OWLOntology result = roundTrip(o, new ManchesterSyntaxDocumentFormat()); + o.axioms().forEach(ax -> assertTrue(result.containsAxiom(ax))); + } + + @Test + void shouldNotFailSubclass() { + // given + String in = "A SubClassOf B"; + OWLOntology o = getOWLOntology(); + o.add(df.getOWLDeclarationAxiom(A), df.getOWLDeclarationAxiom(B)); + // select a short form provider that uses annotations + ShortFormProvider sfp = + new AnnotationValueShortFormProvider(Arrays.asList(df.getRDFSLabel()), + Collections.>emptyMap(), m); + BidirectionalShortFormProvider shortFormProvider = + new BidirectionalShortFormProviderAdapter(asList(m.ontologies()), sfp); + ManchesterOWLSyntaxParser parser = OWLManager.createManchesterParser(); + parser.setStringToParse(in); + ShortFormEntityChecker owlEntityChecker = new ShortFormEntityChecker(shortFormProvider); + parser.setOWLEntityChecker(owlEntityChecker); + parser.setDefaultOntology(o); + // when + // finally parse + OWLAxiom axiom = parser.parseAxiom(); + // then + assertEquals(df.getOWLSubClassOfAxiom(A, B), axiom); + } + + @Test + void shouldNotFailOWLReal() throws OWLOntologyCreationException { + String in = "p max 1 owl:real"; + OWLOntology o = m.createOntology(); + o.addAxiom(df.getOWLDeclarationAxiom(DP)); + o.addAxiom(df.getOWLDeclarationAxiom(B)); + // select a short form provider that uses annotations + ShortFormProvider sfp = + new AnnotationValueShortFormProvider(Arrays.asList(df.getRDFSLabel()), + Collections.>emptyMap(), m); + BidirectionalShortFormProvider shortFormProvider = + new BidirectionalShortFormProviderAdapter(asList(m.ontologies()), sfp); + ManchesterOWLSyntaxParser parser = OWLManager.createManchesterParser(); + parser.setStringToParse(in); + ShortFormEntityChecker owlEntityChecker = new ShortFormEntityChecker(shortFormProvider); + parser.setOWLEntityChecker(owlEntityChecker); + parser.setDefaultOntology(o); + // when + // finally parse + OWLClassExpression expected = + df.getOWLDataMaxCardinality(1, DP, OWL2Datatype.OWL_REAL.getDatatype(df)); + OWLClassExpression cl = parser.parseClassExpression(); + // then + assertEquals(cl, expected); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/ManchesterParseErrorTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/ManchesterParseErrorTestCase.java new file mode 100644 index 0000000000..7cb4c964fc --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/ManchesterParseErrorTestCase.java @@ -0,0 +1,111 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +import javax.annotation.Nullable; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.expression.OWLEntityChecker; +import org.semanticweb.owlapi.manchestersyntax.renderer.ParserException; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.util.mansyntax.ManchesterOWLSyntaxParser; + +class ManchesterParseErrorTestCase extends TestBase { + + private static OWLClassExpression parse(String text) { + MockEntityChecker checker = new MockEntityChecker(df); + ManchesterOWLSyntaxParser parser = OWLManager.createManchesterParser(); + parser.setStringToParse(text); + parser.setOWLEntityChecker(checker); + return parser.parseClassExpression(); + } + + @Test + void shouldNotParse() { + parse("p some rdfs:Literal"); + String text1 = "p some Litera"; + assertThrows(ParserException.class, () -> parse(text1)); + } + + @Test + void shouldNotParseToo() { + parse("p some rdfs:Literal"); + String text1 = "p some Literal"; + assertThrows(ParserException.class, () -> parse(text1)); + } + + /** + * A very simple entity checker that only understands that "p" is a property and rdfs:Literal is + * a datatype. He is an extreme simplification of the entity checker that runs when Protege is + * set to render entities as qnames. + * + * @author tredmond + */ + private static class MockEntityChecker implements OWLEntityChecker { + + private final OWLDataFactory factory; + + MockEntityChecker(OWLDataFactory factory) { + this.factory = factory; + } + + @Override + public @Nullable OWLClass getOWLClass(String name) { + return null; + } + + @Override + public @Nullable OWLObjectProperty getOWLObjectProperty(String name) { + return null; + } + + @Override + public @Nullable OWLDataProperty getOWLDataProperty(@Nullable String name) { + if ("p".equals(name)) { + return factory.getOWLDataProperty("http://protege.org/Test.owl#", "p"); + } else { + return null; + } + } + + @Override + public @Nullable OWLAnnotationProperty getOWLAnnotationProperty(String name) { + return null; + } + + @Override + public @Nullable OWLNamedIndividual getOWLIndividual(String name) { + return null; + } + + @Override + public @Nullable OWLDatatype getOWLDatatype(@Nullable String name) { + if ("rdfs:Literal".equals(name)) { + return factory.getTopDatatype(); + } else { + return null; + } + } + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/OWLXMLNullPointerTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/OWLXMLNullPointerTestCase.java new file mode 100644 index 0000000000..879580057b --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/OWLXMLNullPointerTestCase.java @@ -0,0 +1,67 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +class OWLXMLNullPointerTestCase extends TestBase { + + static final String ANONYMOUS_INDIVIDUAL_ANNOTATION = "Anonymous individual for testing"; + static final String NS = "urn:test"; + + @Test + void testRoundTrip() throws Exception { + OWLOntology ontology = getOWLOntology(IRI(NS, "")); + OWLClass cheesy = Class(IRI(NS + "#", "CheeseyPizza")); + OWLClass cheese = Class(IRI(NS + "#", "CheeseTopping")); + OWLObjectProperty hasTopping = df.getOWLObjectProperty(NS + "#", "hasTopping"); + OWLAnonymousIndividual i = df.getOWLAnonymousIndividual(); + OWLLiteral lit = df.getOWLLiteral(ANONYMOUS_INDIVIDUAL_ANNOTATION); + OWLAxiom annAss = df.getOWLAnnotationAssertionAxiom(i, df.getRDFSLabel(lit)); + OWLAxiom classAss = df.getOWLClassAssertionAxiom(cheesy, i); + OWLIndividual j = df.getOWLAnonymousIndividual(); + OWLAxiom classAssj = df.getOWLClassAssertionAxiom(cheese, j); + OWLAxiom objAss = df.getOWLObjectPropertyAssertionAxiom(hasTopping, i, j); + ontology.add(annAss, classAss, classAssj, objAss); + roundTrip(ontology, new OWLXMLDocumentFormat()); + } + + @Test + void shouldParse() throws Exception { + OWLOntology o = getOWLOntology(); + OWLClass c = df.getOWLClass("urn:test#", "c"); + OWLObjectProperty p = df.getOWLObjectProperty("urn:test#", "p"); + OWLAnonymousIndividual i = df.getOWLAnonymousIndividual(); + OWLSubClassOfAxiom sub = df.getOWLSubClassOfAxiom(c, df.getOWLObjectHasValue(p, i)); + o.addAxiom(sub); + OWLOntology roundtrip = roundTrip(o, new OWLXMLDocumentFormat()); + equal(o, roundtrip); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/OWLXMLTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/OWLXMLTestCase.java new file mode 100644 index 0000000000..feef6e3ab7 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/OWLXMLTestCase.java @@ -0,0 +1,46 @@ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; + +import java.io.File; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; + +class OWLXMLTestCase extends TestBase { + + @Test + void shouldFindExpectedAxiomsForBlankNodes() throws OWLOntologyCreationException { + OWLObjectProperty r = ObjectProperty( + iri("http://www.derivo.de/ontologies/examples/anonymous-individuals#", "r")); + OWLOntology o = + m.loadOntologyFromOntologyDocument(new File(RESOURCES, "owlxml_anonloop.owx")); + o.axioms(AxiomType.CLASS_ASSERTION).forEach(ax -> { + OWLAxiom expected = + df.getOWLObjectPropertyAssertionAxiom(r, ax.getIndividual(), ax.getIndividual()); + assertTrue(o.containsAxiom(expected), expected + " not found"); + }); + } + + @Test + void shouldParseSWRLVariables() throws OWLOntologyStorageException { + OWLOntology o = + loadOntologyFromString(TestFiles.parseSWRLVariable, new OWLXMLDocumentFormat()); + o.axioms(AxiomType.SWRL_RULE).forEach(r -> assertEquals( + "DLSafeRule(Body(SameAsAtom(Variable() Variable())) Head())", + r.toString())); + String out = saveOntology(o, new OWLXMLDocumentFormat()).toString(); + assertTrue(out.contains(""), out); + assertTrue(out.contains(""), out); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/OutputSyntaxSortTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/OutputSyntaxSortTestCase.java new file mode 100644 index 0000000000..fa02ac12e3 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/OutputSyntaxSortTestCase.java @@ -0,0 +1,59 @@ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.io.StringDocumentSource; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; + +class OutputSyntaxSortTestCase extends TestBase { + + static Collection getData() { + return Arrays.asList(new Object[] {new ManchesterSyntaxDocumentFormat()}, + new Object[] {new FunctionalSyntaxDocumentFormat()}, + new Object[] {new TurtleDocumentFormat()}, new Object[] {new RDFXMLDocumentFormat()}, + new Object[] {new OWLXMLDocumentFormat()}); + } + + @ParameterizedTest + @MethodSource("getData") + void shouldOutputAllInSameOrder(OWLDocumentFormat format) + throws OWLOntologyStorageException, OWLOntologyCreationException { + masterConfigurator.withRemapAllAnonymousIndividualsIds(false); + try { + List ontologies = new ArrayList<>(); + List set = new ArrayList<>(); + for (String s : TestFiles.inputSorting) { + OWLOntology o = loadOntologyFromString(new StringDocumentSource(s, + IRI.generateDocumentIRI(), new FunctionalSyntaxDocumentFormat(), null)); + set.add(saveOntology(o, format).toString()); + ontologies.add(o); + } + for (int i = 0; i < ontologies.size() - 1; i++) { + equal(ontologies.get(i), ontologies.get(i + 1)); + } + for (int i = 0; i < set.size() - 1; i++) { + assertEquals(set.get(i), set.get(i + 1)); + } + } finally { + masterConfigurator.withRemapAllAnonymousIndividualsIds(true); + } + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/ParserBanningTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/ParserBanningTestCase.java new file mode 100644 index 0000000000..33dccacb9c --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/ParserBanningTestCase.java @@ -0,0 +1,38 @@ +package org.semanticweb.owlapi.api.test.syntax; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.io.UnparsableOntologyException; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLRuntimeException; + +class ParserBanningTestCase extends TestBase { + + @Test + void shouldFailWithBanningOfTriX() throws OWLOntologyCreationException { + // This ontology is malformed RDF/XML but does not fail under a regular + // parsing because the + // TriX parser does not throw an exception reading it (although it does + // not recognise any axioms) + // This test ensures that TriX can be banned from parsing + OWLOntologyManager manager = setupManager(); + // org.semanticweb.owlapi.rio.RioBinaryRdfParserFactory + // org.semanticweb.owlapi.rio.RioJsonLDParserFactory + // org.semanticweb.owlapi.rio.RioJsonParserFactory + // org.semanticweb.owlapi.rio.RioN3ParserFactory + // org.semanticweb.owlapi.rio.RioNQuadsParserFactory + // org.semanticweb.owlapi.rio.RioNTriplesParserFactory + // org.semanticweb.owlapi.rio.RioRDFaParserFactory + // org.semanticweb.owlapi.rio.RioRDFXMLParserFactory + // org.semanticweb.owlapi.rio.RioTrigParserFactory + // org.semanticweb.owlapi.rio.RioTrixParserFactory + // org.semanticweb.owlapi.rio.RioTurtleParserFactory + String name = "org.semanticweb.owlapi.rio.RioTrixParserFactory"; + manager.getOntologyConfigurator().withBannedParsers(name); + assertThrowsWithCause(OWLRuntimeException.class, UnparsableOntologyException.class, + () -> loadOntologyFromString(TestFiles.failWhenTrixBanned, new RDFXMLDocumentFormat())); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/PrimerTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/PrimerTestCase.java new file mode 100644 index 0000000000..1c82d0d47f --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/PrimerTestCase.java @@ -0,0 +1,97 @@ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.Set; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.profiles.OWL2DLProfile; + +class PrimerTestCase extends TestBase { + + static final String URN_PRIMER = "urn:primer#"; + static final String NS = "http://example.com/owl/families/"; + OWLOntology func = loadOntologyFromString(TestFiles.FUNCTIONAL, iri(URN_PRIMER, "functional"), + new FunctionalSyntaxDocumentFormat()); + OWL2DLProfile profile = new OWL2DLProfile(); + + @BeforeEach + void setUpProfile() { + assertTrue(profile.checkOntology(func).isInProfile()); + } + + @Test + void shouldManchBeEquivalent() throws OWLOntologyCreationException { + OWLOntology manch = loadOntologyFromString(TestFiles.MANCHESTER, + iri(URN_PRIMER, "manchester"), new ManchesterSyntaxDocumentFormat()); + assertTrue(profile.checkOntology(manch).getViolations().isEmpty()); + // XXX Manchester OWL Syntax does not support GCIs + // the input adopts a trick to semantically get around this, by + // asserting a new named class equivalent to the right hand side of the + // GCI and subclass of the left hand side + // Rectifying this to be able to assert equality, and using a different + // ontology + // so that the equality test does not skip gcis because of the format + OWLClass x = df.getOWLClass(NS, "X"); + Set axioms = asUnorderedSet(manch.axioms(x)); + manch.remove(axioms); + OWLClass female = df.getOWLClass(NS, "Female"); + OWLClassExpression oneOf = df.getOWLObjectOneOf(df.getOWLNamedIndividual(NS, "Bill"), + df.getOWLNamedIndividual(NS, "Mary"), df.getOWLNamedIndividual(NS, "Meg")); + OWLClass parent = df.getOWLClass(NS, "Parent"); + OWLObjectProperty hasChild = df.getOWLObjectProperty(NS, "hasChild"); + OWLClassExpression superClass = + df.getOWLObjectIntersectionOf(parent, df.getOWLObjectAllValuesFrom(hasChild, female), + df.getOWLObjectMaxCardinality(1, hasChild)); + manch.addAxiom( + df.getOWLSubClassOfAxiom(df.getOWLObjectIntersectionOf(female, oneOf), superClass)); + OWLOntology replacement = + m.createOntology(manch.axioms(), get(manch.getOntologyID().getOntologyIRI())); + equal(func, replacement); + } + + @Test + void shouldRDFXMLBeEquivalent() { + OWLOntology rdf = loadOntologyFromString(TestFiles.RDFXML, iri(URN_PRIMER, "rdfxml"), + new RDFXMLDocumentFormat()); + assertTrue(profile.checkOntology(rdf).getViolations().isEmpty()); + equal(func, rdf); + } + + @Test + void shouldOWLXMLBeEquivalent() { + OWLOntology owl = loadOntologyFromString(TestFiles.OWLXML, iri(URN_PRIMER, "owlxml"), + new OWLXMLDocumentFormat()); + assertTrue(profile.checkOntology(owl).getViolations().isEmpty()); + equal(func, owl); + } + + @Test + void shouldTURTLEBeEquivalent() { + OWLOntology turt = loadOntologyFromString(TestFiles.TURTLE, iri(URN_PRIMER, "turtle"), + new TurtleDocumentFormat()); + assertTrue(profile.checkOntology(turt).getViolations().isEmpty()); + // XXX somehow the Turtle parser introduces a tautology: the inverse of + // inverse(hasParent) is hasParent + // dropping said tautology to assert equality of the rest of the axioms + OWLObjectProperty hasParent = df.getOWLObjectProperty(NS, "hasParent"); + turt.remove( + df.getOWLInverseObjectPropertiesAxiom(df.getOWLObjectInverseOf(hasParent), hasParent)); + equal(func, turt); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/PunningAndDomainsRangesTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/PunningAndDomainsRangesTestCase.java new file mode 100644 index 0000000000..b3a7f80192 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/PunningAndDomainsRangesTestCase.java @@ -0,0 +1,51 @@ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxParserImpl; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +class PunningAndDomainsRangesTestCase extends TestBase { + + private static final String URN_TEST = "urn:test#"; + + @Test + void shouldKeepDomainsInFSS() throws OWLOntologyCreationException, OWLOntologyStorageException { + OWLOntology o = m.createOntology(iri(URN_TEST, "ontology")); + OWLAnnotationProperty p1 = df.getOWLAnnotationProperty(iri("urn:property#", "p")); + OWLDataProperty p2 = df.getOWLDataProperty(iri("urn:property#", "p")); + o.addAxiom(df.getOWLAnnotationPropertyRangeAxiom(p1, OWL2Datatype.RDFS_LITERAL.getIRI())); + o.addAxiom(df.getOWLDataPropertyRangeAxiom(p2, OWL2Datatype.RDFS_LITERAL.getDatatype(df))); + OWLOntology o2 = roundTrip(o, new FunctionalSyntaxDocumentFormat()); + equal(o, o2); + } + + @Test + void shouldSupportPunningClassesAndPropertiesInManchesterSyntax() + throws OWLOntologyCreationException { + OWLClass b = df.getOWLClass(iri(URN_TEST, "B")); + OWLClass a = df.getOWLClass(iri(URN_TEST, "A")); + OWLOntology o = m.createOntology(); + o.addAxiom(df.getOWLDeclarationAxiom(df.getOWLObjectProperty(iri(URN_TEST, "B")))); + o.addAxiom(df.getOWLDeclarationAxiom(b)); + o.addAxiom(df.getOWLDeclarationAxiom(a)); + ManchesterOWLSyntaxParserImpl parser = + (ManchesterOWLSyntaxParserImpl) OWLManager.createManchesterParser(); + parser.getPrefixManager().setDefaultPrefix(URN_TEST); + parser.setDefaultOntology(o); + parser.setStringToParse(":A or :B"); + OWLClassExpression parseClassExpression = parser.parseClassExpression(); + assertEquals(parseClassExpression, df.getOWLObjectUnionOf(a, b)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/SharedBlankNodeTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/SharedBlankNodeTestCase.java new file mode 100644 index 0000000000..d0aab5f6bf --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/SharedBlankNodeTestCase.java @@ -0,0 +1,194 @@ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Annotation; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnonymousIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataPropertyAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NamedIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectPropertyAssertion; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.add; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.AddOntologyAnnotation; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAnnotationSubject; +import org.semanticweb.owlapi.model.OWLAnnotationValue; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; + +/** + * test for 3294629 - currently disabled. Not clear whether structure sharing is allowed or + * disallowed. Data is equivalent, ontology annotations are not + */ +class SharedBlankNodeTestCase extends TestBase { + + String NS = "urn:test"; + OWLAnonymousIndividual i = AnonymousIndividual(); + OWLNamedIndividual ind = NamedIndividual(IRI(NS + "#", "test")); + + static void testAnnotation(OWLOntology o) { + o.individualsInSignature() + .forEach(i -> assertEquals(2L, o.objectPropertyAssertionAxioms(i).count())); + o.annotations().map(a -> (OWLIndividual) a.getValue()) + .forEach(i -> assertEquals(1L, o.dataPropertyAssertionAxioms(i).count())); + } + + @Test + void shouldSaveOneIndividual() throws Exception { + OWLOntology ontology = createOntology(); + StringDocumentTarget s = saveOntology(ontology, new RDFXMLDocumentFormat()); + StringDocumentTarget functionalSyntax = + saveOntology(ontology, new FunctionalSyntaxDocumentFormat()); + testAnnotation( + loadOntologyFromString(functionalSyntax, new FunctionalSyntaxDocumentFormat())); + OWLOntology o1 = loadOntologyFromString(s, new RDFXMLDocumentFormat()); + testAnnotation(o1); + } + + @Test + void shouldParseOneIndividual() { + testAnnotation(loadOntologyFromString(TestFiles.oneIndividual, new RDFXMLDocumentFormat())); + } + + OWLOntology createOntology() throws OWLOntologyCreationException { + OWLOntology ontology = m.createOntology(IRI(NS, "")); + annotate(ontology, NS + "#ann", i); + ontology.add( + // + dataAssertion(NS + "#p", i, "hello world"), + // + objectAssertion(NS + "#p1", ind, i), + // + objectAssertion(NS + "#p2", ind, i)); + return ontology; + } + + private static void annotate(OWLOntology o, String p, OWLAnnotationValue v) { + o.applyChange(new AddOntologyAnnotation(o, Annotation(AnnotationProperty(IRI(p)), v))); + } + + private static OWLAxiom dataAssertion(String p, OWLIndividual i, String l) { + return DataPropertyAssertion(DataProperty(IRI(p)), i, Literal(l)); + } + + private static OWLAxiom objectAssertion(String p, OWLIndividual i, OWLIndividual j) { + return ObjectPropertyAssertion(ObjectProperty(IRI(p)), i, j); + } + + @Test + void shouldRoundtripBlankNodeAnnotations() throws OWLOntologyStorageException { + OWLOntology o = + loadOntologyFromString(TestFiles.oneAnonIndividuall, new RDFXMLDocumentFormat()); + OWLOntology o1 = + loadOntologyFromString(saveOntology(o, new FunctionalSyntaxDocumentFormat()), + new FunctionalSyntaxDocumentFormat()); + OWLOntology o2 = loadOntologyFromString(saveOntology(o1, new RDFXMLDocumentFormat()), + new RDFXMLDocumentFormat()); + assertEquals(1L, o2.annotationAssertionAxioms(IRI("http://E", "")).count()); + Stream s = o2.annotationAssertionAxioms(IRI("http://E", "")) + .map(a -> (OWLAnnotationSubject) a.getValue()); + s.forEach(a -> assertEquals(1L, o2.annotationAssertionAxioms(a).count())); + } + + @Test + void shouldRemapUponReading() { + OWLOntology o1 = + loadOntologyFromString(TestFiles.remapOnReading, new FunctionalSyntaxDocumentFormat()); + OWLOntology o2 = + loadOntologyFromString(TestFiles.remapOnReading, new FunctionalSyntaxDocumentFormat()); + Set values1 = asUnorderedSet(o1.axioms(AxiomType.ANNOTATION_ASSERTION) + .map(a -> a.getValue()).filter(a -> a instanceof OWLAnonymousIndividual)); + Set values2 = asUnorderedSet(o2.axioms(AxiomType.ANNOTATION_ASSERTION) + .map(a -> a.getValue()).filter(a -> a instanceof OWLAnonymousIndividual)); + assertEquals(1, values1.size(), values1.toString()); + assertEquals(1, values2.size(), values2.toString()); + assertNotEquals(values1, values2); + } + + @Test + void shouldHaveOnlyOneAnonIndividual() { + OWLOntology o1 = + loadOntologyFromString(TestFiles.oneAnonIndividuall, new RDFXMLDocumentFormat()); + OWLOntology o2 = + loadOntologyFromString(TestFiles.oneAnonIndividuall, new RDFXMLDocumentFormat()); + Set values1 = asUnorderedSet(o1.axioms(AxiomType.ANNOTATION_ASSERTION) + .map(a -> a.getValue()).filter(a -> a instanceof OWLAnonymousIndividual)); + Set values2 = asUnorderedSet(o2.axioms(AxiomType.ANNOTATION_ASSERTION) + .map(a -> a.getValue()).filter(a -> a instanceof OWLAnonymousIndividual)); + assertEquals(1, values1.size(), values1.toString()); + assertEquals(1, values2.size(), values2.toString()); + assertNotEquals(values1, values2); + } + + @Test + void shouldNotRemapUponReloading() { + m.getOntologyConfigurator().withRemapAllAnonymousIndividualsIds(false); + Set values1 = new HashSet<>(); + values1.add(m.getOWLDataFactory().getOWLAnonymousIndividual("_:genid-nodeid-1058025095")); + OWLOntology o1 = + loadOntologyFromString(TestFiles.noRemapOnRead, new RDFXMLDocumentFormat()); + add(values1, o1.axioms(AxiomType.ANNOTATION_ASSERTION).map(a -> a.getValue()) + .filter(a -> a instanceof OWLAnonymousIndividual)); + o1 = loadOntologyFromString(TestFiles.noRemapOnRead, new RDFXMLDocumentFormat()); + add(values1, o1.axioms(AxiomType.ANNOTATION_ASSERTION).map(a -> a.getValue()) + .filter(a -> a instanceof OWLAnonymousIndividual)); + assertEquals(1, values1.size(), values1.toString()); + m.getOntologyConfigurator().withRemapAllAnonymousIndividualsIds(true); + } + + @Test + void shouldNotOutputNodeIdWhenNotNeeded() throws OWLOntologyStorageException { + OWLOntology o1 = + loadOntologyFromString(TestFiles.noRemapOnRead, new RDFXMLDocumentFormat()); + StringDocumentTarget result = saveOntology(o1, new RDFXMLDocumentFormat()); + assertFalse(result.toString().contains("rdf:nodeID")); + } + + @Test + void shouldOutputNodeIdEvenIfNotNeeded() throws OWLOntologyStorageException { + OWLOntology o1 = + loadOntologyFromString(TestFiles.unconditionalId, new RDFXMLDocumentFormat()); + masterConfigurator.withSaveIdsForAllAnonymousIndividuals(true); + try { + StringDocumentTarget result = saveOntology(o1, new RDFXMLDocumentFormat()); + assertTrue(result.toString().contains("rdf:nodeID")); + OWLOntology reloaded = loadOntologyFromString(result, new RDFXMLDocumentFormat()); + StringDocumentTarget resaved = saveOntology(reloaded, new RDFXMLDocumentFormat()); + assertEquals(result.toString(), resaved.toString()); + } finally { + // make sure the static variable is reset after the test + masterConfigurator.withSaveIdsForAllAnonymousIndividuals(false); + } + } + + @Test + void shouldOutputNodeIdWhenNeeded() throws OWLOntologyStorageException { + OWLOntology o1 = + loadOntologyFromString(TestFiles.conditionalId, new RDFXMLDocumentFormat()); + StringDocumentTarget result = saveOntology(o1, new RDFXMLDocumentFormat()); + assertTrue(result.toString().contains("rdf:nodeID")); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/ShortFormProviderTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/ShortFormProviderTestCase.java new file mode 100644 index 0000000000..19132cef30 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/ShortFormProviderTestCase.java @@ -0,0 +1,53 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.util.QNameShortFormProvider; + +class ShortFormProviderTestCase { + + @Test + void shouldFindShortForm() { + OWLClass c = Class(IRI("http://www.ebi.ac.uk/fgpt/ontologies/test/", "TEST_00001")); + QNameShortFormProvider shortener = new QNameShortFormProvider(); + String shortform = shortener.getShortForm(c); + assertEquals("test:TEST_00001", shortform); + } + + @Test + void shouldFindShortFormForWoman() { + OWLClass c = Class(IRI("http://www.example.org/#", "Woman")); + QNameShortFormProvider shortener = new QNameShortFormProvider(); + String shortform = shortener.getShortForm(c); + assertEquals("www:Woman", shortform); + } + + @Test + void shouldFindShortFormForSetPRefix() { + OWLClass c = Class(IRI("http://www.example.org/#", "Woman")); + Map prefixes = new HashMap<>(); + prefixes.put("test", "http://www.example.org/#"); + QNameShortFormProvider shortener = new QNameShortFormProvider(prefixes); + String shortform = shortener.getShortForm(c); + assertEquals("test:Woman", shortform); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/SimpleIRIShortFormProviderTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/SimpleIRIShortFormProviderTestCase.java new file mode 100644 index 0000000000..dcb969197b --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/SimpleIRIShortFormProviderTestCase.java @@ -0,0 +1,51 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.util.SimpleIRIShortFormProvider; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +class SimpleIRIShortFormProviderTestCase { + + @Test + void testFragmentShortForm() { + IRI iri = IRI("http://owl.cs.manchester.ac.uk/ontology/x#", "A"); + SimpleIRIShortFormProvider sfp = new SimpleIRIShortFormProvider(); + String shortForm = sfp.getShortForm(iri); + assertEquals("A", shortForm); + } + + @Test + void testLastPathShortForm() { + IRI iri = IRI("http://owl.cs.manchester.ac.uk/ontology/", "x"); + SimpleIRIShortFormProvider sfp = new SimpleIRIShortFormProvider(); + String shortForm = sfp.getShortForm(iri); + assertEquals("x", shortForm); + } + + @Test + void testEmptyPathShortForm() { + IRI iri = IRI("http://owl.cs.manchester.ac.uk/", ""); + SimpleIRIShortFormProvider sfp = new SimpleIRIShortFormProvider(); + String shortForm = sfp.getShortForm(iri); + assertEquals("", shortForm); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/TurtleTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/TurtleTestCase.java new file mode 100644 index 0000000000..f88a78a380 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/TurtleTestCase.java @@ -0,0 +1,454 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ClassAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NamedIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.contains; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.util.Set; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.RioTurtleDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.io.FileDocumentSource; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.PrefixManager; +import org.semanticweb.owlapi.util.DefaultPrefixManager; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +class TurtleTestCase extends TestBase { + + private static final OWLObjectProperty anonR = + ObjectProperty(iri("http://www.derivo.de/ontologies/examples/anonymous-individuals#", "r")); + private static final OWLClass taxTerm = + Class(IRI("http://schema.wolterskluwer.de/", "TaxonomyTerm")); + private static final OWLAnnotationProperty broader = + AnnotationProperty(IRI("http://www.w3.org/2004/02/skos/core#", "broader")); + static final OWLClass concept = Class(IRI("http://www.w3.org/2004/02/skos/core#", "Concept")); + private final IRI iri = iri("urn:test#", "literals"); + private final TurtleDocumentFormat tf = new TurtleDocumentFormat(); + private final IRI s = iri("urn:test#", "s"); + String NS = "http://example.com/ontology"; + IRI individualIRI = IRI.create("http://example.com/ontology/x,y"); + OWLNamedIndividual individual = df.getOWLNamedIndividual(individualIRI); + + private static String normalize(String s) { + return s.replaceAll("\r", "").replaceAll("\\n#.*", "").replaceAll("\\n+", "\n").trim(); + } + + @Test + void shouldSaveIRIsWithCommasInTurtle() + throws OWLOntologyCreationException, OWLOntologyStorageException { + OWLOntology o = m.createOntology(iri(TestFiles.NS)); + OWLAxiom axiom = df.getOWLDeclarationAxiom(individual); + o.add(axiom); + StringDocumentTarget t = new StringDocumentTarget(); + TurtleDocumentFormat turtleFormat = new TurtleDocumentFormat(); + turtleFormat.setDefaultPrefix("http://example.com/ontology/"); + o.saveOntology(turtleFormat, t); + String string = t.toString(); + OWLOntology o1 = loadOntologyFromString(string, new TurtleDocumentFormat()); + equal(o, o1); + } + + @Test + void shouldSaveIRIsWithCommasInRioTurtle() + throws OWLOntologyCreationException, OWLOntologyStorageException { + OWLOntology o = m.createOntology(iri(TestFiles.NS)); + OWLAxiom axiom = df.getOWLDeclarationAxiom(individual); + o.add(axiom); + StringDocumentTarget t = new StringDocumentTarget(); + RioTurtleDocumentFormat turtleFormat = new RioTurtleDocumentFormat(); + turtleFormat.setDefaultPrefix("http://example.com/ontology/"); + o.saveOntology(turtleFormat, t); + String string = t.toString(); + OWLOntology o1 = loadOntologyFromString(string, new RioTurtleDocumentFormat()); + equal(o, o1); + } + + @Test + void shouldSaveBaseIRINotOntologyInTurtle() + throws OWLOntologyCreationException, OWLOntologyStorageException { + String base = "urn:test:base#"; + OWLOntology o = m.createOntology(iri(TestFiles.NS, "")); + OWLNamedIndividual ind = df.getOWLNamedIndividual(iri(base, "i")); + OWLAxiom axiom = df.getOWLDeclarationAxiom(ind); + o.addAxiom(axiom); + StringDocumentTarget t = new StringDocumentTarget(); + TurtleDocumentFormat format = new TurtleDocumentFormat(); + format.setDefaultPrefix(base); + o.saveOntology(format, t); + String string = normalize(t.toString()); + assertEquals( + "@prefix : .\n" + "@prefix owl: .\n" + + "@prefix rdf: .\n" + + "@prefix xml: .\n" + + "@prefix xsd: .\n" + + "@prefix rdfs: .\n" + + "@base .\n" + + " rdf:type owl:Ontology .\n" + + ":i rdf:type owl:NamedIndividual .", + string); + OWLOntology o1 = loadOntologyFromString(string, format); + equal(o, o1); + } + + @Test + void shouldSaveBaseIRINotOntologyInRioTurtle() + throws OWLOntologyCreationException, OWLOntologyStorageException { + String base = "urn:test:base#"; + OWLOntology o = m.createOntology(iri(TestFiles.NS, "")); + OWLNamedIndividual ind = df.getOWLNamedIndividual(iri(base, "i")); + OWLAxiom axiom = df.getOWLDeclarationAxiom(ind); + o.getOWLOntologyManager().addAxiom(o, axiom); + StringDocumentTarget t = new StringDocumentTarget(); + RioTurtleDocumentFormat format = new RioTurtleDocumentFormat(); + format.setDefaultPrefix(base); + o.saveOntology(format, t); + String string = normalize(t.toString()); + assertEquals( + "@base .\n" + "@prefix : .\n" + + "@prefix owl: .\n" + + "@prefix rdf: .\n" + + "@prefix xml: .\n" + + "@prefix xsd: .\n" + + "@prefix rdfs: .\n" + + " a owl:Ontology .\n" + ":i a owl:NamedIndividual .", + string); + OWLOntology o1 = loadOntologyFromString(string, format); + equal(o, o1); + } + + @Test + void irisWithQuotesInTurtle() throws OWLOntologyCreationException { + OWLOntology o = m.createOntology(iri); + m.addAxiom(o, df.getOWLAnnotationAssertionAxiom(IRI.create("urn:test#s't"), + df.getOWLAnnotation(df.getRDFSLabel(), df.getOWLLiteral(true)))); + OWLOntology o1 = roundTrip(o, new TurtleDocumentFormat()); + equal(o, o1); + } + + @Test + void irisWithQuotesInRioTurtle() throws OWLOntologyCreationException { + OWLOntology o = m.createOntology(iri); + m.addAxiom(o, df.getOWLAnnotationAssertionAxiom(IRI.create("urn:test#s't"), + df.getOWLAnnotation(df.getRDFSLabel(), df.getOWLLiteral(true)))); + OWLOntology o1 = roundTrip(o, new RioTurtleDocumentFormat()); + equal(o, o1); + } + + @Test + void testLoadingUTF8BOM() throws Exception { + IRI uri = IRI.create(getClass().getResource("/ttl-with-bom.ttl").toURI()); + m.loadOntologyFromOntologyDocument(uri); + } + + static Stream tests() { + return Stream.of(Arguments.of(TestFiles.quotes1, " ''' "), + Arguments.of(TestFiles.quotes6, "3'''-acetate; [cut]"), + Arguments.of(TestFiles.quotes2, " \"\"\" "), Arguments.of(TestFiles.quotes3, " \"\"a "), + Arguments.of(TestFiles.quotes4, "\"\"\""), Arguments.of(TestFiles.quotes5, "\"\"a")); + } + + @ParameterizedTest + @MethodSource("tests") + void shouldParseFixedQuotesLiterals(String in, String literal) { + OWLOntology o = loadOntologyFromString(in, tf); + o.annotationAssertionAxioms(s) + .forEach(ax -> assertEquals(literal, ((OWLLiteral) ax.getValue()).getLiteral())); + } + + @Test + void shouldParseOntologyThatworked() { + // given + OWLAxiom expected = AnnotationAssertion(df.getRDFSIsDefinedBy(), + IRI("http://xmlns.com/foaf/0.1/", "fundedBy"), IRI("http://xmlns.com/foaf/0.1/", "")); + // when + OWLOntology o = loadOntologyFromString(TestFiles.workingOnto, new TurtleDocumentFormat()); + // then + assertTrue(o.containsAxiom(expected)); + } + + @Test + void shouldParseOntologyThatBroke() { + // given + OWLAxiom expected = + df.getOWLAnnotationAssertionAxiom(df.getOWLAnnotationProperty("urn:test/", "p"), + IRI("urn:test/", "r"), IRI("urn:test/", "")); + // when + OWLOntology o = loadOntologyFromString(TestFiles.brokenOnto, new TurtleDocumentFormat()); + // then + assertTrue(o.containsAxiom(expected)); + } + + @Test + void shouldResolveAgainstBase() { + // given + // when + OWLOntology o = + loadOntologyFromString(TestFiles.resolveAgainstBase, new TurtleDocumentFormat()); + // then + String axioms = o.axioms().iterator().next().toString(); + assertTrue(axioms.contains("http://test.org/a1")); + assertTrue(axioms.contains("http://test.org/b1")); + assertTrue(axioms.contains("http://test.org/c1")); + } + + // test for 3543488 + @Test + void shouldRoundTripTurtleWithsharedBnodes() { + masterConfigurator.withRemapAllAnonymousIndividualsIds(false); + try { + OWLOntology ontology = + loadOntologyFromString(TestFiles.turtleWithShared, new TurtleDocumentFormat()); + OWLOntology onto2 = roundTrip(ontology, new TurtleDocumentFormat()); + equal(ontology, onto2); + } finally { + masterConfigurator.withRemapAllAnonymousIndividualsIds(true); + } + } + + // test for 335 + @Test + void shouldParseScientificNotation() { + OWLOntology ontology = + loadOntologyFromString(TestFiles.scientificNotationPlus, new TurtleDocumentFormat()); + assertTrue(ontology.annotationPropertiesInSignature().anyMatch(ap -> ap.equals(areaTotal))); + assertTrue(ontology.containsAxiom(AnnotationAssertion(areaTotal, southAfrica, + Literal("1.0E7", OWL2Datatype.XSD_DOUBLE)))); + } + + @Test + void shouldParseScientificNotationWithMinus() { + OWLOntology ontology = loadOntologyFromString(TestFiles.scientificNotationWithMinus, + new TurtleDocumentFormat()); + assertTrue(ontology.annotationPropertiesInSignature().anyMatch(ap -> ap.equals(areaTotal))); + assertTrue( + ontology.containsAxiom(AnnotationAssertion(areaTotal, southAfrica, oneMillionth))); + } + + @Test + void shouldParseScientificNotationWithMinusFromBug() { + loadOntologyFromString(TestFiles.scientificNotation, new TurtleDocumentFormat()); + } + + @Test + void shouldParseTwo() { + OWLOntology ontology = + loadOntologyFromString(TestFiles.parseTwo, new TurtleDocumentFormat()); + assertTrue(ontology.annotationPropertiesInSignature().anyMatch(ap -> ap.equals(areaTotal))); + assertTrue(ontology.containsAxiom(AnnotationAssertion(areaTotal, southAfrica, Literal(1)))); + } + + @Test + void shouldParseOne() { + OWLOntology ontology = + loadOntologyFromString(TestFiles.parseOne, new TurtleDocumentFormat()); + assertTrue(ontology.annotationPropertiesInSignature().anyMatch(ap -> ap.equals(areaTotal))); + assertTrue(ontology.containsAxiom( + AnnotationAssertion(areaTotal, southAfrica, Literal("1.0", OWL2Datatype.XSD_DECIMAL)))); + } + + @Test + void shouldParseEmptySpaceInBnode() { + OWLOntology ontology = + loadOntologyFromString(TestFiles.emptySpaceInBnode, new TurtleDocumentFormat()); + OWLIndividual ind = + NamedIndividual(iri("http://taxonomy.wolterskluwer.de/practicearea/", "10112")); + assertTrue(ontology.containsAxiom(ClassAssertion(concept, ind))); + assertTrue(ontology.containsAxiom(ClassAssertion(taxTerm, ind))); + assertTrue(ontology.containsEntityInSignature(broader)); + } + + @Test + void shouldRoundTripAxiomAnnotation() { + masterConfigurator.withRemapAllAnonymousIndividualsIds(false); + try { + OWLOntology ontology = + loadOntologyFromString(TestFiles.axiomAnnotations, new TurtleDocumentFormat()); + OWLOntology o = roundTrip(ontology, new TurtleDocumentFormat()); + equal(ontology, o); + Set axioms = asUnorderedSet(o.axioms(AxiomType.SUBCLASS_OF)); + assertEquals(1, axioms.size()); + OWLAnnotation next = axioms.iterator().next().annotations().iterator().next(); + assertTrue(next.getValue() instanceof OWLAnonymousIndividual); + OWLAnonymousIndividual ind = (OWLAnonymousIndividual) next.getValue(); + Set anns = + asUnorderedSet(o.axioms().filter(ax -> contains(ax.anonymousIndividuals(), ind))); + assertEquals(3, anns.size()); + } finally { + masterConfigurator.withRemapAllAnonymousIndividualsIds(true); + } + } + + @Test + void shouldRoundTripAxiomAnnotationWithSlashOntologyIRI() { + OWLOntology in = + loadOntologyFromString(TestFiles.slashOntologyIRI, new TurtleDocumentFormat()); + String string = "urn:test#test.owl/"; + OWLOntology ontology = getOWLOntology(iri(string, "")); + ontology.add( + df.getOWLSubClassOfAxiom(df.getOWLClass(string, "t"), df.getOWLClass(string, "q"))); + OWLOntology o = roundTrip(ontology, new TurtleDocumentFormat()); + equal(o, in); + } + + @Test + void presentDeclaration() { + // when + OWLOntology o = + loadOntologyFromString(TestFiles.presentDeclaration, new TurtleDocumentFormat()); + // then + o.logicalAxioms().forEach(ax -> assertTrue(ax instanceof OWLObjectPropertyDomainAxiom)); + } + + @Test + void missingDeclaration() { + // when + OWLOntology o = + loadOntologyFromString(TestFiles.missingDeclaration, new TurtleDocumentFormat()); + // then + o.logicalAxioms() + .forEach(ax -> assertTrue(ax instanceof OWLObjectPropertyDomainAxiom, ax.toString())); + } + + @Test + void shouldReloadSamePrefixAbbreviations() { + OWLOntology o = + loadOntologyFromString(TestFiles.prefixAbbreviations, new RioTurtleDocumentFormat()); + StringDocumentTarget t = saveOntology(o); + assertTrue(t.toString().contains("ABA:10")); + } + + @Test + void shouldFindExpectedAxiomsForBlankNodes() { + OWLOntology o = + loadOntologyFromString(TestFiles.axiomsForBlankNodes, new TurtleDocumentFormat()); + o.axioms(AxiomType.CLASS_ASSERTION).forEach(ax -> { + OWLAxiom expected = df.getOWLObjectPropertyAssertionAxiom(anonR, ax.getIndividual(), + ax.getIndividual()); + assertTrue(o.containsAxiom(expected), expected + " not found"); + }); + } + + @Test + void shouldAllowMultipleDotsInIRIs() throws OWLOntologyCreationException { + IRI test1 = IRI.create("http://www.semanticweb.org/ontology#A..."); + IRI test2 = IRI.create("http://www.semanticweb.org/ontology#A...B"); + OWLOntology o = m.createOntology(IRI.create("http://www.semanticweb.org/ontology")); + o.addAxiom(df.getOWLDeclarationAxiom(df.getOWLClass(test1))); + o.addAxiom(df.getOWLDeclarationAxiom(df.getOWLClass(test2))); + TurtleDocumentFormat format = new TurtleDocumentFormat(); + format.setDefaultPrefix("http://www.semanticweb.org/ontology#"); + roundTrip(o, format); + } + + @Test + void shouldSaveWithCorrectPrefixes() { + OWLOntology ont = + loadOntologyFromString(TestFiles.correctPrefix, new TurtleDocumentFormat()); + OWLDocumentFormat ofmt = new TurtleDocumentFormat(); + ofmt.asPrefixOWLDocumentFormat().setPrefix("OBO", "http://purl.obolibrary.org/obo/"); + StringDocumentTarget result = saveOntology(ont, ofmt); + OWLOntology o1 = loadOntologyFromString(result, new TurtleDocumentFormat()); + equal(ont, o1); + } + + @Test + void shouldSaveWithCorrectSlashPrefixes() { + OWLOntology ont = loadOntologyFromString(TestFiles.slashPrefix, new TurtleDocumentFormat()); + OWLDocumentFormat ofmt = new TurtleDocumentFormat(); + ofmt.asPrefixOWLDocumentFormat().setPrefix("OBO", "http://purl.obolibrary.org/obo/"); + StringDocumentTarget result = saveOntology(ont, ofmt); + OWLOntology o1 = loadOntologyFromString(result, new TurtleDocumentFormat()); + equal(ont, o1); + } + + @Test + void shouldUseRightPrefixesWithPercentURLs() + throws OWLOntologyCreationException, OWLOntologyStorageException { + PrefixManager basePrefix = new DefaultPrefixManager("http://www.example.com#"); + OWLOntology ontology = m.createOntology(IRI.create("http://www.example.com")); + OWLObjectProperty owlObjectP = df.getOWLObjectProperty("has%20space", basePrefix); + OWLClass domain = df.getOWLClass("domain1", basePrefix); + ontology.add(df.getOWLObjectPropertyDomainAxiom(owlObjectP, domain)); + TurtleDocumentFormat turtle = new TurtleDocumentFormat(); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + ontology.saveOntology(turtle, out); + String string = out.toString(); + assertTrue( + string.contains(" rdf:type owl:ObjectProperty"), + string); + } + + @Test + void sameFileShouldParseToSameOntology() throws OWLOntologyCreationException { + File file = new File(RESOURCES, "noBaseEscapedSlashes.ttl"); + OWLOntology o1 = m1.loadOntologyFromOntologyDocument( + new FileDocumentSource(file, new TurtleDocumentFormat())); + OWLOntology o2 = m1.loadOntologyFromOntologyDocument( + new FileDocumentSource(file, new RioTurtleDocumentFormat())); + equal(o1, o2); + } + + @Test + void shouldParseEscapedCharacters() throws OWLOntologyCreationException { + OWLOntology ont = m1.loadOntologyFromOntologyDocument(new FileDocumentSource( + new File(RESOURCES, "noBaseEscapedSlashes.ttl"), new TurtleDocumentFormat())); + OWLOntology o1 = roundTrip(ont, new TurtleDocumentFormat()); + equal(ont, o1); + } + + @Test + void shouldParseWithBase() throws OWLOntologyCreationException { + OWLOntology ont = m1.loadOntologyFromOntologyDocument(new FileDocumentSource( + new File(RESOURCES, "noBaseEscapedSlashes.ttl"), new RioTurtleDocumentFormat())); + OWLOntology o1 = roundTrip(ont, new RioTurtleDocumentFormat()); + equal(ont, o1); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/Utf8TestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/Utf8TestCase.java new file mode 100644 index 0000000000..e496dc3347 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/Utf8TestCase.java @@ -0,0 +1,123 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.RDFSLabel; +import static org.semanticweb.owlapi.search.EntitySearcher.getAnnotationObjects; + +import java.io.ByteArrayInputStream; +import java.nio.charset.StandardCharsets; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.io.StreamDocumentSource; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.owlxml.parser.OWLXMLParser; + +class Utf8TestCase extends TestBase { + + @Test + void testUTF8roundTrip() throws Exception { + saveOntology(loadOntologyFromString(TestFiles.roundtripUTF8String, + new FunctionalSyntaxDocumentFormat())); + } + + @Test + void testInvalidUTF8roundTripOWLXML() { + // this test checks for the condition described in issue #47 + // Input with character = 0240 (octal) should fail parsing but is read + // in as an owl/xml file + ByteArrayInputStream in = + new ByteArrayInputStream(TestFiles.INVALID_UTF8.getBytes(StandardCharsets.ISO_8859_1)); + OWLXMLParser parser = new OWLXMLParser(); + assertThrows(Exception.class, + () -> parser.parse(new StreamDocumentSource(in), getOWLOntology(), config)); + // expected to fail, but actual exception depends on the parsers in + // the classpath + } + + @Test + void testInvalidUTF8roundTripWithInputStream() throws OWLOntologyCreationException { + // this test checks for the condition described in issue #47 + // Input with character = 0240 (octal) should work with an input stream, + // not with a reader + ByteArrayInputStream in = + new ByteArrayInputStream(TestFiles.INVALID_UTF8.getBytes(StandardCharsets.ISO_8859_1)); + m.loadOntologyFromOntologyDocument(in); + } + + @Test + void testInvalidUTF8roundTripFromReader() { + // this test checks for the condition described in issue #47 + // Input with character = 0240 (octal) should work with an input stream, + // not with a reader + assertThrows(OWLRuntimeException.class, + () -> loadOntologyFromString(TestFiles.INVALID_UTF8, new RDFXMLDocumentFormat())); + } + + @Test + void testPositiveUTF8roundTrip() throws Exception { + String ns = "http://protege.org/UTF8.owl"; + OWLOntology ontology = getOWLOntology(); + OWLClass a = Class(IRI(ns + "#", "A")); + ontology.add(df.getOWLDeclarationAxiom(a)); + OWLAnnotation ann = df.getRDFSLabel("Chinese=處方"); + OWLAxiom axiom = df.getOWLAnnotationAssertionAxiom(a.getIRI(), ann); + ontology.add(axiom); + ontology = roundTrip(ontology, new FunctionalSyntaxDocumentFormat()); + } + + @Test + void testRoundTrip() throws Exception { + String ns = "http://protege.org/ontologies/UTF8RoundTrip.owl"; + OWLClass c = Class(IRI(ns + "#", "C")); + /* + * The two unicode characters entered here are valid and can be found in the code chart + * http://www.unicode.org/charts/PDF/U4E00.pdf. It has been said that they are chinese and + * they do look the part. In UTF-8 these characters are encoded as \u8655 --> \350\231\225 + * \u65b9 --> \346\226\271 where the right hand side is in octal. (I chose octal because + * this is how emacs represents it with find-file-literally). + */ + String chinese = "Rx\u8655\u65b9"; + System.setProperty("file.encoding", "UTF-8"); + OWLOntology ontology = createOriginalOntology(ns, c, chinese); + checkOntology(ontology, c, chinese); + OWLOntology newOntology = roundTrip(ontology, new RDFXMLDocumentFormat()); + checkOntology(newOntology, c, chinese); + } + + private OWLOntology createOriginalOntology(String ns, OWLClass c, String chinese) { + OWLOntology ontology = getOWLOntology(IRI(ns, "")); + OWLAxiom annotationAxiom = AnnotationAssertion(RDFSLabel(), c.getIRI(), Literal(chinese)); + ontology.add(annotationAxiom); + return ontology; + } + + private static boolean checkOntology(OWLOntology ontology, OWLClass c, String chinese) { + return getAnnotationObjects(c, ontology) + .anyMatch(a -> a.getValue().asLiteral().get().getLiteral().equals(chinese)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/XMLUtilsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/XMLUtilsTestCase.java new file mode 100644 index 0000000000..bbaa54cca3 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/XMLUtilsTestCase.java @@ -0,0 +1,85 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.io.XMLUtils; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.3.0 + */ +class XMLUtilsTestCase extends TestBase { + + private static final int CODE_POINT = 0xEFFFF; + private static final String CODE_POINT_STRING = init(); + + static String init() { + StringBuilder sb = new StringBuilder(); + sb.appendCodePoint(CODE_POINT); + return sb.toString(); + } + + @Test + void testIsNCName() { + assertTrue(XMLUtils.isNCName(CODE_POINT_STRING + "abc" + CODE_POINT_STRING)); + assertTrue(XMLUtils.isNCName(CODE_POINT_STRING + "abc123" + CODE_POINT_STRING)); + assertFalse(XMLUtils.isNCName("123" + CODE_POINT_STRING)); + assertFalse(XMLUtils.isNCName(CODE_POINT_STRING + ":a")); + assertFalse(XMLUtils.isNCName("")); + assertFalse(XMLUtils.isNCName(null)); + } + + @Test + void testIsQName() { + assertTrue(XMLUtils.isQName(CODE_POINT_STRING + "p1:abc" + CODE_POINT_STRING)); + assertFalse(XMLUtils.isQName(CODE_POINT_STRING + "p1:2abc" + CODE_POINT_STRING)); + assertFalse(XMLUtils.isQName("11" + CODE_POINT_STRING + ":abc" + CODE_POINT_STRING)); + assertFalse(XMLUtils.isQName("ab:c%20d")); + } + + @Test + void testEndsWithNCName() { + assertEquals("abc" + CODE_POINT_STRING, + XMLUtils.getNCNameSuffix("1abc" + CODE_POINT_STRING)); + assertTrue(XMLUtils.hasNCNameSuffix("1abc" + CODE_POINT_STRING)); + assertNull(XMLUtils.getNCNameSuffix(CODE_POINT_STRING + "p1:123")); + assertFalse(XMLUtils.hasNCNameSuffix(CODE_POINT_STRING + "p1:123")); + assertEquals("ABC", XMLUtils.getNCNameSuffix("http://owlapi.sourceforge.net/ontology/ABC")); + assertEquals("ABC", XMLUtils.getNCNameSuffix("http://owlapi.sourceforge.net/ontology#ABC")); + assertEquals("ABC", XMLUtils.getNCNameSuffix("http://owlapi.sourceforge.net/ontology:ABC")); + } + + @Test + void testParsesBNode() { + assertEquals("_:test", XMLUtils.getNCNamePrefix("_:test")); + assertNull(XMLUtils.getNCNameSuffix("_:test")); + } + + @Test + void testmissingTypes() { + OWLOntology o = loadOntologyFromString(TestFiles.missingTypes, + IRI.getNextDocumentIRI("testuriwithblankspace"), new RDFXMLDocumentFormat()); + assertEquals(15, o.getAxiomCount()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/manchester/ManchesterSyntaxParserTest.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/manchester/ManchesterSyntaxParserTest.java new file mode 100644 index 0000000000..62d6cbce2f --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/manchester/ManchesterSyntaxParserTest.java @@ -0,0 +1,61 @@ +package org.semanticweb.owlapi.api.test.syntax.manchester; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.util.Arrays; +import java.util.Collection; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.expression.OWLEntityChecker; +import org.semanticweb.owlapi.expression.ShortFormEntityChecker; +import org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxClassExpressionParser; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.util.BidirectionalShortFormProviderAdapter; +import org.semanticweb.owlapi.util.SimpleShortFormProvider; +import org.semanticweb.owlapi.vocab.OWL2Datatype; + +class ManchesterSyntaxParserTest extends TestBase { + + public static Collection data() { + // can't use df at this point - it has not been initialised yet + OWLDataFactory datafactory = OWLManager.getOWLDataFactory(); + OWLDataProperty hasAge = + datafactory.getOWLDataProperty(iri("http://example.org/", "hasAge")); + return Arrays.asList( + //@formatter:off + new Object[] { "hasAge exactly 1 xsd:int", datafactory.getOWLDataExactCardinality(1, hasAge, OWL2Datatype.XSD_INT) }, + new Object[] { "hasAge exactly 1", datafactory.getOWLDataExactCardinality(1, hasAge)}, + new Object[] { "hasAge min 1 xsd:int", datafactory.getOWLDataMinCardinality(1, hasAge, OWL2Datatype.XSD_INT)}, + new Object[] { "hasAge min 1", datafactory.getOWLDataMinCardinality(1, hasAge)}, + new Object[] { "hasAge max 1 xsd:int", datafactory.getOWLDataMaxCardinality(1, hasAge, OWL2Datatype.XSD_INT)}, + new Object[] { "hasAge max 1", datafactory.getOWLDataMaxCardinality(1, hasAge)}); + //@formatter:on + } + + @ParameterizedTest + @MethodSource("data") + public void testParseDataCardinalityExpression(String input, Object expected) + throws OWLOntologyCreationException { + OWLDataProperty hasAge = df.getOWLDataProperty(iri("http://example.org/", "hasAge")); + OWLOntology ont = m.createOntology(); + ont.addAxiom(df.getOWLDeclarationAxiom(hasAge)); + ManchesterOWLSyntaxClassExpressionParser parser = + new ManchesterOWLSyntaxClassExpressionParser(df, checker(m)); + assertEquals(expected, parser.parse(input)); + } + + protected OWLEntityChecker checker(OWLOntologyManager manager) { + BidirectionalShortFormProviderAdapter adapter = new BidirectionalShortFormProviderAdapter( + asList(manager.ontologies()), new SimpleShortFormProvider()); + return new ShortFormEntityChecker(adapter); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/package-info.java new file mode 100644 index 0000000000..36589a52a0 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.api.test.syntax; diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdf/BOMSafeInputStreamAndParseTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdf/BOMSafeInputStreamAndParseTestCase.java new file mode 100644 index 0000000000..f680cc773e --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdf/BOMSafeInputStreamAndParseTestCase.java @@ -0,0 +1,78 @@ +package org.semanticweb.owlapi.api.test.syntax.rdf; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.io.ReaderDocumentSource; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; + +class BOMSafeInputStreamAndParseTestCase extends TestBase { + + static final String RESEARCHER = ""; + static final String ISA14_O = "http://www.example.org/ISA14#o"; + + static Collection data() { + List toReturn = new ArrayList<>(); + List list = Arrays.asList(" ", + "Ontology: <" + IRI.getNextDocumentIRI(ISA14_O) + ">\nClass: " + RESEARCHER, + "Ontology(<" + IRI.getNextDocumentIRI(ISA14_O) + ">\nDeclaration(Class(" + RESEARCHER + + ")))", + "@prefix owl: .\n@prefix rdf: .\n<" + + IRI.getNextDocumentIRI(ISA14_O) + "> rdf:type owl:Ontology .\n" + RESEARCHER + + " rdf:type owl:Class .", + ""); + List prefixes = + Arrays.asList(new int[] {0x00, 0x00, 0xFE, 0xFF}, new int[] {0xFF, 0xFE, 0x00, 0x00}, + new int[] {0xFF, 0xFE}, new int[] {0xFE, 0xFF}, new int[] {0xEF, 0xBB, 0xBF}); + for (int[] p : prefixes) { + for (String s : list) { + toReturn.add(Arguments.of(p, s)); + } + } + return toReturn; + } + + private static InputStream in(int[] b, String s) throws IOException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + for (int i : b) { + out.write(i); + } + out.write(s.getBytes()); + byte[] byteArray = out.toByteArray(); + return new ByteArrayInputStream(byteArray); + } + + // Bytes Encoding Form + // 00 00 FE FF | UTF-32, big-endian + // FF FE 00 00 | UTF-32, little-endian + // FE FF |UTF-16, big-endian + // FF FE |UTF-16, little-endian + // EF BB BF |UTF-8 + @ParameterizedTest + @MethodSource("data") + void testBOMError32big(int[] b, String input) throws OWLOntologyCreationException, IOException { + m.loadOntologyFromOntologyDocument(in(b, input)); + } + + @ParameterizedTest + @MethodSource("data") + void testBOMError32bigReader(int[] b, String input) + throws OWLOntologyCreationException, IOException { + m.loadOntologyFromOntologyDocument( + new ReaderDocumentSource(new InputStreamReader(in(b, input)))); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdf/DisjointsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdf/DisjointsTestCase.java new file mode 100644 index 0000000000..8aa04ad47c --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdf/DisjointsTestCase.java @@ -0,0 +1,94 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax.rdf; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.createClass; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.createObjectProperty; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.contains; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLRuntimeException; + +/** + * Test cases for rendering of disjoint axioms. The OWL 1.1 specification makes it possible to + * specify that a set of classes are mutually disjoint. Unfortunately, this must be represented in + * RDF as a set of pairwise disjoint statements. In other words, DisjointClasses(A, B, C) must be + * represented as DisjointWith(A, B), DisjointWith(A, C) DisjointWith(B, C). ~This test case ensure + * that these axioms are serialsed correctly. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +class DisjointsTestCase extends TestBase { + + @Test + void testAnonDisjoints() throws Exception { + OWLOntology ontA = getOWLOntology(); + OWLClass clsA = createClass(); + OWLClass clsB = createClass(); + OWLObjectProperty prop = createObjectProperty(); + OWLClassExpression descA = df.getOWLObjectSomeValuesFrom(prop, clsA); + OWLClassExpression descB = df.getOWLObjectSomeValuesFrom(prop, clsB); + Set classExpressions = new HashSet<>(); + classExpressions.add(descA); + classExpressions.add(descB); + OWLAxiom ax = df.getOWLDisjointClassesAxiom(classExpressions); + ontA.add(ax); + OWLOntology ontB = roundTrip(ontA); + assertTrue(contains(ontB.axioms(), ax)); + } + + @Test + void shouldAcceptSingleDisjointAxiom() { + // The famous idiomatic use of DisjointClasses with one operand + OWLClass t = df.getOWLClass("urn:test:class"); + OWLDisjointClassesAxiom ax = df.getOWLDisjointClassesAxiom(Arrays.asList(t)); + assertEquals(df.getOWLDisjointClassesAxiom(Arrays.asList(t, df.getOWLThing())), + ax.getAxiomWithoutAnnotations()); + OWLLiteral value = df.getOWLLiteral( + "DisjointClasses() replaced by DisjointClasses( owl:Thing)"); + OWLAnnotation a = ax.annotationsAsList().get(0); + assertEquals(value, a.getValue()); + assertEquals(df.getRDFSComment(), a.getProperty()); + } + + @Test + void shouldRejectDisjointClassesWithSingletonThing() { + assertThrows(OWLRuntimeException.class, + () -> df.getOWLDisjointClassesAxiom(Arrays.asList(df.getOWLThing())), + "DisjointClasses(owl:Thing) cannot be created. It is not a syntactically valid OWL 2 axiom. If the intent is to declare owl:Thing as disjoint with itself and therefore empty, it cannot be created as a DisjointClasses axiom. Please rewrite it as SubClassOf(owl:Thing, owl:Nothing)."); + } + + @Test + void shouldRejectDisjointClassesWithSingletonNothing() { + assertThrows(OWLRuntimeException.class, + () -> df.getOWLDisjointClassesAxiom(Arrays.asList(df.getOWLNothing())), + "DisjointClasses(owl:Nothing) cannot be created. It is not a syntactically valid OWL 2 axiom. If the intent is to declare owl:Nothing as disjoint with itself and therefore empty, it cannot be created as a DisjointClasses axiom, and it is also redundant as owl:Nothing is always empty. Please rewrite it as SubClassOf(owl:Nothing, owl:Nothing) or remove the axiom."); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdf/RendererAndParserTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdf/RendererAndParserTestCase.java new file mode 100644 index 0000000000..236750c402 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdf/RendererAndParserTestCase.java @@ -0,0 +1,100 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax.rdf; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.createClass; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.createDataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.createIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.createObjectProperty; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.Arrays; +import java.util.List; +import java.util.Set; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLLogicalAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.rdf.rdfxml.parser.RDFXMLParserFactory; +import org.semanticweb.owlapi.rdf.rdfxml.renderer.RDFXMLStorerFactory; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +class RendererAndParserTestCase extends TestBase { + + static List getData() { + return Arrays.asList( + // AnonymousIndividual + df.getOWLClassAssertionAxiom(df.getOWLObjectComplementOf(createClass()), + createIndividual()), + // ClassAssertionAxioms + df.getOWLClassAssertionAxiom(createClass(), createIndividual()), + // DifferentIndividualsAxiom + df.getOWLDifferentIndividualsAxiom(createIndividual(), createIndividual(), + createIndividual(), createIndividual(), createIndividual()), + // EquivalentClasses + df.getOWLEquivalentClassesAxiom(createClass(), + df.getOWLObjectSomeValuesFrom(createObjectProperty(), df.getOWLThing())), + // NegativeDataPropertyAssertionAxiom + df.getOWLNegativeDataPropertyAssertionAxiom(createDataProperty(), createIndividual(), + df.getOWLLiteral("TestConstant")), + // NegativeObjectPropertyAssertionAxiom + df.getOWLNegativeObjectPropertyAssertionAxiom(createObjectProperty(), + createIndividual(), createIndividual()), + // QCR + df.getOWLSubClassOfAxiom(createClass(), + df.getOWLObjectMinCardinality(3, createObjectProperty(), + df.getOWLObjectIntersectionOf(createClass(), createClass())))); + } + + @BeforeEach + void setUpManager() { + m.getOntologyStorers().set(new RDFXMLStorerFactory()); + m.getOntologyParsers().set(new RDFXMLParserFactory()); + } + + @ParameterizedTest + @MethodSource("getData") + void testSaveAndReload(OWLAxiom axioms) { + OWLOntology ontA = getOWLOntology(); + ontA.add(axioms); + OWLOntology ontB = roundTrip(ontA); + Set aMinusB = asUnorderedSet(ontA.logicalAxioms()); + ontB.axioms().forEach(aMinusB::remove); + Set bMinusA = asUnorderedSet(ontB.logicalAxioms()); + ontA.axioms().forEach(bMinusA::remove); + StringBuilder msg = new StringBuilder(); + if (aMinusB.isEmpty() && bMinusA.isEmpty()) { + msg.append("Ontology save/load roundtrip OK.\n"); + } else { + msg.append("Ontology save/load roundtripping error.\n"); + msg.append("=> ").append(aMinusB.size()).append(" axioms lost in roundtripping.\n"); + for (OWLAxiom axiom : aMinusB) { + msg.append(axiom).append("\n"); + } + msg.append("=> ").append(bMinusA.size()).append(" axioms added after roundtripping.\n"); + for (OWLAxiom axiom : bMinusA) { + msg.append(axiom).append("\n"); + } + } + assertTrue(aMinusB.isEmpty() && bMinusA.isEmpty(), msg.toString()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdf/UndeclaredAnnotationTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdf/UndeclaredAnnotationTestCase.java new file mode 100644 index 0000000000..0e1469def1 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdf/UndeclaredAnnotationTestCase.java @@ -0,0 +1,88 @@ +package org.semanticweb.owlapi.api.test.syntax.rdf; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.io.StringDocumentSource; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnonymousIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration; + +/** + * Created by ses on 3/10/14. + */ +class UndeclaredAnnotationTestCase extends TestBase { + + @Test + void testRDFXMLUsingUndeclaredAnnotationProperty() throws OWLOntologyCreationException { + OWLOntology oo = loadOntologyFromString(TestFiles.undeclaredAnnotationProperty, + new RDFXMLDocumentFormat()); + RDFXMLDocumentFormat format = (RDFXMLDocumentFormat) oo.getNonnullFormat(); + assertTrue(format.getOntologyLoaderMetaData().isPresent()); + assertEquals(0, format.getOntologyLoaderMetaData().get().getUnparsedTriples().count()); + Set annotationAxioms = + asUnorderedSet(oo.axioms(AxiomType.ANNOTATION_ASSERTION)); + assertEquals(2, annotationAxioms.size()); + OWLAnnotationProperty relProperty = + df.getOWLAnnotationProperty("http://example.com/ns#", "rel"); + OWLAnnotationProperty predProperty = + df.getOWLAnnotationProperty("http://example.com/ns#", "pred"); + Set anonymousIndividualSet = + asUnorderedSet(oo.anonymousIndividuals()); + assertEquals(1, anonymousIndividualSet.size()); + OWLAnonymousIndividual anonymousIndividual = anonymousIndividualSet.iterator().next(); + OWLAnnotationAssertionAxiom relAx = df.getOWLAnnotationAssertionAxiom(relProperty, + iri("http://example.com/ns#", "test"), anonymousIndividual); + OWLLiteral notVisible = df.getOWLLiteral("Not visible", ""); + OWLAnnotationAssertionAxiom predAx = + df.getOWLAnnotationAssertionAxiom(predProperty, anonymousIndividual, notVisible); + assertTrue(annotationAxioms.contains(relAx)); + assertTrue(annotationAxioms.contains(predAx)); + } + + @Test + void testTurtleUsingUndeclaredAnnotationProperty() { + OWLOntology o = loadOntologyFromString(TestFiles.undeclaredAnnotationPropertyTurtle, + new TurtleDocumentFormat()); + OWLAnnotationProperty pred = df.getOWLAnnotationProperty("http://www.example.org/", "pred"); + AtomicInteger countLabels = new AtomicInteger(); + AtomicInteger countPreds = new AtomicInteger(); + AtomicInteger countBNodeAnnotations = new AtomicInteger(); + o.axioms(AxiomType.ANNOTATION_ASSERTION).forEach(oa -> { + if (oa.getProperty().equals(df.getRDFSLabel())) { + countLabels.incrementAndGet(); + } + if (oa.getProperty().equals(pred)) { + countPreds.incrementAndGet(); + } + if (oa.getSubject() instanceof OWLAnonymousIndividual) { + countBNodeAnnotations.incrementAndGet(); + } + }); + assertEquals(3, countPreds.intValue()); + assertEquals(2, countLabels.intValue()); + assertEquals(3, countBNodeAnnotations.intValue()); + } + + @Test + void shouldThrowAnExceptionOnError1AndStrictParsing() { + OWLOntology o = + loadOntologyWithConfig(new StringDocumentSource(TestFiles.error1OnStrictParsing), + new OWLOntologyLoaderConfiguration().setStrict(true)); + assertEquals(0, o.getLogicalAxiomCount()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdf/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdf/package-info.java new file mode 100644 index 0000000000..a0a0941820 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdf/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.api.test.syntax.rdf; diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/EntitiesTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/EntitiesTestCase.java new file mode 100644 index 0000000000..f8c3ad2dc9 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/EntitiesTestCase.java @@ -0,0 +1,33 @@ +package org.semanticweb.owlapi.api.test.syntax.rdfxml; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.io.StringDocumentSource; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.OWLOntology; + +class EntitiesTestCase extends TestBase { + + @Test + void shouldRoundtripEntities() throws Exception { + OWLOntology o = loadOntologyFromString(new StringDocumentSource(TestFiles.roundtripEntities, + iri("urn:test#", "test"), new RDFXMLDocumentFormat(), null)); + o.getOWLOntologyManager().getOntologyConfigurator().withUseNamespaceEntities(true); + StringDocumentTarget o2 = saveOntology(o); + assertTrue(o2.toString().contains("")); + } + + @Test + void shouldNotIncludeExternalEntities() throws Exception { + OWLOntology o = loadOntologyFromString(TestFiles.doNotIncludeExternalEntities, + new RDFXMLDocumentFormat()); + OWLOntology o1 = m.createOntology(); + o1.add(df.getOWLAnnotationAssertionAxiom(df.getRDFSComment(), iri("urn:test:", "i"), + df.getOWLLiteral(""))); + equal(o, o1); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/EquivalentAndSubclassTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/EquivalentAndSubclassTestCase.java new file mode 100644 index 0000000000..c3b41fd312 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/EquivalentAndSubclassTestCase.java @@ -0,0 +1,113 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax.rdfxml; + +import java.util.HashSet; +import java.util.Set; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectCardinalityRestriction; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyID; + +/** + * Tests the loading of a single ontology multiple times, using the same ontologyIRI in the + * {@link OWLOntologyID} as that used in the actual ontology that is being imported. + * + * @author Peter Ansell p_ansell@yahoo.com + */ +class EquivalentAndSubclassTestCase extends TestBase { + + @Test + void testRoundtrip() throws Exception { + // given + OWLOntology o = loadOntologyFromString(TestFiles.equivalentAndSubclasses, + new ManchesterSyntaxDocumentFormat()); + relax(o); + OWLOntology o2 = roundTrip(o, new RDFXMLDocumentFormat()); + equal(o, o2); + } + + static void relax(OWLOntology ontology) { + Set newAxioms = new HashSet<>(); + ontology.axioms(AxiomType.EQUIVALENT_CLASSES).forEach(ax -> { + ax.operands().forEach(x -> { + // we only relax in cases where the equivalence is between one + // named and one anon expression + if (!x.isAnonymous()) { + OWLClass c = (OWLClass) x; + // ax = EquivalentClasses(x y1 y2 ...) + for (OWLClassExpression y : ax.getClassExpressionsMinus(c)) { + // limited structural reasoning: + // return (P some Z), if: + // - y is of the form (P some Z) + // - y is of the form ((P some Z) and ...), + // or any level of nesting + for (OWLObjectSomeValuesFrom svf : getSomeValuesFromAncestor(y, df)) { + newAxioms.add(df.getOWLSubClassOfAxiom(c, svf)); + } + for (OWLClass z : getNamedAncestors(y)) { + newAxioms.add(df.getOWLSubClassOfAxiom(c, z)); + } + } + } + }); + }); + // remove redundant axiom + ontology.addAxioms(newAxioms); + } + + private static Set getSomeValuesFromAncestor(OWLClassExpression x, + OWLDataFactory dataFactory) { + Set svfs = new HashSet<>(); + if (x instanceof OWLObjectSomeValuesFrom) { + OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom) x; + svfs.add(svf); + } else if (x instanceof OWLObjectCardinalityRestriction) { + OWLObjectCardinalityRestriction ocr = (OWLObjectCardinalityRestriction) x; + OWLClassExpression filler = ocr.getFiller(); + OWLObjectPropertyExpression p = ocr.getProperty(); + if (ocr.getCardinality() > 0) { + OWLObjectSomeValuesFrom svf = dataFactory.getOWLObjectSomeValuesFrom(p, filler); + svfs.add(svf); + } + } else if (x instanceof OWLObjectIntersectionOf) { + ((OWLObjectIntersectionOf) x).operands() + .forEach(op -> svfs.addAll(getSomeValuesFromAncestor(op, dataFactory))); + } + return svfs; + } + + private static Set getNamedAncestors(OWLClassExpression x) { + Set cs = new HashSet<>(); + if (!x.isAnonymous()) { + cs.add(x.asOWLClass()); + } else if (x instanceof OWLObjectIntersectionOf) { + ((OWLObjectIntersectionOf) x).operands() + .forEach(op -> cs.addAll(getNamedAncestors(op))); + } + return cs; + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/MultipleDistinctOntologyLoadsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/MultipleDistinctOntologyLoadsTestCase.java new file mode 100644 index 0000000000..e19f7f1eb4 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/MultipleDistinctOntologyLoadsTestCase.java @@ -0,0 +1,162 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax.rdfxml; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.File; +import java.net.URISyntaxException; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.io.FileDocumentSource; +import org.semanticweb.owlapi.io.OWLOntologyDocumentSource; +import org.semanticweb.owlapi.io.OWLParser; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyAlreadyExistsException; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.rdf.rdfxml.parser.RDFXMLParser; + +/** + * Tests the loading of a single ontology multiple times, using a different ontologyIRI in the + * OWLOntologyID as that used in the actual ontology that is being imported. + * + * @author Peter Ansell p_ansell@yahoo.com + */ +class MultipleDistinctOntologyLoadsTestCase extends TestBase { + + IRI jb = IRI("http://example.purl.org.au/domainontology/", "JB_000007"); + IRI v1 = IRI("http://test.example.org/ontology/0139/", "version:1"); + IRI v2 = IRI("http://test.example.org/ontology/0139/", "version:2"); + + @Test + void testMultipleVersionLoadChangeIRI() throws Exception { + OWLOntologyDocumentSource initialDocumentSource = getDocument(); + OWLOntologyID initialUniqueOWLOntologyID = new OWLOntologyID(optional(jb), optional(v2)); + OWLOntology initialOntology = m.createOntology(initialUniqueOWLOntologyID); + OWLParser initialParser = new RDFXMLParser(); + initialParser.parse(initialDocumentSource, initialOntology, config); + OWLOntologyID secondUniqueOWLOntologyID = new OWLOntologyID(optional(jb), optional(v2)); + assertThrowsWithPredicate(OWLOntologyAlreadyExistsException.class, + e -> assertEquals(new OWLOntologyID(optional(jb), optional(v2)), + ((OWLOntologyAlreadyExistsException) e).getOntologyID()), + () -> m.createOntology(secondUniqueOWLOntologyID)); + } + + private OWLOntologyDocumentSource getDocument() { + try { + return new FileDocumentSource( + new File(getClass().getResource("/owlapi/multipleOntologyLoadsTest.rdf").toURI())); + } catch (URISyntaxException e) { + throw new OWLRuntimeException(e); + } + } + + @Test + void testMultipleVersionLoadNoChange() throws Exception { + OWLOntologyDocumentSource documentSource = getDocument(); + OWLOntologyID expected = new OWLOntologyID(optional(jb), optional(v1)); + OWLOntologyID initialUniqueOWLOntologyID = new OWLOntologyID(optional(jb), optional(v1)); + OWLOntology initialOntology = m.createOntology(initialUniqueOWLOntologyID); + OWLParser parser = new RDFXMLParser(); + parser.parse(documentSource, initialOntology, config); + OWLOntologyID secondUniqueOWLOntologyID = new OWLOntologyID(optional(jb), optional(v1)); + assertThrowsWithPredicate(OWLOntologyAlreadyExistsException.class, + e -> assertEquals(expected, ((OWLOntologyAlreadyExistsException) e).getOntologyID()), + () -> m.createOntology(secondUniqueOWLOntologyID)); + } + + @Test + void testMultipleVersionLoadsExplicitOntologyIDs() throws Exception { + OWLOntologyDocumentSource documentSource = getDocument(); + OWLOntologyID initialUniqueOWLOntologyID = new OWLOntologyID(optional(jb), optional(v1)); + OWLOntology initialOntology = m.createOntology(initialUniqueOWLOntologyID); + OWLParser parser = new RDFXMLParser(); + parser.parse(documentSource, initialOntology, config); + assertEquals(jb, initialOntology.getOntologyID().getOntologyIRI().get()); + assertEquals(v1, initialOntology.getOntologyID().getVersionIRI().get()); + OWLOntologyDocumentSource secondDocumentSource = getDocument(); + OWLOntologyID secondUniqueOWLOntologyID = new OWLOntologyID(optional(jb), optional(v2)); + OWLOntology secondOntology = m.createOntology(secondUniqueOWLOntologyID); + OWLParser secondParser = new RDFXMLParser(); + secondParser.parse(secondDocumentSource, secondOntology, config); + assertEquals(jb, secondOntology.getOntologyID().getOntologyIRI().get()); + assertEquals(v2, secondOntology.getOntologyID().getVersionIRI().get()); + } + + @Test + void testMultipleVersionLoadsNoOntologyIDFirstTime() throws Exception { + OWLOntologyDocumentSource documentSource = getDocument(); + OWLOntology initialOntology = m.createOntology(); + OWLParser parser = new RDFXMLParser(); + parser.parse(documentSource, initialOntology, config); + assertEquals(IRI("http://test.example.org/ontology/0139", ""), + initialOntology.getOntologyID().getOntologyIRI().get()); + assertEquals(v1, initialOntology.getOntologyID().getVersionIRI().get()); + OWLOntologyDocumentSource secondDocumentSource = getDocument(); + OWLOntologyID secondUniqueOWLOntologyID = new OWLOntologyID(optional(jb), optional(v2)); + OWLOntology secondOntology = m.createOntology(secondUniqueOWLOntologyID); + OWLParser secondParser = new RDFXMLParser(); + secondParser.parse(secondDocumentSource, secondOntology, config); + assertEquals(jb, secondOntology.getOntologyID().getOntologyIRI().get()); + assertEquals(v2, secondOntology.getOntologyID().getVersionIRI().get()); + } + + @Test + void testMultipleVersionLoadsNoOntologyVersionIRIFirstTime() throws Exception { + OWLOntologyDocumentSource documentSource = getDocument(); + IRI iri = IRI.create("http://test.example.org/ontology/0139"); + OWLOntologyID initialUniqueOWLOntologyID = + new OWLOntologyID(optional(iri), emptyOptional(IRI.class)); + OWLOntology initialOntology = m.createOntology(initialUniqueOWLOntologyID); + OWLParser parser = new RDFXMLParser(); + parser.parse(documentSource, initialOntology, config); + assertEquals(iri, initialOntology.getOntologyID().getOntologyIRI().get()); + assertEquals(v1, initialOntology.getOntologyID().getVersionIRI().get()); + OWLOntologyDocumentSource secondDocumentSource = getDocument(); + OWLOntologyID secondUniqueOWLOntologyID = new OWLOntologyID(optional(jb), optional(v2)); + OWLOntology secondOntology = m.createOntology(secondUniqueOWLOntologyID); + OWLParser secondParser = new RDFXMLParser(); + secondParser.parse(secondDocumentSource, secondOntology, config); + assertEquals(jb, secondOntology.getOntologyID().getOntologyIRI().get()); + assertEquals(v2, secondOntology.getOntologyID().getVersionIRI().get()); + } + + @Test + void testSingleVersionLoadChangeIRI() throws Exception { + OWLOntologyDocumentSource secondDocumentSource = getDocument(); + OWLOntologyID secondUniqueOWLOntologyID = new OWLOntologyID(optional(jb), optional(v2)); + OWLOntology secondOntology = m.createOntology(secondUniqueOWLOntologyID); + OWLParser secondParser = new RDFXMLParser(); + // the following throws the exception + secondParser.parse(secondDocumentSource, secondOntology, config); + assertEquals(jb, secondOntology.getOntologyID().getOntologyIRI().get()); + assertEquals(v2, secondOntology.getOntologyID().getVersionIRI().get()); + } + + @Test + void testSingleVersionLoadNoChange() throws Exception { + OWLOntologyDocumentSource documentSource = getDocument(); + OWLOntologyID initialUniqueOWLOntologyID = new OWLOntologyID(optional(jb), optional(v1)); + OWLOntology initialOntology = m.createOntology(initialUniqueOWLOntologyID); + OWLParser parser = new RDFXMLParser(); + parser.parse(documentSource, initialOntology, config); + assertEquals(jb, initialOntology.getOntologyID().getOntologyIRI().get()); + assertEquals(v1, initialOntology.getOntologyID().getVersionIRI().get()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/MultipleOntologyLoadsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/MultipleOntologyLoadsTestCase.java new file mode 100644 index 0000000000..c4b7021402 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/MultipleOntologyLoadsTestCase.java @@ -0,0 +1,186 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax.rdfxml; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.emptyOptional; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.io.File; +import java.net.URISyntaxException; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.io.FileDocumentSource; +import org.semanticweb.owlapi.io.OWLOntologyDocumentSource; +import org.semanticweb.owlapi.io.OWLParser; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyAlreadyExistsException; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLRuntimeException; +import org.semanticweb.owlapi.rdf.rdfxml.parser.RDFXMLParser; + +/** + * Tests the loading of a single ontology multiple times, using the same ontologyIRI in the + * {@link OWLOntologyID} as that used in the actual ontology that is being imported. + * + * @author Peter Ansell p_ansell@yahoo.com + */ +class MultipleOntologyLoadsTestCase extends TestBase { + + private static final IRI CREATEV1 = IRI("http://test.example.org/ontology/0139/version:1", ""); + private static final IRI CREATEV2 = IRI("http://test.example.org/ontology/0139/version:2", ""); + private static final IRI CREATE0139 = IRI("http://test.example.org/ontology/0139", ""); + + @Test + void testMultipleVersionLoadChangeIRI() { + // given + OWLOntologyDocumentSource initialDocumentSource = getDocumentSource(); + OWLOntologyID expected = new OWLOntologyID(optional(CREATE0139), optional(CREATEV2)); + OWLOntologyID initialUniqueOWLOntologyID = + new OWLOntologyID(optional(CREATE0139), optional(CREATEV2)); + OWLOntology initialOntology = getOWLOntology(initialUniqueOWLOntologyID); + parseOnto(initialDocumentSource, initialOntology); + OWLOntologyID secondUniqueOWLOntologyID = + new OWLOntologyID(optional(CREATE0139), optional(CREATEV2)); + // when + assertThrowsWithCausePredicate(OWLRuntimeException.class, + OWLOntologyAlreadyExistsException.class, + e -> assertEquals(expected, ((OWLOntologyAlreadyExistsException) e).getOntologyID()), + () -> getOWLOntology(secondUniqueOWLOntologyID)); + } + + @Test + void testMultipleVersionLoadNoChange() { + // given + OWLOntologyDocumentSource documentSource = getDocumentSource(); + OWLOntologyID expected = new OWLOntologyID(optional(CREATE0139), optional(CREATEV1)); + OWLOntologyID initialUniqueOWLOntologyID = + new OWLOntologyID(optional(CREATE0139), optional(CREATEV1)); + OWLOntology initialOntology = getOWLOntology(initialUniqueOWLOntologyID); + parseOnto(documentSource, initialOntology); + OWLOntologyID secondUniqueOWLOntologyID = + new OWLOntologyID(optional(CREATE0139), optional(CREATEV1)); + // when + assertThrowsWithCausePredicate(OWLRuntimeException.class, + OWLOntologyAlreadyExistsException.class, + e -> assertEquals(expected, ((OWLOntologyAlreadyExistsException) e).getOntologyID()), + () -> getOWLOntology(secondUniqueOWLOntologyID)); + } + + @Test + void testMultipleVersionLoadsExplicitOntologyIDs() { + // given + OWLOntologyDocumentSource documentSource = getDocumentSource(); + OWLOntologyID initialUniqueOWLOntologyID = + new OWLOntologyID(optional(CREATE0139), optional(CREATEV1)); + OWLOntologyDocumentSource secondDocumentSource = getDocumentSource(); + OWLOntologyID secondUniqueOWLOntologyID = + new OWLOntologyID(optional(CREATE0139), optional(CREATEV2)); + // when + OWLOntology initialOntology = getOWLOntology(initialUniqueOWLOntologyID); + parseOnto(documentSource, initialOntology); + OWLOntology secondOntology = getOWLOntology(secondUniqueOWLOntologyID); + parseOnto(secondDocumentSource, secondOntology); + // then + assertEquals(CREATE0139, initialOntology.getOntologyID().getOntologyIRI().get()); + assertEquals(CREATEV1, initialOntology.getOntologyID().getVersionIRI().get()); + assertEquals(CREATE0139, secondOntology.getOntologyID().getOntologyIRI().get()); + assertEquals(CREATEV2, secondOntology.getOntologyID().getVersionIRI().get()); + } + + @Test + void testMultipleVersionLoadsNoOntologyIDFirstTime() { + // given + OWLOntologyDocumentSource documentSource = getDocumentSource(); + OWLOntologyDocumentSource secondDocumentSource = getDocumentSource(); + OWLOntologyID secondUniqueOWLOntologyID = + new OWLOntologyID(optional(CREATE0139), optional(CREATEV2)); + // when + OWLOntology initialOntology = getAnonymousOWLOntology(); + parseOnto(documentSource, initialOntology); + OWLOntology secondOntology = getOWLOntology(secondUniqueOWLOntologyID); + parseOnto(secondDocumentSource, secondOntology); + // then + assertEquals(CREATE0139, initialOntology.getOntologyID().getOntologyIRI().get()); + assertEquals(CREATEV1, initialOntology.getOntologyID().getVersionIRI().get()); + assertEquals(CREATE0139, secondOntology.getOntologyID().getOntologyIRI().get()); + assertEquals(CREATEV2, secondOntology.getOntologyID().getVersionIRI().get()); + } + + @Test + void testMultipleVersionLoadsNoOntologyVersionIRIFirstTime() { + // given + OWLOntologyDocumentSource documentSource = getDocumentSource(); + OWLOntologyID initialUniqueOWLOntologyID = + new OWLOntologyID(optional(CREATE0139), emptyOptional(IRI.class)); + OWLOntologyDocumentSource secondDocumentSource = getDocumentSource(); + OWLOntologyID secondUniqueOWLOntologyID = + new OWLOntologyID(optional(CREATE0139), optional(CREATEV2)); + // when + OWLOntology initialOntology = getOWLOntology(initialUniqueOWLOntologyID); + parseOnto(documentSource, initialOntology); + OWLOntology secondOntology = getOWLOntology(secondUniqueOWLOntologyID); + parseOnto(secondDocumentSource, secondOntology); + // then + assertEquals(CREATE0139, initialOntology.getOntologyID().getOntologyIRI().get()); + assertEquals(CREATEV1, initialOntology.getOntologyID().getVersionIRI().get()); + assertEquals(CREATE0139, secondOntology.getOntologyID().getOntologyIRI().get()); + assertEquals(CREATEV2, secondOntology.getOntologyID().getVersionIRI().get()); + } + + @Test + void testSingleVersionLoadChangeIRI() { + // given + OWLOntologyDocumentSource secondDocumentSource = getDocumentSource(); + OWLOntologyID secondUniqueOWLOntologyID = + new OWLOntologyID(optional(CREATE0139), optional(CREATEV2)); + // when + OWLOntology secondOntology = getOWLOntology(secondUniqueOWLOntologyID); + parseOnto(secondDocumentSource, secondOntology); + // then + assertEquals(CREATE0139, secondOntology.getOntologyID().getOntologyIRI().get()); + assertEquals(CREATEV2, secondOntology.getOntologyID().getVersionIRI().get()); + } + + @Test + void testSingleVersionLoadNoChange() { + // given + OWLOntologyDocumentSource documentSource = getDocumentSource(); + OWLOntologyID initialUniqueOWLOntologyID = + new OWLOntologyID(optional(CREATE0139), optional(CREATEV1)); + // when + OWLOntology initialOntology = getOWLOntology(initialUniqueOWLOntologyID); + parseOnto(documentSource, initialOntology); + // then + assertEquals(CREATE0139, initialOntology.getOntologyID().getOntologyIRI().get()); + assertEquals(CREATEV1, initialOntology.getOntologyID().getVersionIRI().get()); + } + + private void parseOnto(OWLOntologyDocumentSource initialDocumentSource, + OWLOntology initialOntology) { + OWLParser initialParser = new RDFXMLParser(); + initialParser.parse(initialDocumentSource, initialOntology, config); + } + + private OWLOntologyDocumentSource getDocumentSource() { + try { + return new FileDocumentSource( + new File(getClass().getResource("/owlapi/multipleOntologyLoadsTest.rdf").toURI())); + } catch (URISyntaxException e) { + throw new OWLRuntimeException(e); + } + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/OntologyVersionIsOntologyTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/OntologyVersionIsOntologyTestCase.java new file mode 100644 index 0000000000..92cb86ed47 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/OntologyVersionIsOntologyTestCase.java @@ -0,0 +1,33 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax.rdfxml; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.RioTurtleDocumentFormat; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.OWLOntology; + +public class OntologyVersionIsOntologyTestCase extends TestBase { + + @Test + void testLoad() throws Exception { + OWLOntology o = + loadOntologyFromString(TestFiles.ontologyVersionParse, new RioTurtleDocumentFormat()); + StringDocumentTarget saveOntology = saveOntology(o, new RioTurtleDocumentFormat()); + OWLOntology o1 = + loadOntologyFromString(saveOntology.toString(), new RioTurtleDocumentFormat()); + equal(o, o1); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/RDFParserTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/RDFParserTestCase.java new file mode 100644 index 0000000000..e5fad476a6 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/RDFParserTestCase.java @@ -0,0 +1,90 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax.rdfxml; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + +import java.io.File; +import java.net.URISyntaxException; +import java.net.URL; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLException; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.rdf.rdfxml.renderer.RDFXMLStorerFactory; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +class RDFParserTestCase extends TestBase { + + @BeforeEach + void setUpStorers() { + // Use the reference implementation + m.getOntologyStorers().set(new RDFXMLStorerFactory()); + } + + @Test + void testOWLAPI() throws Exception { + parseFiles("/owlapi/"); + } + + private void parseFiles(String base) throws URISyntaxException, OWLOntologyCreationException { + URL url = getClass().getResource(base); + File file = new File(url.toURI()); + for (File testSuiteFolder : file.listFiles()) { + if (testSuiteFolder.isDirectory()) { + for (File ontologyFile : testSuiteFolder.listFiles()) { + if (ontologyFile.getName().endsWith(".rdf") + || ontologyFile.getName().endsWith(".owlapi")) { + OWLOntology ont = m.loadOntologyFromOntologyDocument(ontologyFile); + m.removeOntology(ont); + } + } + } + } + } + + @Test + void shouldParseDataProperty() { + OWLOntology o = + loadOntologyFromString(TestFiles.parseDataProperty, new RDFXMLDocumentFormat()); + assertFalse(o.containsObjectPropertyInSignature( + iri("http://www.loa-cnr.it/ontologies/Plans.owl#", "iteration-cardinality"))); + } + + @Test + void shouldLoadSubPropertiesAsObjectProperties() { + OWLOntology o = loadOntologyFromString(TestFiles.subPropertiesAsObjectProperties, + new RDFXMLDocumentFormat()); + assertEquals(0, o.axioms(AxiomType.SUB_ANNOTATION_PROPERTY_OF).count()); + assertEquals(1, o.axioms(AxiomType.SUB_OBJECT_PROPERTY).count()); + } + + @Test + void shouldRoundTripLhsSubsetOfRHS() throws OWLException { + OWLOntology o = + loadOntologyFromString(TestFiles.lhsSubsetofRhs, new FunctionalSyntaxDocumentFormat()); + OWLOntology o1 = roundTrip(o, new RDFXMLDocumentFormat()); + equal(o, o1); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/SWRLTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/SWRLTestCase.java new file mode 100644 index 0000000000..8916d276cc --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/SWRLTestCase.java @@ -0,0 +1,34 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.api.test.syntax.rdfxml; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.1.1 + */ +class SWRLTestCase extends TestBase { + + @Test + void testSWRLParser() { + OWLOntology ont = loadOntologyFromString(TestFiles.swrlParser, new RDFXMLDocumentFormat()); + assertEquals(0L, ont.individualsInSignature().count()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/package-info.java new file mode 100644 index 0000000000..6b8fbc5536 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/api/test/syntax/rdfxml/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.api.test.syntax.rdfxml; diff --git a/contract/src/test/java/org/semanticweb/owlapi/apitest/TestFiles.java b/contract/src/test/java/org/semanticweb/owlapi/apitest/TestFiles.java new file mode 100644 index 0000000000..6dac595e08 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/apitest/TestFiles.java @@ -0,0 +1,512 @@ +package org.semanticweb.owlapi.apitest; + +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.apache.commons.io.IOUtils; + +public class TestFiles { + + private static String string(String name) { + try (InputStream in = TestFiles.class.getResourceAsStream(name)) { + return IOUtils.toString(in, StandardCharsets.UTF_8); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + private static String[] strings(String name) { + try (InputStream in = TestFiles.class.getResourceAsStream(name)) { + Iterator readLines = IOUtils.readLines(in, StandardCharsets.UTF_8).iterator(); + List toReturn = new ArrayList<>(); + StringBuilder b = new StringBuilder(); + while (readLines.hasNext()) { + String line = readLines.next(); + if (line.isEmpty()) { + if (b.length() != 0) { + toReturn.add(b.toString()); + } + b = new StringBuilder(); + } else { + b.append(line).append("\n"); + } + } + if (b.length() != 0) { + toReturn.add(b.toString()); + } + assert !toReturn.isEmpty(); + return toReturn.toArray(new String[0]); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + public static String ontFirst = string("ontFirst.txt"); + public static String labelFirst = string("labelFirst.txt"); + public static String nestedAnnotations = string("nestedAnnotations.txt"); + public static String annotatedAnnotation = string("annotatedAnnotation.txt"); + public static String anonOneOf = string("anonOneOf.txt"); + public static final String anonTurtle = string("anonTurtle.txt"); + public static final String opa = string("opa.txt"); + public static final String nop = string("nop.txt"); + public static final String ndp = string("ndp.txt"); + public static final String irreflexive = string("irreflexive.txt"); + public static final String inverseop = string("inverseop.txt"); + public static final String inversefp = string("inversefp.txt"); + public static final String functionalop = string("functionalop.txt"); + public static final String functionaldp = string("functionaldp.txt"); + public static final String eOp = string("eOp.txt"); + public static final String eDp = string("eDp.txt"); + public static final String ec = string("ec.txt"); + public static final String disjointu = string("disjointu.txt"); + public static final String disjointOp = string("disjointOp.txt"); + public static final String disjointDp = string("disjointDp.txt"); + public static final String disjointClasses = string("disjointClasses.txt"); + public static final String assDi = string("assDi.txt"); + public static final String decI = string("decI.txt"); + public static final String decAp = string("decAp.txt"); + public static final String decDt = string("decDt.txt"); + public static final String decDp = string("decDp.txt"); + public static final String decOp = string("decOp.txt"); + public static final String decC = string("decC.txt"); + public static final String dDef = string("dDef.txt"); + public static final String dRange = string("dRange.txt"); + public static final String dDom = string("dDom.txt"); + public static final String assDPlain = string("assDPlain.txt"); + public static final String assD = string("assD.txt"); + public static final String dRangeRestrict = string("dRangeRestrict.txt"); + public static final String dataNot = string("dataNot.txt"); + public static final String dataOneOf = string("dataOneOf.txt"); + public static final String assDEq = string("assDEq.txt"); + public static final String assDMax = string("assDMax.txt"); + public static final String assDMin = string("assDMin.txt"); + public static final String assDHas = string("assDHas.txt"); + public static final String assDAll = string("assDAll.txt"); + public static final String assDSome = string("assDSome.txt"); + public static final String OPAINV = string("OPAINV.txt"); + public static final String OPAINVJ = string("OPAINVJ.txt"); + public static final String ODOM = string("ODOM.txt"); + public static final String ORANGE = string("ORANGE.txt"); + public static final String CHAIN = string("CHAIN.txt"); + public static final String REF = string("REF.txt"); + public static final String SAME = string("SAME.txt"); + public static final String SUBANN = string("SUBANN.txt"); + public static final String SUBCLASS = string("SUBCLASS.txt"); + public static final String SUBDATA = string("SUBDATA.txt"); + public static final String SUBOBJECT = string("SUBOBJECT.txt"); + public static final String SYMM = string("SYMM.txt"); + public static final String TRANS = string("TRANS.txt"); + public static final String HASKEY = string("HASKEY.txt"); + public static final String ASSONEOF = string("ASSONEOF.txt"); + public static final String ASSHASSELF = string("ASSHASSELF.txt"); + public static final String ASSEQ = string("ASSEQ.txt"); + public static final String ASSMAX = string("ASSMAX.txt"); + public static final String ASSMIN = string("ASSMIN.txt"); + public static final String ASSHAS = string("ASSHAS.txt"); + public static final String ASSALL = string("ASSALL.txt"); + public static final String ASSSOME = string("ASSSOME.txt"); + public static final String ASSNOTANON = string("ASSNOTANON.txt"); + public static final String ASSNOT = string("ASSNOT.txt"); + public static final String DRANGEOR = string("DRANGEOR.txt"); + public static final String DRANGEAND = string("DRANGEAND.txt"); + public static final String ASSOR = string("ASSOR.txt"); + public static final String ASSAND = string("ASSAND.txt"); + public static final String ASS = string("ASS.txt"); + public static final String ANNRANGE = string("ANNRANGE.txt"); + public static final String ANNDOM = string("ANNDOM.txt"); + public static final String ASYMM = string("ASYMM.txt"); + public static final String ANN = string("ANN.txt"); + public static final String ONTO = string("ONTO.txt"); + public static final String BIGRULE = string("BIGRULE.txt"); + public static final String RULE = string("RULE.txt"); + public static final String CI = string("CI.txt"); + public static final String C = string("C.txt"); + public static final String DTD = string("DTD.txt"); + public static final String DB = string("DB.txt"); + public static final String DT = string("DT.txt"); + public static final String DP = string("DP.txt"); + public static final String DPI = string("DPI.txt"); + public static final String DTI = string("DTI.txt"); + public static final String DPR = string("DPR.txt"); + public static final String DC = string("DC.txt"); + public static final String OP = string("OP.txt"); + public static final String OPI = string("OPI.txt"); + public static final String DOP = string("DOP.txt"); + public static final String ANNSHORT = string("ANNSHORT.txt"); + public static final String ANNI = string("ANNI.txt"); + public static final String DANN = string("DANN.txt"); + public static final String DDP = string("DDP.txt"); + public static final String DD = string("DD.txt"); + public static final String FDP = string("FDP.txt"); + public static final String FOP = string("FOP.txt"); + public static final String IFP = string("IFP.txt"); + public static final String IOP = string("IOP.txt"); + public static final String DIND = string("DIND.txt"); + public static final String DIFF = string("DIFF.txt"); + public static final String DSJC = string("DSJC.txt"); + public static final String IRI = string("IRI.txt"); + public static final String IRII = string("IRII.txt"); + public static final String I = string("I.txt"); + public static final String DISJDP = string("DISJDP.txt"); + public static final String DSJOP = string("DSJOP.txt"); + public static final String II = string("II.txt"); + public static final String plain = string("plain.txt"); + public static final String adp = string("adp.txt"); + public static final String dpdomain = string("dpdomain.txt"); + public static final String VAR1 = string("VAR1.txt"); + public static final String DRA = string("DRA.txt"); + public static final String v1 = string("v1.txt"); + public static final String v2 = string("v2.txt"); + public static final String var2 = string("var2.txt"); + public static final String diffvar2 = string("diffvar2.txt"); + public static final String opavar2 = string("opavar2.txt"); + public static final String dpvar2 = string("dpvar2.txt"); + public static final String classvar2 = string("classvar2.txt"); + public static final String dlsaferule = string("dlsaferule.txt"); + public static final String T = string("T.txt"); + public static final String AANN = string("AANN.txt"); + public static final String noDC = string("noDC.txt"); + public static final String lazyDC = string("lazyDC.txt"); + public static final String doubleOntology = string("doubleOntology.txt"); + public static final String asymmetric = string("asymmetric.txt"); + public static final String APD = string("APD.txt"); + public static final String APR = string("APR.txt"); + public static final String ACL = string("ACL.txt"); + public static final String ACLAND = string("ACLAND.txt"); + public static final String AND = string("AND.txt"); + public static final String ACLOR = string("ACLOR.txt"); + public static final String OR = string("OR.txt"); + public static final String DPRAND = string("DPRAND.txt"); + public static final String DONEOF = string("DONEOF.txt"); + public static final String DAND = string("DAND.txt"); + public static final String DOR = string("DOR.txt"); + public static final String DPROR = string("DPROR.txt"); + public static final String CNOT = string("CNOT.txt"); + public static final String NOT = string("NOT.txt"); + public static final String ACNOT = string("ACNOT.txt"); + public static final String ACSOME = string("ACSOME.txt"); + public static final String SOME = string("SOME.txt"); + public static final String ACALL = string("ACALL.txt"); + public static final String ALL = string("ALL.txt"); + public static final String ACHAS = string("ACHAS.txt"); + public static final String HAS = string("HAS.txt"); + public static final String AOMIN = string("AOMIN.txt"); + public static final String OMIN = string("OMIN.txt"); + public static final String AOMAX = string("AOMAX.txt"); + public static final String MAX = string("MAX.txt"); + public static final String AOEQ = string("AOEQ.txt"); + public static final String OEQ = string("OEQ.txt"); + public static final String ASELF = string("ASELF.txt"); + public static final String SELF = string("SELF.txt"); + public static final String AONE = string("AONE.txt"); + public static final String ONE = string("ONE.txt"); + public static final String ADSOME = string("ADSOME.txt"); + public static final String DSOME = string("DSOME.txt"); + public static final String ADALL = string("ADALL.txt"); + public static final String DALL = string("DALL.txt"); + public static final String ADHAS = string("ADHAS.txt"); + public static final String DHAS = string("DHAS.txt"); + public static final String ADMIN = string("ADMIN.txt"); + public static final String DMIN = string("DMIN.txt"); + public static final String ADMAX = string("ADMAX.txt"); + public static final String DMAX = string("DMAX.txt"); + public static final String ADEQ = string("ADEQ.txt"); + public static final String DEQ = string("DEQ.txt"); + public static final String ADONEOF = string("ADONEOF.txt"); + public static final String DPRNOT = string("DPRNOT.txt"); + public static final String DNOT = string("DNOT.txt"); + public static final String MINMAX = string("MINMAX.txt"); + public static final String MINMXSIX = string("MINMXSIX.txt"); + public static final String MIN5 = string("MIN5.txt"); + public static final String MAXSIX = string("MAXSIX.txt"); + public static final String dpafalse = string("dpafalse.txt"); + public static final String EQC = string("EQC.txt"); + public static final String EQDP = string("EQDP.txt"); + public static final String EQOP = string("EQOP.txt"); + public static final String IRR = string("IRR.txt"); + public static final String BLN = string("BLN.txt"); + public static final String DU = string("DU.txt"); + public static final String ANDP = string("ANDP.txt"); + public static final String ANOP = string("ANOP.txt"); + public static final String AOP = string("AOP.txt"); + public static final String INVERSE = string("INVERSE.txt"); + public static final String AOINV = string("AOINV.txt"); + public static final String AOPJ = string("AOPJ.txt"); + public static final String OPD = string("OPD.txt"); + public static final String OPR = string("OPR.txt"); + public static final String SUBO = string("SUBO.txt"); + public static final String R = string("R.txt"); + public static final String SUBA = string("SUBA.txt"); + public static final String SUBC = string("SUBC.txt"); + public static final String SUBD = string("SUBD.txt"); + public static final String SUBOP = string("SUBOP.txt"); + public static final String v34 = string("v34.txt"); + public static final String v3 = string("v3.txt"); + public static final String var236 = string("var236.txt"); + public static final String SHORTRULE = string("SHORTRULE.txt"); + public static final String BFO = string("BFO.txt"); + public static String declareDatatypes = string("declareDatatypes.txt"); + public static final String original = string("original.txt"); + public static final String HEAD = string("HEAD.txt"); + public static final String TAIL = string("TAIL.txt"); + public static final String DL_RULE = string("DL_RULE.txt"); + public static final String STRING9 = string("STRING9.txt"); + public static final String STRING8 = string("STRING8.txt"); + public static final String STRING7 = string("STRING7.txt"); + public static final String STRING6 = string("STRING6.txt"); + public static final String STRING5 = string("STRING5.txt"); + public static final String STRING4 = string("STRING4.txt"); + public static final String STRING3 = string("STRING3.txt"); + public static final String STRING2 = string("STRING2.txt"); + public static final String STRING1 = string("STRING1.txt"); + public static final String BROKEN = string("BROKEN.txt"); + public static final String FIXED = string("FIXED.txt"); + public static final String conditionalId = string("conditionalId.txt"); + public static final String unconditionalId = string("unconditionalId.txt"); + public static final String noRemapOnRead = string("noRemapOnRead.txt"); + public static final String oneAnonIndividuall = string("oneAnonIndividuall.txt"); + public static final String remapOnReading = string("remapOnReading.txt"); + public static final String oneIndividual = string("oneIndividual.txt"); + public static final String remapImportRdfXml = string("remapImportRdfXml.txt"); + public static final String remapImport = string("remapImport.txt"); + public static final String unloadableImport = string("unloadableImport.txt"); + public static final String loadRight = string("loadRight.txt"); + public static final String strtransdRange = string("strtransdRange.txt"); + public static final String strtransdDef = string("strtransdDef.txt"); + public static final String strtransdecC = string("strtransdecC.txt"); + public static final String strtransdecOp = string("strtransdecOp.txt"); + public static final String strtransdecDp = string("strtransdecDp.txt"); + public static final String strtransdecDt = string("strtransdecDt.txt"); + public static final String strtransdecAp = string("strtransdecAp.txt"); + public static final String strtransdecI = string("strtransdecI.txt"); + public static final String strtransdDp = string("strtransdDp.txt"); + public static final String strtransdOp = string("strtransdOp.txt"); + public static final String strtranseDp = string("strtranseDp.txt"); + public static final String strtranseOp = string("strtranseOp.txt"); + public static final String strtransfdp = string("strtransfdp.txt"); + public static final String strtransfop = string("strtransfop.txt"); + public static final String strtransifp = string("strtransifp.txt"); + public static final String strtransiop = string("strtransiop.txt"); + public static final String strtransirr = string("strtransirr.txt"); + public static final String strtransopa = string("strtransopa.txt"); + public static final String strtransopaInv = string("strtransopaInv.txt"); + public static final String strtransopaInvj = string("strtransopaInvj.txt"); + public static final String strtransoDom = string("strtransoDom.txt"); + public static final String strtransoRange = string("strtransoRange.txt"); + public static final String strtranschain = string("strtranschain.txt"); + public static final String strtransref = string("strtransref.txt"); + public static final String strtranssubAnn = string("strtranssubAnn.txt"); + public static final String strtranssubClass = string("strtranssubClass.txt"); + public static final String strtranssubData = string("strtranssubData.txt"); + public static final String strtranssubObject = string("strtranssubObject.txt"); + public static final String strtransrule = string("strtransrule.txt"); + public static final String strtranssymm = string("strtranssymm.txt"); + public static final String strtranstrans = string("strtranstrans.txt"); + public static final String strtranshasKey = string("strtranshasKey.txt"); + public static final String strtransbigRule = string("strtransbigRule.txt"); + public static final String strtransann = string("strtransann.txt"); + public static final String strtransasymm = string("strtransasymm.txt"); + public static final String strtransannDom = string("strtransannDom.txt"); + public static final String strtransannRange = string("strtransannRange.txt"); + public static final String strtransdRangeAnd = string("strtransdRangeAnd.txt"); + public static final String strtransdRangeOr = string("strtransdRangeOr.txt"); + public static final String strtransdOneOf = string("strtransdOneOf.txt"); + public static final String strtransdNot = string("strtransdNot.txt"); + public static final String strtransdRangeRestrict = string("strtransdRangeRestrict.txt"); + public static final String strtransassD = string("strtransassD.txt"); + public static final String strtransassDPlain = string("strtransassDPlain.txt"); + public static final String strtransdDom = string("strtransdDom.txt"); + public static final String strtransdc = string("strtransdc.txt"); + public static final String strtransdu = string("strtransdu.txt"); + public static final String strtransec = string("strtransec.txt"); + public static final String RDFXML = string("RDFXML.txt"); + public static final String OWLXML = string("OWLXML.txt"); + public static final String FUNCTIONAL = string("FUNCTIONAL.txt"); + public static final String MANCHESTER = string("MANCHESTER.txt"); + public static final String TURTLE = string("TURTLE.txt"); + public static String[] inputSorting = strings("inputSorting.txt"); + public static final String quotes1 = string("quotes1.txt"); + public static final String quotes6 = string("quotes6.txt"); + public static final String quotes2 = string("quotes2.txt"); + public static final String quotes3 = string("quotes3.txt"); + public static final String quotes4 = string("quotes4.txt"); + public static final String quotes5 = string("quotes5.txt"); + public static final String workingOnto = string("workingOnto.txt"); + public static final String brokenOnto = string("brokenOnto.txt"); + public static final String resolveAgainstBase = string("resolveAgainstBase.txt"); + public static final String turtleWithShared = string("turtleWithShared.txt"); + public static final String scientificNotationPlus = string("scientificNotationPlus.txt"); + public static final String scientificNotationWithMinus = + string("scientificNotationWithMinus.txt"); + public static final String scientificNotation = string("scientificNotation.txt"); + public static final String parseTwo = string("parseTwo.txt"); + public static final String parseOne = string("parseOne.txt"); + public static final String emptySpaceInBnode = string("emptySpaceInBnode.txt"); + public static final String axiomAnnotations = string("axiomAnnotations.txt"); + public static final String slashOntologyIRI = string("slashOntologyIRI.txt"); + public static final String presentDeclaration = string("presentDeclaration.txt"); + public static final String missingDeclaration = string("missingDeclaration.txt"); + public static final String prefixAbbreviations = string("prefixAbbreviations.txt"); + public static final String axiomsForBlankNodes = string("axiomsForBlankNodes.txt"); + public static final String correctPrefix = string("correctPrefix.txt"); + public static final String slashPrefix = string("slashPrefix.txt"); + public static final String PREFIX = "http://example.com/ontology/"; + public static final String XY = "http://example.com/ontology/x,y"; + public static final String NS = "http://example.com/ontology"; + public static final String nnfdRange = string("nnfdRange.txt"); + public static final String nnfdDef = string("nnfdDef.txt"); + public static final String nnfdecC = string("nnfdecC.txt"); + public static final String nnfdecOp = string("nnfdecOp.txt"); + public static final String nnfdecDp = string("nnfdecDp.txt"); + public static final String nnfdecDt = string("nnfdecDt.txt"); + public static final String nnfdecAp = string("nnfdecAp.txt"); + public static final String nnfdecI = string("nnfdecI.txt"); + public static final String nnfassDi = string("nnfassDi.txt"); + public static final String nnfdc = string("nnfdc.txt"); + public static final String nnfdDp = string("nnfdDp.txt"); + public static final String nnfdOp = string("nnfdOp.txt"); + public static final String nnfdu = string("nnfdu.txt"); + public static final String nnfec = string("nnfec.txt"); + public static final String nnfeDp = string("nnfeDp.txt"); + public static final String nnfeOp = string("nnfeOp.txt"); + public static final String nnffdp = string("nnffdp.txt"); + public static final String nnffop = string("nnffop.txt"); + public static final String nnfifp = string("nnfifp.txt"); + public static final String nnfiop = string("nnfiop.txt"); + public static final String nnfirr = string("nnfirr.txt"); + public static final String nnfndp = string("nnfndp.txt"); + public static final String nnfnop = string("nnfnop.txt"); + public static final String nnfopa = string("nnfopa.txt"); + public static final String nnfopaInv = string("nnfopaInv.txt"); + public static final String nnfopaInvj = string("nnfopaInvj.txt"); + public static final String nnfoDom = string("nnfoDom.txt"); + public static final String nnfoRange = string("nnfoRange.txt"); + public static final String nnfchain = string("nnfchain.txt"); + public static final String nnfref = string("nnfref.txt"); + public static final String nnfsame = string("nnfsame.txt"); + public static final String nnfsubAnn = string("nnfsubAnn.txt"); + public static final String nnfsubClass = string("nnfsubClass.txt"); + public static final String nnfsubData = string("nnfsubData.txt"); + public static final String nnfsubObject = string("nnfsubObject.txt"); + public static final String nnfrule = string("nnfrule.txt"); + public static final String nnfsymm = string("nnfsymm.txt"); + public static final String nnftrans = string("nnftrans.txt"); + public static final String nnfhasKey = string("nnfhasKey.txt"); + public static final String nnfbigRule = string("nnfbigRule.txt"); + public static final String nnfann = string("nnfann.txt"); + public static final String nnfasymm = string("nnfasymm.txt"); + public static final String nnfannDom = string("nnfannDom.txt"); + public static final String nnfannRange = string("nnfannRange.txt"); + public static final String nnfass = string("nnfass.txt"); + public static final String nnfassAnd = string("nnfassAnd.txt"); + public static final String nnfassOr = string("nnfassOr.txt"); + public static final String nnfdRangeAnd = string("nnfdRangeAnd.txt"); + public static final String nnfdRangeOr = string("nnfdRangeOr.txt"); + public static final String nnfassNot = string("nnfassNot.txt"); + public static final String nnfassNotAnon = string("nnfassNotAnon.txt"); + public static final String nnfassSome = string("nnfassSome.txt"); + public static final String nnfassAll = string("nnfassAll.txt"); + public static final String nnfassHas = string("nnfassHas.txt"); + public static final String nnfassMin = string("nnfassMin.txt"); + public static final String nnfassMax = string("nnfassMax.txt"); + public static final String nnfassEq = string("nnfassEq.txt"); + public static final String nnfassHasSelf = string("nnfassHasSelf.txt"); + public static final String nnfassOneOf = string("nnfassOneOf.txt"); + public static final String nnfassDSome = string("nnfassDSome.txt"); + public static final String nnfassDAll = string("nnfassDAll.txt"); + public static final String nnfassDHas = string("nnfassDHas.txt"); + public static final String nnfassDMin = string("nnfassDMin.txt"); + public static final String nnfassDMax = string("nnfassDMax.txt"); + public static final String nnfassDEq = string("nnfassDEq.txt"); + public static final String nnfdOneOf = string("nnfdOneOf.txt"); + public static final String nnfdNot = string("nnfdNot.txt"); + public static final String nnfdRangeRestrict = string("nnfdRangeRestrict.txt"); + public static final String nnfassD = string("nnfassD.txt"); + public static final String nnfassDPlain = string("nnfassDPlain.txt"); + public static final String nnfdDom = string("nnfdDom.txt"); + public static final String KOALA = string("KOALA.txt"); + public static final String allowInstanceStanza = string("allowInstanceStanza.txt"); + public static final String forbiddenInput1 = string("forbiddenInput1.txt"); + public static final String forbiddenInput2 = string("forbiddenInput2.txt"); + public static String ontology = string("ontology.txt"); + public static String galenFragment = string("galenFragment.txt"); + public static String violation = string("violation.txt"); + public static String[] profileFullTestCases = strings("profileFullTestCases.txt"); + public static String[] profileDLTestCases = strings("profileDLTestCases.txt"); + public static String[] profileAllTestCases = strings("profileAllTestCases.txt"); + public static String[] profileELDLTestCases = strings("profileELDLTestCases.txt"); + public static String[] profileRLDLTestCases = strings("profileRLDLTestCases.txt"); + public static String[] profileQLDLTestCases = strings("profileQLDLTestCases.txt"); + public static String[] profileNOQLTestCases = strings("profileNOQLTestCases.txt"); + public static String[] profileNORLTestCases = strings("profileNORLTestCases.txt"); + public static String[] profileNOELTestCases = strings("profileNOELTestCases.txt"); + public static final String disjoint4InHTML = string("disjoint4InHTML.txt"); + public static final String disjointTwoInHTML = string("disjointTwoInHTML.txt"); + public static final String disjointInHTML = string("disjointInHTML.txt"); + public static String renameApUsages = string("renameApUsages.txt"); + public static String distinctMembers1 = string("distinctMembers1.txt"); + public static String distinctMembers2 = string("distinctMembers2.txt"); + public static final String IRITestCase = string("IRITestCase.txt"); + public static String parseSWRL = string("parseSWRL.txt"); + public static String parseSWRL2 = string("parseSWRL2.txt"); + public static String individualSWRLTest = string("individualSWRLTest.txt"); + public static String parseDataProperty = string("parseDataProperty.txt"); + public static String subPropertiesAsObjectProperties = + string("subPropertiesAsObjectProperties.txt"); + public static String lhsSubsetofRhs = string("lhsSubsetofRhs.txt"); + public static String swrlParser = string("swrlParser.txt"); + public static final String cardMultipleDigits = string("cardMultipleDigits.txt"); + public static final String parseMultilineComment = string("parseMultilineComment.txt"); + public static final String parseComment = string("parseComment.txt"); + public static final String annotationTestCase = string("annotationTestCase.txt"); + public static final String roundtripTest = string("roundtripTest.txt"); + public static final String manSyntaxInput = string("manSyntaxInput.txt"); + public static final String manSyntaxRule = string("manSyntaxRule.txt"); + public static final String manSyntaxParserTest = string("manSyntaxParserTest.txt"); + public static final String annotatedAnnotationMansyntax = + string("annotatedAnnotationMansyntax.txt"); + public static final String parseSWRLVariable = string("parseSWRLVariable.txt"); + public static final String error1OnStrictParsing = string("error1OnStrictParsing.txt"); + public static final String undeclaredAnnotationPropertyTurtle = + string("undeclaredAnnotationPropertyTurtle.txt"); + public static final String undeclaredAnnotationProperty = + string("undeclaredAnnotationProperty.txt"); + public static final String largeInteger = string("largeInteger.txt"); + public static final String minusInf = string("minusInf.txt"); + public static final String webOnt = string("webOnt.txt"); + public static String wrong = + "rdf:datatype=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral\""; + public static String correct = "rdf:parseType=\"Literal\""; + public static String preamble = string("preamble.txt"); + public static String closure = string("closure.txt"); + public static String literalMalformedXML = string("literalMalformedXML.txt"); + public static String literalXMl = string("literalXMl.txt"); + public static final String roundtripPaddedLiterals = string("roundtripPaddedLiterals.txt"); + public static final String missingTypes = string("missingTypes.txt"); + public static final String loadOboAnonymous = string("loadOboAnonymous.txt"); + public static String inputManSyntax = string("inputManSyntax.txt"); + public static final String failWhenTrixBanned = string("failWhenTrixBanned.txt"); + public static final String roundtripUTF8String = string("roundtripUTF8String.txt"); + public static final String INVALID_UTF8 = string("INVALID_UTF8.txt"); + public static final String latexExpectedOutput = string("latexExpectedOutput.txt"); + public static final String latexWithInverse = string("latexWithInverse.txt"); + public static final String latexWithUnderscores = string("latexWithUnderscores.txt"); + public static final String doNotIncludeExternalEntities = + string("doNotIncludeExternalEntities.txt"); + public static final String roundtripEntities = string("roundtripEntities.txt"); + public static final String convertToFunctional = string("convertToFunctional.txt"); + public static final String roundtripRIWithQuery = string("roundtripRIWithQuery.txt"); + public final static String moveTest = string("moveTest.txt"); + public static final String parsePlainLiteral = string("parsePlainLiteral.txt"); + public static String rdfContentForException = string("rdfContentForException.txt"); + public static String parseDisjointClasses = string("parseDisjointClasses.txt"); + public static String ontologyVersionParse = string("ontologyVersionParse.txt"); + public static String uniquePropertiesTurtle = string("uniquePropertiesTurtle.txt"); + public static String equivalentAndSubclasses = string("equivalentAndSubclasses.txt"); + public static String premiseOntology = string("premiseOntology.txt"); +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/atomicdecomposition/ModuleAnnotationsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/atomicdecomposition/ModuleAnnotationsTestCase.java new file mode 100644 index 0000000000..97b468a802 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/atomicdecomposition/ModuleAnnotationsTestCase.java @@ -0,0 +1,61 @@ +package org.semanticweb.owlapi.atomicdecomposition; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; + +import uk.ac.manchester.cs.owlapi.modularity.SyntacticLocalityModuleExtractor; + +class ModuleAnnotationsTestCase extends TestBase { + + private final OWLAnnotationProperty a = df.getOWLAnnotationProperty(IRI.create("urn:test:a")); + private final OWLAnnotationProperty b = df.getOWLAnnotationProperty(IRI.create("urn:test:b")); + private final OWLAnnotationProperty replaced = + df.getOWLAnnotationProperty("urn:test:term_replaced_by"); + OWLDeclarationAxiom dA = df.getOWLDeclarationAxiom(a); + OWLDeclarationAxiom dR = df.getOWLDeclarationAxiom(replaced); + OWLDeclarationAxiom dB = df.getOWLDeclarationAxiom(b); + OWLAnnotationAssertionAxiom ax = + df.getOWLAnnotationAssertionAxiom(replaced, a.getIRI(), b.getIRI()); + Set e = new HashSet<>(Arrays.asList(a)); + + @Test + void shouldNotAddAnnotations() throws OWLOntologyCreationException { + Set expected = new HashSet<>(); + IRI iri = IRI.create("urn:test:noanns"); + OWLOntology o = m.createOntology(iri); + Set axioms = new HashSet<>(Arrays.asList(dR, dA, dB, ax)); + o.add(axioms); + Set module = new SyntacticLocalityModuleExtractor(m, + m.getOntologyLoaderConfiguration().withSkipModuleAnnotations(true), axioms.stream(), + uk.ac.manchester.cs.owlapi.modularity.ModuleType.STAR, false).extract(e); + assertEquals(expected, module); + } + + @Test + void shouldAddAnnotations() throws OWLOntologyCreationException { + Set expected = new HashSet<>(); + expected.add(ax); + expected.add(dA); + IRI iri = IRI.create("urn:test:anns"); + OWLOntology o = m.createOntology(iri); + Set axioms = new HashSet<>(Arrays.asList(dR, dA, dB, ax)); + o.add(axioms); + Set module = new SyntacticLocalityModuleExtractor(m, axioms.stream(), + uk.ac.manchester.cs.owlapi.modularity.ModuleType.STAR, false).extract(e); + assertEquals(expected, module); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/change/NamesTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/change/NamesTestCase.java new file mode 100644 index 0000000000..b5626e53cd --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/change/NamesTestCase.java @@ -0,0 +1,88 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.change; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.functional.parser.OWLFunctionalSyntaxOWLParser; +import org.semanticweb.owlapi.krss1.parser.KRSSOWLParser; +import org.semanticweb.owlapi.krss2.parser.KRSS2OWLParser; +import org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxOntologyParser; +import org.semanticweb.owlapi.metrics.AverageAssertedNamedSuperclassCount; +import org.semanticweb.owlapi.metrics.AxiomCount; +import org.semanticweb.owlapi.metrics.HiddenGCICount; +import org.semanticweb.owlapi.metrics.ImportClosureSize; +import org.semanticweb.owlapi.metrics.MaximumNumberOfNamedSuperclasses; +import org.semanticweb.owlapi.metrics.NumberOfClassesWithMultipleInheritance; +import org.semanticweb.owlapi.metrics.UnsatisfiableClassCountMetric; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLImportsDeclaration; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.owlxml.parser.OWLXMLParser; +import org.semanticweb.owlapi.rdf.rdfxml.parser.RDFXMLParser; +import org.semanticweb.owlapi.rdf.turtle.parser.TurtleOntologyParser; +import org.semanticweb.owlapi.reasoner.OWLReasoner; + +class NamesTestCase extends TestBase { + + @Test + void shoudReturnRightName() throws OWLOntologyCreationException { + assertEquals("AddAxiomData", new AddAxiomData(mock(OWLAxiom.class)).getName()); + assertEquals("AddImportData", + new AddImportData(mock(OWLImportsDeclaration.class)).getName()); + assertEquals("AddOntologyAnnotationData", + new AddOntologyAnnotationData(mock(OWLAnnotation.class)).getName()); + assertEquals("OWLOntologyChangeRecord", + new OWLOntologyChangeRecord(mock(OWLOntologyID.class), + mock(OWLOntologyChangeData.class)).getName()); + assertEquals("RemoveAxiomData", new RemoveAxiomData(mock(OWLAxiom.class)).getName()); + assertEquals("RemoveImportData", + new RemoveImportData(mock(OWLImportsDeclaration.class)).getName()); + assertEquals("RemoveOntologyAnnotationData", + new RemoveOntologyAnnotationData(mock(OWLAnnotation.class)).getName()); + assertEquals("SetOntologyIDData", + new SetOntologyIDData(new OWLOntologyID(optional(iri("urn:test#", "test1")), + optional(iri("urn:test#", "test2")))).getName()); + assertEquals("KRSS2OWLParser", new KRSS2OWLParser().getName()); + assertEquals("KRSSOWLParser", new KRSSOWLParser().getName()); + assertEquals("OWLFunctionalSyntaxOWLParser", new OWLFunctionalSyntaxOWLParser().getName()); + assertEquals("ManchesterOWLSyntaxOntologyParser", + new ManchesterOWLSyntaxOntologyParser().getName()); + assertEquals("OWLXMLParser", new OWLXMLParser().getName()); + assertEquals("RDFXMLParser", new RDFXMLParser().getName()); + assertEquals("TurtleOntologyParser", new TurtleOntologyParser().getName()); + OWLOntology createOntology = OWLManager.createOWLOntologyManager().createOntology(); + assertEquals("Average number of named superclasses", + new AverageAssertedNamedSuperclassCount(createOntology).getName()); + assertEquals("Axiom", new AxiomCount(createOntology).getName()); + assertEquals("Hidden GCI Count", new HiddenGCICount(createOntology).getName()); + assertEquals("Imports closure size", new ImportClosureSize(createOntology).getName()); + assertEquals("Maximum number of asserted named superclasses", + new MaximumNumberOfNamedSuperclasses(createOntology).getName()); + assertEquals("Number of classes with asserted multiple inheritance", + new NumberOfClassesWithMultipleInheritance(createOntology).getName()); + OWLReasoner mock = mock(OWLReasoner.class); + when(mock.getRootOntology()).thenReturn(createOntology); + assertEquals("Unsatisfiable class count", + new UnsatisfiableClassCountMetric(mock).getName()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/change/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/change/package-info.java new file mode 100644 index 0000000000..c9dd358ea3 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/change/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.change; diff --git a/contract/src/test/java/org/semanticweb/owlapi/examples/DLQueryExample.java b/contract/src/test/java/org/semanticweb/owlapi/examples/DLQueryExample.java new file mode 100644 index 0000000000..97f2916345 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/examples/DLQueryExample.java @@ -0,0 +1,331 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.examples; + +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.expression.OWLEntityChecker; +import org.semanticweb.owlapi.expression.ShortFormEntityChecker; +import org.semanticweb.owlapi.io.StringDocumentSource; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.reasoner.Node; +import org.semanticweb.owlapi.reasoner.NodeSet; +import org.semanticweb.owlapi.reasoner.OWLReasoner; +import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; +import org.semanticweb.owlapi.reasoner.structural.StructuralReasonerFactory; +import org.semanticweb.owlapi.util.BidirectionalShortFormProvider; +import org.semanticweb.owlapi.util.BidirectionalShortFormProviderAdapter; +import org.semanticweb.owlapi.util.ShortFormProvider; +import org.semanticweb.owlapi.util.SimpleShortFormProvider; +import org.semanticweb.owlapi.util.mansyntax.ManchesterOWLSyntaxParser; + +/** + * An example that shows how to do a Protege like DLQuery. The example contains several helper + * classes:
    + * DLQueryEngine - This takes a string representing a class expression built from the terms in the + * signature of some ontology. DLQueryPrinter - This takes a string class expression and prints out + * the sub/super/equivalent classes and the instances of the specified class expression. + * DLQueryParser - this parses the specified class expression string + * + * @author Matthew Horridge, The University of Manchester, Bio-Health Informatics Group + * @since 3.1.0 + */ +public class DLQueryExample { + + private DLQueryExample() {} + + public static void main(String[] args) { + try { + // Load the KOALA example ontology defined before as a constant. + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + OWLOntology ontology = + manager.loadOntologyFromOntologyDocument(new StringDocumentSource(TestFiles.KOALA)); + System.out.println("Loaded ontology: " + ontology.getOntologyID()); + // We need a reasoner to do our query answering + OWLReasoner reasoner = createReasoner(ontology); + // Entities are named using IRIs. These are usually too long for use + // in user interfaces. To solve this + // problem, and so a query can be written using short class, + // property, individual names we use a short form + // provider. In this case, we'll just use a simple short form + // provider that generates short froms from IRI + // fragments. + ShortFormProvider shortFormProvider = new SimpleShortFormProvider(); + // Create the DLQueryPrinter helper class. This will manage the + // parsing of input and printing of results + DLQueryPrinter dlQueryPrinter = new DLQueryPrinter( + new DLQueryEngine(reasoner, shortFormProvider), shortFormProvider); + // Enter the query loop. A user is expected to enter class + // expression on the command line. + doQueryLoop(dlQueryPrinter); + } catch (OWLOntologyCreationException e) { + System.out.println("Could not load ontology: " + e.getMessage()); + } catch (IOException ioEx) { + System.out.println(ioEx.getMessage()); + } + } + + private static void doQueryLoop(DLQueryPrinter dlQueryPrinter) throws IOException { + while (true) { + // Prompt the user to enter a class expression + System.out.println( + "Please type a class expression in Manchester Syntax and press Enter (or press x to exit):"); + System.out.println(""); + String classExpression = readInput(); + // Check for exit condition + if (classExpression.equalsIgnoreCase("x")) { + break; + } + dlQueryPrinter.askQuery(classExpression.trim()); + System.out.println(); + System.out.println(); + } + } + + private static String readInput() throws IOException { + InputStream is = System.in; + InputStreamReader reader; + reader = new InputStreamReader(is, StandardCharsets.UTF_8); + BufferedReader br = new BufferedReader(reader); + return br.readLine(); + } + + private static OWLReasoner createReasoner(OWLOntology rootOntology) { + // We need to create an instance of OWLReasoner. An OWLReasoner provides + // the basic query functionality that we need, for example the ability + // obtain the subclasses of a class etc. To do this we use a reasoner + // factory. + // Create a reasoner factory. + OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory(); + return reasonerFactory.createReasoner(rootOntology); + } +} + + +/** + * This example shows how to perform a "dlquery". The DLQuery view/tab in Protege 4 works like this. + */ +class DLQueryEngine { + + private final OWLReasoner reasoner; + private final DLQueryParser parser; + + /** + * Constructs a DLQueryEngine. This will answer "DL queries" using the specified reasoner. A + * short form provider specifies how entities are rendered. + * + * @param reasoner The reasoner to be used for answering the queries. + * @param shortFormProvider A short form provider. + */ + DLQueryEngine(OWLReasoner reasoner, ShortFormProvider shortFormProvider) { + this.reasoner = reasoner; + OWLOntology rootOntology = reasoner.getRootOntology(); + parser = new DLQueryParser(rootOntology, shortFormProvider); + } + + /** + * Gets the superclasses of a class expression parsed from a string. + * + * @param classExpressionString The string from which the class expression will be parsed. + * @param direct Specifies whether direct superclasses should be returned or not. + * @return The superclasses of the specified class expression If there was a problem parsing the + * class expression. + */ + public Set getSuperClasses(String classExpressionString, boolean direct) { + if (classExpressionString.trim().isEmpty()) { + return Collections.emptySet(); + } + OWLClassExpression classExpression = parser.parseClassExpression(classExpressionString); + NodeSet superClasses = reasoner.getSuperClasses(classExpression, direct); + return asUnorderedSet(superClasses.entities()); + } + + /** + * Gets the equivalent classes of a class expression parsed from a string. + * + * @param classExpressionString The string from which the class expression will be parsed. + * @return The equivalent classes of the specified class expression If there was a problem + * parsing the class expression. + */ + public Set getEquivalentClasses(String classExpressionString) { + if (classExpressionString.trim().isEmpty()) { + return Collections.emptySet(); + } + OWLClassExpression classExpression = parser.parseClassExpression(classExpressionString); + Node equivalentClasses = reasoner.getEquivalentClasses(classExpression); + return asUnorderedSet(equivalentClasses.entities().filter(c -> !c.equals(classExpression))); + } + + /** + * Gets the subclasses of a class expression parsed from a string. + * + * @param classExpressionString The string from which the class expression will be parsed. + * @param direct Specifies whether direct subclasses should be returned or not. + * @return The subclasses of the specified class expression If there was a problem parsing the + * class expression. + */ + public Set getSubClasses(String classExpressionString, boolean direct) { + if (classExpressionString.trim().isEmpty()) { + return Collections.emptySet(); + } + OWLClassExpression classExpression = parser.parseClassExpression(classExpressionString); + NodeSet subClasses = reasoner.getSubClasses(classExpression, direct); + return asUnorderedSet(subClasses.entities()); + } + + /** + * Gets the instances of a class expression parsed from a string. + * + * @param classExpressionString The string from which the class expression will be parsed. + * @param direct Specifies whether direct instances should be returned or not. + * @return The instances of the specified class expression If there was a problem parsing the + * class expression. + */ + public Set getInstances(String classExpressionString, boolean direct) { + if (classExpressionString.trim().isEmpty()) { + return Collections.emptySet(); + } + OWLClassExpression classExpression = parser.parseClassExpression(classExpressionString); + NodeSet individuals = reasoner.getInstances(classExpression, direct); + return asUnorderedSet(individuals.entities()); + } +} + + +class DLQueryParser { + + private final OWLOntology rootOntology; + private final BidirectionalShortFormProvider bidiShortFormProvider; + + /** + * Constructs a DLQueryParser using the specified ontology and short form provider to map entity + * IRIs to short names. + * + * @param rootOntology The root ontology. This essentially provides the domain vocabulary for + * the query. + * @param shortFormProvider A short form provider to be used for mapping back and forth between + * entities and their short names (renderings). + */ + DLQueryParser(OWLOntology rootOntology, ShortFormProvider shortFormProvider) { + this.rootOntology = rootOntology; + OWLOntologyManager manager = rootOntology.getOWLOntologyManager(); + List importsClosure = asList(rootOntology.importsClosure()); + // Create a bidirectional short form provider to do the actual mapping. + // It will generate names using the input + // short form provider. + bidiShortFormProvider = + new BidirectionalShortFormProviderAdapter(manager, importsClosure, shortFormProvider); + } + + /** + * Parses a class expression string to obtain a class expression. + * + * @param classExpressionString The class expression string + * @return The corresponding class expression if the class expression string is malformed or + * contains unknown entity names. + */ + public OWLClassExpression parseClassExpression(String classExpressionString) { + // Set up the real parser + ManchesterOWLSyntaxParser parser = OWLManager.createManchesterParser(); + parser.setStringToParse(classExpressionString); + parser.setDefaultOntology(rootOntology); + // Specify an entity checker that wil be used to check a class + // expression contains the correct names. + OWLEntityChecker entityChecker = new ShortFormEntityChecker(bidiShortFormProvider); + parser.setOWLEntityChecker(entityChecker); + // Do the actual parsing + return parser.parseClassExpression(); + } +} + + +class DLQueryPrinter { + + private final DLQueryEngine dlQueryEngine; + private final ShortFormProvider shortFormProvider; + + /** + * @param engine the engine + * @param shortFormProvider the short form provider + */ + DLQueryPrinter(DLQueryEngine engine, ShortFormProvider shortFormProvider) { + this.shortFormProvider = shortFormProvider; + dlQueryEngine = engine; + } + + /** + * @param classExpression the class expression to use for interrogation + */ + public void askQuery(String classExpression) { + if (classExpression.isEmpty()) { + System.out.println("No class expression specified"); + } else { + StringBuilder sb = new StringBuilder(1000); + sb.append( + "\n--------------------------------------------------------------------------------\n"); + sb.append("QUERY: "); + sb.append(classExpression); + sb.append('\n'); + sb.append( + "--------------------------------------------------------------------------------\n\n"); + // Ask for the subclasses, superclasses etc. of the specified + // class expression. Print out the results. + Set superClasses = dlQueryEngine.getSuperClasses(classExpression, true); + printEntities("SuperClasses", superClasses, sb); + Set equivalentClasses = dlQueryEngine.getEquivalentClasses(classExpression); + printEntities("EquivalentClasses", equivalentClasses, sb); + Set subClasses = dlQueryEngine.getSubClasses(classExpression, true); + printEntities("SubClasses", subClasses, sb); + Set individuals = dlQueryEngine.getInstances(classExpression, true); + printEntities("Instances", individuals, sb); + System.out.println(sb); + } + } + + private void printEntities(String name, Set entities, StringBuilder sb) { + sb.append(name); + int length = 50 - name.length(); + for (int i = 0; i < length; i++) { + sb.append('.'); + } + sb.append("\n\n"); + if (!entities.isEmpty()) { + for (OWLEntity entity : entities) { + sb.append('\t'); + sb.append(shortFormProvider.getShortForm(entity)); + sb.append('\n'); + } + } else { + sb.append("\t[NONE]\n"); + } + sb.append('\n'); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/examples/Examples.java b/contract/src/test/java/org/semanticweb/owlapi/examples/Examples.java new file mode 100644 index 0000000000..43d17d53ee --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/examples/Examples.java @@ -0,0 +1,1792 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.examples; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED; +import static org.semanticweb.owlapi.search.EntitySearcher.getAnnotationObjects; +import static org.semanticweb.owlapi.search.Searcher.sup; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; +import static org.semanticweb.owlapi.vocab.OWLFacet.MAX_EXCLUSIVE; +import static org.semanticweb.owlapi.vocab.OWLFacet.MIN_INCLUSIVE; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.ManchesterSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.formats.TurtleDocumentFormat; +import org.semanticweb.owlapi.io.StreamDocumentTarget; +import org.semanticweb.owlapi.io.StringDocumentSource; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.AddOntologyAnnotation; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLClassExpressionVisitor; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDataUnionOf; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLOntologyIRIMapper; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; +import org.semanticweb.owlapi.model.PrefixManager; +import org.semanticweb.owlapi.model.SWRLAtom; +import org.semanticweb.owlapi.model.SWRLObjectPropertyAtom; +import org.semanticweb.owlapi.model.SWRLRule; +import org.semanticweb.owlapi.model.SWRLVariable; +import org.semanticweb.owlapi.model.SetOntologyID; +import org.semanticweb.owlapi.reasoner.BufferingMode; +import org.semanticweb.owlapi.reasoner.InferenceType; +import org.semanticweb.owlapi.reasoner.Node; +import org.semanticweb.owlapi.reasoner.NodeSet; +import org.semanticweb.owlapi.reasoner.OWLReasoner; +import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; +import org.semanticweb.owlapi.reasoner.SimpleConfiguration; +import org.semanticweb.owlapi.reasoner.structural.StructuralReasoner; +import org.semanticweb.owlapi.reasoner.structural.StructuralReasonerFactory; +import org.semanticweb.owlapi.search.Filters; +import org.semanticweb.owlapi.util.AutoIRIMapper; +import org.semanticweb.owlapi.util.DefaultPrefixManager; +import org.semanticweb.owlapi.util.InferredAxiomGenerator; +import org.semanticweb.owlapi.util.InferredOntologyGenerator; +import org.semanticweb.owlapi.util.InferredSubClassAxiomGenerator; +import org.semanticweb.owlapi.util.OWLEntityRemover; +import org.semanticweb.owlapi.util.OWLOntologyMerger; +import org.semanticweb.owlapi.util.OWLOntologyWalker; +import org.semanticweb.owlapi.util.OWLOntologyWalkerVisitorEx; +import org.semanticweb.owlapi.util.SimpleIRIMapper; +import org.semanticweb.owlapi.vocab.OWL2Datatype; +import org.semanticweb.owlapi.vocab.OWLFacet; + +import uk.ac.manchester.cs.owlapi.modularity.ModuleType; +import uk.ac.manchester.cs.owlapi.modularity.SyntacticLocalityModuleExtractor; + +/** + * @author Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group + * @since 2.0.0 + */ +@SuppressWarnings("unused") +public class Examples extends TestBase { + + private static final String QUOKKA_IRI = + "http://protege.stanford.edu/plugins/owl/owl-library/koala.owl#Quokka"; + + private static void print(Node parent, OWLReasoner reasoner, int depth) { + // We don't want to print out the bottom node (containing owl:Nothing + // and unsatisfiable classes) because this would appear as a leaf node + // everywhere + if (parent.isBottomNode()) { + return; + } + // Print an indent to denote parent-child relationships + printIndent(depth); + // Now print the node (containing the child classes) + printNode(parent); + for (Node child : reasoner.getSubClasses(parent.getRepresentativeElement(), + true)) { + // Recurse to do the children. Note that we don't have to worry + // about cycles as there are non in the inferred class hierarchy + // graph - a cycle gets collapsed into a single node since each + // class in the cycle is equivalent. + print(child, reasoner, depth + 1); + } + } + + private static void printIndent(int depth) { + for (int i = 0; i < depth; i++) { + // System.out.print(" "); + } + } + + private static void printNode(Node node) { + // The default prefix used here is only an example. + // For real ontologies, choose a meaningful prefix - the best + // choice depends on the actual ontology. + DefaultPrefixManager pm = + new DefaultPrefixManager(null, null, "http://owl.man.ac.uk/2005/07/sssw/people#"); + // Print out a node as a list of class names in curly brackets + for (Iterator it = node.entities().iterator(); it.hasNext();) { + OWLClass cls = it.next(); + // User a prefix manager to provide a slightly nicer shorter name + String shortForm = pm.getShortForm(cls); + assertNotNull(shortForm); + } + } + + private static boolean hasProperty(OWLOntologyManager man, OWLReasoner reasoner, OWLClass cls, + OWLObjectPropertyExpression prop) { + // To test whether the instances of a class must have a property we + // create a some values from restriction and then ask for the + // satisfiability of the class interesected with the complement of this + // some values from restriction. If the intersection is satisfiable then + // the instances of the class don't have to have the property, + // otherwise, they do. + OWLDataFactory dataFactory = man.getOWLDataFactory(); + OWLClassExpression restriction = + dataFactory.getOWLObjectSomeValuesFrom(prop, dataFactory.getOWLThing()); + // Now we see if the intersection of the class and the complement of + // this restriction is satisfiable + OWLClassExpression complement = dataFactory.getOWLObjectComplementOf(restriction); + OWLClassExpression intersection = dataFactory.getOWLObjectIntersectionOf(cls, complement); + return !reasoner.isSatisfiable(intersection); + } + + private static void printOntologyAndImports(OWLOntologyManager manager, OWLOntology ontology) { + // Print ontology IRI and where it was loaded from (they will be the + // same) + printOntology(manager, ontology); + // List the imported ontologies + ontology.imports().forEach(o -> printOntology(manager, o)); + } + + /** + * Prints the IRI of an ontology and its document IRI. + * + * @param manager The manager that manages the ontology + * @param ontology The ontology + */ + private static void printOntology(OWLOntologyManager manager, OWLOntology ontology) { + IRI ontologyIRI = ontology.getOntologyID().getOntologyIRI().get(); + IRI documentIRI = manager.getOntologyDocumentIRI(ontology); + // System.out.println(ontologyIRI == null ? "anonymous" : ontologyIRI + // .toQuotedString()); + // System.out.println(" from " + documentIRI.toQuotedString()); + } + + /** + * Convenience method that obtains the document IRI of an ontology contained in the TONES + * ontology repository given the ontology IRI. The TONES repository contains various ontologies + * of interest to reasoner developers and tools developers. Ontologies in the repository may be + * accessed in a RESTful way (see http://owl.cs.manchester.ac.uk/repository/) for more details). + * We basically get an ontology by specifying the repository IRI with an ontology query + * parameter that has the ontology IRI that we're after as its value. + * + * @param ontologyIRI The IRI of the ontology. + * @param tones tones iri + * @return The document IRI of the ontology in the TONES repository. + */ + private static IRI getTONESRepositoryDocumentIRI(IRI ontologyIRI, IRI tones) { + return IRI.create(tones + "?ontology=" + ontologyIRI); + } + + /** + * The examples here show how to load ontologies. + * + * @throws Exception exception + */ + public void shouldLoad() throws Exception { + // Get hold of an ontology manager + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + OWLOntology ontology = load(manager); + // We can always obtain the location where an ontology was loaded from; + // for this test, though, since the ontology was loaded from a string, + // this does not return a file + IRI documentIRI = manager.getOntologyDocumentIRI(ontology); + // In cases where a local copy of one of more ontologies is used, an + // ontology IRI mapper can be used to provide a redirection mechanism. + // This means that ontologies can be loaded as if they were located on + // the web. In this example, we simply redirect the loading from + // an IRI to our local copy above. + // iri and file here are used as examples + IRI iri = ontology.getOntologyID().getOntologyIRI().get(); + IRI remoteOntology = IRI.create("http://remote.ontology/we/dont/want/to/", "load"); + manager.getIRIMappers().add(new SimpleIRIMapper(remoteOntology, iri)); + // Load the ontology as if we were loading it from the web (from its + // ontology IRI) + OWLOntology redirectedOntology = manager.loadOntology(remoteOntology); + assertEquals(redirectedOntology, ontology); + // Note that when imports are loaded an ontology manager will be + // searched for mappings + } + + /** + * @param manager manager + * @return loaded ontology + * @throws OWLOntologyCreationException if a problem pops up + */ + OWLOntology load(OWLOntologyManager manager) throws OWLOntologyCreationException { + // in this test, the ontology is loaded from a string + return manager.loadOntologyFromOntologyDocument(new StringDocumentSource(TestFiles.KOALA)); + } + + /** + * This example shows how an ontology can be saved in various formats to various locations and + * streams. + * + * @throws Exception exception + */ + @Test + public void shouldSaveOntologies() throws Exception { + // Get hold of an ontology manager + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + OWLOntology ontology = load(manager); + // Now save a local copy of the ontology. (Specify a path appropriate to + // your setup) + File file = new File(folder, "owlapiexamples_saving.owl"); + manager.saveOntology(ontology, IRI.create(file.toURI())); + // By default ontologies are saved in the format from which they were + // loaded. In this case the ontology was loaded from rdf/xml. We + // can get information about the format of an ontology from its manager + OWLDocumentFormat format = ontology.getNonnullFormat(); + // We can save the ontology in a different format. Lets save the + // ontology + // in owl/xml format + OWLXMLDocumentFormat owlxmlFormat = new OWLXMLDocumentFormat(); + // Some ontology formats support prefix names and prefix IRIs. In our + // case we loaded the Koala ontology from an rdf/xml format, which + // supports prefixes. When we save the ontology in the new format we + // will copy the prefixes over so that we have nicely abbreviated IRIs + // in the new ontology document + if (format.isPrefixOWLDocumentFormat()) { + owlxmlFormat.copyPrefixesFrom(format.asPrefixOWLDocumentFormat()); + } + manager.saveOntology(ontology, owlxmlFormat, IRI.create(file.toURI())); + // We can also dump an ontology to System.out by specifying a different + // OWLOntologyOutputTarget. Note that we can write an ontology to a + // stream in a similar way using the StreamOutputTarget class + // Try another format - The Manchester OWL Syntax + ManchesterSyntaxDocumentFormat manSyntaxFormat = new ManchesterSyntaxDocumentFormat(); + if (format.isPrefixOWLDocumentFormat()) { + manSyntaxFormat.copyPrefixesFrom(format.asPrefixOWLDocumentFormat()); + } + // Replace the ByteArrayOutputStream wth an actual output stream to save + // to a file. + manager.saveOntology(ontology, manSyntaxFormat, + new StreamDocumentTarget(new ByteArrayOutputStream())); + } + + /** + * This example shows how to get access to objects that represent entities. + * + * @throws Exception exception + */ + @Test + public void shouldAccessEntities() throws Exception { + // In order to create objects that represent entities we need a + // data factory. + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + // We can get a reference to a data factory from an OWLOntologyManager. + OWLDataFactory factory = manager.getOWLDataFactory(); + // In OWL, entities are named objects that are used to build class + // expressions and axioms. They include classes, properties (object, + // data and annotation), named individuals and datatypes. All entities + // may be obtained from an OWLDataFactory. Let's create an object to + // represent a class. In this case, we'll choose + // http://www.semanticweb.org/owlapi/ontologies/ontology#A as the IRI + // for our class. There are two ways we can create classes (and other + // entities). The first is by specifying the full IRI. First we create + // an IRI object: + IRI iri = IRI.create("http://www.semanticweb.org/owlapi/ontologies/ontology#", "A"); + // Now we create the class + OWLClass clsAMethodA = factory.getOWLClass(iri); + // The second is to use a prefix manager and specify abbreviated IRIs. + // This is useful for creating lots of entities with the same prefix + // IRIs. First create our prefix manager and specify that the default + // prefix IRI (bound to the empty prefix name) is + // http://www.semanticweb.org/owlapi/ontologies/ontology# + PrefixManager pm = new DefaultPrefixManager(null, null, + "http://www.semanticweb.org/owlapi/ontologies/ontology#"); + // Now we use the prefix manager and just specify an abbreviated IRI + OWLClass clsAMethodB = factory.getOWLClass(":A", pm); + // Note that clsAMethodA will be equal to clsAMethodB because they are + // both OWLClass objects and have the same IRI. Creating entities in the + // above manner does not "add them to an ontology". They are merely + // objects that allow us to reference certain objects (classes etc.) for + // use in class expressions, and axioms (which can be added to an + // ontology). Lets create an ontology, and add a declaration axiom to + // the ontology that declares the above class + OWLOntology ontology = + manager.createOntology(IRI.create("http://anyiri.com/can/be/used/", "ontology")); + // We can add a declaration axiom to the ontology, that essentially adds + // the class to the signature of our ontology. + OWLDeclarationAxiom declarationAxiom = factory.getOWLDeclarationAxiom(clsAMethodA); + manager.addAxiom(ontology, declarationAxiom); + // Note that it isn't necessary to add declarations to an ontology in + // order to use an entity. Declarations will automatically be added in + // the + // saved version of the ontology. + } + + /** + * This example shows how to create dataranges. + */ + @Test + public void shouldBuildDataRanges() throws Exception { + // OWLDataRange is the superclass of all data ranges in the OWL API. + // Data ranges are used as the types of literals, as the ranges for data + // properties, as filler for data reatrictions. Get hold of a manager to + // work with + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + OWLDataFactory factory = manager.getOWLDataFactory(); + // OWLDatatype represents named datatypes in OWL. These are a bit like + // classes whose instances are data values OWLDatatype objects are + // obtained from a data factory. The OWL2Datatype enum defines built in + // OWL 2 Datatypes Get hold of the integer datatype + OWLDatatype integer = factory.getOWLDatatype(OWL2Datatype.XSD_INTEGER); + // For common data types there are some convenience methods of + // OWLDataFactory. For example + OWLDatatype integerDatatype = factory.getIntegerOWLDatatype(); + OWLDatatype floatDatatype = factory.getFloatOWLDatatype(); + OWLDatatype doubleDatatype = factory.getDoubleOWLDatatype(); + OWLDatatype booleanDatatype = factory.getBooleanOWLDatatype(); + // The top datatype (analgous to owl:Thing) is rdfs:Literal, which can + // be obtained from the data factory + OWLDatatype rdfsLiteral = factory.getTopDatatype(); + // Custom data ranges can be built up from these basic datatypes. For + // example, it is possible to restrict a datatype using facets from XML + // Schema Datatypes. For example, lets create a data range that + // describes integers that are greater or equal to 18 To do this, we + // restrict the xsd:integer datatype using the xsd:minInclusive facet + // with a value of 18. Get hold of a literal that is an integer value 18 + OWLLiteral eighteen = factory.getOWLLiteral(18); + // Now create the restriction. The OWLFacet enum provides an enumeration + // of the various facets that can be used + OWLDatatypeRestriction integerGE18 = + factory.getOWLDatatypeRestriction(integer, MIN_INCLUSIVE, eighteen); + // We could use this datatype in restriction, as the range of data + // properties etc. For example, if we want to restrict the range of the + // :hasAge data property to 18 or more we specify its range as this data + // range + PrefixManager pm = new DefaultPrefixManager(null, null, + "http://www.semanticweb.org/ontologies/dataranges#"); + OWLDataProperty hasAge = factory.getOWLDataProperty(":hasAge", pm); + OWLDataPropertyRangeAxiom rangeAxiom = + factory.getOWLDataPropertyRangeAxiom(hasAge, integerGE18); + OWLOntology ontology = manager + .createOntology(IRI.create("http://www.semanticweb.org/ontologies/", "dataranges")); + // Add the range axiom to our ontology + manager.addAxiom(ontology, rangeAxiom); + // For creating datatype restrictions on integers or doubles there are + // some convenience methods on OWLDataFactory For example: Create a data + // range of integers greater or equal to 60 + OWLDatatypeRestriction integerGE60 = factory.getOWLDatatypeMinInclusiveRestriction(60); + // Create a data range of integers less than 16 + OWLDatatypeRestriction integerLT16 = factory.getOWLDatatypeMaxExclusiveRestriction(18); + // In OWL 2 it is possible to represent the intersection, union and + // complement of data types For example, we could create a union of data + // ranges of the data range integer less than 16 or integer greater or + // equal to 60 + OWLDataUnionOf concessionaryAge = factory.getOWLDataUnionOf(integerLT16, integerGE60); + // We can also coin names for custom data ranges. To do this we use an + // OWLDatatypeDefintionAxiom Get hold of a named datarange (datatype) + // that will be used to assign a name to our above datatype + OWLDatatype concessionaryAgeDatatype = factory.getOWLDatatype(":ConcessionaryAge", pm); + // Now create a datatype definition axiom + OWLDatatypeDefinitionAxiom datatypeDef = + factory.getOWLDatatypeDefinitionAxiom(concessionaryAgeDatatype, concessionaryAge); + // Add the definition to our ontology + manager.addAxiom(ontology, datatypeDef); + // Dump our ontology + manager.saveOntology(ontology, new StreamDocumentTarget(new ByteArrayOutputStream())); + } + + /** + * This example shows how to work with dataranges. OWL 1.1 (and newer) allows data ranges to be + * created by taking a base datatype e.g. int, string etc. and then by applying facets to + * restrict the data range. For example, int greater than 18 + * + * @throws Exception exception + */ + @Test + public void shouldUseDataranges() throws Exception { + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + String base = "http://org.semanticweb.datarangeexample#"; + OWLOntology ontology = manager.createOntology(IRI.create(base, "")); + // We want to add an axiom to our ontology that states that adults have + // an age greater than 18. To do this, we will create a restriction + // along a hasAge property, with a filler that corresponds to the set of + // integers greater than 18. First get a reference to our hasAge + // property + OWLDataFactory factory = manager.getOWLDataFactory(); + OWLDataProperty hasAge = factory.getOWLDataProperty(base, "hasAge"); + // For completeness, we will make hasAge functional by adding an axiom + // to state this + OWLFunctionalDataPropertyAxiom funcAx = factory.getOWLFunctionalDataPropertyAxiom(hasAge); + manager.applyChange(new AddAxiom(ontology, funcAx)); + // Now create the data range which correponds to int greater than 18. To + // do this, we get hold of the int datatype and then restrict it with a + // minInclusive facet restriction. + OWLDatatype intDatatype = factory.getIntegerOWLDatatype(); + // Create the value "18", which is an int. + OWLLiteral eighteenConstant = factory.getOWLLiteral(18); + // Now create our custom datarange, which is int greater than or equal + // to 18. To do this, we need the minInclusive facet + OWLFacet facet = MIN_INCLUSIVE; + // Create the restricted data range by applying the facet restriction + // with a value of 18 to int + OWLDataRange intGreaterThan18 = + factory.getOWLDatatypeRestriction(intDatatype, facet, eighteenConstant); + // Now we can use this in our datatype restriction on hasAge + OWLClassExpression thingsWithAgeGreaterOrEqualTo18 = + factory.getOWLDataSomeValuesFrom(hasAge, intGreaterThan18); + // Now we want to say all adults have an age that is greater or equal to + // 18 - i.e. Adult is a subclass of hasAge some int[>= 18] Obtain a + // reference to the Adult class + OWLClass adult = factory.getOWLClass(base, "Adult"); + // Now make adult a subclass of the things that have an age greater to + // or equal to 18 + OWLSubClassOfAxiom ax = + factory.getOWLSubClassOfAxiom(adult, thingsWithAgeGreaterOrEqualTo18); + // Add our axiom to the ontology + manager.applyChange(new AddAxiom(ontology, ax)); + } + + @Test + public void shouldInstantiateLiterals() { + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + OWLDataFactory factory = manager.getOWLDataFactory(); + // Get an plain literal with an empty language tag + OWLLiteral literal1 = factory.getOWLLiteral("My string literal", ""); + // Get an untyped string literal with a language tag + OWLLiteral literal2 = factory.getOWLLiteral("My string literal", "en"); + // Typed literals are literals that are typed with a datatype Create a + // typed literal to represent the integer 33 + OWLDatatype integerDatatype = factory.getOWLDatatype(OWL2Datatype.XSD_INTEGER); + OWLLiteral literal3 = factory.getOWLLiteral("33", integerDatatype); + // There is are short cut methods on OWLDataFactory for creating typed + // literals with common datatypes Internallym these methods create + // literals as above Create a literal to represent the integer 33 + OWLLiteral literal4 = factory.getOWLLiteral(33); + // Create a literal to represent the double 33.3 + OWLLiteral literal5 = factory.getOWLLiteral(33.3); + // Create a literal to represent the boolean value true + OWLLiteral literal6 = factory.getOWLLiteral(true); + } + + /** + * @throws Exception exception + */ + @Test + public void shouldLoadAndSave() throws Exception { + // A simple example of how to load and save an ontology We first need to + // obtain a copy of an OWLOntologyManager, which, as the name suggests, + // manages a set of ontologies. An ontology is unique within an ontology + // manager. Each ontology knows its ontology manager. To load multiple + // copies of an ontology, multiple managers would have to be used. + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + // In this test we don't rely on a remote ontology and load it from + // a string + OWLOntology ontology = + manager.loadOntologyFromOntologyDocument(new StringDocumentSource(TestFiles.KOALA)); + // Print out all of the classes which are contained in the signature of + // the ontology. These are the classes that are referenced by axioms in + // the ontology. + // for (OWLClass cls : ontology.getClassesInSignature()) { + // System.out.println(cls); + // } + // Now save a copy to another location in OWL/XML format (i.e. disregard + // the format that the ontology was loaded in). + File file = new File(folder, "owlapiexample_example1.xml"); + file.createNewFile(); + IRI destination = IRI.create(file); + manager.saveOntology(ontology, new OWLXMLDocumentFormat(), destination); + } + + @Test + public void shouldAddAxiom() throws Exception { + // Create the manager that we will use to load ontologies. + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + // Ontologies can have an IRI, which is used to identify the ontology. + // You should think of the ontology IRI as the "name" of the ontology. + // This IRI frequently resembles a Web address (i.e. http://...), but it + // is important to realise that the ontology IRI might not necessarily + // be resolvable. In other words, we can't necessarily get a document + // from the URL corresponding to the ontology IRI, which represents the + // ontology. In order to have a concrete representation of an ontology + // (e.g. an RDF/XML file), we MAP the ontology IRI to a PHYSICAL IRI. We + // do this using an IRIMapper Let's create an ontology and name it + // "http://www.co-ode.org/ontologies/testont.owl" We need to set up a + // mapping which points to a concrete file where the ontology will be + // stored. (It's good practice to do this even if we don't intend to + // save the ontology). + IRI ontologyIRI = IRI.create("http://www.co-ode.org/ontologies/", "testont.owl"); + // Create the document IRI for our ontology + IRI documentIRI = IRI.create("file:/tmp/", "MyOnt.owl"); + // Set up a mapping, which maps the ontology to the document IRI + SimpleIRIMapper mapper = new SimpleIRIMapper(ontologyIRI, documentIRI); + manager.getIRIMappers().add(mapper); + // Now create the ontology - we use the ontology IRI (not the physical + // IRI) + OWLOntology ontology = manager.createOntology(ontologyIRI); + // Now we want to specify that A is a subclass of B. To do this, we add + // a subclass axiom. A subclass axiom is simply an object that specifies + // that one class is a subclass of another class. We need a data factory + // to create various object from. Each manager has a reference to a data + // factory that we can use. + OWLDataFactory factory = manager.getOWLDataFactory(); + // Get hold of references to class A and class B. Note that the ontology + // does not contain class A or classB, we simply get references to + // objects from a data factory that represent class A and class B + OWLClass clsA = factory.getOWLClass(ontologyIRI + "#", "A"); + OWLClass clsB = factory.getOWLClass(ontologyIRI + "#", "B"); + // Now create the axiom + OWLAxiom axiom = factory.getOWLSubClassOfAxiom(clsA, clsB); + // We now add the axiom to the ontology, so that the ontology states + // that A is a subclass of B. To do this we create an AddAxiom change + // object. At this stage neither classes A or B, or the axiom are + // contained in the ontology. We have to add the axiom to the ontology. + AddAxiom addAxiom = new AddAxiom(ontology, axiom); + // We now use the manager to apply the change + manager.applyChange(addAxiom); + // The ontology will now contain references to class A and class B - + // that is, class A and class B are contained within the SIGNATURE of + // the ontology let's print them out + ontology.classesInSignature().forEach(Object::toString); + // do anything that's necessary, e.g., print them out + // System.out.println("Referenced class: " + cls); + // We should also find that B is an ASSERTED superclass of A + Iterable superClasses = + asList(sup(ontology.axioms(Filters.subClassWithSub, clsA, INCLUDED), + OWLClassExpression.class)); + // Now save the ontology. The ontology will be saved to the location + // where we loaded it from, in the default ontology format + manager.saveOntology(ontology); + } + + /** + * These examples show how to create new ontologies. + * + * @throws Exception exception + */ + @Test + public void shouldCreateOntology() throws Exception { + // We first need to create an OWLOntologyManager, which will provide a + // point for creating, loading and saving ontologies. We can create a + // default ontology manager with the OWLManager class. This provides a + // common setup of an ontology manager. It registers parsers etc. for + // loading ontologies in a variety of syntaxes + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + // In OWL 2, an ontology may be named with an IRI (Internationalised + // Resource Identifier) We can create an instance of the IRI class as + // follows: + IRI ontologyIRI = IRI.create("http://www.semanticweb.org/ontologies/", "myontology"); + // Here we have decided to call our ontology + // "http://www.semanticweb.org/ontologies/myontology" If we publish our + // ontology then we should make the location coincide with the ontology + // IRI Now we have an IRI we can create an ontology using the manager + OWLOntology ontology = manager.createOntology(ontologyIRI); + // System.out.println("Created ontology: " + ontology); + // In OWL 2 if an ontology has an ontology IRI it may also have a + // version IRI The OWL API encapsulates ontology IRI and possible + // version IRI information in an OWLOntologyID Each ontology knows about + // its ID + OWLOntologyID ontologyID = ontology.getOntologyID(); + // In this case our ontology has an IRI but does not have a version IRI + // System.out.println("Ontology IRI: " + ontologyID.getOntologyIRI()); + // Our version IRI will be Optional.empty() to indicate that we don't + // have a version IRI + // An ontology may not have a version IRI - in this case, we count the + // ontology as an anonymous ontology. Our ontology does have an IRI so + // it is not anonymous: + // System.out.println("Anonymous Ontology: " + + // ontologyID.isAnonymous()); + // Once an ontology has been created its ontology ID (Ontology IRI and + // version IRI can be changed) to do this we must apply a SetOntologyID + // change through the ontology manager. Lets specify a version IRI for + // our ontology. In our case we will just "extend" our ontology IRI with + // some version information. We could of course specify any IRI for our + // version IRI. + IRI versionIRI = IRI.create(ontologyIRI + "/", "version1"); + // Note that we MUST specify an ontology IRI if we want to specify a + // version IRI + OWLOntologyID newOntologyID = + new OWLOntologyID(optional(ontologyIRI), optional(versionIRI)); + // Create the change that will set our version IRI + SetOntologyID setOntologyID = new SetOntologyID(ontology, newOntologyID); + // Apply the change + manager.applyChange(setOntologyID); + // We can also just specify the ontology IRI and possibly the version + // IRI at ontology creation time Set up our ID by specifying an ontology + // IRI and version IRI + IRI ontologyIRI2 = IRI.create("http://www.semanticweb.org/ontologies/", "myontology2"); + IRI versionIRI2 = + IRI.create("http://www.semanticweb.org/ontologies/myontology2/", "newversion"); + OWLOntologyID ontologyID2 = + new OWLOntologyID(optional(ontologyIRI2), optional(versionIRI2)); + // Now create the ontology + OWLOntology ontology2 = manager.createOntology(ontologyID2); + // Finally, if we don't want to give an ontology an IRI, in OWL 2 we + // don't have to + OWLOntology anonOntology = manager.createOntology(); + // This ontology is anonymous + // System.out.println("Anonymous: " + anonOntology.isAnonymous()); + } + + /** + * This example shows how to specify various property assertions for individuals. + * + * @throws Exception exception + */ + @Test + public void shouldCreatePropertyAssertions() throws Exception { + // We can specify the properties of an individual using property + // assertions Get a copy of an ontology manager + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + IRI ontologyIRI = IRI.create("http://example.com/owl/families/", ""); + OWLOntology ontology = manager.createOntology(ontologyIRI); + // Get hold of a data factory from the manager and set up a prefix + // manager to make things easier + OWLDataFactory factory = manager.getOWLDataFactory(); + PrefixManager pm = new DefaultPrefixManager(null, null, ontologyIRI.toString()); + // Let's specify the :John has a wife :Mary Get hold of the necessary + // individuals and object property + OWLNamedIndividual john = factory.getOWLNamedIndividual(":John", pm); + OWLNamedIndividual mary = factory.getOWLNamedIndividual(":Mary", pm); + OWLObjectProperty hasWife = factory.getOWLObjectProperty(":hasWife", pm); + // To specify that :John is related to :Mary via the :hasWife property + // we create an object property assertion and add it to the ontology + OWLObjectPropertyAssertionAxiom propertyAssertion = + factory.getOWLObjectPropertyAssertionAxiom(hasWife, john, mary); + manager.addAxiom(ontology, propertyAssertion); + // Now let's specify that :John is aged 51. Get hold of a data property + // called :hasAge + OWLDataProperty hasAge = factory.getOWLDataProperty(":hasAge", pm); + // To specify that :John has an age of 51 we create a data property + // assertion and add it to the ontology + OWLDataPropertyAssertionAxiom dataPropertyAssertion = + factory.getOWLDataPropertyAssertionAxiom(hasAge, john, 51); + manager.addAxiom(ontology, dataPropertyAssertion); + // Note that the above is a shortcut for creating a typed literal and + // specifying this typed literal as the value of the property assertion. + // That is, Get hold of the xsd:integer datatype + OWLDatatype integerDatatype = factory.getOWLDatatype(OWL2Datatype.XSD_INTEGER); + // Create a typed literal. We type the literal "51" with the datatype + OWLLiteral literal = factory.getOWLLiteral("51", integerDatatype); + // Create the property assertion and add it to the ontology + OWLAxiom ax = factory.getOWLDataPropertyAssertionAxiom(hasAge, john, literal); + manager.addAxiom(ontology, ax); + // Dump the ontology to System.out + manager.saveOntology(ontology, new StreamDocumentTarget(new ByteArrayOutputStream())); + } + + /** + * @throws Exception exception + */ + @Test + public void shouldAddClassAssertion() throws Exception { + // For more information on classes and instances see the OWL 2 Primer + // http://www.w3.org/TR/2009/REC-owl2-primer-20091027/#Classes_and_Instances + // In order to say that an individual is an instance of a class (in an + // ontology), we can add a ClassAssertion to the ontology. For example, + // suppose we wanted to specify that :Mary is an instance of the class + // :Person. First we need to obtain the individual :Mary and the class + // :Person Create an ontology manager to work with + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + OWLDataFactory dataFactory = manager.getOWLDataFactory(); + // The IRIs used here are taken from the OWL 2 Primer + String base = "http://example.com/owl/families/"; + PrefixManager pm = new DefaultPrefixManager(null, null, base); + // Get the reference to the :Person class (the full IRI will be + // ) + OWLClass person = dataFactory.getOWLClass(":Person", pm); + // Get the reference to the :Mary class (the full IRI will be + // ) + OWLNamedIndividual mary = dataFactory.getOWLNamedIndividual(":Mary", pm); + // Now create a ClassAssertion to specify that :Mary is an instance of + // :Person + OWLClassAssertionAxiom classAssertion = dataFactory.getOWLClassAssertionAxiom(person, mary); + // We need to add the class assertion to the ontology that we want + // specify that :Mary is a :Person + OWLOntology ontology = manager.createOntology(IRI.create(base, "")); + // Add the class assertion + manager.addAxiom(ontology, classAssertion); + // Dump the ontology to stdout + manager.saveOntology(ontology, new StreamDocumentTarget(new ByteArrayOutputStream())); + } + + /** + * @throws Exception exception + */ + @Test + public void shouldCreateAndSaveOntology() throws Exception { + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + // Let's create an ontology and name it + // "http://www.co-ode.org/ontologies/testont.owl" We need to set up a + // mapping which points to a concrete file where the ontology will be + // stored. (It's good practice to do this even if we don't intend to + // save the ontology). + IRI ontologyIRI = IRI.create("http://www.co-ode.org/ontologies/", "testont.owl"); + // Create a document IRI which can be resolved to point to where our + // ontology will be saved. + IRI documentIRI = IRI.create("file:/tmp/", "SWRLTest.owl"); + // Set up a mapping, which maps the ontology to the document IRI + SimpleIRIMapper mapper = new SimpleIRIMapper(ontologyIRI, documentIRI); + manager.getIRIMappers().add(mapper); + // Now create the ontology - we use the ontology IRI (not the physical + // IRI) + OWLOntology ontology = manager.createOntology(ontologyIRI); + OWLDataFactory factory = manager.getOWLDataFactory(); + // Get hold of references to class A and class B. Note that the ontology + // does not contain class A or classB, we simply get references to + // objects from a data factory that represent class A and class B + OWLClass clsA = factory.getOWLClass(ontologyIRI + "#", "A"); + OWLClass clsB = factory.getOWLClass(ontologyIRI + "#", "B"); + SWRLVariable var = factory.getSWRLVariable(ontologyIRI + "#", "x"); + SWRLRule rule = factory.getSWRLRule(singleton(factory.getSWRLClassAtom(clsA, var)), + singleton(factory.getSWRLClassAtom(clsB, var))); + manager.applyChange(new AddAxiom(ontology, rule)); + OWLObjectProperty prop = factory.getOWLObjectProperty(ontologyIRI + "#", "propA"); + OWLObjectProperty propB = factory.getOWLObjectProperty(ontologyIRI + "#", "propB"); + SWRLObjectPropertyAtom propAtom = factory.getSWRLObjectPropertyAtom(prop, var, var); + SWRLObjectPropertyAtom propAtom2 = factory.getSWRLObjectPropertyAtom(propB, var, var); + Set antecedent = new HashSet(); + antecedent.add(propAtom); + antecedent.add(propAtom2); + SWRLRule rule2 = factory.getSWRLRule(antecedent, Collections.singleton(propAtom)); + manager.applyChange(new AddAxiom(ontology, rule2)); + // Now save the ontology. The ontology will be saved to the location + // where we loaded it from, in the default ontology format + manager.saveOntology(ontology); + } + + /** + * This example shows how add an object property assertion (triple) of the form prop(subject, + * object) for example hasPart(a, b). + * + * @throws Exception exception + */ + @Test + public void shouldAddObjectPropertyAssertions() throws Exception { + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + String base = "http://www.semanticweb.org/ontologies/individualsexample"; + OWLOntology ont = man.createOntology(IRI.create(base, "")); + OWLDataFactory dataFactory = man.getOWLDataFactory(); + // In this case, we would like to state that matthew has a father who is + // peter. We need a subject and object - matthew is the subject and + // peter is the object. We use the data factory to obtain references to + // these individuals + OWLIndividual matthew = dataFactory.getOWLNamedIndividual(base + "#", "matthew"); + OWLIndividual peter = dataFactory.getOWLNamedIndividual(base + "#", "peter"); + // We want to link the subject and object with the hasFather property, + // so use the data factory to obtain a reference to this object + // property. + OWLObjectProperty hasFather = dataFactory.getOWLObjectProperty(base + "#", "hasFather"); + // Now create the actual assertion (triple), as an object property + // assertion axiom matthew --> hasFather --> peter + OWLObjectPropertyAssertionAxiom assertion = + dataFactory.getOWLObjectPropertyAssertionAxiom(hasFather, matthew, peter); + // Finally, add the axiom to our ontology and save + AddAxiom addAxiomChange = new AddAxiom(ont, assertion); + man.applyChange(addAxiomChange); + // We can also specify that matthew is an instance of Person. To do this + // we use a ClassAssertion axiom. First we need a reference to the + // person class + OWLClass personClass = dataFactory.getOWLClass(base + "#", "Person"); + // Now we will create out Class Assertion to specify that matthew is an + // instance of Person (or rather that Person has matthew as an instance) + OWLClassAssertionAxiom ax = dataFactory.getOWLClassAssertionAxiom(personClass, matthew); + // Add this axiom to our ontology. We can use a short cut method - + // instead of creating the AddAxiom change ourselves, it will be created + // automatically and the change applied + man.addAxiom(ont, ax); + // Save our ontology + man.saveOntology(ont, IRI.create("file:/tmp/", "example.owl")); + } + + /** + * An example which shows how to "delete" entities, in this case individuals, from and ontology. + * + * @throws Exception exception + */ + @Test + public void shouldDeleteIndividuals() throws Exception { + // The Koala ontology contains an individual of type Degree. + // In this example we will delete it.. + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + OWLOntology ont = load(man); + // We can't directly delete individuals, properties or classes from an + // ontology because ontologies don't directly contain entities -- they + // are merely referenced by the axioms that the ontology contains. For + // example, if an ontology contained a subclass axiom SubClassOf(A, B) + // which stated A was a subclass of B, then that ontology would contain + // references to classes A and B. If we essentially want to "delete" + // classes A and B from this ontology we have to remove all axioms that + // contain class A and class B in their SIGNATURE (in this case just one + // axiom SubClassOf(A, B)). To do this, we can use the OWLEntityRemove + // utility class, which will remove an entity (class, property or + // individual) from a set of ontologies. Create the entity remover - in + // this case we just want to remove the individuals from the + // ontology, so pass our reference to the ontology in as a + // singleton set. + OWLEntityRemover remover = new OWLEntityRemover(singleton(ont)); + // System.out.println("Number of individuals: " + // + ont.getIndividualsInSignature().size()); + // Loop through each individual that is referenced in the + // ontology, and ask it to accept a visit from the entity remover. The + // remover will automatically accumulate the changes which are necessary + // to remove the individual from the ontologies which it knows about + ont.individualsInSignature().forEach(i -> i.accept(remover)); + // Now we get all of the changes from the entity remover, which should + // be applied to remove all of the individuals that we have visited from + // the ontology. Notice that "batch" deletes can essentially be + // performed - we simply visit all of the classes, properties and + // individuals that we want to remove and then apply ALL of the changes + // after using the entity remover to collect them + man.applyChanges(remover.getChanges()); + // System.out.println("Number of individuals: " + // + ont.getIndividualsInSignature().size()); + // At this point, if we wanted to reuse the entity remover, we would + // have to reset it + remover.reset(); + } + + /** + * An example which shows how to create restrictions and add them as superclasses of a class + * (i.e. "adding restrictions to classes") + * + * @throws Exception exception + */ + @Test + public void shouldCreateRestrictions() throws Exception { + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + String base = "http://org.semanticweb.restrictionexample"; + OWLOntology ont = man.createOntology(IRI.create(base, "")); + // In this example we will add an axiom to state that all Heads have + // parts that are noses (in fact, here we merely state that a Head has + // at least one nose!). We do this by creating an existential (some) + // restriction to describe the class of things which have a part that is + // a nose (hasPart some Nose), and then we use this restriction in a + // subclass axiom to state that Head is a subclass of things that have + // parts that are Noses SubClassOf(Head, hasPart some Nose) -- in other + // words, Heads have parts that are noses! First we need to obtain + // references to our hasPart property and our Nose class + OWLDataFactory factory = man.getOWLDataFactory(); + OWLObjectProperty hasPart = factory.getOWLObjectProperty(base + "#", "hasPart"); + OWLClass nose = factory.getOWLClass(base + "#", "Nose"); + // Now create a restriction to describe the class of individuals that + // have at least one part that is a kind of nose + OWLClassExpression hasPartSomeNose = factory.getOWLObjectSomeValuesFrom(hasPart, nose); + // Obtain a reference to the Head class so that we can specify that + // Heads have noses + OWLClass head = factory.getOWLClass(base + "#", "Head"); + // We now want to state that Head is a subclass of hasPart some Nose, to + // do this we create a subclass axiom, with head as the subclass and + // "hasPart some Nose" as the superclass (remember, restrictions are + // also classes - they describe classes of individuals -- they are + // anonymous classes). + OWLSubClassOfAxiom ax = factory.getOWLSubClassOfAxiom(head, hasPartSomeNose); + // Add the axiom to our ontology + AddAxiom addAx = new AddAxiom(ont, ax); + man.applyChange(addAx); + } + + /** + * An example which shows how to interact with a reasoner. In this example Pellet is used as the + * reasoner. You must get hold of the pellet libraries from pellet.owldl.com. + * + * @throws Exception exception + */ + @Test + public void shouldUseReasoner() throws Exception { + // Create our ontology manager in the usual way. + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + OWLOntology ont = load(manager); + // We need to create an instance of OWLReasoner. An OWLReasoner provides + // the basic query functionality that we need, for example the ability + // obtain the subclasses of a class etc. To do this we use a reasoner + // factory. Create a reasoner factory. In this case, we will use HermiT, + // but we could also use FaCT++ (http://code.google.com/p/factplusplus/) + // or Pellet(http://clarkparsia.com/pellet) Note that (as of 03 Feb + // 2010) FaCT++ and Pellet OWL API 3.0.0 compatible libraries are + // expected to be available in the near future). For now, we'll use + // HermiT HermiT can be downloaded from http://hermit-reasoner.com Make + // sure you get the HermiT library and add it to your class path. You + // can then instantiate the HermiT reasoner factory: Comment out the + // first line below and uncomment the second line below to instantiate + // the HermiT reasoner factory. You'll also need to import the + // org.semanticweb.HermiT.Reasoner package. + OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory(); + // OWLReasonerFactory reasonerFactory = new Reasoner.ReasonerFactory(); + // We'll now create an instance of an OWLReasoner (the implementation + // being provided by HermiT as we're using the HermiT reasoner factory). + // The are two categories of reasoner, Buffering and NonBuffering. In + // our case, we'll create the buffering reasoner, which is the default + // kind of reasoner. We'll also attach a progress monitor to the + // reasoner. To do this we set up a configuration that knows about a + // progress monitor. Create a console progress monitor. This will print + // the reasoner progress out to the console. + // ConsoleProgressMonitor progressMonitor = new + // ConsoleProgressMonitor(); + // Specify the progress monitor via a configuration. We could also + // specify other setup parameters in the configuration, and different + // reasoners may accept their own defined parameters this way. + // OWLReasonerConfiguration config = new SimpleConfiguration( + // progressMonitor); + // Create a reasoner that will reason over our ontology and its imports + // closure. Pass in the configuration. + // OWLReasoner reasoner = reasonerFactory.createReasoner(ont, config); + OWLReasoner reasoner = reasonerFactory.createReasoner(ont); + // Ask the reasoner to do all the necessary work now + reasoner.precomputeInferences(); + // We can determine if the ontology is actually consistent (in this + // case, it should be). + boolean consistent = reasoner.isConsistent(); + // System.out.println("Consistent: " + consistent); + // We can easily get a list of unsatisfiable classes. (A class is + // unsatisfiable if it can't possibly have any instances). Note that the + // getUnsatisfiableClasses method is really just a convenience method + // for obtaining the classes that are equivalent to owl:Nothing. + Node bottomNode = reasoner.getUnsatisfiableClasses(); + // This node contains owl:Nothing and all the classes that are + // equivalent to owl:Nothing - i.e. the unsatisfiable classes. We just + // want to print out the unsatisfiable classes excluding owl:Nothing, + // and we can used a convenience method on the node to get these + Set unsatisfiable = bottomNode.getEntitiesMinusBottom(); + if (!unsatisfiable.isEmpty()) { + // System.out.println("The following classes are unsatisfiable: "); + for (OWLClass cls : unsatisfiable) { + // System.out.println(" " + cls); + } + } else { + // System.out.println("There are no unsatisfiable classes"); + } + // Now we want to query the reasoner for all descendants of Marsupial. + // Vegetarians are defined in the ontology to be animals that don't eat + // animals or parts of animals. + OWLDataFactory fac = manager.getOWLDataFactory(); + // Get a reference to the vegetarian class so that we can as the + // reasoner about it. The full IRI of this class happens to be: + // + OWLClass marsupials = fac.getOWLClass( + "http://protege.stanford.edu/plugins/owl/owl-library/koala.owl#", "Marsupials"); + // Now use the reasoner to obtain the subclasses of Marsupials. We can + // ask for the direct subclasses or all of the (proper) + // subclasses. In this case we just want the direct ones + // (which we specify by the "true" flag). + NodeSet subClses = reasoner.getSubClasses(marsupials, true); + // The reasoner returns a NodeSet, which represents a set of Nodes. Each + // node in the set represents a subclass of Marsupial. A node of + // classes contains classes, where each class in the node is equivalent. + // For example, if we asked for the subclasses of some class A and got + // back a NodeSet containing two nodes {B, C} and {D}, then A would have + // two proper subclasses. One of these subclasses would be equivalent to + // the class D, and the other would be the class that is equivalent to + // class B and class C. In this case, we don't particularly care about + // the equivalences, so we will flatten this set of sets and print the + // result + Set clses = asSet(subClses.entities()); + // for (OWLClass cls : clses) { + // System.out.println(" " + cls); + // } + // We can easily + // retrieve the instances of a class. In this example we'll obtain the + // instances of the class Marsupials. + NodeSet individualsNodeSet = reasoner.getInstances(marsupials, false); + // The reasoner returns a NodeSet again. This time the NodeSet contains + // individuals. Again, we just want the individuals, so get a flattened + // set. + Set individuals = asSet(individualsNodeSet.entities()); + // for (OWLNamedIndividual ind : individuals) { + // System.out.println(" " + ind); + // } + // Again, it's worth noting that not all of the individuals that are + // returned were explicitly stated to be marsupials. Finally, we can ask + // for + // the property values (property assertions in OWL speak) for a given + // individual and property. + // Let's get all properties for all individuals + ont.individualsInSignature().forEach(i -> ont.objectPropertiesInSignature().forEach(p -> { + NodeSet individualValues = reasoner.getObjectPropertyValues(i, p); + Set values = asUnorderedSet(individualValues.entities()); + // System.out.println("The property values for "+p+" for + // individual "+i+" are: "); + // for (OWLNamedIndividual ind : values) { + // System.out.println(" " + ind); + // } + })); + // Finally, let's print out the class hierarchy. + Node topNode = reasoner.getTopClassNode(); + print(topNode, reasoner, 0); + } + + /** + * This example shows how to examine the restrictions on a class. + * + * @throws Exception exception + */ + @Test + public void shouldLookAtRestrictions() throws Exception { + // Create our manager + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + // Load the Koala ontology + OWLOntology ont = load(man); + // We want to examine the restrictions on Quokka. To do this, + // we need to obtain a reference to the Quokka class. In this + // case, we know the IRI (it happens to be the ontology IRI + #Quokka + // This isn't always the case. A class may have a IRI that bears no + // resemblance to the ontology IRI which contains axioms about the + // class. + IRI quokkaIRI = IRI.create(ont.getOntologyID().getOntologyIRI().get() + "#", "Quokka"); + OWLClass quokka = man.getOWLDataFactory().getOWLClass(quokkaIRI); + // Now we want to collect the properties which are used in existential + // restrictions on the class. To do this, we will create a utility class + // - RestrictionVisitor, which acts as a filter for existential + // restrictions. This uses the Visitor Pattern (google Visitor Design + // Pattern for more information on this design pattern, or see + // http://en.wikipedia.org/wiki/Visitor_pattern) + RestrictionVisitor restrictionVisitor = new RestrictionVisitor(singleton(ont)); + // In this case, restrictions are used as (anonymous) superclasses, so + // to get the restrictions on quokka we need to obtain the + // subclass axioms for quokka. + ont.subClassAxiomsForSubClass(quokka) + .forEach(ax -> ax.getSuperClass().accept(restrictionVisitor)); + // Ask our superclass to accept a visit from the RestrictionVisitor + // - if it is an existential restiction then our restriction visitor + // will answer it - if not our visitor will ignore it + // Our RestrictionVisitor has now collected all of the properties that + // have been restricted in existential restrictions - print them out. + // System.out.println("Restricted properties for " + quokka + // + ": " + restrictionVisitor.getRestrictedProperties().size()); + // for (OWLObjectPropertyExpression prop : restrictionVisitor + // .getRestrictedProperties()) { + // System.out.println(" " + prop); + // } + } + + /** + * This example shows how to create and read annotations. + * + * @throws Exception exception + */ + @Test + public void shouldCreateAndReadAnnotations() throws Exception { + // Create our manager + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + // Load the Koala ontology + OWLOntology ont = load(man); + // We want to add a comment to the Quokka class. First, we need to + // obtain + // a reference to the class + OWLClass quokka = + df.getOWLClass(ont.getOntologyID().getOntologyIRI().get() + "#", "Quokka"); + // Now we create the content of our comment. In this case we simply want + // a plain string literal. We'll attach a language to the comment to + // specify that our comment is written in English (en). + OWLAnnotation commentAnno = + df.getRDFSComment(df.getOWLLiteral("A class which represents quokkas", "en")); + // Specify that the class has an annotation - to do this we attach + // an entity annotation using an entity annotation axiom (remember, + // classes are entities) + OWLAxiom ax = df.getOWLAnnotationAssertionAxiom(quokka.getIRI(), commentAnno); + // Add the axiom to the ontology + man.applyChange(new AddAxiom(ont, ax)); + // Now lets add a version info annotation to the ontology. There is no + // 'standard' OWL annotation object for this, like there is for + // comments and labels, so the creation of the annotation is a bit more + // involved. First we'll create a constant for the annotation value. + // Version info should probably contain a version number for the + // ontology, but in this case, we'll add some text to describe why the + // version has been updated + OWLLiteral lit = df.getOWLLiteral("Added a comment to the quokka class"); + // The above constant is just a plain literal containing the version + // info text/comment we need to create an annotation, which pairs a IRI + // with the constant + OWLAnnotation anno = df.getOWLAnnotation(df.getOWLVersionInfo(), lit); + // Now we can add this as an ontology annotation Apply the change in the + // usual way + man.applyChange(new AddOntologyAnnotation(ont, anno)); + // It is worth noting that literals + // can be typed or untyped. If literals are untyped then they can have + // language tags, which are optional - typed literals cannot have + // language tags. For each class in the ontology, we retrieve its + // annotations and sift through them. If the annotation annotates the + // class with a constant which is untyped then we check the language tag + // to see if it is English. Firstly, get the annotation property for + // rdfs:label + OWLAnnotationProperty label = df.getRDFSLabel(); + // Get the annotations on the class that use the label property + ont.classesInSignature().forEach(c -> getAnnotationObjects(c, ont.importsClosure(), label) + .map(a -> a.getValue().asLiteral()).filter(v -> v.isPresent() && v.get().hasLang("en")) + .forEach(v -> v.get().getLiteral())); + } + + /** + * This example shows how to generate an ontology containing some inferred information. + * + * @throws Exception exception + */ + @Test + public void shouldCreateInferredAxioms() throws Exception { + // Create a reasoner factory. + // See Profiles for a list of known reasoner factories; note that you + // will need to add the reasoner and any dependency to the classpath for + // this to work. + // The structural reasoner is a mock reasoner that does no inferences; + // it is used only for examples. + OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory(); + // Uncomment the line below reasonerFactory = new + // PelletReasonerFactory(); Load an example ontology - for the purposes + // of the example, we will just load the ontology. + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + OWLOntology ont = load(man); + // Create the reasoner and classify the ontology + OWLReasoner reasoner = reasonerFactory.createNonBufferingReasoner(ont); + reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY); + // To generate an inferred ontology we use implementations of inferred + // axiom generators to generate the parts of the ontology we want (e.g. + // subclass axioms, equivalent classes axioms, class assertion axiom + // etc. - see the org.semanticweb.owlapi.util package for more + // implementations). Set up our list of inferred axiom generators + List> gens = + new ArrayList>(); + gens.add(new InferredSubClassAxiomGenerator()); + // Put the inferred axioms into a fresh empty ontology - note that there + // is nothing stopping us stuffing them back into the original asserted + // ontology if we wanted to do this. + OWLOntology infOnt = man.createOntology(); + // Now get the inferred ontology generator to generate some inferred + // axioms for us (into our fresh ontology). We specify the reasoner that + // we want to use and the inferred axiom generators that we want to use. + InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens); + iog.fillOntology(man.getOWLDataFactory(), infOnt); + // Save the inferred ontology. (Replace the IRI with one that is + // appropriate for your setup) + man.saveOntology(infOnt, new StringDocumentTarget()); + } + + /** + * This example shows how to merge to ontologies (by simply combining axioms from one ontology + * into another ontology). + * + * @throws Exception exception + */ + @Test + public void shouldMergeOntologies() throws Exception { + // Just load two arbitrary ontologies for the purposes of this example + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + load(man); + OWLOntology o = man.createOntology(IRI.create("urn:test", "")); + man.addAxiom(o, man.getOWLDataFactory() + .getOWLDeclarationAxiom(man.getOWLDataFactory().getOWLClass("urn:test#", "class"))); + // Create our ontology merger + OWLOntologyMerger merger = new OWLOntologyMerger(man); + // We merge all of the loaded ontologies. Since an OWLOntologyManager is + // an OWLOntologySetProvider we just pass this in. We also need to + // specify the IRI of the new ontology that will be created. + IRI mergedOntologyIRI = IRI.create("http://www.semanticweb.com/", "mymergedont"); + OWLOntology merged = merger.createMergedOntology(man, mergedOntologyIRI); + // Print out the axioms in the merged ontology. + // for (OWLAxiom ax : merged.getAxioms()) { + // System.out.println(ax); + // } + } + + /** + * @throws Exception exception + */ + @Test + public void shouldWalkOntology() throws Exception { + // This example shows how to use an ontology walker to walk the asserted + // structure of an ontology. Suppose we want to find the axioms that use + // a some values from (existential restriction) we can use the walker to + // do this. We'll use the Koala ontology as an example. Load the + // ontology from the web: + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + OWLOntology ont = load(man); + // Create the walker. Pass in the koala ontology - we need to put it + // into a set though, so we just create a singleton set in this case. + OWLOntologyWalker walker = new OWLOntologyWalker(singleton(ont)); + // Now ask our walker to walk over the ontology. We specify a visitor + // who gets visited by the various objects as the walker encounters + // them. We need to create out visitor. This can be any ordinary + // visitor, but we will extend the OWLOntologyWalkerVisitor because it + // provides a convenience method to get the current axiom being visited + // as we go. Create an instance and override the + // visit(OWLObjectSomeValuesFrom) method, because we are interested in + // some values from restrictions. + OWLOntologyWalkerVisitorEx visitor = + new OWLOntologyWalkerVisitorEx(walker) { + + @Override + public Object visit(OWLObjectSomeValuesFrom ce) { + // Print out the restriction + // System.out.println(desc); + // Print out the axiom where the restriction is used + // System.out.println(" " + getCurrentAxiom()); + // We don't need to return anything here. + return ""; + } + }; + // Now ask the walker to walk over the ontology structure using our + // visitor instance. + walker.walkStructure(visitor); + } + + /** + * @throws Exception exception + */ + @Test + public void shouldQueryWithReasoner() throws Exception { + // We will load the Koala ontology and query it using a reasoner + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + OWLOntology ont = load(man); + // For this particular ontology, we know that all class, properties + // names etc. have IRIs that is made up of the ontology IRI plus # plus + // the local name + String prefix = ont.getOntologyID().getOntologyIRI().get() + "#"; + // Create a reasoner. We will use Pellet in this case. Make sure that + // the latest version of the Pellet libraries are on the runtime class + // path + OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory(); + // Uncomment the line below reasonerFactory = new + // PelletReasonerFactory(); + OWLReasoner reasoner = reasonerFactory.createNonBufferingReasoner(ont); + // Now we can query the reasoner, suppose we want to determine the + // properties that instances of Quokka must have + OWLClass quokka = man.getOWLDataFactory().getOWLClass(prefix, "Quokka"); + // printProperties(man, ont, reasoner, quokka); + // We can also ask if the instances of a class must have a property + OWLClass koala = man.getOWLDataFactory().getOWLClass(prefix, "KoalaWithPhD"); + OWLObjectProperty hasDegree = + man.getOWLDataFactory().getOWLObjectProperty(prefix, "hasDegree"); + if (hasProperty(man, reasoner, koala, hasDegree)) { + // System.out.println("Instances of " + koala + // + " have a degree"); + } + } + + /** + * This example shows how to use IRI mappers to redirect imports and loading. + * + * @throws Exception exception + */ + @Disabled("This test is ignored. We do not want to fetch stuff from the network just to run a unit test for an example") + @Test + public void shouldUseIRIMappers() throws Exception { + IRI mgedOntologyIri = + IRI.create("http://mged.sourceforge.net/ontologies/", "MGEDOntology.owl"); + IRI protegeOntologyIri = IRI.create("http://protege.stanford.edu/plugins/owl/", "protege"); + IRI tonesRepositoryIri = + IRI.create("http://owl.cs.manchester.ac.uk/repository/", "download"); + // Create a manager to work with + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + // Load the MGED ontology. There is a copy of the MGED ontology located + // at the address pointed to by its ontology IRI (this is good practice + // and is recommended in the OWL 2 specifications). + OWLOntology ontology = manager.loadOntology(mgedOntologyIri); + // Print out the ontology IRI and its imported ontology IRIs + printOntologyAndImports(manager, ontology); + // We'll load the MGED ontology again, but this time, we'll get the + // Protege ontology (that it imports) from the TONES repository. To tell + // the ontology manager to do this we need to add an IRI mapper. We need + // an implementation of OWLOntologyIRIMapper. Given and IRI and + // OWLOntologyIRIMapper simply returns some other IRI. There are quite a + // few implementations of IRI mapper in the OWL API, here we will just + // use a really basic implementation that maps a specific IRI to another + // specific IRI. Create a mapper that maps the Protege ontology IRI to + // the document IRI that points to a copy in the TONES ontology + // repository. + IRI protegeOntologyDocumentIRI = + getTONESRepositoryDocumentIRI(protegeOntologyIri, tonesRepositoryIri); + OWLOntologyIRIMapper iriMapper = + new SimpleIRIMapper(protegeOntologyIri, protegeOntologyDocumentIRI); + // Create a new manager that we will use to load the MGED ontology + OWLOntologyManager manager2 = OWLManager.createOWLOntologyManager(); + // Register our mapper with the manager + manager2.getIRIMappers().add(iriMapper); + // Now load our MGED ontology + OWLOntology ontology2 = load(manager2); + // Print out the details + printOntologyAndImports(manager2, ontology2); + // Notice that the document IRI of the protege ontology is different to + // the document IRI of the ontology when it was loaded the first time. + // This is due to the mapper redirecting the ontology loader. For + // example, AutoIRIMapper: An AutoIRIMapper finds ontologies in a local + // folder and maps their IRIs to their locations in this folder We + // specify a directory/folder where the ontologies are located. In this + // case we've just specified the tmp directory. + // We can also specify a flag to indicate whether the directory should + // be searched recursively. + OWLOntologyIRIMapper autoIRIMapper = new AutoIRIMapper(folder, false); + // We can now use this mapper in the usual way, i.e. + manager2.getIRIMappers().add(autoIRIMapper); + // Of course, applications (such as Protege) usually implement their own + // mappers to deal with specific application requirements. + } + + /** + * This example shows how to extract modules. + * + * @throws Exception exception + */ + @Test + public void shouldExtractModules() throws Exception { + // Create our manager + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + OWLDataFactory dataFactory = OWLManager.getOWLDataFactory(); + // Load the Koala ontology + OWLOntology ont = load(man); + // We want to extract a module for all toppings. We therefore have to + // generate a seed signature that contains "Quokka" and its + // subclasses. We start by creating a signature that consists of + // "Quokka". + OWLClass toppingCls = + df.getOWLClass(ont.getOntologyID().getOntologyIRI().get() + "#", "Quokka"); + Set sig = new HashSet(); + sig.add(toppingCls); + // We now add all subclasses (direct and indirect) of the chosen + // classes. Ideally, it should be done using a DL reasoner, in order to + // take inferred subclass relations into account. We are using the + // structural reasoner of the OWL API for simplicity. + Set seedSig = new HashSet(); + OWLReasoner reasoner = + new StructuralReasoner(ont, new SimpleConfiguration(), BufferingMode.NON_BUFFERING); + for (OWLEntity ent : sig) { + seedSig.add(ent); + if (OWLClass.class.isAssignableFrom(ent.getClass())) { + NodeSet subClasses = reasoner.getSubClasses((OWLClass) ent, false); + seedSig.addAll(asList(subClasses.entities())); + } + } + // We now extract a locality-based module. For most reuse purposes, the + // module type should be STAR -- this yields the smallest possible + // locality-based module. These modules guarantee that all entailments + // of the original ontology that can be formulated using only terms from + // the seed signature or the module will also be entailments of the + // module. In easier words, the module preserves all knowledge of the + // ontology about the terms in the seed signature or the module. + SyntacticLocalityModuleExtractor sme = + new SyntacticLocalityModuleExtractor(man, ont, ModuleType.STAR); + IRI moduleIRI = IRI.create("urn:test:QuokkaModule.owl", ""); + OWLOntology mod = sme.extractAsOntology(seedSig, moduleIRI); + // The module can now be saved as usual + } + + /** + * The following example uses entities and axioms that are used in the OWL Primer. The purpose + * of this example is to illustrate some of the methods of creating class expressions and + * various types of axioms. Typically, an ontology wouldn't be constructed programmatically in a + * long drawn out fashion like this, it would be constructed in an ontology editor such as + * Protege 4, or Swoop. The OWL API would then be used to examine the asserted structure of the + * ontology, and in conjunction with an OWL reasoner such as FaCT++ or Pellet used to query the + * inferred ontology. + * + * @throws Exception exception + */ + @Test + public void owlPrimer() throws Exception { + // The OWLOntologyManager is at the heart of the OWL API, we can create + // an instance of this using the OWLManager class, which will set up + // commonly used options (such as which parsers are registered etc. + // etc.) + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + // We want to create an ontology that corresponds to the ontology used + // in the OWL Primer. Every ontology has a IRI that uniquely identifies + // the ontology. The IRI is essentially a name for the ontology. Note + // that the IRI doesn't necessarily point to a location on the web - in + // this example, we won't publish the ontology at the URL corresponding + // to the ontology IRI below. + IRI ontologyIRI = IRI.create("http://example.com/owlapi/", "families"); + // Now that we have a IRI for out ontology, we can create the actual + // ontology. Note that the create ontology method throws an + // OWLOntologyCreationException if there was a problem creating the + // ontology. + OWLOntology ont = manager.createOntology(ontologyIRI); + // We can use the manager to get a reference to an OWLDataFactory. The + // data factory provides a point for creating OWL API objects such as + // classes, properties and individuals. + OWLDataFactory factory = manager.getOWLDataFactory(); + // We first need to create some references to individuals. All of our + // individual must have IRIs. A common convention is to take the IRI of + // an ontology, append a # and then a local name. For example we can + // create the individual 'John', using the ontology IRI and appending + // #John. Note however, that there is no requirement that a IRI of a + // class, property or individual that is used in an ontology have a + // correspondence with the IRI of the ontology. + OWLIndividual john = factory.getOWLNamedIndividual(ontologyIRI + "#", "John"); + OWLIndividual mary = factory.getOWLNamedIndividual(ontologyIRI + "#", "Mary"); + OWLIndividual susan = factory.getOWLNamedIndividual(ontologyIRI + "#", "Susan"); + OWLIndividual bill = factory.getOWLNamedIndividual(ontologyIRI + "#", "Bill"); + // The ontologies that we created aren't contained in any ontology at + // the moment. Individuals (or classes or properties) can't directly be + // added to an ontology, they have to be used in axioms, and then the + // axioms are added to an ontology. We now want to add some facts to the + // ontology. These facts are otherwise known as property assertions. In + // our case, we want to say that John has a wife Mary. To do this we + // need to have a reference to the hasWife object property (object + // properties link an individual to an individual, and data properties + // link and individual to a constant - here, we need an object property + // because John and Mary are individuals). + OWLObjectProperty hasWife = factory.getOWLObjectProperty(ontologyIRI + "#", "hasWife"); + // Now we need to create the assertion that John hasWife Mary. To do + // this we need an axiom, in this case an object property assertion + // axiom. This can be thought of as a "triple" that has a subject, john, + // a predicate, hasWife and an object Mary + OWLObjectPropertyAssertionAxiom axiom1 = + factory.getOWLObjectPropertyAssertionAxiom(hasWife, john, mary); + // We now need to add this assertion to our ontology. To do this, we + // apply an ontology change to the ontology via the OWLOntologyManager. + // First we create the change object that will tell the manager that we + // want to add the axiom to the ontology + AddAxiom addAxiom1 = new AddAxiom(ont, axiom1); + // Now we apply the change using the manager. + manager.applyChange(addAxiom1); + // Now we want to add the other facts/assertions to the ontology John + // hasSon Bill Get a refernece to the hasSon property + OWLObjectProperty hasSon = factory.getOWLObjectProperty(ontologyIRI + "#", "hasSon"); + // Create the assertion, John hasSon Bill + OWLAxiom axiom2 = factory.getOWLObjectPropertyAssertionAxiom(hasSon, john, bill); + // Apply the change + manager.applyChange(new AddAxiom(ont, axiom2)); + // John hasDaughter Susan + OWLObjectProperty hasDaughter = + factory.getOWLObjectProperty(ontologyIRI + "#", "hasDaughter"); + OWLAxiom axiom3 = factory.getOWLObjectPropertyAssertionAxiom(hasDaughter, john, susan); + manager.applyChange(new AddAxiom(ont, axiom3)); + // John hasAge 33 In this case, hasAge is a data property, which we need + // a reference to + OWLDataProperty hasAge = factory.getOWLDataProperty(ontologyIRI + "#", "hasAge"); + // We create a data property assertion instead of an object property + // assertion + OWLAxiom axiom4 = factory.getOWLDataPropertyAssertionAxiom(hasAge, john, 33); + manager.applyChange(new AddAxiom(ont, axiom4)); + // In the above code, 33 is an integer, so we can just pass 33 into the + // data factory method. Behind the scenes the OWL API will create a + // typed constant that it will use as the value of the data property + // assertion. We could have manually created the constant as follows: + OWLDatatype intDatatype = factory.getIntegerOWLDatatype(); + OWLLiteral thirtyThree = factory.getOWLLiteral("33", intDatatype); + // We would then create the axiom as follows: + factory.getOWLDataPropertyAssertionAxiom(hasAge, john, thirtyThree); + // However, the convenice method is much shorter! We can now create the + // other facts/assertion for Mary. The OWL API uses a change object + // model, which means we can stack up changes (or sets of axioms) and + // apply the changes (or add the axioms) in one go. We will do this for + // Mary + Set axioms = new HashSet(); + axioms.add(factory.getOWLObjectPropertyAssertionAxiom(hasSon, mary, bill)); + axioms.add(factory.getOWLObjectPropertyAssertionAxiom(hasDaughter, mary, susan)); + axioms.add(factory.getOWLDataPropertyAssertionAxiom(hasAge, mary, 31)); + // Add facts/assertions for Bill and Susan + axioms.add(factory.getOWLDataPropertyAssertionAxiom(hasAge, bill, 13)); + axioms.add(factory.getOWLDataPropertyAssertionAxiom(hasAge, mary, 8)); + // Now add all the axioms in one go - there is a convenience method on + // OWLOntologyManager that will automatically generate the AddAxiom + // change objects for us. We need to specify the ontology that the + // axioms should be added to and the axioms to add. + ont.add(axioms); + // Now specify the genders of John, Mary, Bill and Susan. To do this we + // need the male and female individuals and the hasGender object + // property. + OWLIndividual male = factory.getOWLNamedIndividual(ontologyIRI + "#", "male"); + OWLIndividual female = factory.getOWLNamedIndividual(ontologyIRI + "#", "female"); + OWLObjectProperty hasGender = factory.getOWLObjectProperty(ontologyIRI + "#", "hasGender"); + Set genders = new HashSet(); + genders.add(factory.getOWLObjectPropertyAssertionAxiom(hasGender, john, male)); + genders.add(factory.getOWLObjectPropertyAssertionAxiom(hasGender, mary, female)); + genders.add(factory.getOWLObjectPropertyAssertionAxiom(hasGender, bill, male)); + genders.add(factory.getOWLObjectPropertyAssertionAxiom(hasGender, susan, female)); + // Add the facts about the genders + ont.add(genders); + // Domain and Range Axioms //At this point, we have an ontology + // containing facts about several individuals. We now want to specify + // more information about the various properties that we have used. We + // want to say that the domains and ranges of hasWife, hasSon and + // hasDaughter are the class Person. To do this we need various domain + // and range axioms, and we need a reference to the class Person First + // get a reference to the person class + OWLClass person = factory.getOWLClass(ontologyIRI + "#", "Person"); + // Now we add the domain and range axioms that specify the domains and + // ranges of the various properties that we are interested in. + Set domainsAndRanges = new HashSet(); + // Domain and then range of hasWife + domainsAndRanges.add(factory.getOWLObjectPropertyDomainAxiom(hasWife, person)); + domainsAndRanges.add(factory.getOWLObjectPropertyRangeAxiom(hasWife, person)); + // Domain and range of hasSon and also hasDaugher + domainsAndRanges.add(factory.getOWLObjectPropertyDomainAxiom(hasSon, person)); + domainsAndRanges.add(factory.getOWLObjectPropertyRangeAxiom(hasSon, person)); + domainsAndRanges.add(factory.getOWLObjectPropertyDomainAxiom(hasDaughter, person)); + domainsAndRanges.add(factory.getOWLObjectPropertyRangeAxiom(hasDaughter, person)); + // We also have the domain of the data property hasAge as Person, and + // the range as integer. We need the integer datatype. The XML Schema + // Datatype IRIs are used for data types. The OWL API provide a built in + // set via the XSDVocabulary enum. + domainsAndRanges.add(factory.getOWLDataPropertyDomainAxiom(hasAge, person)); + OWLDatatype integerDatatype = factory.getIntegerOWLDatatype(); + domainsAndRanges.add(factory.getOWLDataPropertyRangeAxiom(hasAge, integerDatatype)); + // Now add all of our domain and range axioms + ont.add(domainsAndRanges); + // Class assertion axioms //We can also explicitly say than an + // individual is an instance of a given class. To do this we use a Class + // assertion axiom. + OWLClassAssertionAxiom classAssertionAx = factory.getOWLClassAssertionAxiom(person, john); + // Add the axiom directly using the addAxiom convenience method on + // OWLOntologyManager + manager.addAxiom(ont, classAssertionAx); + // Inverse property axioms //We can specify the inverse property of + // hasWife as hasHusband We first need a reference to the hasHusband + // property. + OWLObjectProperty hasHusband = factory + .getOWLObjectProperty(ont.getOntologyID().getOntologyIRI().get() + "#", "hasHusband"); + // The full IRI of the hasHusband property will be + // http://example.com/owlapi/families#hasHusband since the IRI of our + // ontology is http://example.com/owlapi/families Create the inverse + // object properties axiom and add it + manager.addAxiom(ont, factory.getOWLInverseObjectPropertiesAxiom(hasWife, hasHusband)); + // Sub property axioms //OWL allows a property hierarchy to be + // specified. Here, hasSon and hasDaughter will be specified as + // hasChild. + OWLObjectProperty hasChild = factory + .getOWLObjectProperty(ont.getOntologyID().getOntologyIRI().get() + "#", "hasChild"); + OWLSubObjectPropertyOfAxiom hasSonSubHasChildAx = + factory.getOWLSubObjectPropertyOfAxiom(hasSon, hasChild); + // Add the axiom + manager.addAxiom(ont, hasSonSubHasChildAx); + // And hasDaughter, which is also a sub property of hasChild + manager.addAxiom(ont, factory.getOWLSubObjectPropertyOfAxiom(hasDaughter, hasChild)); + // Property characteristics //Next, we want to say that the hasAge + // property is Functional. This means that something can have at most + // one hasAge property. We can do this with a functional data property + // axiom First create the axiom + OWLFunctionalDataPropertyAxiom hasAgeFuncAx = + factory.getOWLFunctionalDataPropertyAxiom(hasAge); + // Now add it to the ontology + manager.addAxiom(ont, hasAgeFuncAx); + // The hasWife property should be Functional, InverseFunctional, + // Irreflexive and Asymmetric. Note that the asymmetric property axiom + // used to be called antisymmetric - older versions of the OWL API may + // refer to antisymmetric property axioms + Set hasWifeAxioms = new HashSet(); + hasWifeAxioms.add(factory.getOWLFunctionalObjectPropertyAxiom(hasWife)); + hasWifeAxioms.add(factory.getOWLInverseFunctionalObjectPropertyAxiom(hasWife)); + hasWifeAxioms.add(factory.getOWLIrreflexiveObjectPropertyAxiom(hasWife)); + hasWifeAxioms.add(factory.getOWLAsymmetricObjectPropertyAxiom(hasWife)); + // Add all of the axioms that specify the characteristics of hasWife + ont.add(hasWifeAxioms); + // SubClass axioms //Now we want to start specifying something about + // classes in our ontology. To begin with we will simply say something + // about the relationship between named classes Besides the Person class + // that we already have, we want to say something about the classes Man, + // Woman and Parent. To say something about these classes, as usual, we + // need references to them: + OWLClass man = factory.getOWLClass(ontologyIRI + "#", "Man"); + OWLClass woman = factory.getOWLClass(ontologyIRI + "#", "Woman"); + OWLClass parent = factory.getOWLClass(ontologyIRI + "#", "Parent"); + // It is important to realise that simply getting references to a class + // via the data factory does not add them to an ontology - only axioms + // can be added to an ontology. Now say that Man, Woman and Parent are + // subclasses of Person + manager.addAxiom(ont, factory.getOWLSubClassOfAxiom(man, person)); + manager.addAxiom(ont, factory.getOWLSubClassOfAxiom(woman, person)); + manager.addAxiom(ont, factory.getOWLSubClassOfAxiom(parent, person)); + // Restrictions //Now we want to say that Person has exactly 1 Age, + // exactly 1 Gender and, only has gender that is male or female. We will + // deal with these restrictions one by one and then combine them as a + // superclass (Necessary conditions) of Person. All anonymous class + // expressions extend OWLClassExpression. First, hasAge exactly 1 + OWLDataExactCardinality hasAgeRestriction = factory.getOWLDataExactCardinality(1, hasAge); + // Now the hasGender exactly 1 + OWLObjectExactCardinality hasGenderRestriction = + factory.getOWLObjectExactCardinality(1, hasGender); + // And finally, the hasGender only {male female} To create this + // restriction, we need an OWLObjectOneOf class expression since male + // and female are individuals We can just list as many individuals as we + // need as the argument of the method. + OWLObjectOneOf maleOrFemale = factory.getOWLObjectOneOf(male, female); + // Now create the actual restriction + OWLObjectAllValuesFrom hasGenderOnlyMaleFemale = + factory.getOWLObjectAllValuesFrom(hasGender, maleOrFemale); + // Finally, we bundle these restrictions up into an intersection, since + // we want person to be a subclass of the intersection of them + OWLObjectIntersectionOf intersection = factory.getOWLObjectIntersectionOf(hasAgeRestriction, + hasGenderRestriction, hasGenderOnlyMaleFemale); + // And now we set this anonymous intersection class to be a superclass + // of Person using a subclass axiom + manager.addAxiom(ont, factory.getOWLSubClassOfAxiom(person, intersection)); + // Restrictions and other anonymous classes can also be used anywhere a + // named class can be used. Let's set the range of hasSon to be Person + // and hasGender value male. This requires an anonymous class that is + // the intersection of Person, and also, hasGender value male. We need + // to create the hasGender value male restriction - this describes the + // class of things that have a hasGender relationship to the individual + // male. + OWLObjectHasValue hasGenderValueMaleRestriction = + factory.getOWLObjectHasValue(hasGender, male); + // Now combine this with Person in an intersection + OWLClassExpression personAndHasGenderValueMale = + factory.getOWLObjectIntersectionOf(person, hasGenderValueMaleRestriction); + // Now specify this anonymous class as the range of hasSon using an + // object property range axioms + manager.addAxiom(ont, + factory.getOWLObjectPropertyRangeAxiom(hasSon, personAndHasGenderValueMale)); + // We can do a similar thing for hasDaughter, by specifying that + // hasDaughter has a range of Person and hasGender value female. This + // time, we will make things a little more compact by not using so many + // variables + OWLClassExpression rangeOfHasDaughter = factory.getOWLObjectIntersectionOf(person, + factory.getOWLObjectHasValue(hasGender, female)); + manager.addAxiom(ont, + factory.getOWLObjectPropertyRangeAxiom(hasDaughter, rangeOfHasDaughter)); + // Data Ranges and Equivalent Classes axioms //In OWL 2, we can specify + // expressive data ranges. Here, we will specify the classes Teenage, + // Adult and Child by saying something about individuals ages. First we + // take the class Teenager, all of whose instance have an age greater or + // equal to 13 and less than 20. In Manchester Syntax this is written as + // Person and hasAge some int[>=13, <20] We create a data range by + // taking the integer datatype and applying facet restrictions to it. + // Note that we have statically imported the data range facet vocabulary + // OWLFacet + OWLFacetRestriction geq13 = + factory.getOWLFacetRestriction(MIN_INCLUSIVE, factory.getOWLLiteral(13)); + // We don't have to explicitly create the typed constant, there are + // convenience methods to do this + OWLFacetRestriction lt20 = factory.getOWLFacetRestriction(MAX_EXCLUSIVE, 20); + // Restrict the base type, integer (which is just an XML Schema + // Datatype) with the facet restrictions. + OWLDataRange dataRng = factory.getOWLDatatypeRestriction(integerDatatype, geq13, lt20); + // Now we have the data range of greater than equal to 13 and less than + // 20 we can use this in a restriction. + OWLDataSomeValuesFrom teenagerAgeRestriction = + factory.getOWLDataSomeValuesFrom(hasAge, dataRng); + // Now make Teenager equivalent to Person and hasAge some int[>=13, <20] + // First create the class Person and hasAge some int[>=13, <20] + OWLClassExpression teenagePerson = + factory.getOWLObjectIntersectionOf(person, teenagerAgeRestriction); + OWLClass teenager = factory.getOWLClass(ontologyIRI + "#", "Teenager"); + OWLEquivalentClassesAxiom teenagerDefinition = + factory.getOWLEquivalentClassesAxiom(teenager, teenagePerson); + manager.addAxiom(ont, teenagerDefinition); + // Do the same for Adult that has an age greater than 21 + OWLDataRange geq21 = factory.getOWLDatatypeRestriction(integerDatatype, + factory.getOWLFacetRestriction(MIN_INCLUSIVE, 21)); + OWLClass adult = factory.getOWLClass(ontologyIRI + "#", "Adult"); + OWLClassExpression adultAgeRestriction = factory.getOWLDataSomeValuesFrom(hasAge, geq21); + OWLClassExpression adultPerson = + factory.getOWLObjectIntersectionOf(person, adultAgeRestriction); + OWLAxiom adultDefinition = factory.getOWLEquivalentClassesAxiom(adult, adultPerson); + manager.addAxiom(ont, adultDefinition); + // And finally Child + OWLDataRange notGeq21 = factory.getOWLDataComplementOf(geq21); + OWLClass child = factory.getOWLClass(ontologyIRI + "#", "Child"); + OWLClassExpression childAgeRestriction = factory.getOWLDataSomeValuesFrom(hasAge, notGeq21); + OWLClassExpression childPerson = + factory.getOWLObjectIntersectionOf(person, childAgeRestriction); + OWLAxiom childDefinition = factory.getOWLEquivalentClassesAxiom(child, childPerson); + manager.addAxiom(ont, childDefinition); + // Different individuals //In OWL, we can say that individuals are + // different from each other. To do this we use a different individuals + // axiom. Since John, Mary, Bill and Susan are all different + // individuals, we can express this using a different individuals axiom. + OWLDifferentIndividualsAxiom diffInds = + factory.getOWLDifferentIndividualsAxiom(john, mary, bill, susan); + manager.addAxiom(ont, diffInds); + // Male and Female are also different + manager.addAxiom(ont, factory.getOWLDifferentIndividualsAxiom(male, female)); + // Disjoint classes //Two say that two classes do not have any instances + // in common we use a disjoint classes axiom: + OWLDisjointClassesAxiom disjointClassesAxiom = + factory.getOWLDisjointClassesAxiom(man, woman); + manager.addAxiom(ont, disjointClassesAxiom); + // Ontology Management //Having added axioms to out ontology we can now + // save it (in a variety of formats). RDF/XML is the default format + // System.out.println("RDF/XML: "); + manager.saveOntology(ont, new StringDocumentTarget()); + // OWL/XML + // System.out.println("OWL/XML: "); + manager.saveOntology(ont, new OWLXMLDocumentFormat(), new StringDocumentTarget()); + // Manchester Syntax + // System.out.println("Manchester syntax: "); + manager.saveOntology(ont, new ManchesterSyntaxDocumentFormat(), new StringDocumentTarget()); + // Turtle + // System.out.println("Turtle: "); + manager.saveOntology(ont, new TurtleDocumentFormat(), new StringDocumentTarget()); + } + + /** + * Visits existential restrictions and collects the properties which are restricted. + */ + private static class RestrictionVisitor implements OWLClassExpressionVisitor { + + private final Set processedClasses; + private final Set onts; + + RestrictionVisitor(Set onts) { + processedClasses = new HashSet(); + this.onts = onts; + } + + @Override + public void visit(OWLClass ce) { + if (!processedClasses.contains(ce)) { + // If we are processing inherited restrictions then we + // recursively visit named supers. Note that we need to keep + // track of the classes that we have processed so that we don't + // get caught out by cycles in the taxonomy + processedClasses.add(ce); + for (OWLOntology ont : onts) { + ont.subClassAxiomsForSubClass(ce) + .forEach(ax -> ax.getSuperClass().accept(this)); + } + } + } + + @Override + public void visit(OWLObjectSomeValuesFrom ce) { + // This method gets called when a class expression is an existential + // (someValuesFrom) restriction and it asks us to visit it + } + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/examples/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/examples/package-info.java new file mode 100644 index 0000000000..72f3f37a5e --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/examples/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.examples; diff --git a/contract/src/test/java/org/semanticweb/owlapi/profiles/ForbiddenVocabularyTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/profiles/ForbiddenVocabularyTestCase.java new file mode 100644 index 0000000000..5f996e35e5 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/profiles/ForbiddenVocabularyTestCase.java @@ -0,0 +1,130 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Arrays; +import java.util.List; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForAnnotationPropertyIRI; +import org.semanticweb.owlapi.util.OWLObjectPropertyManager; + +class ForbiddenVocabularyTestCase extends TestBase { + + private static final String URN_TEST = "urn:test:"; + OWLObjectProperty father = df.getOWLObjectProperty(URN_TEST, "hasFather"); + OWLObjectProperty brother = df.getOWLObjectProperty(URN_TEST, "hasBrother"); + OWLObjectProperty child = df.getOWLObjectProperty(URN_TEST, "hasChild"); + OWLObjectProperty uncle = df.getOWLObjectProperty(URN_TEST, "hasUncle"); + + @Test + void shouldFindViolation() { + OWLOntology o = loadOntologyFromString(TestFiles.violation, new RDFXMLDocumentFormat()); + OWL2DLProfile p = new OWL2DLProfile(); + OWLProfileReport checkOntology = p.checkOntology(o); + assertEquals(1, checkOntology.getViolations().size()); + OWLProfileViolation v = checkOntology.getViolations().get(0); + assertTrue(v instanceof UseOfReservedVocabularyForAnnotationPropertyIRI); + } + + @Test + void testGenIdGalenFragment() { + OWLOntology o = loadOntologyFromString(TestFiles.galenFragment, new RDFXMLDocumentFormat()); + OWL2DLProfile profile = new OWL2DLProfile(); + OWLProfileReport report = profile.checkOntology(o); + assertTrue(report.isInProfile()); + } + + @Test + void testOWLEL() { + OWLOntology o = loadOntologyFromString(TestFiles.ontology, new RDFXMLDocumentFormat()); + OWL2RLProfile p = new OWL2RLProfile(); + OWLProfileReport report = p.checkOntology(o); + assertTrue(report.getViolations().isEmpty()); + } + + @Test + void shouldCauseViolationsWithUseOfPropertyInChain() throws OWLOntologyCreationException { + OWLOntology o = m.createOntology(); + o.addAxiom(df.getOWLDeclarationAxiom(father)); + o.addAxiom(df.getOWLDeclarationAxiom(brother)); + o.addAxiom(df.getOWLDeclarationAxiom(child)); + o.addAxiom(df.getOWLDeclarationAxiom(uncle)); + OWLSubPropertyChainOfAxiom brokenAxiom1 = + df.getOWLSubPropertyChainOfAxiom(Arrays.asList(father, brother), uncle); + OWLSubPropertyChainOfAxiom brokenAxiom2 = + df.getOWLSubPropertyChainOfAxiom(Arrays.asList(child, uncle), brother); + OWLObjectPropertyManager manager = new OWLObjectPropertyManager(o); + o.addAxiom(brokenAxiom1); + o.addAxiom(brokenAxiom2); + assertTrue(manager.isLessThan(brother, uncle)); + assertTrue(manager.isLessThan(uncle, brother)); + assertTrue(manager.isLessThan(brother, brother)); + assertTrue(manager.isLessThan(uncle, uncle)); + OWL2DLProfile profile = new OWL2DLProfile(); + List violations = profile.checkOntology(o).getViolations(); + assertFalse(violations.isEmpty()); + for (OWLProfileViolation v : violations) { + assertTrue(brokenAxiom1.equals(v.getAxiom()) || brokenAxiom2.equals(v.getAxiom())); + } + } + + @Test + void shouldNotCauseViolations() throws OWLOntologyCreationException { + OWLOntology o = m.createOntology(); + o.addAxiom(df.getOWLDeclarationAxiom(father)); + o.addAxiom(df.getOWLDeclarationAxiom(brother)); + o.addAxiom(df.getOWLDeclarationAxiom(child)); + o.addAxiom(df.getOWLDeclarationAxiom(uncle)); + OWLSubPropertyChainOfAxiom brokenAxiom1 = + df.getOWLSubPropertyChainOfAxiom(Arrays.asList(father, brother), uncle); + OWLObjectPropertyManager manager = new OWLObjectPropertyManager(o); + o.addAxiom(brokenAxiom1); + assertTrue(manager.isLessThan(brother, uncle)); + OWL2DLProfile profile = new OWL2DLProfile(); + List violations = profile.checkOntology(o).getViolations(); + assertTrue(violations.isEmpty()); + for (OWLProfileViolation v : violations) { + assertEquals(brokenAxiom1, v.getAxiom()); + } + } + + @Test + void shouldNotCauseViolationsInput1() { + OWLOntology o = + loadOntologyFromString(TestFiles.forbiddenInput1, new RDFXMLDocumentFormat()); + OWL2DLProfile profile = new OWL2DLProfile(); + List violations = profile.checkOntology(o).getViolations(); + assertTrue(violations.isEmpty()); + } + + @Test + void shouldNotCauseViolationsInput2() { + OWLOntology o = + loadOntologyFromString(TestFiles.forbiddenInput2, new RDFXMLDocumentFormat()); + OWL2DLProfile profile = new OWL2DLProfile(); + List violations = profile.checkOntology(o).getViolations(); + assertTrue(violations.isEmpty()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/profiles/OWLProfileTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/profiles/OWLProfileTestCase.java new file mode 100644 index 0000000000..83c4ce381e --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/profiles/OWLProfileTestCase.java @@ -0,0 +1,1356 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnnotationProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AnonymousIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.AsymmetricObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Boolean; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ClassAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataAllValuesFrom; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataComplementOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataExactCardinality; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataIntersectionOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataMaxCardinality; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataMinCardinality; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataOneOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataPropertyAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataPropertyDomain; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataPropertyRange; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataUnionOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Datatype; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DatatypeDefinition; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DatatypeRestriction; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Declaration; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DifferentIndividuals; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DisjointClasses; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DisjointDataProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DisjointObjectProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DisjointUnion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Double; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentClasses; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentDataProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentObjectProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.FacetRestriction; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.FunctionalDataProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.FunctionalObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.HasKey; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Integer; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.InverseFunctionalObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.InverseObjectProperties; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IrreflexiveObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NamedIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NegativeDataPropertyAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NegativeObjectPropertyAssertion; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.OWLNothing; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.OWLThing; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectAllValuesFrom; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectComplementOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectExactCardinality; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectHasSelf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectIntersectionOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectInverseOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectMaxCardinality; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectMinCardinality; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectOneOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectPropertyDomain; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectPropertyRange; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectSomeValuesFrom; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectUnionOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SameIndividual; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubAnnotationPropertyOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubClassOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubDataPropertyOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubObjectPropertyOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubPropertyChainOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SymmetricObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.TransitiveObjectProperty; +import static org.semanticweb.owlapi.util.OWLAPIPreconditions.optional; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.List; +import java.util.Optional; +import java.util.stream.Stream; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyID; +import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration; +import org.semanticweb.owlapi.model.SWRLAtom; +import org.semanticweb.owlapi.profiles.violations.CycleInDatatypeDefinition; +import org.semanticweb.owlapi.profiles.violations.DatatypeIRIAlsoUsedAsClassIRI; +import org.semanticweb.owlapi.profiles.violations.EmptyOneOfAxiom; +import org.semanticweb.owlapi.profiles.violations.IllegalPunning; +import org.semanticweb.owlapi.profiles.violations.InsufficientIndividuals; +import org.semanticweb.owlapi.profiles.violations.InsufficientOperands; +import org.semanticweb.owlapi.profiles.violations.InsufficientPropertyExpressions; +import org.semanticweb.owlapi.profiles.violations.LastPropertyInChainNotInImposedRange; +import org.semanticweb.owlapi.profiles.violations.LexicalNotInLexicalSpace; +import org.semanticweb.owlapi.profiles.violations.OntologyIRINotAbsolute; +import org.semanticweb.owlapi.profiles.violations.OntologyVersionIRINotAbsolute; +import org.semanticweb.owlapi.profiles.violations.UseOfAnonymousIndividual; +import org.semanticweb.owlapi.profiles.violations.UseOfBuiltInDatatypeInDatatypeDefinition; +import org.semanticweb.owlapi.profiles.violations.UseOfDataOneOfWithMultipleLiterals; +import org.semanticweb.owlapi.profiles.violations.UseOfDefinedDatatypeInDatatypeRestriction; +import org.semanticweb.owlapi.profiles.violations.UseOfDefinedDatatypeInLiteral; +import org.semanticweb.owlapi.profiles.violations.UseOfIllegalAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfIllegalClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfIllegalDataRange; +import org.semanticweb.owlapi.profiles.violations.UseOfIllegalFacetRestriction; +import org.semanticweb.owlapi.profiles.violations.UseOfNonAbsoluteIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfNonAtomicClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfNonEquivalentClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInCardinalityRestriction; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInDisjointPropertiesAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInFunctionalPropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInIrreflexivePropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSimplePropertyInObjectHasSelf; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSubClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfNonSuperClassExpression; +import org.semanticweb.owlapi.profiles.violations.UseOfObjectOneOfWithMultipleIndividuals; +import org.semanticweb.owlapi.profiles.violations.UseOfObjectPropertyInverse; +import org.semanticweb.owlapi.profiles.violations.UseOfPropertyInChainCausesCycle; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForAnnotationPropertyIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForIndividualIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForObjectPropertyIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForOntologyIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfReservedVocabularyForVersionIRI; +import org.semanticweb.owlapi.profiles.violations.UseOfTopDataPropertyAsSubPropertyInSubPropertyAxiom; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredAnnotationProperty; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredClass; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredDataProperty; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredDatatype; +import org.semanticweb.owlapi.profiles.violations.UseOfUndeclaredObjectProperty; +import org.semanticweb.owlapi.profiles.violations.UseOfUnknownDatatype; +import org.semanticweb.owlapi.vocab.OWL2Datatype; +import org.semanticweb.owlapi.vocab.OWLFacet; + +class OWLProfileTestCase extends TestBase { + + private static final String TEST = "test"; + private static final String URN_TEST = "urn:test#"; + private static final String URN_DATATYPE = "urn:datatype#"; + protected static final Comparator> comp = + (o1, o2) -> o1.getSimpleName().compareTo(o2.getSimpleName()); + private static final String START = OWLThing().getIRI().getNamespace(); + private static final OWLClass CL = Class(IRI(URN_TEST, "fakeclass")); + private static final OWLDataProperty DATAP = + DataProperty(IRI(URN_DATATYPE, "fakedatatypeproperty")); + private static final OWLDataPropertyRangeAxiom DATA_PROPERTY_RANGE2 = DataPropertyRange(DATAP, + DatatypeRestriction(Integer(), FacetRestriction(OWLFacet.LANG_RANGE, Literal(1)))); + private static final OWLDataPropertyRangeAxiom DATA_PROPERTY_RANGE = DataPropertyRange(DATAP, + DatatypeRestriction(Integer(), FacetRestriction(OWLFacet.MAX_EXCLUSIVE, Literal(1)))); + private static final OWLObjectProperty OP = + ObjectProperty(IRI(URN_DATATYPE, "fakeobjectproperty")); + private static final OWLDatatype UNKNOWNFAKEDATATYPE = + Datatype(IRI(START, "unknownfakedatatype")); + private static final OWLDatatype FAKEUNDECLAREDDATATYPE = + Datatype(IRI(URN_DATATYPE, "fakeundeclareddatatype")); + private static final OWLDatatype FAKEDATATYPE = Datatype(IRI(URN_DATATYPE, "fakedatatype")); + private static final IRI onto = iri(URN_TEST, "ontology"); + private static final OWLDataFactory DF = OWLManager.getOWLDataFactory(); + private static final OWLObjectProperty P = ObjectProperty(IRI(URN_TEST, "objectproperty")); + OWLOntology o; + + @BeforeEach + public void setupManagersClean() { + o = getOWLOntology(onto); + } + + public void declare(OWLOntology ont, OWLEntity... entities) { + Stream.of(entities).map(e -> Declaration(e)).forEach(ax -> ont.add(ax)); + } + + public void checkInCollection(List violations, Class[] inputList) { + List> list = new ArrayList<>(Arrays.asList(inputList)); + List> list1 = new ArrayList<>(); + for (OWLProfileViolation v : violations) { + list1.add(v.getClass()); + } + Collections.sort(list, comp); + Collections.sort(list1, comp); + assertEquals(list, list1, list1.toString()); + } + + public void runAssert(OWLOntology ontology, OWLProfile profile, int expected, + Class... expectedViolations) { + List violations = profile.checkOntology(ontology).getViolations(); + assertEquals(expected, violations.size(), violations.toString()); + checkInCollection(violations, expectedViolations); + for (OWLProfileViolation violation : violations) { + ontology.getOWLOntologyManager().applyChanges(violation.repair()); + violation.accept(new OWLProfileViolationVisitor() {}); + violation.accept(new OWLProfileViolationVisitorEx() { + + @Override + public Optional doDefault(OWLProfileViolation object) { + return optional(object.toString()); + } + }); + } + violations = profile.checkOntology(ontology).getViolations(); + assertEquals(0, violations.size()); + } + + @Test + @Tests(method = "Object visit(OWLDatatype datatype)") + void shouldCreateViolationForOWLDatatypeInOWL2DLProfile() { + declare(o, UNKNOWNFAKEDATATYPE, FAKEDATATYPE, Class(FAKEDATATYPE.getIRI()), DATAP); + o.addAxiom(DataPropertyRange(DATAP, FAKEUNDECLAREDDATATYPE)); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, UseOfUndeclaredDatatype.class); + } + + @Test + @Tests(method = "Object visit(OWLDatatypeDefinitionAxiom axiom)") + void shouldCreateViolationForOWLDatatypeDefinitionAxiomInOWL2DLProfile() { + declare(o, Integer(), Boolean(), FAKEDATATYPE); + o.add(DatatypeDefinition(Boolean(), Integer()), DatatypeDefinition(FAKEDATATYPE, Integer()), + DatatypeDefinition(Integer(), FAKEDATATYPE)); + int expected = 4; + runAssert(o, Profiles.OWL2_DL, expected, CycleInDatatypeDefinition.class, + CycleInDatatypeDefinition.class, UseOfBuiltInDatatypeInDatatypeDefinition.class, + UseOfBuiltInDatatypeInDatatypeDefinition.class); + } + + @Test + @Tests(method = "Object visit(OWLDatatypeDefinitionAxiom axiom)") + void shouldCreateViolationForOWLDatatypeDefinitionAxiomInOWL2DLProfileCycles() { + OWLDatatype d = Datatype(IRI(START, TEST)); + declare(o, d, Integer(), Boolean(), FAKEDATATYPE); + o.add(DatatypeDefinition(d, Boolean()), DatatypeDefinition(Boolean(), d), + DatatypeDefinition(FAKEDATATYPE, Integer()), + DatatypeDefinition(Integer(), FAKEDATATYPE)); + int expected = 9; + runAssert(o, Profiles.OWL2_DL, expected, CycleInDatatypeDefinition.class, + CycleInDatatypeDefinition.class, CycleInDatatypeDefinition.class, + CycleInDatatypeDefinition.class, UseOfBuiltInDatatypeInDatatypeDefinition.class, + UseOfBuiltInDatatypeInDatatypeDefinition.class, + UseOfBuiltInDatatypeInDatatypeDefinition.class, UseOfUnknownDatatype.class, + UseOfUnknownDatatype.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectProperty property)") + void shouldCreateViolationForOWLObjectPropertyInOWL2DLProfile() { + IRI iri = IRI(START, TEST); + declare(o, ObjectProperty(iri), DataProperty(iri), AnnotationProperty(iri)); + o.addAxiom(SubObjectPropertyOf(OP, ObjectProperty(iri))); + int expected = 4; + runAssert(o, Profiles.OWL2_DL, expected, UseOfReservedVocabularyForObjectPropertyIRI.class, + UseOfUndeclaredObjectProperty.class, IllegalPunning.class, IllegalPunning.class); + } + + @Test + @Tests(method = "Object visit(OWLDataProperty property)") + void shouldCreateViolationForOWLDataPropertyInOWL2DLProfile1() { + declare(o, DataProperty(IRI(START, "fail"))); + int expected = 0; + runAssert(o, Profiles.OWL2_DL, expected); + } + + @Test + @Tests(method = "Object visit(OWLDataProperty property)") + void shouldCreateViolationForOWLDataPropertyInOWL2DLProfile2() { + o.addAxiom(FunctionalDataProperty(DATAP)); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, UseOfUndeclaredDataProperty.class); + } + + @Test + @Tests(method = "Object visit(OWLDataProperty property)") + void shouldCreateViolationForOWLDataPropertyInOWL2DLProfile3() { + declare(o, DATAP, AnnotationProperty(DATAP.getIRI())); + int expected = 0; + runAssert(o, Profiles.OWL2_DL, expected); + } + + @Test + @Tests(method = "Object visit(OWLDataProperty property)") + void shouldCreateViolationForOWLDataPropertyInOWL2DLProfile4() { + declare(o, DATAP, ObjectProperty(DATAP.getIRI())); + int expected = 0; + runAssert(o, Profiles.OWL2_DL, expected); + } + + @Test + @Tests(method = "Object visit(OWLAnnotationProperty property)") + void shouldCreateViolationForOWLAnnotationPropertyInOWL2DLProfile() { + IRI iri = IRI(START, TEST); + declare(o, ObjectProperty(iri), DataProperty(iri), AnnotationProperty(iri)); + o.add(SubAnnotationPropertyOf(AnnotationProperty(IRI(URN_TEST, "t")), + AnnotationProperty(iri))); + int expected = 4; + runAssert(o, Profiles.OWL2_DL, expected, + UseOfReservedVocabularyForAnnotationPropertyIRI.class, + UseOfUndeclaredAnnotationProperty.class, IllegalPunning.class, IllegalPunning.class); + } + + @Test + @Tests(method = "Object visit(OWLOntology ontology)") + void shouldCreateViolationForOWLOntologyInOWL2DLProfile() throws OWLOntologyCreationException { + o = m.createOntology( + new OWLOntologyID(optional(IRI(START, TEST)), optional(IRI(START, "test1")))); + int expected = 2; + runAssert(o, Profiles.OWL2_DL, expected, UseOfReservedVocabularyForOntologyIRI.class, + UseOfReservedVocabularyForVersionIRI.class); + } + + @Test + @Tests(method = "Object visit(OWLClass desc)") + void shouldCreateViolationForOWLClassInOWL2DLProfile() { + declare(o, Class(IRI(START, TEST)), FAKEDATATYPE); + o.add(ClassAssertion(Class(FAKEDATATYPE.getIRI()), AnonymousIndividual())); + int expected = 2; + runAssert(o, Profiles.OWL2_DL, expected, UseOfUndeclaredClass.class, + DatatypeIRIAlsoUsedAsClassIRI.class); + } + + @Test + @Tests(method = "Object visit(OWLDataOneOf node)") + void shouldCreateViolationForOWLDataOneOfInOWL2DLProfile() { + declare(o, DATAP); + o.add(DataPropertyRange(DATAP, DataOneOf())); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, EmptyOneOfAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLDataUnionOf node)") + void shouldCreateViolationForOWLDataUnionOfInOWL2DLProfile() { + declare(o, DATAP); + o.add(DataPropertyRange(DATAP, DataUnionOf( + DatatypeRestriction(Integer(), FacetRestriction(OWLFacet.MAX_EXCLUSIVE, Literal(1)))))); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, InsufficientOperands.class); + } + + @Test + @Tests(method = "Object visit(OWLDataIntersectionOf node)") + void shouldCreateViolationForOWLDataIntersectionOfInOWL2DLProfile() { + declare(o, DATAP); + o.add(DataPropertyRange(DATAP, DataIntersectionOf( + DatatypeRestriction(Integer(), FacetRestriction(OWLFacet.MAX_EXCLUSIVE, Literal(1)))))); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, InsufficientOperands.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectIntersectionOf node)") + void shouldCreateViolationForOWLObjectIntersectionOfInOWL2DLProfile() { + declare(o, OP, CL); + o.add(ObjectPropertyRange(OP, ObjectIntersectionOf(CL))); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, InsufficientOperands.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectOneOf node)") + void shouldCreateViolationForOWLObjectOneOfInOWL2DLProfile() { + declare(o, OP); + o.add(ObjectPropertyRange(OP, ObjectOneOf())); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, EmptyOneOfAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectUnionOf node)") + void shouldCreateViolationForOWLObjectUnionOfInOWL2DLProfile() { + declare(o, OP, CL); + o.add(ObjectPropertyRange(OP, ObjectUnionOf(CL))); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, InsufficientOperands.class); + } + + @Test + @Tests(method = "Object visit(OWLEquivalentClassesAxiom node)") + void shouldCreateViolationForOWLEquivalentClassesAxiomInOWL2DLProfile() { + declare(o, OP, CL); + o.add(EquivalentClasses(CL)); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, InsufficientOperands.class); + } + + @Test + @Tests(method = "Object visit(OWLDisjointClassesAxiom node)") + void shouldCreateViolationForOWLDisjointClassesAxiomInOWL2DLProfile() { + declare(o, OP, CL); + OWLDataFactory df2 = OWLManager.getOWLDataFactory( + new OWLOntologyLoaderConfiguration().withAllowDuplicatesInConstructSets(true)); + o.add(df2.getOWLDisjointClassesAxiom(CL)); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, InsufficientOperands.class); + } + + @Test + @Tests(method = "Object visit(OWLDisjointUnionAxiom node)") + void shouldCreateViolationForOWLDisjointUnionAxiomInOWL2DLProfile() { + declare(o, OP); + OWLClass otherfakeclass = Class(IRI(URN_TEST, "otherfakeclass")); + declare(o, CL); + declare(o, otherfakeclass); + o.add(DisjointUnion(CL, otherfakeclass)); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, InsufficientOperands.class); + } + + @Test + @Tests(method = "Object visit(OWLEquivalentObjectPropertiesAxiom node)") + void shouldCreateViolationForOWLEquivalentObjectPropertiesAxiomInOWL2DLProfile() { + declare(o, P); + o.add(EquivalentObjectProperties(P)); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, InsufficientPropertyExpressions.class); + } + + @Test + @Tests(method = "Object visit(OWLDisjointDataPropertiesAxiom node)") + void shouldCreateViolationForOWLDisjointDataPropertiesAxiomInOWL2DLProfile() { + declare(o, DATAP); + o.add(DisjointDataProperties(DATAP)); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, InsufficientPropertyExpressions.class); + } + + @Test + @Tests(method = "Object visit(OWLEquivalentDataPropertiesAxiom node)") + void shouldCreateViolationForOWLEquivalentDataPropertiesAxiomInOWL2DLProfile() { + declare(o, DATAP); + o.add(EquivalentDataProperties(DATAP)); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, InsufficientPropertyExpressions.class); + } + + @Test + @Tests(method = "Object visit(OWLHasKeyAxiom node)") + void shouldCreateViolationForOWLHasKeyAxiomInOWL2DLProfile() { + declare(o, CL); + o.add(HasKey(CL)); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, InsufficientPropertyExpressions.class); + } + + @Test + @Tests(method = "Object visit(OWLSameIndividualAxiom node)") + void shouldCreateViolationForOWLSameIndividualAxiomInOWL2DLProfile() { + o.add(SameIndividual(NamedIndividual(IRI(URN_TEST, "i")))); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, InsufficientIndividuals.class); + } + + @Test + @Tests(method = "Object visit(OWLDifferentIndividualsAxiom node)") + void shouldCreateViolationForOWLDifferentIndividualsAxiomInOWL2DLProfile() { + o.add(DifferentIndividuals(NamedIndividual(IRI(URN_TEST, "i")))); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, InsufficientIndividuals.class); + } + + @Test + @Tests(method = "Object visit(OWLNamedIndividual individual)") + void shouldCreateViolationForOWLNamedIndividualInOWL2DLProfile() { + o.add(ClassAssertion(OWLThing(), NamedIndividual(IRI(START, "i")))); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, UseOfReservedVocabularyForIndividualIRI.class); + } + + @Test + @Tests(method = "Object visit(OWLSubDataPropertyOfAxiom axiom)") + void shouldCreateViolationForOWLSubDataPropertyOfAxiomInOWL2DLProfile() { + o.add(SubDataPropertyOf(DF.getOWLTopDataProperty(), DF.getOWLTopDataProperty())); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, + UseOfTopDataPropertyAsSubPropertyInSubPropertyAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectMinCardinality desc)") + void shouldCreateViolationForOWLObjectMinCardinalityInOWL2DLProfile() { + declare(o, OP, CL); + o.add(TransitiveObjectProperty(OP), + SubClassOf(CL, ObjectMinCardinality(1, OP, OWLThing()))); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, + UseOfNonSimplePropertyInCardinalityRestriction.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectMaxCardinality desc)") + void shouldCreateViolationForOWLObjectMaxCardinalityInOWL2DLProfile() { + declare(o, OP, CL); + o.add(TransitiveObjectProperty(OP), + SubClassOf(CL, ObjectMaxCardinality(1, OP, OWLThing()))); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, + UseOfNonSimplePropertyInCardinalityRestriction.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectExactCardinality desc)") + void shouldCreateViolationForOWLObjectExactCardinalityInOWL2DLProfile() { + declare(o, OP, CL); + o.add(TransitiveObjectProperty(OP), + SubClassOf(CL, ObjectExactCardinality(1, OP, OWLThing()))); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, + UseOfNonSimplePropertyInCardinalityRestriction.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectHasSelf desc)") + void shouldCreateViolationForOWLObjectHasSelfInOWL2DLProfile() { + declare(o, OP); + o.add(TransitiveObjectProperty(OP), ObjectPropertyRange(OP, ObjectHasSelf(OP))); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, UseOfNonSimplePropertyInObjectHasSelf.class); + } + + @Test + @Tests(method = "Object visit(OWLFunctionalObjectPropertyAxiom axiom)") + void shouldCreateViolationForOWLFunctionalObjectPropertyAxiomInOWL2DLProfile() { + declare(o, OP); + o.add(TransitiveObjectProperty(OP), FunctionalObjectProperty(OP)); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, + UseOfNonSimplePropertyInFunctionalPropertyAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLInverseFunctionalObjectPropertyAxiom axiom)") + void shouldCreateViolationForOWLInverseFunctionalObjectPropertyAxiomInOWL2DLProfile() { + declare(o, OP); + o.add(TransitiveObjectProperty(OP), InverseFunctionalObjectProperty(OP)); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, + UseOfNonSimplePropertyInInverseFunctionalObjectPropertyAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLIrreflexiveObjectPropertyAxiom axiom)") + void shouldCreateViolationForOWLIrreflexiveObjectPropertyAxiomInOWL2DLProfile() { + declare(o, OP); + o.add(TransitiveObjectProperty(OP), IrreflexiveObjectProperty(OP)); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, + UseOfNonSimplePropertyInIrreflexivePropertyAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLAsymmetricObjectPropertyAxiom axiom)") + void shouldCreateViolationForOWLAsymmetricObjectPropertyAxiomInOWL2DLProfile() { + declare(o, OP); + o.add(TransitiveObjectProperty(OP), AsymmetricObjectProperty(OP)); + int expected = 1; + runAssert(o, Profiles.OWL2_DL, expected, + UseOfNonSimplePropertyInAsymmetricObjectPropertyAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLDisjointObjectPropertiesAxiom axiom)") + void shouldCreateViolationForOWLDisjointObjectPropertiesAxiomInOWL2DLProfile() { + declare(o, OP); + o.add(TransitiveObjectProperty(OP), DisjointObjectProperties(OP)); + int expected = 2; + runAssert(o, Profiles.OWL2_DL, expected, InsufficientPropertyExpressions.class, + UseOfNonSimplePropertyInDisjointPropertiesAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLSubPropertyChainOfAxiom axiom)") + void shouldCreateViolationForOWLSubPropertyChainOfAxiomInOWL2DLProfile() { + OWLObjectProperty op1 = ObjectProperty(IRI(URN_TEST, "op")); + declare(o, OP, op1); + o.add(SubPropertyChainOf(Arrays.asList(op1), OP), + SubPropertyChainOf(Arrays.asList(OP, op1, OP), OP), + SubPropertyChainOf(Arrays.asList(OP, op1), OP), + SubPropertyChainOf(Arrays.asList(op1, OP, op1, OP), OP)); + int expected = 4; + runAssert(o, Profiles.OWL2_DL, expected, InsufficientPropertyExpressions.class, + UseOfPropertyInChainCausesCycle.class, UseOfPropertyInChainCausesCycle.class, + UseOfPropertyInChainCausesCycle.class); + } + + @Test + @Tests(method = "Object visit(OWLOntology ont)") + void shouldCreateViolationForOWLOntologyInOWL2Profile() throws OWLOntologyCreationException { + o = m + .createOntology(new OWLOntologyID(optional(IRI(TEST, "")), optional(IRI("test1", "")))); + int expected = 2; + runAssert(o, Profiles.OWL2_FULL, expected, OntologyIRINotAbsolute.class, + OntologyVersionIRINotAbsolute.class); + } + + @Test + @Tests(method = "Object visit(IRI iri)") + void shouldCreateViolationForIRIInOWL2Profile() { + declare(o, Class(IRI(TEST, ""))); + int expected = 1; + runAssert(o, Profiles.OWL2_FULL, expected, UseOfNonAbsoluteIRI.class); + } + + @Test + @Tests(method = "Object visit(OWLLiteral node)") + void shouldCreateViolationForOWLLiteralInOWL2Profile() { + declare(o, DATAP); + o.add(DataPropertyAssertion(DATAP, AnonymousIndividual(), + Literal("wrong", OWL2Datatype.XSD_INTEGER))); + int expected = 1; + runAssert(o, Profiles.OWL2_FULL, expected, LexicalNotInLexicalSpace.class); + } + + @Test + @Tests(method = "Object visit(OWLLiteral node)") + void shouldCreateViolationForDefineDatatypeOWLLiteralInOWL2Profile() { + declare(o, DATAP); + o.add(DataPropertyAssertion(DATAP, AnonymousIndividual(), + Literal("wrong", df.getOWLDatatype("urn:test:defineddatatype")))); + int expected = 1; + runAssert(o, Profiles.OWL2_FULL, expected, UseOfDefinedDatatypeInLiteral.class); + } + + @Test + @Tests(method = "Object visit(OWLDatatypeRestriction node)") + void shouldCreateViolationForOWLDatatypeRestrictionInOWL2Profile() { + declare(o, DATAP); + o.add(DatatypeDefinition(Integer(), Boolean()), + DatatypeDefinition(df.getOWLDatatype("urn:test:undeclaredDatatype"), Boolean()), + DATA_PROPERTY_RANGE2); + int expected = 3; + runAssert(o, Profiles.OWL2_FULL, expected, UseOfDefinedDatatypeInDatatypeRestriction.class, + UseOfIllegalFacetRestriction.class, UseOfUndeclaredDatatype.class); + } + + @Test + @Tests(method = "Object visit(OWLDatatypeDefinitionAxiom axiom)") + void shouldCreateViolationForOWLDatatypeDefinitionAxiomInOWL2Profile() { + o.add(DatatypeDefinition(FAKEDATATYPE, Boolean())); + int expected = 1; + runAssert(o, Profiles.OWL2_FULL, expected, UseOfUndeclaredDatatype.class); + } + + @Test + @Tests(method = "Object visit(OWLDatatype node)") + void shouldCreateViolationForOWLDatatypeInOWL2ELProfile() { + declare(o, Boolean()); + int expected = 0; + runAssert(o, Profiles.OWL2_EL, expected); + } + + @Test + @Tests(method = "Object visit(OWLAnonymousIndividual individual)") + void shouldCreateViolationForOWLAnonymousIndividualInOWL2ELProfile() { + o.add(ClassAssertion(OWLThing(), DF.getOWLAnonymousIndividual())); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfAnonymousIndividual.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectInverseOf property)") + void shouldCreateViolationForOWLObjectInverseOfInOWL2ELProfile() { + declare(o, OP); + o.add(SubObjectPropertyOf(OP, ObjectInverseOf(OP))); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfObjectPropertyInverse.class); + } + + @Test + @Tests(method = "Object visit(OWLDataAllValuesFrom desc)") + void shouldCreateViolationForOWLDataAllValuesFromInOWL2ELProfile() { + declare(o, DATAP, CL); + o.add(SubClassOf(CL, DataAllValuesFrom(DATAP, Integer()))); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLDataExactCardinality desc)") + void shouldCreateViolationForOWLDataExactCardinalityInOWL2ELProfile() { + declare(o, DATAP, CL, Integer()); + o.add(SubClassOf(CL, DataExactCardinality(1, DATAP, Integer()))); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLDataMaxCardinality desc)") + void shouldCreateViolationForOWLDataMaxCardinalityInOWL2ELProfile() { + declare(o, DATAP, CL, Integer()); + o.add(SubClassOf(CL, DataMaxCardinality(1, DATAP, Integer()))); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLDataMinCardinality desc)") + void shouldCreateViolationForOWLDataMinCardinalityInOWL2ELProfile() { + declare(o, DATAP, CL, Integer()); + o.add(SubClassOf(CL, DataMinCardinality(1, DATAP, Integer()))); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectAllValuesFrom desc)") + void shouldCreateViolationForOWLObjectAllValuesFromInOWL2ELProfile() { + declare(o, OP, CL); + o.add(SubClassOf(CL, ObjectAllValuesFrom(OP, OWLThing()))); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectComplementOf desc)") + void shouldCreateViolationForOWLObjectComplementOfInOWL2ELProfile() { + declare(o, OP); + o.add(ObjectPropertyRange(OP, ObjectComplementOf(OWLNothing()))); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectExactCardinality desc)") + void shouldCreateViolationForOWLObjectExactCardinalityInOWL2ELProfile() { + declare(o, OP, CL); + o.add(SubClassOf(CL, ObjectExactCardinality(1, OP, OWLThing()))); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectMaxCardinality desc)") + void shouldCreateViolationForOWLObjectMaxCardinalityInOWL2ELProfile() { + declare(o, OP, CL); + o.add(SubClassOf(CL, ObjectMaxCardinality(1, OP, OWLThing()))); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectMinCardinality desc)") + void shouldCreateViolationForOWLObjectMinCardinalityInOWL2ELProfile() { + declare(o, OP, CL); + o.add(SubClassOf(CL, ObjectMinCardinality(1, OP, OWLThing()))); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectOneOf desc)") + void shouldCreateViolationForOWLObjectOneOfInOWL2ELProfile() { + declare(o, OP); + o.add(ObjectPropertyRange(OP, ObjectOneOf(NamedIndividual(IRI(URN_TEST, "i1")), + NamedIndividual(IRI(URN_TEST, "i2"))))); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfObjectOneOfWithMultipleIndividuals.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectUnionOf desc)") + void shouldCreateViolationForOWLObjectUnionOfInOWL2ELProfile() { + declare(o, OP); + o.add(ObjectPropertyRange(OP, ObjectUnionOf(OWLThing(), OWLNothing()))); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLDataComplementOf node)") + void shouldCreateViolationForOWLDataComplementOfInOWL2ELProfile() { + declare(o, DATAP); + o.add(DataPropertyRange(DATAP, DataComplementOf(Double()))); + int expected = 2; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalDataRange.class, + UseOfIllegalDataRange.class); + } + + @Test + @Tests(method = "Object visit(OWLDataOneOf node)") + void shouldCreateViolationForOWLDataOneOfInOWL2ELProfile() { + declare(o, DATAP); + o.add(DataPropertyRange(DATAP, DataOneOf(Literal(1), Literal(2)))); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfDataOneOfWithMultipleLiterals.class); + } + + @Test + @Tests(method = "Object visit(OWLDatatypeRestriction node)") + void shouldCreateViolationForOWLDatatypeRestrictionInOWL2ELProfile() { + declare(o, DATAP); + o.add(DATA_PROPERTY_RANGE); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalDataRange.class); + } + + @Test + @Tests(method = "Object visit(OWLDataUnionOf node)") + void shouldCreateViolationForOWLDataUnionOfInOWL2ELProfile() { + declare(o, DATAP); + o.add(DataPropertyRange(DATAP, DataUnionOf(Double(), Integer()))); + int expected = 2; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalDataRange.class, + UseOfIllegalDataRange.class); + } + + @Test + @Tests(method = "Object visit(OWLAsymmetricObjectPropertyAxiom axiom)") + void shouldCreateViolationForOWLAsymmetricObjectPropertyAxiomInOWL2ELProfile() { + declare(o, OP); + o.add(AsymmetricObjectProperty(OP)); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLDisjointDataPropertiesAxiom axiom)") + void shouldCreateViolationForOWLDisjointDataPropertiesAxiomInOWL2ELProfile() { + OWLDataProperty dp = DataProperty(IRI(URN_TEST, "other")); + declare(o, DATAP, dp); + o.add(DisjointDataProperties(DATAP, dp)); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLDisjointObjectPropertiesAxiom axiom)") + void shouldCreateViolationForOWLDisjointObjectPropertiesAxiomInOWL2ELProfile() { + OWLObjectProperty op1 = ObjectProperty(IRI(URN_TEST, TEST)); + declare(o, OP, op1); + o.add(DisjointObjectProperties(op1, OP)); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLDisjointUnionAxiom axiom)") + void shouldCreateViolationForOWLDisjointUnionAxiomInOWL2ELProfile() { + declare(o, CL); + o.add(DisjointUnion(CL, OWLThing(), OWLNothing())); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLFunctionalObjectPropertyAxiom axiom)") + void shouldCreateViolationForOWLFunctionalObjectPropertyAxiomInOWL2ELProfile() { + declare(o, OP); + o.add(FunctionalObjectProperty(OP)); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLHasKeyAxiom axiom)") + void shouldCreateViolationForOWLHasKeyAxiomInOWL2ELProfile() { + declare(o, CL, OP); + o.add(HasKey(CL, OP)); + int expected = 0; + runAssert(o, Profiles.OWL2_EL, expected); + } + + @Test + @Tests(method = "Object visit(OWLInverseFunctionalObjectPropertyAxiom axiom)") + void shouldCreateViolationForOWLInverseFunctionalObjectPropertyAxiomInOWL2ELProfile() { + declare(o, P); + o.add(InverseFunctionalObjectProperty(P)); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLInverseObjectPropertiesAxiom axiom)") + void shouldCreateViolationForOWLInverseObjectPropertiesAxiomInOWL2ELProfile() { + declare(o, P); + OWLObjectProperty p1 = ObjectProperty(IRI(URN_TEST, "objectproperty")); + declare(o, p1); + o.add(InverseObjectProperties(P, p1)); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLIrreflexiveObjectPropertyAxiom axiom)") + void shouldCreateViolationForOWLIrreflexiveObjectPropertyAxiomInOWL2ELProfile() { + declare(o, P); + o.add(IrreflexiveObjectProperty(P)); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLSymmetricObjectPropertyAxiom axiom)") + void shouldCreateViolationForOWLSymmetricObjectPropertyAxiomInOWL2ELProfile() { + declare(o, P); + o.add(SymmetricObjectProperty(P)); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(SWRLRule rule)") + void shouldCreateViolationForSWRLRuleInOWL2ELProfile() { + o.add(DF.getSWRLRule(new HashSet(), new HashSet())); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLSubPropertyChainOfAxiom axiom)") + void shouldCreateViolationForOWLSubPropertyChainOfAxiomInOWL2ELProfile() { + OWLObjectProperty op1 = ObjectProperty(IRI(URN_TEST, "op1")); + OWLObjectProperty op2 = ObjectProperty(IRI(URN_TEST, "op")); + declare(o, op1, OP, op2, CL); + o.add(ObjectPropertyRange(OP, CL)); + List asList = Arrays.asList(op2, op1); + o.add(SubPropertyChainOf(asList, OP)); + int expected = 1; + runAssert(o, Profiles.OWL2_EL, expected, LastPropertyInChainNotInImposedRange.class); + } + + @Test + @Tests(method = "Object visit(OWLDatatype node)") + void shouldCreateViolationForOWLDatatypeInOWL2QLProfile() { + declare(o, FAKEDATATYPE); + int expected = 0; + runAssert(o, Profiles.OWL2_QL, expected); + } + + @Test + @Tests(method = "Object visit(OWLAnonymousIndividual individual)") + void shouldCreateViolationForOWLAnonymousIndividualInOWL2QLProfile() { + o.add(ClassAssertion(OWLThing(), DF.getOWLAnonymousIndividual())); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfAnonymousIndividual.class); + } + + @Test + @Tests(method = "Object visit(OWLHasKeyAxiom axiom)") + void shouldCreateViolationForOWLHasKeyAxiomInOWL2QLProfile() { + declare(o, CL, OP); + o.add(HasKey(CL, OP)); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLSubClassOfAxiom axiom)") + void shouldCreateViolationForOWLSubClassOfAxiomInOWL2QLProfile() { + declare(o, OP); + o.add( + SubClassOf(ObjectComplementOf(OWLNothing()), ObjectUnionOf(OWLThing(), OWLNothing()))); + int expected = 2; + runAssert(o, Profiles.OWL2_QL, expected, UseOfNonSubClassExpression.class, + UseOfNonSuperClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLEquivalentClassesAxiom axiom)") + void shouldCreateViolationForOWLEquivalentClassesAxiomInOWL2QLProfile() { + o.add(EquivalentClasses(ObjectUnionOf(OWLNothing(), OWLThing()), OWLNothing())); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfNonSubClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLDisjointClassesAxiom axiom)") + void shouldCreateViolationForOWLDisjointClassesAxiomInOWL2QLProfile() { + o.add(DisjointClasses(ObjectComplementOf(OWLThing()), OWLThing())); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfNonSubClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectPropertyDomainAxiom axiom)") + void shouldCreateViolationForOWLObjectPropertyDomainAxiomInOWL2QLProfile() { + declare(o, OP); + o.add(ObjectPropertyDomain(OP, ObjectUnionOf(OWLNothing(), OWLThing()))); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfNonSuperClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectPropertyRangeAxiom axiom)") + void shouldCreateViolationForOWLObjectPropertyRangeAxiomInOWL2QLProfile() { + declare(o, OP); + o.add(ObjectPropertyRange(OP, ObjectUnionOf(OWLNothing(), OWLThing()))); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfNonSuperClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLSubPropertyChainOfAxiom axiom)") + void shouldCreateViolationForOWLSubPropertyChainOfAxiomInOWL2QLProfile() { + OWLObjectProperty op1 = ObjectProperty(IRI(URN_TEST, "op")); + declare(o, OP, op1); + o.add(SubPropertyChainOf(Arrays.asList(OP, op1), OP)); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLFunctionalObjectPropertyAxiom axiom)") + void shouldCreateViolationForOWLFunctionalObjectPropertyAxiomInOWL2QLProfile() { + declare(o, OP); + o.add(FunctionalObjectProperty(OP)); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLInverseFunctionalObjectPropertyAxiom axiom)") + void shouldCreateViolationForOWLInverseFunctionalObjectPropertyAxiomInOWL2QLProfile() { + declare(o, OP); + o.add(InverseFunctionalObjectProperty(OP)); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLTransitiveObjectPropertyAxiom axiom)") + void shouldCreateViolationForOWLTransitiveObjectPropertyAxiomInOWL2QLProfile() { + declare(o, OP); + o.add(TransitiveObjectProperty(OP)); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLFunctionalDataPropertyAxiom axiom)") + void shouldCreateViolationForOWLFunctionalDataPropertyAxiomInOWL2QLProfile() { + declare(o, DATAP); + o.add(FunctionalDataProperty(DATAP)); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLDataPropertyDomainAxiom axiom)") + void shouldCreateViolationForOWLDataPropertyDomainAxiomInOWL2QLProfile() { + declare(o, DATAP, OP); + o.add(DataPropertyDomain(DATAP, ObjectMaxCardinality(1, OP, OWLNothing()))); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfNonSuperClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLClassAssertionAxiom axiom)") + void shouldCreateViolationForOWLClassAssertionAxiomInOWL2QLProfile() { + OWLNamedIndividual i = NamedIndividual(IRI(URN_TEST, "i")); + declare(o, OP, i); + o.add(ClassAssertion(ObjectSomeValuesFrom(OP, OWLThing()), i)); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfNonAtomicClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLSameIndividualAxiom axiom)") + void shouldCreateViolationForOWLSameIndividualAxiomInOWL2QLProfile() { + o.add(SameIndividual(NamedIndividual(IRI(URN_TEST, "individual1")), + NamedIndividual(IRI(URN_TEST, "individual2")))); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLNegativeObjectPropertyAssertionAxiom axiom)") + void shouldCreateViolationForOWLNegativeObjectPropertyAssertionAxiomInOWL2QLProfile() { + declare(o, OP); + OWLNamedIndividual i = NamedIndividual(IRI(URN_TEST, "i")); + OWLNamedIndividual i1 = NamedIndividual(IRI(URN_TEST, "i")); + declare(o, i, i1); + o.add(NegativeObjectPropertyAssertion(OP, i, i1)); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLNegativeDataPropertyAssertionAxiom axiom)") + void shouldCreateViolationForOWLNegativeDataPropertyAssertionAxiomInOWL2QLProfile() { + declare(o, DATAP); + OWLNamedIndividual i = NamedIndividual(IRI(URN_TEST, "i")); + declare(o, i); + o.add(NegativeDataPropertyAssertion(DATAP, i, Literal(1))); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLDisjointUnionAxiom axiom)") + void shouldCreateViolationForOWLDisjointUnionAxiomInOWL2QLProfile() { + declare(o, CL); + o.add(DisjointUnion(CL, OWLThing(), OWLNothing())); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLIrreflexiveObjectPropertyAxiom axiom)") + void shouldCreateViolationForOWLIrreflexiveObjectPropertyAxiomInOWL2QLProfile() { + declare(o, OP); + o.add(IrreflexiveObjectProperty(OP)); + int expected = 0; + runAssert(o, Profiles.OWL2_QL, expected); + } + + @Test + @Tests(method = "Object visit(SWRLRule rule)") + void shouldCreateViolationForSWRLRuleInOWL2QLProfile() { + o.add(DF.getSWRLRule(new HashSet(), new HashSet())); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLDataComplementOf node)") + void shouldCreateViolationForOWLDataComplementOfInOWL2QLProfile() { + declare(o, DATAP); + o.add(DataPropertyRange(DATAP, DataComplementOf(Integer()))); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfIllegalDataRange.class); + } + + @Test + @Tests(method = "Object visit(OWLDataOneOf node)") + void shouldCreateViolationForOWLDataOneOfInOWL2QLProfile() { + declare(o, DATAP); + o.add(DataPropertyRange(DATAP, DataOneOf(Literal(1), Literal(2)))); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfIllegalDataRange.class); + } + + @Test + @Tests(method = "Object visit(OWLDatatypeRestriction node)") + void shouldCreateViolationForOWLDatatypeRestrictionInOWL2QLProfile() { + declare(o, DATAP); + o.add(DATA_PROPERTY_RANGE); + int expected = 1; + runAssert(o, Profiles.OWL2_QL, expected, UseOfIllegalDataRange.class); + } + + @Test + @Tests(method = "Object visit(OWLDataUnionOf node)") + void shouldCreateViolationForOWLDataUnionOfInOWL2QLProfile() { + declare(o, DATAP); + o.add(DataPropertyRange(DATAP, DataUnionOf(Integer(), Boolean()))); + int expected = 2; + runAssert(o, Profiles.OWL2_QL, expected, UseOfIllegalDataRange.class, + UseOfIllegalDataRange.class); + } + + @Test + @Tests(method = "Object visit(OWLClassAssertionAxiom axiom)") + void shouldCreateViolationForOWLClassAssertionAxiomInOWL2RLProfile() { + declare(o, OP); + o.add(ClassAssertion(ObjectMinCardinality(1, OP, OWLThing()), + NamedIndividual(IRI(URN_TEST, "i")))); + int expected = 1; + runAssert(o, Profiles.OWL2_RL, expected, UseOfNonSuperClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLDataPropertyDomainAxiom axiom)") + void shouldCreateViolationForOWLDataPropertyDomainAxiomInOWL2RLProfile() { + declare(o, DATAP, OP); + o.add(DataPropertyDomain(DATAP, ObjectMinCardinality(1, OP, OWLThing()))); + int expected = 1; + runAssert(o, Profiles.OWL2_RL, expected, UseOfNonSuperClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLDisjointClassesAxiom axiom)") + void shouldCreateViolationForOWLDisjointClassesAxiomInOWL2RLProfile() { + o.add(DisjointClasses(ObjectComplementOf(OWLThing()), OWLThing())); + int expected = 2; + runAssert(o, Profiles.OWL2_RL, expected, UseOfNonSubClassExpression.class, + UseOfNonSubClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLDisjointDataPropertiesAxiom axiom)") + void shouldCreateViolationForOWLDisjointDataPropertiesAxiomInOWL2RLProfile() { + OWLDataProperty dp = DataProperty(IRI(URN_TEST, "dproperty")); + declare(o, DATAP, dp); + o.add(DisjointDataProperties(DATAP, dp)); + int expected = 0; + runAssert(o, Profiles.OWL2_RL, expected); + } + + @Test + @Tests(method = "Object visit(OWLDisjointUnionAxiom axiom)") + void shouldCreateViolationForOWLDisjointUnionAxiomInOWL2RLProfile() { + declare(o, CL); + o.add(DisjointUnion(CL, OWLThing(), OWLNothing())); + int expected = 1; + runAssert(o, Profiles.OWL2_RL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLEquivalentClassesAxiom axiom)") + void shouldCreateViolationForOWLEquivalentClassesAxiomInOWL2RLProfile() { + o.add(EquivalentClasses(ObjectComplementOf(OWLThing()), OWLNothing())); + int expected = 1; + runAssert(o, Profiles.OWL2_RL, expected, UseOfNonEquivalentClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLEquivalentDataPropertiesAxiom axiom)") + void shouldCreateViolationForOWLEquivalentDataPropertiesAxiomInOWL2RLProfile() { + OWLDataProperty dp = DataProperty(IRI(URN_TEST, TEST)); + declare(o, DATAP, dp); + o.add(EquivalentDataProperties(DATAP, dp)); + int expected = 0; + runAssert(o, Profiles.OWL2_RL, expected); + } + + @Test + @Tests(method = "Object visit(OWLFunctionalDataPropertyAxiom axiom)") + void shouldCreateViolationForOWLFunctionalDataPropertyAxiomInOWL2RLProfile() { + declare(o, DATAP); + o.add(FunctionalDataProperty(DATAP)); + int expected = 0; + runAssert(o, Profiles.OWL2_RL, expected); + } + + @Test + @Tests(method = "Object visit(OWLHasKeyAxiom axiom)") + void shouldCreateViolationForOWLHasKeyAxiomInOWL2RLProfile() { + declare(o, CL, OP); + o.add(HasKey(ObjectComplementOf(CL), OP)); + int expected = 1; + runAssert(o, Profiles.OWL2_RL, expected, UseOfNonSubClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectPropertyDomainAxiom axiom)") + void shouldCreateViolationForOWLObjectPropertyDomainAxiomInOWL2RLProfile() { + declare(o, OP, OP); + o.add(ObjectPropertyDomain(OP, ObjectMinCardinality(1, OP, OWLThing()))); + int expected = 1; + runAssert(o, Profiles.OWL2_RL, expected, UseOfNonSuperClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLObjectPropertyRangeAxiom axiom)") + void shouldCreateViolationForOWLObjectPropertyRangeAxiomInOWL2RLProfile() { + declare(o, OP); + o.add(ObjectPropertyRange(OP, ObjectMinCardinality(1, OP, OWLThing()))); + int expected = 1; + runAssert(o, Profiles.OWL2_RL, expected, UseOfNonSuperClassExpression.class); + } + + @Test + @Tests(method = "Object visit(OWLSubClassOfAxiom axiom)") + void shouldCreateViolationForOWLSubClassOfAxiomInOWL2RLProfile() { + o.add(SubClassOf(ObjectComplementOf(OWLThing()), + ObjectOneOf(NamedIndividual(IRI(URN_TEST, TEST))))); + int expected = 2; + runAssert(o, Profiles.OWL2_RL, expected, UseOfNonSubClassExpression.class, + UseOfNonSuperClassExpression.class); + } + + @Test + @Tests(method = "Object visit(SWRLRule rule)") + void shouldCreateViolationForSWRLRuleInOWL2RLProfile() { + o.add(DF.getSWRLRule(new HashSet(), new HashSet())); + int expected = 1; + runAssert(o, Profiles.OWL2_RL, expected, UseOfIllegalAxiom.class); + } + + @Test + @Tests(method = "Object visit(OWLDataComplementOf node)") + void shouldCreateViolationForOWLDataComplementOfInOWL2RLProfile() { + declare(o, DATAP); + o.add(DataPropertyRange(DATAP, DataComplementOf(Integer()))); + int expected = 1; + runAssert(o, Profiles.OWL2_RL, expected, UseOfIllegalDataRange.class); + } + + @Test + @Tests(method = "Object visit(OWLDataIntersectionOf node)") + void shouldCreateViolationForOWLDataIntersectionOfInOWL2RLProfile() { + declare(o, DATAP); + o.add(DataPropertyRange(DATAP, DataIntersectionOf(Integer(), Boolean()))); + int expected = 0; + runAssert(o, Profiles.OWL2_RL, expected); + } + + @Test + @Tests(method = "Object visit(OWLDataOneOf node)") + void shouldCreateViolationForOWLDataOneOfInOWL2RLProfile() { + declare(o, DATAP); + o.add(DataPropertyRange(DATAP, DataOneOf(Literal(1), Literal(2)))); + int expected = 1; + runAssert(o, Profiles.OWL2_RL, expected, UseOfIllegalDataRange.class); + } + + @Test + @Tests(method = "Object visit(OWLDatatype node)") + void shouldCreateViolationForOWLDatatypeInOWL2RLProfile() { + declare(o, Datatype(IRI(URN_TEST, TEST))); + int expected = 0; + runAssert(o, Profiles.OWL2_RL, expected); + } + + @Test + @Tests(method = "Object visit(OWLDatatypeRestriction node)") + void shouldCreateViolationForOWLDatatypeRestrictionInOWL2RLProfile() { + declare(o, DATAP); + o.add(DATA_PROPERTY_RANGE); + int expected = 1; + runAssert(o, Profiles.OWL2_RL, expected, UseOfIllegalDataRange.class); + } + + @Test + @Tests(method = "Object visit(OWLDataUnionOf node)") + void shouldCreateViolationForOWLDataUnionOfInOWL2RLProfile() { + declare(o, DATAP); + o.add(DataPropertyRange(DATAP, DataUnionOf(Double(), Integer()))); + int expected = 1; + runAssert(o, Profiles.OWL2_RL, expected, UseOfIllegalDataRange.class); + } + + @Test + @Tests(method = "Object visit(OWLDatatypeDefinitionAxiom axiom)") + void shouldCreateViolationForOWLDatatypeDefinitionAxiomInOWL2RLProfile() { + OWLDatatype datatype = Datatype(IRI(URN_TEST, "datatype")); + declare(o, datatype); + o.add(DatatypeDefinition(datatype, Boolean())); + int expected = 2; + runAssert(o, Profiles.OWL2_RL, expected, UseOfIllegalAxiom.class, + UseOfIllegalDataRange.class); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/profiles/ProfileAllProfilesTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/profiles/ProfileAllProfilesTestCase.java new file mode 100644 index 0000000000..95a47e940a --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/profiles/ProfileAllProfilesTestCase.java @@ -0,0 +1,23 @@ +package org.semanticweb.owlapi.profiles; + +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; + +class ProfileAllProfilesTestCase extends ProfileBase { + + static Stream data() { + return Stream.of(TestFiles.profileAllTestCases); + } + + @ParameterizedTest + @MethodSource("data") + void testAllProfiles(String premise) { + test(premise.startsWith(" 0); + assertTrue(el == OWL2_EL.checkOntology(o).isInProfile()); + assertTrue(ql == OWL2_QL.checkOntology(o).isInProfile()); + assertTrue(rl == OWL2_RL.checkOntology(o).isInProfile()); + assertTrue(dl == OWL2_DL.checkOntology(o).isInProfile()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/profiles/ProfileDLOnlyTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/profiles/ProfileDLOnlyTestCase.java new file mode 100644 index 0000000000..3457c510ab --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/profiles/ProfileDLOnlyTestCase.java @@ -0,0 +1,23 @@ +package org.semanticweb.owlapi.profiles; + +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; + +class ProfileDLOnlyTestCase extends ProfileBase { + + static Stream data() { + return Stream.of(TestFiles.profileDLTestCases); + } + + @ParameterizedTest + @MethodSource("data") + void testDLOnly(String premise) { + test(premise.startsWith("<") ? new RDFXMLDocumentFormat() + : new FunctionalSyntaxDocumentFormat(), premise, false, false, false, true); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/profiles/ProfileELDLOnlyTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/profiles/ProfileELDLOnlyTestCase.java new file mode 100644 index 0000000000..d866bcc313 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/profiles/ProfileELDLOnlyTestCase.java @@ -0,0 +1,23 @@ +package org.semanticweb.owlapi.profiles; + +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; + +class ProfileELDLOnlyTestCase extends ProfileBase { + + static Stream data() { + return Stream.of(TestFiles.profileELDLTestCases); + } + + @ParameterizedTest + @MethodSource("data") + void testELDLONLY(String premise) { + test(premise.startsWith(" data() { + return Stream.of(TestFiles.profileFullTestCases); + } + + @ParameterizedTest + @MethodSource("data") + void testFull(String premise) { + test(premise.startsWith(" data() { + return Stream.of(TestFiles.profileNOELTestCases); + } + + @ParameterizedTest + @MethodSource("data") + void testNoEL(String premise) { + test(premise.startsWith(" data() { + return Stream.of(TestFiles.profileNOQLTestCases); + } + + @ParameterizedTest + @MethodSource("data") + void testNoQL(String premise) { + test(premise.startsWith(" data() { + return Stream.of(TestFiles.profileNORLTestCases); + } + + @ParameterizedTest + @MethodSource("data") + void testNoRL(String premise) { + test(premise.startsWith(" data() { + return Stream.of(TestFiles.profileQLDLTestCases); + } + + @ParameterizedTest + @MethodSource("data") + void testQLDLOnly(String premise) { + test(premise.startsWith(" data() { + return Stream.of(TestFiles.profileRLDLTestCases); + } + + @ParameterizedTest + @MethodSource("data") + void testRLDLOnly(String premise) { + test(premise.startsWith(" vals = + asUnorderedSet(values(testCasesOntology.dataPropertyAssertionAxioms(ind), + rdfXMLPremiseOntologyProperty)); + if (vals.size() != 1) { + continue; + } + String ontologySerialisation = vals.iterator().next().getLiteral(); + OWLOntology ontology = loadOntologyFromString(ontologySerialisation); + // FULL? + Collection finder = asUnorderedSet( + values(testCasesOntology.objectPropertyAssertionAxioms(ind), speciesProperty)); + if (finder.contains(full)) { + checkProfile(ontology, new OWL2Profile(), true); + } + Collection negativeFinder = asUnorderedSet(negValues( + testCasesOntology.negativeObjectPropertyAssertionAxioms(ind), speciesProperty)); + if (negativeFinder.contains(full)) { + checkProfile(ontology, new OWL2Profile(), false); + } + // DL? + if (finder.contains(dl)) { + checkProfile(ontology, new OWL2DLProfile(), true); + } + if (negativeFinder.contains(dl)) { + checkProfile(ontology, new OWL2DLProfile(), false); + } + // EL? + if (finder.contains(el)) { + checkProfile(ontology, new OWL2ELProfile(), true); + } + if (negativeFinder.contains(el)) { + checkProfile(ontology, new OWL2ELProfile(), false); + } + // QL? + if (finder.contains(ql)) { + checkProfile(ontology, new OWL2QLProfile(), true); + } + if (negativeFinder.contains(ql)) { + checkProfile(ontology, new OWL2QLProfile(), false); + } + // RL? + if (finder.contains(rl)) { + checkProfile(ontology, new OWL2RLProfile(), true); + } + if (negativeFinder.contains(rl)) { + checkProfile(ontology, new OWL2RLProfile(), false); + } + m.removeOntology(ontology); + } + } + + @Test + void shouldNotFailELBecauseOfBoolean() { + OWLOntology o = getOWLOntology(); + OWLAnnotation ann = df.getRDFSLabel(df.getOWLLiteral(true)); + OWLAnnotationAssertionAxiom ax = + df.getOWLAnnotationAssertionAxiom(iri("urn:test#", "ELProfile"), ann); + o.add(ax, Declaration(OWL2Datatype.XSD_BOOLEAN.getDatatype(df))); + checkProfile(o, new OWL2ELProfile(), true); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/profiles/Tests.java b/contract/src/test/java/org/semanticweb/owlapi/profiles/Tests.java new file mode 100644 index 0000000000..29b81ba732 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/profiles/Tests.java @@ -0,0 +1,32 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.profiles; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Tests annotation + * + * @author ignazio + */ +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface Tests { + + /** + * method name + */ + String method(); +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/profiles/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/profiles/package-info.java new file mode 100644 index 0000000000..122c29d5a9 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/profiles/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.profiles; diff --git a/contract/src/test/java/org/semanticweb/owlapi/rio/OWLOntologyStorerFactoryRegistryTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/rio/OWLOntologyStorerFactoryRegistryTestCase.java new file mode 100644 index 0000000000..cd89329277 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/rio/OWLOntologyStorerFactoryRegistryTestCase.java @@ -0,0 +1,23 @@ +package org.semanticweb.owlapi.rio; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.OWLStorerFactory; +import org.semanticweb.owlapi.util.PriorityCollection; + +/** + * @author Peter Ansell p_ansell@yahoo.com + */ +class OWLOntologyStorerFactoryRegistryTestCase { + + private static final int EXPECTED_STORERS = 21; + + @Test + void setUp() { + PriorityCollection ontologyStorers = + OWLManager.createOWLOntologyManager().getOntologyStorers(); + assertEquals(EXPECTED_STORERS, ontologyStorers.size()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/rio/OWLParserFactoryRegistryTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/rio/OWLParserFactoryRegistryTestCase.java new file mode 100644 index 0000000000..4541dc821c --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/rio/OWLParserFactoryRegistryTestCase.java @@ -0,0 +1,61 @@ +package org.semanticweb.owlapi.rio; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.HashSet; +import java.util.Set; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.functional.parser.OWLFunctionalSyntaxOWLParserFactory; +import org.semanticweb.owlapi.io.OWLParserFactory; +import org.semanticweb.owlapi.krss2.parser.KRSS2OWLParserFactory; +import org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxOntologyParserFactory; +import org.semanticweb.owlapi.oboformat.OBOFormatOWLAPIParserFactory; +import org.semanticweb.owlapi.owlxml.parser.OWLXMLParserFactory; +import org.semanticweb.owlapi.rdf.rdfxml.parser.RDFXMLParserFactory; +import org.semanticweb.owlapi.rdf.turtle.parser.TurtleOntologyParserFactory; +import org.semanticweb.owlapi.util.PriorityCollection; + +/** + * @author Peter Ansell p_ansell@yahoo.com + */ +class OWLParserFactoryRegistryTestCase { + + @Test + void setUp() { + // this test used to count the parsers. However, the extra parser in the + // compatibility package will show up here in Eclipse tests, creating + // confusion + // Switched to list the expected parsers anc checking they all appear. + // Any extra ones are welcome. + Set> factories = new HashSet<>(); + factories.add(RDFXMLParserFactory.class); + factories.add(OWLXMLParserFactory.class); + factories.add(OWLFunctionalSyntaxOWLParserFactory.class); + factories.add(TurtleOntologyParserFactory.class); + factories.add(ManchesterOWLSyntaxOntologyParserFactory.class); + factories.add(OBOFormatOWLAPIParserFactory.class); + factories.add(KRSS2OWLParserFactory.class); + factories.add(RioTurtleParserFactory.class); + factories.add(RioNQuadsParserFactory.class); + factories.add(RioJsonParserFactory.class); + factories.add(RioNTriplesParserFactory.class); + factories.add(RioTrigParserFactory.class); + factories.add(RioBinaryRdfParserFactory.class); + factories.add(RioJsonLDParserFactory.class); + factories.add(RioN3ParserFactory.class); + factories.add(RioRDFXMLParserFactory.class); + factories.add(RioTrixParserFactory.class); + factories.add(RioRDFaParserFactory.class); + PriorityCollection ontologyParsers = + OWLManager.createOWLOntologyManager().getOntologyParsers(); + Set> found = new HashSet<>(); + for (OWLParserFactory p : ontologyParsers) { + found.add(p.getClass()); + } + for (Class p : factories) { + assertTrue(found.contains(p), "Expected among parsers: " + p.getSimpleName()); + } + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/rio/RioParserTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/rio/RioParserTestCase.java new file mode 100644 index 0000000000..4b8d8af468 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/rio/RioParserTestCase.java @@ -0,0 +1,155 @@ +/** + * + */ +package org.semanticweb.owlapi.rio; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RioRDFXMLDocumentFormat; +import org.semanticweb.owlapi.formats.RioRDFXMLDocumentFormatFactory; +import org.semanticweb.owlapi.io.StreamDocumentSource; +import org.semanticweb.owlapi.model.OWLDocumentFormat; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.rdf.rdfxml.parser.RDFXMLParser; + +/** + * @author Peter Ansell p_ansell@yahoo.com + */ +class RioParserTestCase extends TestBase { + + private static final String MINIMAL_RDF = "/rioParserTest1-minimal.rdf"; + + @BeforeEach + void setUpManager() { + // Use non-Rio storers + // limit to Rio parsers for RioParserImpl Test + // testManager = OWLOntologyManagerFactoryRegistry + // .createOWLOntologyManager( + // OWLOntologyManagerFactoryRegistry.getOWLDataFactory(), + // storerRegistry, parserRegistry); + m.getOntologyParsers().set(new RioRDFXMLParserFactory()); + // testOntologyKoala = + // testManager.loadOntologyFromOntologyDocument(this.getClass().getResourceAsStream("/koala.owl")); + } + + /* + * Test method for {@link + * org.semanticweb.owlapi.rio.RioParserImpl#parse(org.semanticweb.owlapi.io. + * OWLOntologyDocumentSource, org.semanticweb.owlapi.model.OWLOntology)} + */ + @Test + void testParse() throws Exception { + OWLOntology owlapiOntologyPrimer = getAnonymousOWLOntology(); + RDFXMLParser owlapiParser = new RDFXMLParser(); + OWLDocumentFormat format = + owlapiParser.parse(getStream("/koala.owl"), owlapiOntologyPrimer, config); + assertEquals(70, owlapiOntologyPrimer.getAxiomCount()); + assertEquals(new RDFXMLDocumentFormat(), format); + RioParserImpl rioParser = new RioParserImpl(new RioRDFXMLDocumentFormatFactory()); + // OWLOntology ontology = OWLOntologyManagerFactoryRegistry + // .createOWLOntologyManager().createOntology( + OWLOntology ontology = m1.createOntology( + iri("http://protege.stanford.edu/plugins/owl/owl-library/", "koala.owl")); + OWLDocumentFormat rioOntologyFormat = + rioParser.parse(getStream("/koala.owl"), ontology, config); + assertEquals(new RioRDFXMLDocumentFormat(), rioOntologyFormat); + equal(owlapiOntologyPrimer, ontology); + assertEquals(70, ontology.getAxiomCount()); + } + + /* + * Test method for {@link + * org.semanticweb.owlapi.rio.RioParserImpl#parse(org.semanticweb.owlapi.io. + * OWLOntologyDocumentSource, org.semanticweb.owlapi.model.OWLOntology)} + */ + @Test + void testParsePrimer() throws Exception { + OWLOntology owlapiOntologyPrimer = getAnonymousOWLOntology(); + RDFXMLParser owlapiParser = new RDFXMLParser(); + OWLDocumentFormat format = + owlapiParser.parse(getStream("/primer.rdfxml.xml"), owlapiOntologyPrimer, config); + assertEquals(93, owlapiOntologyPrimer.getAxiomCount()); + assertEquals(new RDFXMLDocumentFormat(), format); + RioParserImpl rioParser = new RioParserImpl(new RioRDFXMLDocumentFormatFactory()); + // OWLOntology rioOntologyPrimer = OWLOntologyManagerFactoryRegistry + // .createOWLOntologyManager() + OWLOntology rioOntologyPrimer = + m1.createOntology(iri("http://example.com/owl/", "families")); + OWLDocumentFormat rioOntologyFormat = + rioParser.parse(getStream("/primer.rdfxml.xml"), rioOntologyPrimer, config); + assertEquals(new RioRDFXMLDocumentFormat(), rioOntologyFormat); + equal(owlapiOntologyPrimer, rioOntologyPrimer); + assertEquals(93, rioOntologyPrimer.getAxiomCount()); + } + + /** + * @return stream + */ + StreamDocumentSource getStream(String name) { + return new StreamDocumentSource(getClass().getResourceAsStream(name)); + } + + /* + * Test method for {@link + * org.semanticweb.owlapi.rio.RioParserImpl#parse(org.semanticweb.owlapi.io. + * OWLOntologyDocumentSource, org.semanticweb.owlapi.model.OWLOntology)} + */ + @Test + void testParsePrimerSubset() throws Exception { + // XXX this test does not work yet + // output: + // Rio: + // DatatypeDefinition( + // DataIntersectionOf( + // DataComplementOf() )) + // OWLAPI: + // DatatypeDefinition( + // DataIntersectionOf( + // DataComplementOf() ))] + OWLOntology owlapiOntologyPrimer = getAnonymousOWLOntology(); + RDFXMLParser owlapiParser = new RDFXMLParser(); + OWLDocumentFormat format = + owlapiParser.parse(getStream(MINIMAL_RDF), owlapiOntologyPrimer, config); + assertEquals(4, owlapiOntologyPrimer.getAxiomCount()); + assertEquals(new RDFXMLDocumentFormat(), format); + RioParserImpl rioParser = new RioParserImpl(new RioRDFXMLDocumentFormatFactory()); + // OWLOntology rioOntologyPrimer = OWLOntologyManagerFactoryRegistry + // .createOWLOntologyManager().createOntology( + OWLOntology rioOntologyPrimer = + m1.createOntology(iri("http://example.com/owl/", "families")); + OWLDocumentFormat rioOntologyFormat = + rioParser.parse(getStream(MINIMAL_RDF), rioOntologyPrimer, config); + assertEquals(new RioRDFXMLDocumentFormat(), rioOntologyFormat); + equal(owlapiOntologyPrimer, rioOntologyPrimer); + assertEquals(4, rioOntologyPrimer.getAxiomCount()); + } + + /* + * Test method for {@link + * org.semanticweb.owlapi.rio.RioParserImpl#parse(org.semanticweb.owlapi.io. + * OWLOntologyDocumentSource, org.semanticweb.owlapi.model.OWLOntology)} + */ + @Test + void testParsePrimerMinimalSubset() throws Exception { + OWLOntology owlapiOntologyPrimer = getAnonymousOWLOntology(); + RDFXMLParser owlapiParser = new RDFXMLParser(); + OWLDocumentFormat format = + owlapiParser.parse(getStream(MINIMAL_RDF), owlapiOntologyPrimer, config); + assertEquals(4, owlapiOntologyPrimer.getAxiomCount()); + assertEquals(new RDFXMLDocumentFormat(), format); + RioParserImpl rioParser = new RioParserImpl(new RioRDFXMLDocumentFormatFactory()); + // OWLOntology rioOntologyPrimer = OWLOntologyManagerFactoryRegistry + // .createOWLOntologyManager().createOntology( + OWLOntology rioOntologyPrimer = + m1.createOntology(iri("http://example.com/owl/", "families")); + OWLDocumentFormat rioOntologyFormat = + rioParser.parse(getStream(MINIMAL_RDF), rioOntologyPrimer, config); + assertEquals(new RioRDFXMLDocumentFormat(), rioOntologyFormat); + equal(owlapiOntologyPrimer, rioOntologyPrimer); + assertEquals(4, rioOntologyPrimer.getAxiomCount()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/rio/RioRendererTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/rio/RioRendererTestCase.java new file mode 100644 index 0000000000..51d61c7a39 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/rio/RioRendererTestCase.java @@ -0,0 +1,213 @@ +/** + * + */ +package org.semanticweb.owlapi.rio; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.StringReader; +import java.io.StringWriter; +import java.util.HashSet; + +import org.eclipse.rdf4j.model.Statement; +import org.eclipse.rdf4j.model.impl.SimpleValueFactory; +import org.eclipse.rdf4j.model.vocabulary.OWL; +import org.eclipse.rdf4j.model.vocabulary.RDF; +import org.eclipse.rdf4j.rio.RDFFormat; +import org.eclipse.rdf4j.rio.RDFParser; +import org.eclipse.rdf4j.rio.RDFWriter; +import org.eclipse.rdf4j.rio.Rio; +import org.eclipse.rdf4j.rio.helpers.StatementCollector; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.RioRDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Peter Ansell p_ansell@yahoo.com + */ +class RioRendererTestCase extends TestBase { + + private static final String DUPLICATE_STATEMENTS = "Duplicate statements were emitted"; + private final IRI testOntologyUri1 = iri("urn:test:ontology:uri:1", ""); + private SimpleValueFactory vf; + private OWLOntology testOntologyEmpty; + private OWLOntology testOntologyKoala; + private Statement testOntologyEmptyStatement; + private StatementCollector testHandlerStatementCollector; + private StringWriter testRdfXmlStringWriter; + private RDFWriter testRdfXmlRioWriter; + private StringWriter testTurtleStringWriter; + private RDFWriter testTurtleRioWriter; + private StringWriter testNTriplesStringWriter; + private RDFWriter testNTriplesRioWriter; + private final RioRDFXMLDocumentFormat format = new RioRDFXMLDocumentFormat(); + + @BeforeEach + void setUp() throws Exception { + vf = SimpleValueFactory.getInstance(); + m.getOntologyStorers().set(new RioNTriplesStorerFactory(), new RioRDFXMLStorerFactory(), + new RioTurtleStorerFactory()); + testOntologyEmpty = m.createOntology(testOntologyUri1); + testOntologyKoala = + m.loadOntologyFromOntologyDocument(getClass().getResourceAsStream("/koala.owl")); + assertEquals(70, testOntologyKoala.getAxiomCount()); + testHandlerStatementCollector = new StatementCollector(); + testOntologyEmptyStatement = + vf.createStatement(vf.createIRI("urn:test:ontology:uri:1"), RDF.TYPE, OWL.ONTOLOGY); + testRdfXmlStringWriter = new StringWriter(); + testRdfXmlRioWriter = Rio.createWriter(RDFFormat.RDFXML, testRdfXmlStringWriter); + testTurtleStringWriter = new StringWriter(); + testTurtleRioWriter = Rio.createWriter(RDFFormat.TURTLE, testTurtleStringWriter); + testNTriplesStringWriter = new StringWriter(); + testNTriplesRioWriter = Rio.createWriter(RDFFormat.NTRIPLES, testNTriplesStringWriter); + } + + @Test + void testRenderEmptyStatementCollector() { + RioRenderer testRenderer = + new RioRenderer(testOntologyEmpty, testHandlerStatementCollector, null); + testRenderer.render(); + assertEquals(6, testHandlerStatementCollector.getNamespaces().size()); + assertEquals(1, testHandlerStatementCollector.getStatements().size()); + // Verify that the RDF:TYPE OWL:ONTOLOGY statement was generated for the + // otherwise empty + // ontology + assertEquals(testOntologyEmptyStatement, + testHandlerStatementCollector.getStatements().iterator().next()); + } + + @Test + void testRenderEmptyRdfXmlWriter() { + RioRenderer testRenderer = new RioRenderer(testOntologyEmpty, testRdfXmlRioWriter, null); + testRenderer.render(); + // testRdfXmlRioWriter outputs its results to testRdfXmlStringWriter + String result = testRdfXmlStringWriter.toString(); + assertTrue(result.length() > 560, "Result was smaller than expected:" + result); + assertTrue(result.length() < 590, "Result was larger than expected:" + result); + } + + @Test + void testRenderEmptyTurtleWriter() { + RioRenderer testRenderer = new RioRenderer(testOntologyEmpty, testTurtleRioWriter, null); + testRenderer.render(); + // testTurtleRioWriter outputs its results to testTurtleStringWriter + String result = testTurtleStringWriter.toString(); + assertTrue(result.length() > 420, "Result was smaller than expected:" + result); + assertTrue(result.length() < 450, "Result was larger than expected:" + result); + } + + @Test + void testRenderEmptyNTriplesWriter() { + RioRenderer testRenderer = new RioRenderer(testOntologyEmpty, testNTriplesRioWriter, null); + testRenderer.render(); + // testNTriplesRioWriter outputs its results to testNTriplesStringWriter + String result = testNTriplesStringWriter.toString(); + assertTrue(result.length() > 190, "Result was smaller than expected:" + result); + assertTrue(result.length() < 220, "Result was larger than expected:" + result); + } + + @Test + void testRenderKoalaStatementCollector() { + RioRenderer testRenderer = + new RioRenderer(testOntologyKoala, testHandlerStatementCollector, null); + testRenderer.render(); + assertEquals(6, testHandlerStatementCollector.getNamespaces().size()); + assertEquals(171, testHandlerStatementCollector.getStatements().size()); + // check for duplicate statements + HashSet resultStatements = + new HashSet<>(testHandlerStatementCollector.getStatements()); + assertEquals(171, resultStatements.size(), DUPLICATE_STATEMENTS); + } + + @Test + void testRenderKoalaRdfXmlWriter() throws Exception { + RioRenderer testRenderer = new RioRenderer(testOntologyKoala, testRdfXmlRioWriter, null); + testRenderer.render(); + // testRdfXmlRioWriter outputs its results to testRdfXmlStringWriter + String result = testRdfXmlStringWriter.toString(); + // actual length depends on the length of dynamically assigned blank + // node identifiers, so we + // only test a minimum length and a maximum length + assertTrue(result.length() > 24000, + "result.length()=" + result.length() + " was not inside the expected bounds"); + assertTrue(result.length() < 26000, + "result.length()=" + result.length() + " was not inside the expected bounds"); + RDFParser parser = Rio.createParser(RDFFormat.RDFXML, vf); + parser.setRDFHandler(testHandlerStatementCollector); + parser.parse(new StringReader(result), ""); + // NOTE: The base xmlns: does not get counted as a namespace by the Rio + // RDFXML parser, which + // is why it counts to 5, compared to direct StatementCollector result + // and the turtle result + assertEquals(5, testHandlerStatementCollector.getNamespaces().size()); + assertEquals(171, testHandlerStatementCollector.getStatements().size()); + // check for duplicate statements + HashSet resultStatements = + new HashSet<>(testHandlerStatementCollector.getStatements()); + assertEquals(171, resultStatements.size(), DUPLICATE_STATEMENTS); + } + + @Test + void testRenderKoalaTurtleWriter() throws Exception { + RioRenderer testRenderer = new RioRenderer(testOntologyKoala, testTurtleRioWriter, null); + testRenderer.render(); + // testTurtleRioWriter outputs its results to testTurtleStringWriter + String result = testTurtleStringWriter.toString(); + // actual length depends on the length of dynamically assigned blank + // node identifiers, so we + // only test a minimum length and a maximum length + assertTrue(result.length() > 8000, + "result.length()=" + result.length() + " was not inside the expected bounds"); + assertTrue(result.length() < 9500, + "result.length()=" + result.length() + " was not inside the expected bounds"); + RDFParser parser = Rio.createParser(RDFFormat.TURTLE, vf); + parser.setRDFHandler(testHandlerStatementCollector); + parser.parse(new StringReader(result), ""); + assertEquals(6, testHandlerStatementCollector.getNamespaces().size()); + assertEquals(171, testHandlerStatementCollector.getStatements().size()); + // check for duplicate statements + HashSet resultStatements = + new HashSet<>(testHandlerStatementCollector.getStatements()); + assertEquals(171, resultStatements.size(), DUPLICATE_STATEMENTS); + } + + @Test + void testRenderKoalaNTriplesWriter() throws Exception { + RioRenderer testRenderer = new RioRenderer(testOntologyKoala, testNTriplesRioWriter, null); + testRenderer.render(); + // testNTriplesRioWriter outputs its results to testNTriplesStringWriter + String result = testNTriplesStringWriter.toString(); + // actual length depends on the length of dynamically assigned blank + // node identifiers, so we + // only test a minimum length and a maximum length + assertTrue(result.length() > 26200, + "result.length()=" + result.length() + " was not inside the expected bounds"); + assertTrue(result.length() < 27500, + "result.length()=" + result.length() + " was not inside the expected bounds"); + RDFParser parser = Rio.createParser(RDFFormat.NTRIPLES, vf); + parser.setRDFHandler(testHandlerStatementCollector); + parser.parse(new StringReader(result), ""); + // NTriples does not contain namespaces, so we will not find any when + // parsing the document + assertEquals(0, testHandlerStatementCollector.getNamespaces().size()); + assertEquals(171, testHandlerStatementCollector.getStatements().size()); + // check for duplicate statements + HashSet resultStatements = + new HashSet<>(testHandlerStatementCollector.getStatements()); + assertEquals(171, resultStatements.size(), DUPLICATE_STATEMENTS); + } + + @Test + void testRioOWLRDFParser() throws Exception { + RDFParser parser = new RioManchesterSyntaxParserFactory().getParser(); + parser.setRDFHandler(testHandlerStatementCollector); + parser.parse(new StringReader(TestFiles.inputManSyntax), + "http://www.owl-ontologies.com/Ontology1307394066.owl"); + assertEquals(36, testHandlerStatementCollector.getStatements().size()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/rio/RioUtilsTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/rio/RioUtilsTestCase.java new file mode 100644 index 0000000000..b546aef1df --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/rio/RioUtilsTestCase.java @@ -0,0 +1,141 @@ +/** + * + */ +package org.semanticweb.owlapi.rio; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.eclipse.rdf4j.model.BNode; +import org.eclipse.rdf4j.model.Literal; +import org.eclipse.rdf4j.model.Statement; +import org.eclipse.rdf4j.model.ValueFactory; +import org.eclipse.rdf4j.model.impl.SimpleValueFactory; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.io.RDFLiteral; +import org.semanticweb.owlapi.io.RDFResourceBlankNode; +import org.semanticweb.owlapi.io.RDFResourceIRI; +import org.semanticweb.owlapi.io.RDFTriple; +import org.semanticweb.owlapi.rio.utils.RioUtils; + +/** + * @author Peter Ansell p_ansell@yahoo.com + */ +class RioUtilsTestCase extends TestBase { + + private static final String TEST_LITERAL = "Test literal"; + private static final ValueFactory VF = SimpleValueFactory.getInstance(); + private RDFTriple testOwlApiTripleAllIRI; + private RDFTriple testOwlApiTriplePlainLiteral; + private RDFTriple testOwlApiTripleLangLiteral; + private RDFTriple testOwlApiTripleTypedLiteral; + private RDFTriple testOwlApiTripleSubjectBNode; + private RDFTriple testOwlApiTripleObjectBNode; + private RDFTriple testOwlApiTripleSubjectObjectBNode; + private Statement testSesameTripleAllIRI; + private Statement testSesameTriplePlainLiteral; + private Statement testSesameTripleLangLiteral; + private Statement testSesameTripleTypedLiteral; + private Statement testSesameTripleSubjectBNode; + private Statement testSesameTripleObjectBNode; + private Statement testSesameTripleSubjectObjectBNode; + + @BeforeEach + void setUp() { + RDFResourceIRI testOwlApiSubjectUri1 = + new RDFResourceIRI(iri("urn:test:subject:uri:1", "")); + RDFResourceIRI testOwlApiPredicateUri1 = + new RDFResourceIRI(iri("urn:test:predicate:uri:1", "")); + RDFResourceIRI testOwlApiObjectUri1 = new RDFResourceIRI(iri("urn:test:object:uri:1", "")); + RDFLiteral testOwlApiObjectPlainLiteral1 = new RDFLiteral(TEST_LITERAL, "", null); + RDFLiteral testOwlApiObjectLangLiteral1 = new RDFLiteral(TEST_LITERAL, "en", null); + RDFLiteral testOwlApiObjectTypedLiteral1 = + new RDFLiteral(TEST_LITERAL, null, iri("urn:test:datatype:1", "")); + RDFResourceBlankNode testOwlApiSubjectBNode1 = + new RDFResourceBlankNode(iri("subjectBnode1", ""), true, false, false); + RDFResourceBlankNode testOwlApiObjectBNode1 = + new RDFResourceBlankNode(iri("objectBnode1", ""), true, false, false); + testOwlApiTripleAllIRI = + new RDFTriple(testOwlApiSubjectUri1, testOwlApiPredicateUri1, testOwlApiObjectUri1); + testOwlApiTriplePlainLiteral = new RDFTriple(testOwlApiSubjectUri1, testOwlApiPredicateUri1, + testOwlApiObjectPlainLiteral1); + testOwlApiTripleLangLiteral = new RDFTriple(testOwlApiSubjectUri1, testOwlApiPredicateUri1, + testOwlApiObjectLangLiteral1); + testOwlApiTripleTypedLiteral = new RDFTriple(testOwlApiSubjectUri1, testOwlApiPredicateUri1, + testOwlApiObjectTypedLiteral1); + testOwlApiTripleSubjectBNode = + new RDFTriple(testOwlApiSubjectBNode1, testOwlApiPredicateUri1, testOwlApiObjectUri1); + testOwlApiTripleObjectBNode = + new RDFTriple(testOwlApiSubjectUri1, testOwlApiPredicateUri1, testOwlApiObjectBNode1); + testOwlApiTripleSubjectObjectBNode = + new RDFTriple(testOwlApiSubjectBNode1, testOwlApiPredicateUri1, testOwlApiObjectBNode1); + org.eclipse.rdf4j.model.IRI testSesameSubjectUri1 = VF.createIRI("urn:test:subject:uri:1"); + org.eclipse.rdf4j.model.IRI testSesamePredicateUri1 = + VF.createIRI("urn:test:predicate:uri:1"); + org.eclipse.rdf4j.model.IRI testSesameObjectUri1 = VF.createIRI("urn:test:object:uri:1"); + Literal testSesameObjectPlainLiteral1 = VF.createLiteral(TEST_LITERAL); + Literal testSesameObjectLangLiteral1 = VF.createLiteral(TEST_LITERAL, "en"); + Literal testSesameObjectTypedLiteral1 = + VF.createLiteral(TEST_LITERAL, VF.createIRI("urn:test:datatype:1")); + BNode testSesameSubjectBNode1 = VF.createBNode("subjectBnode1"); + BNode testSesameObjectBNode1 = VF.createBNode("objectBnode1"); + testSesameTripleAllIRI = VF.createStatement(testSesameSubjectUri1, testSesamePredicateUri1, + testSesameObjectUri1); + testSesameTriplePlainLiteral = VF.createStatement(testSesameSubjectUri1, + testSesamePredicateUri1, testSesameObjectPlainLiteral1); + testSesameTripleLangLiteral = VF.createStatement(testSesameSubjectUri1, + testSesamePredicateUri1, testSesameObjectLangLiteral1); + testSesameTripleTypedLiteral = VF.createStatement(testSesameSubjectUri1, + testSesamePredicateUri1, testSesameObjectTypedLiteral1); + testSesameTripleSubjectBNode = VF.createStatement(testSesameSubjectBNode1, + testSesamePredicateUri1, testSesameObjectUri1); + testSesameTripleObjectBNode = VF.createStatement(testSesameSubjectUri1, + testSesamePredicateUri1, testSesameObjectBNode1); + testSesameTripleSubjectObjectBNode = VF.createStatement(testSesameSubjectBNode1, + testSesamePredicateUri1, testSesameObjectBNode1); + } + + @Test + void testTripleAllIRI() { + Statement tripleAsStatement = RioUtils.tripleAsStatement(testOwlApiTripleAllIRI); + assertEquals(testSesameTripleAllIRI, tripleAsStatement); + } + + @Test + void testTripleBNodeComparisonObject() { + Statement tripleAsStatement = RioUtils.tripleAsStatement(testOwlApiTripleObjectBNode); + assertEquals(testSesameTripleObjectBNode, tripleAsStatement); + } + + @Test + void testTripleBNodeComparisonSubject() { + Statement tripleAsStatement = RioUtils.tripleAsStatement(testOwlApiTripleSubjectBNode); + assertEquals(testSesameTripleSubjectBNode, tripleAsStatement); + } + + @Test + void testTripleBNodeComparisonSubjectAndObject() { + Statement tripleAsStatement = + RioUtils.tripleAsStatement(testOwlApiTripleSubjectObjectBNode); + assertEquals(testSesameTripleSubjectObjectBNode, tripleAsStatement); + } + + @Test + void testTripleLangLiteral() { + Statement tripleAsStatement = RioUtils.tripleAsStatement(testOwlApiTripleLangLiteral); + assertEquals(testSesameTripleLangLiteral, tripleAsStatement); + } + + @Test + void testTriplePlainLiteral() { + Statement tripleAsStatement = RioUtils.tripleAsStatement(testOwlApiTriplePlainLiteral); + assertEquals(testSesameTriplePlainLiteral, tripleAsStatement); + } + + @Test + void testTripleTypedLiteral() { + Statement tripleAsStatement = RioUtils.tripleAsStatement(testOwlApiTripleTypedLiteral); + assertEquals(testSesameTripleTypedLiteral, tripleAsStatement); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/rio/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/rio/package-info.java new file mode 100644 index 0000000000..fad8aef86b --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/rio/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.rio; diff --git a/contract/src/test/java/org/semanticweb/owlapi/util/EntitySearcherTestCase.java b/contract/src/test/java/org/semanticweb/owlapi/util/EntitySearcherTestCase.java new file mode 100644 index 0000000000..b1864c5ae5 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/util/EntitySearcherTestCase.java @@ -0,0 +1,64 @@ +package org.semanticweb.owlapi.util; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectInverseOf; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ObjectProperty; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Ontology; +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SubObjectPropertyOf; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Stream; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.PrefixManager; +import org.semanticweb.owlapi.search.EntitySearcher; + +class EntitySearcherTestCase extends TestBase { + + private OWLObjectProperty superProperty; + private OWLObjectPropertyExpression inverseProperty; + private OWLObjectProperty subProperty; + private Set ontologies; + + @BeforeEach + void setUp() { + PrefixManager pm = new DefaultPrefixManager(); + pm.setDefaultPrefix("http://www.ontologies.com/ontology"); + subProperty = ObjectProperty("subProperty", pm); + superProperty = ObjectProperty("superProperty", pm); + inverseProperty = ObjectInverseOf(ObjectProperty("inverseProperty", pm)); + OWLOntology ontology = Ontology(m, SubObjectPropertyOf(subProperty, superProperty), + SubObjectPropertyOf(subProperty, inverseProperty)); + ontologies = Collections.singleton(ontology); + } + + @Test + void shouldReturnSuperProperty() { + Stream superProperties = + EntitySearcher.getSuperProperties(subProperty, ontologies.stream()); + assertTrue(superProperties.anyMatch(superProperty::equals)); + } + + @Test + void shouldWorkWithInverse() { + Set expressions = new HashSet<>(); + EntitySearcher.getSuperProperties(subProperty, ontologies.stream()) + .forEach(expressions::add); + assertEquals(2, expressions.size()); + } + + @Test + void shouldReturnSubProperty() { + Stream subs = + EntitySearcher.getSubProperties(superProperty, ontologies.stream()); + assertTrue(subs.anyMatch(subProperty::equals)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/util/FormatsMimeTestcase.java b/contract/src/test/java/org/semanticweb/owlapi/util/FormatsMimeTestcase.java new file mode 100644 index 0000000000..4a17cfafb0 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/util/FormatsMimeTestcase.java @@ -0,0 +1,67 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package org.semanticweb.owlapi.util; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.io.OWLParserFactory; + +/** + * Test the generic factory and all the formats it can build. + * + * @author ignazio + */ +class FormatsMimeTestcase { + public static Stream params() { + return Stream.of( + //@formatter:off + Arguments.of(new org.semanticweb.owlapi.oboformat.OBOFormatOWLAPIParserFactory(), "OBO Format", null, Collections.emptyList()), + Arguments.of(new org.semanticweb.owlapi.krss2.parser.KRSS2OWLParserFactory(), "KRSS2 Syntax", null, Collections.emptyList()), + Arguments.of(new org.semanticweb.owlapi.dlsyntax.parser.DLSyntaxOWLParserFactory(), "DL Syntax Format", null, Collections.emptyList()), + Arguments.of(new org.semanticweb.owlapi.rdf.rdfxml.parser.RDFXMLParserFactory(), "RDF/XML Syntax", "application/rdf+xml", Arrays.asList("application/rdf+xml", "application/xml", "text/xml")), + Arguments.of(new org.semanticweb.owlapi.rio.RioRDFXMLParserFactory(), "RDF/XML", "application/rdf+xml", Arrays.asList("application/rdf+xml", "application/xml", "text/xml")), + Arguments.of(new org.semanticweb.owlapi.rio.RioNQuadsParserFactory(), "N-Quads", "application/n-quads", Arrays.asList("application/n-quads", "text/x-nquads", "text/nquads")), + Arguments.of(new org.semanticweb.owlapi.rio.RioRDFaParserFactory(), "RDFa", "application/xhtml+xml", Arrays.asList("application/xhtml+xml", "application/html", "text/html")), + Arguments.of(new org.semanticweb.owlapi.rdf.turtle.parser.TurtleOntologyParserFactory(), "Turtle Syntax", "text/turtle", Arrays.asList("text/turtle", "application/x-turtle")), + Arguments.of(new org.semanticweb.owlapi.rio.RioTurtleParserFactory(), "Turtle", "text/turtle", Arrays.asList("text/turtle", "application/x-turtle")), + Arguments.of(new org.semanticweb.owlapi.rio.RioN3ParserFactory(), "N3", "text/n3", Arrays.asList("text/n3", "text/rdf+n3")), + Arguments.of(new org.semanticweb.owlapi.owlxml.parser.OWLXMLParserFactory(), "OWL/XML Syntax", "application/owl+xml", Arrays.asList("application/owl+xml", "text/xml")), + Arguments.of(new org.semanticweb.owlapi.rio.RioNTriplesParserFactory(), "N-Triples", "application/n-triples", Arrays.asList("application/n-triples", "text/plain")), + Arguments.of(new org.semanticweb.owlapi.rio.RioTrigParserFactory(), "TriG", "application/trig", Arrays.asList("application/trig", "application/x-trig")), + Arguments.of(new org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxOntologyParserFactory(), "Manchester OWL Syntax", "text/owl-manchester", Arrays.asList("text/owl-manchester")), + Arguments.of(new org.semanticweb.owlapi.functional.parser.OWLFunctionalSyntaxOWLParserFactory(), "OWL Functional Syntax", "text/owl-functional", Arrays.asList("text/owl-functional")), + Arguments.of(new org.semanticweb.owlapi.rio.RioBinaryRdfParserFactory(), "BinaryRDF", "application/x-binary-rdf", Arrays.asList("application/x-binary-rdf")), + Arguments.of(new org.semanticweb.owlapi.rio.RioJsonLDParserFactory(), "JSON-LD", "application/ld+json", Arrays.asList("application/ld+json")), + Arguments.of(new org.semanticweb.owlapi.rio.RioJsonParserFactory(), "RDF/JSON", "application/rdf+json", Arrays.asList("application/rdf+json")), + Arguments.of(new org.semanticweb.owlapi.rio.RioTrixParserFactory(), "TriX", "application/trix", Arrays.asList("application/trix")) + //@formatter:on + ); + } + + @ParameterizedTest + @MethodSource("params") + public void shouldMatchExpectedValues(OWLParserFactory f, String key, String defaultmime, + List mimes) { + assertEquals(key, f.getSupportedFormat().getKey()); + assertEquals(mimes, f.getMIMETypes()); + assertEquals(defaultmime, f.getDefaultMIMEType()); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/util/OWLEntityURIConverterTest.java b/contract/src/test/java/org/semanticweb/owlapi/util/OWLEntityURIConverterTest.java new file mode 100644 index 0000000000..c46054674c --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/util/OWLEntityURIConverterTest.java @@ -0,0 +1,64 @@ +package org.semanticweb.owlapi.util; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; + +import java.io.File; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; + +public class OWLEntityURIConverterTest extends TestBase { + + private static final String TEST_ONTOLOGY_RESOURCE = "testUriConverterOntology.owl"; + private static final String OLD_NAMESPACE = "http://www.example.org/testOntology#"; + private static final String NEW_NAMESPACE = "http://www.example.org/newTestOntology#"; + + @Test + public void test() throws OWLOntologyCreationException { + File ontologyFile = new File( + this.getClass().getClassLoader().getResource(TEST_ONTOLOGY_RESOURCE).getFile()); + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + OWLOntology ontology = manager.loadOntologyFromOntologyDocument(ontologyFile); + checkEntityNamespace(ontology, OLD_NAMESPACE); + OWLEntityURIConverter converter = + getOWLEntityNamespaceConverter(manager, OLD_NAMESPACE, NEW_NAMESPACE); + manager.applyChanges(converter.getChanges()); + checkEntityNamespace(ontology, NEW_NAMESPACE); + } + + private static OWLEntityURIConverter getOWLEntityNamespaceConverter(OWLOntologyManager manager, + String oldNamespace, String newNamespace) { + OWLEntityURIConverterStrategy strategy = entity -> { + IRI newIRI = entity.getIRI(); + if (!entity.isAnonymous()) { + newIRI = IRI.create(entity.getIRI().toString().replace(oldNamespace, newNamespace)); + } + return newIRI; + }; + return new OWLEntityURIConverter(manager, asList(manager.ontologies()), strategy); + } + + private static void checkEntityNamespace(OWLOntology ontology, String namespace) { + ontology.classesInSignature() + .forEach(x -> assertTrue(x.getIRI().toString().contains(namespace))); + ontology.individualsInSignature() + .forEach(x -> assertTrue(x.getIRI().toString().contains(namespace))); + ontology.objectPropertiesInSignature() + .filter(x -> !x.asOWLObjectProperty().isOWLTopObjectProperty()) + .forEach(x -> assertTrue(x.getIRI().toString().contains(namespace))); + ontology.dataPropertiesInSignature() + .filter(x -> !x.asOWLDataProperty().isOWLTopDataProperty()) + .forEach(x -> assertTrue(x.getIRI().toString().contains(namespace))); + ontology.annotationPropertiesInSignature() + .forEach(x -> assertTrue(x.getIRI().toString().contains(namespace))); + ontology.datatypesInSignature().filter(x -> !x.asOWLDatatype().isBuiltIn()) + .forEach(x -> assertTrue(x.getIRI().toString().contains(namespace))); + } + +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/util/OWLObjectWalkerTest.java b/contract/src/test/java/org/semanticweb/owlapi/util/OWLObjectWalkerTest.java new file mode 100644 index 0000000000..ab4920ab18 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/util/OWLObjectWalkerTest.java @@ -0,0 +1,80 @@ +package org.semanticweb.owlapi.util; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.util.AnnotationWalkingControl.DONT_WALK_ANNOTATIONS; +import static org.semanticweb.owlapi.util.AnnotationWalkingControl.WALK_ANNOTATIONS; +import static org.semanticweb.owlapi.util.AnnotationWalkingControl.WALK_ONTOLOGY_ANNOTATIONS_ONLY; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.model.AddOntologyAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLObject; +import org.semanticweb.owlapi.model.OWLObjectVisitor; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * Created by ses on 8/15/15. + */ +class OWLObjectWalkerTest extends TestBase { + + private OWLAnnotation world; + private OWLAnnotation cruelWorld; + private OWLAnnotationProperty ap; + private OWLAnnotation goodbye; + private OWLAnnotation hello; + + private static void checkWalkWithFlags(OWLOntology o, AnnotationWalkingControl walkFlag, + List expected) { + final List visitedAnnotations = new ArrayList<>(); + OWLObjectVisitor visitor = new OWLObjectVisitor() { + + @Override + public void visit(OWLAnnotation node) { + visitedAnnotations.add(node); + } + }; + Set ontologySet = Collections.singleton(o); + OWLObjectWalker walker; + if (walkFlag == WALK_ONTOLOGY_ANNOTATIONS_ONLY) { + walker = new OWLObjectWalker<>(ontologySet); + } else { + walker = new OWLObjectWalker<>(ontologySet, true, walkFlag); + } + walker.walkStructure(visitor); + assertEquals(expected, visitedAnnotations); + } + + @BeforeEach + public void setUp() { + ap = df.getOWLAnnotationProperty(iri("ap")); + cruelWorld = df.getOWLAnnotation(ap, df.getOWLLiteral("cruel world")); + goodbye = df.getOWLAnnotation(ap, df.getOWLLiteral("goodbye"), singleton(cruelWorld)); + world = df.getOWLAnnotation(ap, df.getOWLLiteral("world")); + hello = df.getOWLAnnotation(ap, df.getOWLLiteral("hello"), singleton(world)); + } + + @Test + public void testWalkAnnotations() { + OWLOntology o = getOwlOntology(); + List emptyAnnotationList = Collections.emptyList(); + checkWalkWithFlags(o, DONT_WALK_ANNOTATIONS, emptyAnnotationList); + checkWalkWithFlags(o, WALK_ONTOLOGY_ANNOTATIONS_ONLY, Arrays.asList(hello)); + checkWalkWithFlags(o, WALK_ANNOTATIONS, Arrays.asList(hello, world, goodbye, cruelWorld)); + } + + private OWLOntology getOwlOntology() { + OWLOntology o = getOWLOntology(); + o.applyChange(new AddOntologyAnnotation(o, hello)); + o.addAxiom(df.getOWLDeclarationAxiom(ap, singleton(goodbye))); + return o; + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapi/util/package-info.java b/contract/src/test/java/org/semanticweb/owlapi/util/package-info.java new file mode 100644 index 0000000000..bbd5cbff84 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapi/util/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.semanticweb.owlapi.util; diff --git a/contract/src/test/java/org/semanticweb/owlapitools/decomposition/test/AtomicDecomposerDepedenciesTest.java b/contract/src/test/java/org/semanticweb/owlapitools/decomposition/test/AtomicDecomposerDepedenciesTest.java new file mode 100644 index 0000000000..4e8f23bd39 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapitools/decomposition/test/AtomicDecomposerDepedenciesTest.java @@ -0,0 +1,55 @@ +package org.semanticweb.owlapitools.decomposition.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.util.Set; + +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; + +import uk.ac.manchester.cs.atomicdecomposition.Atom; +import uk.ac.manchester.cs.atomicdecomposition.AtomicDecomposition; +import uk.ac.manchester.cs.atomicdecomposition.AtomicDecompositionImpl; + +class AtomicDecomposerDepedenciesTest { + + private static final String URN_TEST = "urn:test#"; + + @Test + public void atomicDecomposerDepedenciesTest() throws OWLOntologyCreationException { + // given + OWLOntology o = getOntology(); + assertEquals(3, o.getAxiomCount()); + AtomicDecomposition ad = new AtomicDecompositionImpl(o); + assertEquals(3, ad.getAtoms().size()); + Atom atom = ad.getBottomAtoms().iterator().next(); + assertNotNull(atom); + // when + Set dependencies = ad.getDependencies(atom, true); + Set dependencies2 = ad.getDependencies(atom, false); + dependencies2.remove(atom); + // then + assertEquals(0, dependencies2.size()); + assertEquals(0, dependencies.size()); + } + + private static OWLOntology getOntology() throws OWLOntologyCreationException { + OWLOntologyManager m = OWLManager.createOWLOntologyManager(); + OWLOntology o = m.createOntology(); + OWLDataFactory f = m.getOWLDataFactory(); + OWLClass powerYoga = f.getOWLClass(URN_TEST, "PowerYoga"); + OWLClass yoga = f.getOWLClass(URN_TEST, "Yoga"); + OWLClass relaxation = f.getOWLClass(URN_TEST, "Relaxation"); + OWLClass activity = f.getOWLClass(URN_TEST, "Activity"); + o.addAxiom(f.getOWLSubClassOfAxiom(powerYoga, yoga)); + o.addAxiom(f.getOWLSubClassOfAxiom(yoga, relaxation)); + o.addAxiom(f.getOWLSubClassOfAxiom(relaxation, activity)); + return o; + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapitools/decomposition/test/OldModularisationEquivalenceTestCase.java b/contract/src/test/java/org/semanticweb/owlapitools/decomposition/test/OldModularisationEquivalenceTestCase.java new file mode 100644 index 0000000000..66318fa255 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapitools/decomposition/test/OldModularisationEquivalenceTestCase.java @@ -0,0 +1,192 @@ +package org.semanticweb.owlapitools.decomposition.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLException; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; + +import uk.ac.manchester.cs.atomicdecomposition.AtomicDecomposition; +import uk.ac.manchester.cs.atomicdecomposition.AtomicDecompositionImpl; +import uk.ac.manchester.cs.owlapi.modularity.ModuleType; +import uk.ac.manchester.cs.owlapi.modularity.SyntacticLocalityModuleExtractor; + +class OldModularisationEquivalenceTestCase extends TestBase { + + static final String DRY_EUCALYPT_FOREST = "DryEucalyptForest"; + static final String QUOKKA = "Quokka"; + static final String STUDENT = "Student"; + static final String KOALA2 = "Koala"; + static final String MALE_STUDENT_WITH3_DAUGHTERS = "MaleStudentWith3Daughters"; + static final String KOALA_WITH_PHD = "KoalaWithPhD"; + static final String TASMANIAN_DEVIL = "TasmanianDevil"; + static final String GRADUATE_STUDENT = "GraduateStudent"; + static final String RAINFOREST = "Rainforest"; + static final String KOALA = "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + " true\n" + + " 1.2\n" + + " \n" + + " false\n" + + " Male111.1\n" + + " \n" + + " \n" + + " \n" + + " 1\n" + + " \n" + + " true\n" + + " \n" + + " 3\n" + + " \n \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n"; + static String ns = "http://protege.stanford.edu/plugins/owl/owl-library/koala.owl#"; + static OWLDataFactory f = OWLManager.getOWLDataFactory(); + + static Set l(String... s) { + return asSet(Stream.of(s).map(st -> f.getOWLClass(ns, st)), OWLEntity.class); + } + + static List> params() { + List> l = new ArrayList<>(); + l.add(l("Person")); + l.add(l("Habitat")); + l.add(l("Forest")); + l.add(l("Degree")); + l.add(l("Parent")); + l.add(l(GRADUATE_STUDENT)); + l.add(l(RAINFOREST)); + l.add(l("Marsupials")); + l.add(l(KOALA_WITH_PHD)); + l.add(l(TASMANIAN_DEVIL)); + l.add(l("University")); + l.add(l("Animal")); + l.add(l("Male")); + l.add(l(MALE_STUDENT_WITH3_DAUGHTERS)); + l.add(l("Female")); + l.add(l(KOALA2)); + l.add(l(STUDENT)); + l.add(l(QUOKKA)); + l.add(l("Gender")); + l.add(l(DRY_EUCALYPT_FOREST)); + l.add(l(GRADUATE_STUDENT, KOALA2, KOALA_WITH_PHD, MALE_STUDENT_WITH3_DAUGHTERS, "Person", + QUOKKA, STUDENT)); + l.add(l(DRY_EUCALYPT_FOREST, "Forest", "Habitat", KOALA2, KOALA_WITH_PHD, QUOKKA, + RAINFOREST, "University")); + l.add(l(DRY_EUCALYPT_FOREST, "Forest", KOALA2, KOALA_WITH_PHD, QUOKKA, RAINFOREST)); + l.add(l("Degree", KOALA2, KOALA_WITH_PHD, QUOKKA)); + l.add(l(KOALA2, KOALA_WITH_PHD, MALE_STUDENT_WITH3_DAUGHTERS, "Parent", QUOKKA)); + l.add(l(GRADUATE_STUDENT, KOALA2, KOALA_WITH_PHD, QUOKKA)); + l.add(l(KOALA2, KOALA_WITH_PHD, QUOKKA, RAINFOREST)); + l.add(l(KOALA2, KOALA_WITH_PHD, "Marsupials", QUOKKA, TASMANIAN_DEVIL)); + l.add(l(KOALA2, KOALA_WITH_PHD, QUOKKA)); + l.add(l(KOALA2, KOALA_WITH_PHD, QUOKKA, TASMANIAN_DEVIL)); + l.add(l(KOALA2, KOALA_WITH_PHD, QUOKKA, "University")); + l.add(l("Animal", "Female", GRADUATE_STUDENT, KOALA2, KOALA_WITH_PHD, "Male", + MALE_STUDENT_WITH3_DAUGHTERS, "Marsupials", "Parent", "Person", QUOKKA, STUDENT, + TASMANIAN_DEVIL)); + l.add(l(KOALA2, KOALA_WITH_PHD, "Male", MALE_STUDENT_WITH3_DAUGHTERS, QUOKKA)); + l.add(l(KOALA2, KOALA_WITH_PHD, MALE_STUDENT_WITH3_DAUGHTERS, QUOKKA)); + l.add(l("Female", KOALA2, KOALA_WITH_PHD, QUOKKA)); + l.add(l(KOALA2, KOALA_WITH_PHD, QUOKKA)); + l.add(l(GRADUATE_STUDENT, KOALA2, KOALA_WITH_PHD, MALE_STUDENT_WITH3_DAUGHTERS, QUOKKA, + STUDENT)); + l.add(l(KOALA2, KOALA_WITH_PHD, QUOKKA)); + l.add(l("Gender", KOALA2, KOALA_WITH_PHD, QUOKKA)); + l.add(l(DRY_EUCALYPT_FOREST, KOALA2, KOALA_WITH_PHD, QUOKKA)); + return l; + } + + @ParameterizedTest + @MethodSource("params") + @Disabled + void testModularizationWithAtomicDecompositionStar(Set signature) + throws OWLException { + OWLOntology o = loadOntologyFromString(TestFiles.KOALA, new RDFXMLDocumentFormat()); + List module1 = + asList(getADModule1(o, signature, ModuleType.STAR).stream().sorted()); + List module2 = asList(getTraditionalModule(m, o, signature, ModuleType.STAR) + .stream().filter(ax -> ax.isLogicalAxiom()).sorted()); + makeAssertion(module1, module2); + } + + @ParameterizedTest + @MethodSource("params") + void testModularizationWithAtomicDecompositionTop(Set signature) + throws OWLException { + OWLOntology o = loadOntologyFromString(TestFiles.KOALA, new RDFXMLDocumentFormat()); + List module1 = + asList(getADModule1(o, signature, ModuleType.TOP).stream().sorted()); + List module2 = asList(getTraditionalModule(m, o, signature, ModuleType.TOP) + .stream().filter(ax -> ax.isLogicalAxiom()).sorted()); + makeAssertion(module1, module2); + } + + @ParameterizedTest + @MethodSource("params") + void testModularizationWithAtomicDecompositionBottom(Set signature) + throws OWLException { + OWLOntology o = loadOntologyFromString(TestFiles.KOALA, new RDFXMLDocumentFormat()); + List module1 = + asList(getADModule1(o, signature, ModuleType.BOT).stream().sorted()); + List module2 = asList(getTraditionalModule(m, o, signature, ModuleType.BOT) + .stream().filter(ax -> ax.isLogicalAxiom()).sorted()); + makeAssertion(module1, module2); + } + + protected void makeAssertion(List module1, List module2) { + List l = new ArrayList<>(module1); + module1.removeAll(module2); + module2.removeAll(l); + String s1 = module1.toString().replace(ns, ""); + String s2 = module2.toString().replace(ns, ""); + if (!s1.equals(s2)) { + System.out.println( + "OldModularisationEquivalenceTestCase.testModularizationWithAtomicDecomposition() \n" + + s1 + "\n" + s2); + } + assertEquals(s1, s2); + } + + protected Set getTraditionalModule(OWLOntologyManager man, OWLOntology o, + Set seedSig, ModuleType type) { + SyntacticLocalityModuleExtractor sme = new SyntacticLocalityModuleExtractor(man, o, type); + return sme.extract(seedSig); + } + + // protected Set getADModule(OWLOntology o, Set sig) { + // OntologyBasedModularizer om = new OntologyBasedModularizer(o, + // ModuleMethod.SYNTACTIC_STANDARD); + // return new HashSet<>(om.getModule(sig.stream(), ModuleType.STAR)); + // } + protected Set getADModule1(OWLOntology o, Set sig, ModuleType mt) { + AtomicDecomposition ad = new AtomicDecompositionImpl(o, mt, false); + return asSet(ad.getModule(sig.stream(), false, mt)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapitools/decomposition/test/SemanticLocalityTestCase.java b/contract/src/test/java/org/semanticweb/owlapitools/decomposition/test/SemanticLocalityTestCase.java new file mode 100644 index 0000000000..a32d0204aa --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapitools/decomposition/test/SemanticLocalityTestCase.java @@ -0,0 +1,525 @@ +package org.semanticweb.owlapitools.decomposition.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Stream; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.SWRLAtom; +import org.semanticweb.owlapi.reasoner.structural.StructuralReasonerFactory; +import org.semanticweb.owlapitools.decomposition.AxiomWrapper; +import org.semanticweb.owlapitools.decomposition.SemanticLocalityChecker; + +@Disabled +@SuppressWarnings("boxing") +class SemanticLocalityTestCase extends TestBase { + + private OWLAxiom axiom; + private SemanticLocalityChecker testSubject; + + @Test + void shouldBeLocalowlDeclarationAxiom() { + // declare a + axiom = df.getOWLDeclarationAxiom(A); + // signature intersects + test(axiom, true, A); + // signature does not intersect + test(axiom, true, B); + } + + @Test + void shouldBeLocalowlEquivalentClassesAxiom() { + axiom = df.getOWLEquivalentClassesAxiom(A, B); + // signature intersects + test(axiom, false, A); + // signature does not intersect + // test(axiom, true, c); + // illegal axiom + test(df.getOWLEquivalentClassesAxiom(A), true, A); + // include bottom + test(df.getOWLEquivalentClassesAxiom(owlNothing, A, B), false, A); + // include top + test(df.getOWLEquivalentClassesAxiom(owlThing, A, B), false, A); + // include bottom and top + test(df.getOWLEquivalentClassesAxiom(owlNothing, owlThing, A, B), false, A); + } + + @Test + void shouldBeLocalowlDisjointClassesAxiom() { + axiom = df.getOWLDisjointClassesAxiom(A, B); + // signature intersects + // test(axiom, true, a); + // signature does not intersect + // test(axiom, true, c); + axiom = df.getOWLDisjointClassesAxiom(A, B, C); + // signature intersects + test(axiom, false, A, B); + // signature does not intersect + // test(axiom, true, d); + // include top + test(df.getOWLDisjointClassesAxiom(owlThing, A, B), false, A); + } + + @Test + void shouldBeLocalowlDisjointUnionAxiom() { + axiom = disjointUnion(A, B, C); + // signature intersects + test(axiom, false, A); + // signature does not intersect + // test(axiom, true, d); + // partition top + axiom = disjointUnion(owlThing, B, C); + // signature intersects + test(axiom, false, B); + // partition top + axiom = disjointUnion(owlThing, B, owlThing); + // signature intersects + test(axiom, false, B); + } + + /** @return disjoint union of superclass and classes */ + private OWLDisjointUnionAxiom disjointUnion(OWLClass superclass, OWLClass... classes) { + return df.getOWLDisjointUnionAxiom(superclass, + new HashSet(Arrays.asList(classes))); + } + + @Test + void shouldBeLocalowlEquivalentObjectPropertiesAxiom() { + axiom = df.getOWLEquivalentObjectPropertiesAxiom(P, Q); + // signature intersects + test(axiom, false, P); + // signature does not intersect + // test(axiom, true, r); + // illegal axiom + test(df.getOWLEquivalentObjectPropertiesAxiom(Q), true, Q); + } + + @Test + void shouldBeLocalowlEquivalentDataPropertiesAxiom() { + axiom = df.getOWLEquivalentDataPropertiesAxiom(s, t); + // signature intersects + test(axiom, false, s); + // signature does not intersect + // test(axiom, true, v); + // illegal axiom + test(df.getOWLEquivalentDataPropertiesAxiom(v), true, v); + } + + @Test + void shouldBeLocalowlDisjointObjectPropertiesAxiom() { + axiom = df.getOWLDisjointObjectPropertiesAxiom(P, Q); + // signature intersects + // test(axiom, true, p); + test(axiom, false, true, P); + // signature does not intersect + test(axiom, false, true, R); + // top locality sig + test(df.getOWLDisjointObjectPropertiesAxiom(P, Q), false, true, P); + // top property + test(df.getOWLDisjointObjectPropertiesAxiom(P, Q, topObject), false, P); + // bottom property + // test(df.getOWLDisjointObjectPropertiesAxiom(p, q, bottomObject), + // true, p); + } + + @Test + void shouldBeLocalowlDisjointDataPropertiesAxiom() { + axiom = df.getOWLDisjointDataPropertiesAxiom(s, t); + // signature intersects + // test(axiom, true, s); + // signature does not intersect + // test(axiom, true, v); + // top locality + test(axiom, false, true, P); + // top property + test(df.getOWLDisjointDataPropertiesAxiom(topData, s, t), false, s); + } + + @Test + void shouldBeLocalowlSameIndividualAxiom() { + axiom = df.getOWLSameIndividualAxiom(x, y); + // signature intersects + test(axiom, false, x); + // signature does not intersect + test(axiom, false, z); + } + + @Test + void shouldBeLocalowlDifferentIndividualsAxiom() { + axiom = df.getOWLDifferentIndividualsAxiom(x, y); + // signature intersects + test(axiom, false, x); + // signature does not intersect + test(axiom, false, z); + } + + @Test + void shouldBeLocalowlInverseObjectPropertiesAxiom() { + axiom = df.getOWLInverseObjectPropertiesAxiom(P, Q); + // signature intersects + test(axiom, false, P); + // signature does not intersect + // test(axiom, true, r); + // top property + axiom = df.getOWLInverseObjectPropertiesAxiom(P, topObject); + // test(axiom, false, true, p); + axiom = df.getOWLInverseObjectPropertiesAxiom(topObject, P); + test(axiom, false, true, P); + } + + @Test + void shouldBeLocalowlSubObjectPropertyOfAxiom() { + axiom = df.getOWLSubObjectPropertyOfAxiom(P, Q); + // signature intersects + test(axiom, false, P); + // signature does not intersect + // test(axiom, true, r); + // top property + axiom = df.getOWLSubObjectPropertyOfAxiom(P, topObject); + test(axiom, true, P); + axiom = df.getOWLSubObjectPropertyOfAxiom(topObject, P); + test(axiom, false, P); + } + + @Test + void shouldBeLocalowlSubDataPropertyOfAxiom() { + axiom = df.getOWLSubDataPropertyOfAxiom(s, t); + // signature intersects + test(axiom, false, s); + // signature does not intersect + // test(axiom, true, v); + // top property + axiom = df.getOWLSubDataPropertyOfAxiom(v, topData); + // signature intersects + test(axiom, true, v); + axiom = df.getOWLSubDataPropertyOfAxiom(topData, v); + test(axiom, false, v); + } + + @Test + void shouldBeLocalowlObjectPropertyDomainAxiom() { + axiom = df.getOWLObjectPropertyDomainAxiom(P, A); + // signature intersects + test(axiom, true, A); + // signature does not intersect + test(axiom, true, D); + // top class + axiom = df.getOWLObjectPropertyDomainAxiom(P, owlThing); + test(axiom, true, P); + // bottom property + axiom = df.getOWLObjectPropertyDomainAxiom(bottomObject, A); + test(axiom, true, A); + } + + @Test + void shouldBeLocalowlDataPropertyDomainAxiom() { + axiom = df.getOWLDataPropertyDomainAxiom(s, A); + // signature intersects + test(axiom, true, A); + // signature does not intersect + test(axiom, true, D); + // top class + axiom = df.getOWLDataPropertyDomainAxiom(v, owlThing); + test(axiom, true, v); + // bottom property + axiom = df.getOWLDataPropertyDomainAxiom(bottomData, owlThing); + test(axiom, true, A); + } + + @Test + void shouldBeLocalowlObjectPropertyRangeAxiom() { + axiom = df.getOWLObjectPropertyRangeAxiom(P, A); + // signature intersects + // test(axiom, true, a); + // signature does not intersect + // test(axiom, true, d); + } + + @Test + void shouldBeLocalowlDataPropertyRangeAxiom() { + axiom = df.getOWLDataPropertyRangeAxiom(s, i); + // signature intersects + // test(axiom, false, s); + // signature does not intersect + // test(axiom, true, p); + } + + @Test + void shouldBeLocalowlTransitiveObjectPropertyAxiom() { + axiom = df.getOWLTransitiveObjectPropertyAxiom(P); + // signature intersects + test(axiom, false, P); + // signature does not intersect + // test(axiom, true, q); + } + + @Test + void shouldBeLocalowlReflexiveObjectPropertyAxiom() { + axiom = df.getOWLReflexiveObjectPropertyAxiom(P); + // signature intersects + test(axiom, false, P); + // signature does not intersect + test(axiom, false, Q); + } + + @Test + void shouldBeLocalowlIrreflexiveObjectPropertyAxiom() { + axiom = df.getOWLIrreflexiveObjectPropertyAxiom(P); + // signature intersects + test(axiom, false, P); + // signature does not intersect + // test(axiom, true, q); + } + + @Test + void shouldBeLocalowlSymmetricObjectPropertyAxiom() { + axiom = df.getOWLSymmetricObjectPropertyAxiom(P); + // signature intersects + test(axiom, false, P); + // signature does not intersect + // test(axiom, true, q); + } + + @Test + void shouldBeLocalowlAsymmetricObjectPropertyAxiom() { + axiom = df.getOWLAsymmetricObjectPropertyAxiom(P); + // signature intersects + test(axiom, false, P); + // signature does not intersect + // test(axiom, true, q); + } + + @Test + void shouldBeLocalowlFunctionalObjectPropertyAxiom() { + axiom = df.getOWLFunctionalObjectPropertyAxiom(P); + // signature intersects + test(axiom, false, P); + // signature does not intersect + // test(axiom, true, q); + } + + @Test + void shouldBeLocalowlFunctionalDataPropertyAxiom() { + axiom = df.getOWLFunctionalDataPropertyAxiom(s); + // signature intersects + test(axiom, false, s); + // signature does not intersect + // test(axiom, true, t); + } + + @Test + void shouldBeLocalowlInverseFunctionalObjectPropertyAxiom() { + axiom = df.getOWLInverseFunctionalObjectPropertyAxiom(P); + // signature intersects + test(axiom, false, P); + // signature does not intersect + // test(axiom, true, q); + } + + @Test + void shouldBeLocalowlSubClassOfAxiom() { + axiom = df.getOWLSubClassOfAxiom(A, B); + // signature intersects + test(axiom, false, A); + // signature does not intersect + // test(axiom, true, d); + } + + @Test + void shouldBeLocalowlClassAssertionAxiom() { + axiom = df.getOWLClassAssertionAxiom(A, x); + // signature intersects + test(axiom, false, A); + // signature does not intersect + test(axiom, false, D); + } + + @Test + void shouldBeLocalowlObjectPropertyAssertionAxiom() { + axiom = df.getOWLObjectPropertyAssertionAxiom(P, y, z); + // signature intersects + test(axiom, false, P); + // signature does not intersect + test(axiom, false, x); + } + + @Test + void shouldBeLocalowlNegativeObjectPropertyAssertionAxiom() { + axiom = df.getOWLNegativeObjectPropertyAssertionAxiom(P, x, y); + // signature intersects + test(axiom, false, P); + // signature does not intersect + // test(axiom, true, z); + } + + @Test + void shouldBeLocalowlDataPropertyAssertionAxiom() { + axiom = df.getOWLDataPropertyAssertionAxiom(s, x, l); + // signature intersects + test(axiom, false, s); + // signature does not intersect + test(axiom, false, P); + } + + @Test + void shouldBeLocalowlNegativeDataPropertyAssertionAxiom() { + axiom = df.getOWLNegativeDataPropertyAssertionAxiom(s, x, j); + // signature intersects + test(axiom, false, s); + // signature does not intersect + // test(axiom, true, p); + } + + @Test + void shouldBeLocalowlAnnotationAssertionAxiom() { + axiom = df.getOWLAnnotationAssertionAxiom(A.getIRI(), df.getOWLAnnotation(g, l)); + // signature intersects + test(axiom, true, g); + // signature does not intersect + test(axiom, true, B); + } + + @Test + void shouldBeLocalowlSubAnnotationPropertyOfAxiom() { + axiom = df.getOWLSubAnnotationPropertyOfAxiom(g, h); + // signature intersects + test(axiom, true, g); + // signature does not intersect + test(axiom, true, P); + } + + @Test + void shouldBeLocalowlAnnotationPropertyDomainAxiom() { + axiom = df.getOWLAnnotationPropertyDomainAxiom(g, A.getIRI()); + // signature intersects + test(axiom, true, g); + // signature does not intersect + test(axiom, true, h); + } + + @Test + void shouldBeLocalowlAnnotationPropertyRangeAxiom() { + axiom = df.getOWLAnnotationPropertyRangeAxiom(g, A.getIRI()); + // signature intersects + test(axiom, true, g); + // signature does not intersect + test(axiom, true, h); + } + + @Test + void shouldBeLocalowlSubPropertyChainOfAxiom() { + axiom = df.getOWLSubPropertyChainOfAxiom(Arrays.asList(P, Q), R); + // signature intersects + // test(axiom, true, p); + // signature does not intersect + // test(axiom, true, s); + // signature equals + test(axiom, false, P, Q, R); + // top property + axiom = df.getOWLSubPropertyChainOfAxiom(Arrays.asList(P, Q), topObject); + // signature intersects + test(axiom, true, P); + } + + @Test + void shouldBeLocalowlHasKeyAxiom() { + axiom = df.getOWLHasKeyAxiom(A, P, s); + // signature intersects + test(axiom, true, A); + // signature does not intersect + test(axiom, true, Q); + } + + @Test + void shouldBeLocalowlDatatypeDefinitionAxiom() { + axiom = + df.getOWLDatatypeDefinitionAxiom(i, df.getOWLDatatypeMinMaxExclusiveRestriction(1, 3)); + // signature intersects + // test(axiom, true, i); + // signature does not intersect + // test(axiom, true, d); + } + + @Test + void shouldBeLocalswrlRule() { + Set head = + new HashSet<>(Arrays.asList(df.getSWRLClassAtom(A, df.getSWRLIndividualArgument(x)))); + Set body = + new HashSet<>(Arrays.asList(df.getSWRLClassAtom(B, df.getSWRLIndividualArgument(y)))); + axiom = df.getSWRLRule(head, body); + // signature intersects + test(axiom, true, A); + // signature does not intersect + test(axiom, true, D); + } + + @Test + void shouldResetSignature() { + OWLSubClassOfAxiom ax = df.getOWLSubClassOfAxiom(A, B); + testSubject.preprocessOntology(Arrays.asList(new AxiomWrapper(ax))); + } + + static final String NS = "urn:test#"; + static final OWLAnnotationProperty g = df.getOWLAnnotationProperty(iri(NS, "g")); + static final OWLAnnotationProperty h = df.getOWLAnnotationProperty(iri(NS, "h")); + static final OWLDatatype i = df.getOWLDatatype(iri(NS, "i")); + static final OWLLiteral j = df.getOWLLiteral(true); + static final OWLLiteral l = df.getOWLLiteral(3.5D); + static final OWLDataProperty s = df.getOWLDataProperty(iri(NS, "s")); + static final OWLDataProperty t = df.getOWLDataProperty(iri(NS, "t")); + static final OWLDataProperty v = df.getOWLDataProperty(iri(NS, "v")); + static final OWLNamedIndividual x = df.getOWLNamedIndividual(iri(NS, "x")); + static final OWLNamedIndividual y = df.getOWLNamedIndividual(iri(NS, "y")); + static final OWLNamedIndividual z = df.getOWLNamedIndividual(iri(NS, "z")); + static final OWLClass owlNothing = df.getOWLNothing(); + static final OWLClass owlThing = df.getOWLThing(); + static final OWLDataProperty bottomData = df.getOWLBottomDataProperty(); + static final OWLDataProperty topData = df.getOWLTopDataProperty(); + static final OWLObjectProperty bottomObject = df.getOWLBottomObjectProperty(); + static final OWLObjectProperty topObject = df.getOWLTopObjectProperty(); + + @BeforeEach + void setUp() { + // XXX add a reasoner factory + testSubject = new SemanticLocalityChecker(new StructuralReasonerFactory(), + OWLManager.createOWLOntologyManager()); + } + + private void set(OWLEntity... entities) { + testSubject.getSignature().addAll(Stream.of(entities)); + } + + private void test(OWLAxiom ax, boolean expected, OWLEntity... entities) { + testSubject.preprocessOntology(Arrays.asList(new AxiomWrapper(ax))); + set(entities); + boolean local = testSubject.local(ax); + assertEquals(Boolean.valueOf(expected), Boolean.valueOf(local)); + } + + private void test(OWLAxiom ax, boolean expected, boolean locality, OWLEntity... entities) { + testSubject.preprocessOntology(Arrays.asList(new AxiomWrapper(ax))); + set(entities); + testSubject.getSignature().setLocality(locality); + boolean local = testSubject.local(ax); + assertEquals(Boolean.valueOf(expected), Boolean.valueOf(local)); + } +} diff --git a/contract/src/test/java/org/semanticweb/owlapitools/decomposition/test/SyntacticLocalityTestCase.java b/contract/src/test/java/org/semanticweb/owlapitools/decomposition/test/SyntacticLocalityTestCase.java new file mode 100644 index 0000000000..532fad1689 --- /dev/null +++ b/contract/src/test/java/org/semanticweb/owlapitools/decomposition/test/SyntacticLocalityTestCase.java @@ -0,0 +1,521 @@ +package org.semanticweb.owlapitools.decomposition.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asSet; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Stream; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.semanticweb.owlapi.api.test.baseclasses.TestBase; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.SWRLAtom; +import org.semanticweb.owlapitools.decomposition.AxiomWrapper; +import org.semanticweb.owlapitools.decomposition.Signature; +import org.semanticweb.owlapitools.decomposition.SyntacticLocalityChecker; + +@SuppressWarnings("boxing") +class SyntacticLocalityTestCase extends TestBase { + + @Test + void shouldBeLocalowlDeclarationAxiom() { + // declare a + axiom = df.getOWLDeclarationAxiom(A); + // signature intersects + test(axiom, true, A); + // signature does not intersect + test(axiom, true, B); + } + + @Test + void shouldBeLocalowlEquivalentClassesAxiom() { + axiom = df.getOWLEquivalentClassesAxiom(A, B); + // signature intersects + test(axiom, false, A); + // signature does not intersect + test(axiom, true, C); + // illegal axiom + test(df.getOWLEquivalentClassesAxiom(A), true, A); + // include bottom + test(df.getOWLEquivalentClassesAxiom(owlNothing, A, B), false, A); + // include top + test(df.getOWLEquivalentClassesAxiom(owlThing, A, B), false, A); + // include bottom and top + test(df.getOWLEquivalentClassesAxiom(owlNothing, owlThing, A, B), false, A); + } + + @Test + void shouldBeLocalowlDisjointClassesAxiom() { + axiom = df.getOWLDisjointClassesAxiom(A, B); + // signature intersects + test(axiom, true, A); + // signature does not intersect + test(axiom, true, C); + axiom = df.getOWLDisjointClassesAxiom(A, B, C); + // signature intersects + test(axiom, false, A, B); + // signature does not intersect + test(axiom, true, D); + // include top + test(df.getOWLDisjointClassesAxiom(owlThing, A, B), false, A); + } + + @Test + void shouldBeLocalowlDisjointUnionAxiom() { + axiom = disjointUnion(A, B, C); + // signature intersects + test(axiom, false, A); + // signature does not intersect + test(axiom, true, D); + // partition top + axiom = disjointUnion(owlThing, B, C); + // signature intersects + test(axiom, false, B); + // partition top + axiom = disjointUnion(owlThing, B, owlThing); + // signature intersects + test(axiom, false, B); + } + + /** @return disjoint union of superclass and classes */ + private OWLDisjointUnionAxiom disjointUnion(OWLClass superclass, OWLClass... classes) { + return df.getOWLDisjointUnionAxiom(superclass, + new HashSet(Arrays.asList(classes))); + } + + @Test + void shouldBeLocalowlEquivalentObjectPropertiesAxiom() { + axiom = df.getOWLEquivalentObjectPropertiesAxiom(P, Q); + // signature intersects + test(axiom, false, P); + // signature does not intersect + test(axiom, true, R); + // illegal axiom + test(df.getOWLEquivalentObjectPropertiesAxiom(Q), true, Q); + } + + @Test + void shouldBeLocalowlEquivalentDataPropertiesAxiom() { + axiom = df.getOWLEquivalentDataPropertiesAxiom(s, t); + // signature intersects + test(axiom, false, s); + // signature does not intersect + test(axiom, true, v); + // illegal axiom + test(df.getOWLEquivalentDataPropertiesAxiom(v), true, v); + } + + @Test + void shouldBeLocalowlDisjointObjectPropertiesAxiom() { + axiom = df.getOWLDisjointObjectPropertiesAxiom(P, Q); + // signature intersects + test(axiom, true, P); + test(axiom, false, true, P); + // signature does not intersect + test(axiom, false, true, R); + // top locality sig + test(df.getOWLDisjointObjectPropertiesAxiom(P, Q), false, true, P); + // top property + test(df.getOWLDisjointObjectPropertiesAxiom(P, Q, topObject), false, P); + // bottom property + test(df.getOWLDisjointObjectPropertiesAxiom(P, Q, bottomObject), true, P); + } + + @Test + void shouldBeLocalowlDisjointDataPropertiesAxiom() { + axiom = df.getOWLDisjointDataPropertiesAxiom(s, t); + // signature intersects + test(axiom, true, s); + // signature does not intersect + test(axiom, true, v); + // top locality + test(axiom, false, true, P); + // top property + test(df.getOWLDisjointDataPropertiesAxiom(topData, s, t), false, s); + } + + @Test + void shouldBeLocalowlSameIndividualAxiom() { + axiom = df.getOWLSameIndividualAxiom(x, y); + // signature intersects + test(axiom, false, x); + // signature does not intersect + test(axiom, false, z); + } + + @Test + void shouldBeLocalowlDifferentIndividualsAxiom() { + axiom = df.getOWLDifferentIndividualsAxiom(x, y); + // signature intersects + test(axiom, false, x); + // signature does not intersect + test(axiom, false, z); + } + + @Test + void shouldBeLocalowlInverseObjectPropertiesAxiom() { + axiom = df.getOWLInverseObjectPropertiesAxiom(P, Q); + // signature intersects + test(axiom, false, P); + // signature does not intersect + test(axiom, true, R); + // top property + axiom = df.getOWLInverseObjectPropertiesAxiom(P, topObject); + test(axiom, false, true, P); + axiom = df.getOWLInverseObjectPropertiesAxiom(topObject, P); + test(axiom, false, true, P); + } + + @Test + void shouldBeLocalowlSubObjectPropertyOfAxiom() { + axiom = df.getOWLSubObjectPropertyOfAxiom(P, Q); + // signature intersects + test(axiom, false, P); + // signature does not intersect + test(axiom, true, R); + // top property + axiom = df.getOWLSubObjectPropertyOfAxiom(P, topObject); + test(axiom, true, P); + axiom = df.getOWLSubObjectPropertyOfAxiom(topObject, P); + test(axiom, false, P); + } + + @Test + void shouldBeLocalowlSubDataPropertyOfAxiom() { + axiom = df.getOWLSubDataPropertyOfAxiom(s, t); + // signature intersects + test(axiom, false, s); + // signature does not intersect + test(axiom, true, v); + // top property + axiom = df.getOWLSubDataPropertyOfAxiom(v, topData); + // signature intersects + test(axiom, true, v); + axiom = df.getOWLSubDataPropertyOfAxiom(topData, v); + test(axiom, false, v); + } + + @Test + void shouldBeLocalowlObjectPropertyDomainAxiom() { + axiom = df.getOWLObjectPropertyDomainAxiom(P, A); + // signature intersects + test(axiom, true, A); + // signature does not intersect + test(axiom, true, D); + // top class + axiom = df.getOWLObjectPropertyDomainAxiom(P, owlThing); + test(axiom, true, P); + // bottom property + axiom = df.getOWLObjectPropertyDomainAxiom(bottomObject, A); + test(axiom, true, A); + } + + @Test + void shouldBeLocalowlDataPropertyDomainAxiom() { + axiom = df.getOWLDataPropertyDomainAxiom(s, A); + // signature intersects + test(axiom, true, A); + // signature does not intersect + test(axiom, true, D); + // top class + axiom = df.getOWLDataPropertyDomainAxiom(v, owlThing); + test(axiom, true, v); + // bottom property + axiom = df.getOWLDataPropertyDomainAxiom(bottomData, owlThing); + test(axiom, true, A); + } + + @Test + void shouldBeLocalowlObjectPropertyRangeAxiom() { + axiom = df.getOWLObjectPropertyRangeAxiom(P, A); + // signature intersects + test(axiom, true, A); + // signature does not intersect + test(axiom, true, D); + } + + @Test + void shouldBeLocalowlDataPropertyRangeAxiom() { + axiom = df.getOWLDataPropertyRangeAxiom(s, i); + // signature intersects + test(axiom, false, s); + // signature does not intersect + test(axiom, true, P); + } + + @Test + void shouldBeLocalowlTransitiveObjectPropertyAxiom() { + axiom = df.getOWLTransitiveObjectPropertyAxiom(P); + // signature intersects + test(axiom, false, P); + // signature does not intersect + test(axiom, true, Q); + } + + @Test + void shouldBeLocalowlReflexiveObjectPropertyAxiom() { + axiom = df.getOWLReflexiveObjectPropertyAxiom(P); + // signature intersects + test(axiom, false, P); + // signature does not intersect + test(axiom, false, Q); + } + + @Test + void shouldBeLocalowlIrreflexiveObjectPropertyAxiom() { + axiom = df.getOWLIrreflexiveObjectPropertyAxiom(P); + // signature intersects + test(axiom, false, P); + // signature does not intersect + test(axiom, true, Q); + } + + @Test + void shouldBeLocalowlSymmetricObjectPropertyAxiom() { + axiom = df.getOWLSymmetricObjectPropertyAxiom(P); + // signature intersects + test(axiom, false, P); + // signature does not intersect + test(axiom, true, Q); + } + + @Test + void shouldBeLocalowlAsymmetricObjectPropertyAxiom() { + axiom = df.getOWLAsymmetricObjectPropertyAxiom(P); + // signature intersects + test(axiom, false, P); + // signature does not intersect + test(axiom, true, Q); + } + + @Test + void shouldBeLocalowlFunctionalObjectPropertyAxiom() { + axiom = df.getOWLFunctionalObjectPropertyAxiom(P); + // signature intersects + test(axiom, false, P); + // signature does not intersect + test(axiom, true, Q); + } + + @Test + void shouldBeLocalowlFunctionalDataPropertyAxiom() { + axiom = df.getOWLFunctionalDataPropertyAxiom(s); + // signature intersects + test(axiom, false, s); + // signature does not intersect + test(axiom, true, t); + } + + @Test + void shouldBeLocalowlInverseFunctionalObjectPropertyAxiom() { + axiom = df.getOWLInverseFunctionalObjectPropertyAxiom(P); + // signature intersects + test(axiom, false, P); + // signature does not intersect + test(axiom, true, Q); + } + + @Test + void shouldBeLocalowlSubClassOfAxiom() { + axiom = df.getOWLSubClassOfAxiom(A, B); + // signature intersects + test(axiom, false, A); + // signature does not intersect + test(axiom, true, D); + } + + @Test + void shouldBeLocalowlClassAssertionAxiom() { + axiom = df.getOWLClassAssertionAxiom(A, x); + // signature intersects + test(axiom, false, A); + // signature does not intersect + test(axiom, false, D); + } + + @Test + void shouldBeLocalowlObjectPropertyAssertionAxiom() { + axiom = df.getOWLObjectPropertyAssertionAxiom(P, y, z); + // signature intersects + test(axiom, false, P); + // signature does not intersect + test(axiom, false, x); + } + + @Test + void shouldBeLocalowlNegativeObjectPropertyAssertionAxiom() { + axiom = df.getOWLNegativeObjectPropertyAssertionAxiom(P, x, y); + // signature intersects + test(axiom, false, P); + // signature does not intersect + test(axiom, true, z); + } + + @Test + void shouldBeLocalowlDataPropertyAssertionAxiom() { + axiom = df.getOWLDataPropertyAssertionAxiom(s, x, l); + // signature intersects + test(axiom, false, s); + // signature does not intersect + test(axiom, false, P); + } + + @Test + void shouldBeLocalowlNegativeDataPropertyAssertionAxiom() { + axiom = df.getOWLNegativeDataPropertyAssertionAxiom(s, x, j); + // signature intersects + test(axiom, false, s); + // signature does not intersect + test(axiom, false, P); + } + + @Test + void shouldBeLocalowlAnnotationAssertionAxiom() { + axiom = df.getOWLAnnotationAssertionAxiom(A.getIRI(), df.getOWLAnnotation(g, l)); + // signature intersects + test(axiom, true, g); + // signature does not intersect + test(axiom, true, B); + } + + @Test + void shouldBeLocalowlSubAnnotationPropertyOfAxiom() { + axiom = df.getOWLSubAnnotationPropertyOfAxiom(g, h); + // signature intersects + test(axiom, true, g); + // signature does not intersect + test(axiom, true, P); + } + + @Test + void shouldBeLocalowlAnnotationPropertyDomainAxiom() { + axiom = df.getOWLAnnotationPropertyDomainAxiom(g, A.getIRI()); + // signature intersects + test(axiom, true, g); + // signature does not intersect + test(axiom, true, h); + } + + @Test + void shouldBeLocalowlAnnotationPropertyRangeAxiom() { + axiom = df.getOWLAnnotationPropertyRangeAxiom(g, A.getIRI()); + // signature intersects + test(axiom, true, g); + // signature does not intersect + test(axiom, true, h); + } + + @Test + void shouldBeLocalowlSubPropertyChainOfAxiom() { + axiom = df.getOWLSubPropertyChainOfAxiom(Arrays.asList(P, Q), R); + // signature intersects + test(axiom, true, P); + // signature does not intersect + test(axiom, true, s); + // signature equals + test(axiom, false, P, Q, R); + // top property + axiom = df.getOWLSubPropertyChainOfAxiom(Arrays.asList(P, Q), topObject); + // signature intersects + test(axiom, true, P); + } + + @Test + void shouldBeLocalowlHasKeyAxiom() { + axiom = df.getOWLHasKeyAxiom(A, P, s); + // signature intersects + test(axiom, true, A); + // signature does not intersect + test(axiom, true, Q); + } + + @Test + void shouldBeLocalowlDatatypeDefinitionAxiom() { + axiom = + df.getOWLDatatypeDefinitionAxiom(i, df.getOWLDatatypeMinMaxExclusiveRestriction(1, 3)); + // signature intersects + test(axiom, true, i); + // signature does not intersect + test(axiom, true, D); + } + + @Test + void shouldBeLocalswrlRule() { + Set head = + new HashSet<>(Arrays.asList(df.getSWRLClassAtom(A, df.getSWRLIndividualArgument(x)))); + Set body = + new HashSet<>(Arrays.asList(df.getSWRLClassAtom(B, df.getSWRLIndividualArgument(y)))); + axiom = df.getSWRLRule(head, body); + // signature intersects + test(axiom, true, A); + // signature does not intersect + test(axiom, true, D); + } + + @Test + void shouldResetSignature() { + OWLSubClassOfAxiom ax = df.getOWLSubClassOfAxiom(A, B); + testSubject.preprocessOntology(Arrays.asList(new AxiomWrapper(ax))); + assertEquals(asSet(ax.signature()), testSubject.getSignature().getSignature()); + } + + static final String NS = "urn:test#"; + static final OWLDataFactory df = OWLManager.getOWLDataFactory(); + static final OWLAnnotationProperty g = df.getOWLAnnotationProperty(iri(NS, "g")); + static final OWLAnnotationProperty h = df.getOWLAnnotationProperty(iri(NS, "h")); + static final OWLDatatype i = df.getOWLDatatype(iri(NS, "i")); + static final OWLLiteral j = df.getOWLLiteral(true); + static final OWLLiteral l = df.getOWLLiteral(3.5D); + static final OWLDataProperty s = df.getOWLDataProperty(iri(NS, "s")); + static final OWLDataProperty t = df.getOWLDataProperty(iri(NS, "t")); + static final OWLDataProperty v = df.getOWLDataProperty(iri(NS, "v")); + static final OWLNamedIndividual x = df.getOWLNamedIndividual(iri(NS, "x")); + static final OWLNamedIndividual y = df.getOWLNamedIndividual(iri(NS, "y")); + static final OWLNamedIndividual z = df.getOWLNamedIndividual(iri(NS, "z")); + static final OWLClass owlNothing = df.getOWLNothing(); + static final OWLClass owlThing = df.getOWLThing(); + static final OWLDataProperty bottomData = df.getOWLBottomDataProperty(); + static final OWLDataProperty topData = df.getOWLTopDataProperty(); + static final OWLObjectProperty bottomObject = df.getOWLBottomObjectProperty(); + static final OWLObjectProperty topObject = df.getOWLTopObjectProperty(); + private OWLAxiom axiom; + private SyntacticLocalityChecker testSubject; + + @BeforeEach + void setUp() { + testSubject = new SyntacticLocalityChecker(); + } + + private void set(OWLEntity... entities) { + testSubject.setSignatureValue(new Signature(Stream.of(entities))); + } + + private void test(OWLAxiom ax, boolean expected, OWLEntity... entities) { + set(entities); + boolean local = testSubject.local(ax); + assertEquals(Boolean.valueOf(expected), Boolean.valueOf(local)); + } + + private void test(OWLAxiom ax, boolean expected, boolean locality, OWLEntity... entities) { + set(entities); + testSubject.getSignature().setLocality(locality); + boolean local = testSubject.local(ax); + assertEquals(Boolean.valueOf(expected), Boolean.valueOf(local)); + } +} diff --git a/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/ClosureAxioms.java b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/ClosureAxioms.java new file mode 100644 index 0000000000..480fee1d6b --- /dev/null +++ b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/ClosureAxioms.java @@ -0,0 +1,79 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package uk.ac.manchester.owl.owlapi.tutorial; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; + +/** + * This class demonstrates some aspects of the OWL API. Given a class in an ontology, it will + * determine the subclass axioms that define the class. For each of these, if the superclass is a + * conjunction of existential restrictions, then an additional subclass axiom will be added to the + * ontology, "closing" the restrictions. + * + * @author Sean Bechhofer, The University Of Manchester, Information Management Group + * @since 2.0.0 + */ +public class ClosureAxioms { + + private final OWLOntology ontology; + private final OWLDataFactory factory; + + public ClosureAxioms(OWLOntology ontology) { + this.ontology = ontology; + factory = ontology.getOWLOntologyManager().getOWLDataFactory(); + } + + public void addClosureAxioms(OWLClass clazz) { + /* Get the class axioms */ + /* Collect those that assert superclasses of the class */ + SubClassCollector collector = new SubClassCollector(clazz); + ontology.axioms(AxiomType.SUBCLASS_OF).forEach(a -> a.accept(collector)); + Map> restrictions = new HashMap<>(); + /* For each axiom.... */ + for (OWLSubClassOfAxiom axiom : collector.getAxioms()) { + /* Get the superclass */ + OWLClassExpression superClass = axiom.getSuperClass(); + /* Collect any existentials */ + ExistentialCollector ec = new ExistentialCollector(restrictions); + superClass.accept(ec); + } + /* For any existentials.... */ + for (OWLObjectPropertyExpression prop : restrictions.keySet()) { + System.out.println("prop: " + prop); + Set fillers = restrictions.get(prop); + for (OWLClassExpression filler : fillers) { + System.out.println("------> " + filler); + } + /* Create a union of the fillers */ + OWLClassExpression union = factory.getOWLObjectUnionOf(fillers); + /* Create a universal restriction */ + OWLClassExpression universal = factory.getOWLObjectAllValuesFrom(prop, union); + /* Create a new axiom */ + OWLAxiom newAxiom = factory.getOWLSubClassOfAxiom(clazz, universal); + /* Now add the axiom to the ontology */ + ontology.add(newAxiom); + } + } +} diff --git a/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/ExistentialCollector.java b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/ExistentialCollector.java new file mode 100644 index 0000000000..b23448fbd1 --- /dev/null +++ b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/ExistentialCollector.java @@ -0,0 +1,57 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package uk.ac.manchester.owl.owlapi.tutorial; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLClassExpressionVisitor; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; + +/** + * A visitor that collects existential restrictions. If the given expression is an intersection, + * then the visitor will recurse and visit the operands. Otherwise, if it's an existential + * restriction, the visitor will add the restriction to the collection.
    + * The visitor returns a map of properties to collections of fillers using that property. + * + * @author Sean Bechhofer, The University Of Manchester, Information Management Group + * @since 2.0.0 + */ +public class ExistentialCollector implements OWLClassExpressionVisitor { + + /* Collected axioms */ + private final Map> restrictions; + + public ExistentialCollector( + Map> restrictions) { + this.restrictions = restrictions; + } + + @Override + public void visit(OWLObjectIntersectionOf ce) { + ce.operands().forEach(o -> o.accept(this)); + } + + @Override + public void visit(OWLObjectSomeValuesFrom ce) { + Set fillers = restrictions.get(ce.getProperty()); + if (fillers == null) { + fillers = new HashSet<>(); + restrictions.put(ce.getProperty(), fillers); + } + fillers.add(ce.getFiller()); + } +} diff --git a/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/LabelExtractor.java b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/LabelExtractor.java new file mode 100644 index 0000000000..9b3451d1d4 --- /dev/null +++ b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/LabelExtractor.java @@ -0,0 +1,45 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package uk.ac.manchester.owl.owlapi.tutorial; + +import javax.annotation.Nullable; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationObjectVisitor; +import org.semanticweb.owlapi.model.OWLLiteral; + +/** + * Simple visitor that grabs any labels on an entity. + * + * @author Sean Bechhofer, The University Of Manchester, Information Management Group + * @since 2.0.0 + */ +public class LabelExtractor implements OWLAnnotationObjectVisitor { + + protected @Nullable String result = null; + + @Override + public void visit(OWLAnnotation node) { + /* + * If it's a label, grab it as the result. Note that if there are multiple labels, the last + * one will be used. + */ + if (node.getProperty().isLabel()) { + OWLLiteral c = (OWLLiteral) node.getValue(); + result = c.getLiteral(); + } + } + + public @Nullable String getResult() { + return result; + } +} diff --git a/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/SubClassCollector.java b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/SubClassCollector.java new file mode 100644 index 0000000000..90806e32ff --- /dev/null +++ b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/SubClassCollector.java @@ -0,0 +1,49 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package uk.ac.manchester.owl.owlapi.tutorial; + +import java.util.HashSet; +import java.util.Set; +import org.semanticweb.owlapi.model.OWLAxiomVisitor; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; + +/** + * A visitor that simply collects any subclass axioms that have the given class as the subclass. + * + * @author Sean Bechhofer, The University Of Manchester, Information Management Group + * @since 2.0.0 + */ +public class SubClassCollector implements OWLAxiomVisitor { + + /* Collected axioms */ + private final Set axioms; + /* Class to look for */ + private final OWLClass clazz; + + public SubClassCollector(OWLClass clazz) { + axioms = new HashSet<>(); + this.clazz = clazz; + } + + @Override + public void visit(OWLSubClassOfAxiom axiom) { + if (axiom.getSubClass().equals(clazz)) { + axioms.add(axiom); + } + } + + public Set getAxioms() { + return axioms; + } +} diff --git a/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/examples/ClosureAxiomsExample.java b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/examples/ClosureAxiomsExample.java new file mode 100644 index 0000000000..32f946678c --- /dev/null +++ b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/examples/ClosureAxiomsExample.java @@ -0,0 +1,76 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package uk.ac.manchester.owl.owlapi.tutorial.examples; + +import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; + +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLException; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import uk.ac.manchester.owl.owlapi.tutorial.ClosureAxioms; + +/** + * This class demonstrates some aspects of the OWL API. It expects three arguments: + *
      + *
    1. The URI of an ontology
    2. + *
    3. The URI of destination
    4. + *
    5. The URI of a class
    6. + *
    + * When executed, the class will find all subclass axioms that form part of the definition of the + * given class. For each of these, if the superclass is a conjunction of existential restrictions, + * then an additional subclass axiom will be added to the ontology, "closing" the restrictions. + * + * @author Sean Bechhofer, The University Of Manchester, Information Management Group + * @since 2.0.0 + */ +public class ClosureAxiomsExample { + + /** + * @param inputOntology input ontology IRI + * @param outputOntology output ontology IRI + * @param classToClose the class to compute the closure of + * @throws OWLException if an exception is raised + */ + public void closure(String inputOntology, String outputOntology, String classToClose) + throws OWLException { + /* Create and Ontology Manager */ + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + IRI documentIRI = IRI.create(inputOntology); + IRI classIRI = IRI.create(classToClose); + IRI outputDocumentIRI = IRI.create(outputOntology); + /* Load an ontology */ + System.out.println("Loading: " + documentIRI); + OWLOntology ontology = manager.loadOntologyFromOntologyDocument(documentIRI); + System.out.println("Ontology Loaded..."); + System.out.println("Logical URI : " + documentIRI); + System.out.println("Document IRI: " + ontology.getOntologyID()); + System.out.println("Format : " + ontology.getFormat()); + ClosureAxioms closureAxioms = new ClosureAxioms(ontology); + OWLClass clazz = Class(classIRI); + System.out.println("Class URI : " + classIRI); + System.out.println(clazz); + /* Add the closure axioms */ + closureAxioms.addClosureAxioms(clazz); + /* Now save a copy to another location */ + System.out.println("Saving: " + outputDocumentIRI); + ontology.saveOntology(outputDocumentIRI); + System.out.println("Ontology Saved..."); + System.out.println("Document IRI : " + outputDocumentIRI); + /* Remove the ontology from the manager */ + manager.removeOntology(ontology); + System.out.println("Done"); + } +} diff --git a/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/examples/RenderingExample.java b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/examples/RenderingExample.java new file mode 100644 index 0000000000..6e78b7de8e --- /dev/null +++ b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/examples/RenderingExample.java @@ -0,0 +1,58 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package uk.ac.manchester.owl.owlapi.tutorial.examples; + +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLOntologyStorageException; + +/** + * Simple Rendering Example. Reads an ontology and then renders it. + * + * @author Sean Bechhofer, The University Of Manchester, Information Management Group + * @since 2.0.0 + */ +public class RenderingExample { + + /** + * @param inputOntology input ontology IRI + * @param outputOntology output ontology IRI + * @throws OWLOntologyCreationException OWLOntologyCreationException + * @throws OWLOntologyStorageException OWLOntologyStorageException + */ + public void render(String inputOntology, String outputOntology) + throws OWLOntologyCreationException, OWLOntologyStorageException { + // A simple example of how to load and save an ontology + /* Get an Ontology Manager */ + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + IRI inputDocumentIRI = IRI.create(inputOntology); + IRI outputDocumentIRI = IRI.create(outputOntology); + /* Load an ontology from a document IRI */ + OWLOntology ontology = manager.loadOntologyFromOntologyDocument(inputDocumentIRI); + /* Report information about the ontology */ + System.out.println("Ontology Loaded..."); + System.out.println("Document IRI: " + inputDocumentIRI); + System.out.println("Logical IRI : " + ontology.getOntologyID()); + System.out.println("Format : " + ontology.getFormat()); + /* Save using a different format */ + System.out.println("Storing : " + outputDocumentIRI); + ontology.saveOntology(new FunctionalSyntaxDocumentFormat(), outputDocumentIRI); + /* Remove the ontology from the manager */ + manager.removeOntology(ontology); + System.out.println("Done"); + } +} diff --git a/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/examples/SimpleHierarchyExample.java b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/examples/SimpleHierarchyExample.java new file mode 100644 index 0000000000..89c8a5113a --- /dev/null +++ b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/examples/SimpleHierarchyExample.java @@ -0,0 +1,123 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package uk.ac.manchester.owl.owlapi.tutorial.examples; + +import static org.semanticweb.owlapi.search.EntitySearcher.getAnnotationObjects; + +import java.io.PrintStream; +import javax.annotation.Nonnull; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLException; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.reasoner.OWLReasoner; +import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; +import uk.ac.manchester.owl.owlapi.tutorial.LabelExtractor; + +/** + * Simple example. Read an ontology, and display the class hierarchy. May use a reasoner to + * calculate the hierarchy. + * + * @author Sean Bechhofer, The University Of Manchester, Information Management Group + * @since 2.0.0 + */ +public final class SimpleHierarchyExample { + + private static final int INDENT = 4; + private final OWLReasonerFactory reasonerFactory; + private final OWLOntology ontology; + private final PrintStream out; + + private SimpleHierarchyExample(OWLReasonerFactory reasonerFactory, OWLOntology inputOntology) { + this.reasonerFactory = reasonerFactory; + ontology = inputOntology; + out = System.out; + } + + /** + * Print the class hierarchy for the given ontology from this class down, assuming this class is + * at the given level. Makes no attempt to deal sensibly with multiple inheritance. + */ + private void printHierarchy(OWLClass clazz) { + OWLReasoner reasoner = reasonerFactory.createNonBufferingReasoner(ontology); + printHierarchy(reasoner, clazz, 0); + /* Now print out any unsatisfiable classes */ + ontology.classesInSignature().filter(c -> !reasoner.isSatisfiable(c)) + .forEach(c -> out.println("XXX: " + labelFor(c))); + reasoner.dispose(); + } + + private String labelFor(OWLClass clazz) { + /* + * Use a visitor to extract label annotations + */ + LabelExtractor le = new LabelExtractor(); + getAnnotationObjects(clazz, ontology).forEach(a -> a.accept(le)); + /* Print out the label if there is one. If not, just use the class URI */ + String result = le.getResult(); + if (result != null) { + return result; + } + return clazz.getIRI().toString(); + } + + /** + * Print the class hierarchy from this class down, assuming this class is at the given level. + * Makes no attempt to deal sensibly with multiple inheritance. + */ + private void printHierarchy(OWLReasoner reasoner, OWLClass clazz, int level) { + /* + * Only print satisfiable classes -- otherwise we end up with bottom everywhere + */ + if (reasoner.isSatisfiable(clazz)) { + for (int i = 0; i < level * INDENT; i++) { + out.print(" "); + } + out.println(labelFor(clazz)); + /* Find the children and recurse */ + reasoner.getSubClasses(clazz, true).entities().filter(c -> !c.equals(clazz)) + .forEach(c -> printHierarchy(reasoner, c, level + 1)); + } + } + + public static void main(String[] args) throws Exception { + String reasonerFactoryClassName = null; + // We first need to obtain a copy of an + // OWLOntologyManager, which, as the name + // suggests, manages a set of ontologies. + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + // We load an ontology from the URI specified + // on the command line + String x = args[0]; + System.out.println(x); + IRI documentIRI = IRI.create(x); + // Now load the ontology. + OWLOntology ontology = manager.loadOntologyFromOntologyDocument(documentIRI); + // Report information about the ontology + System.out.println("Ontology Loaded..."); + System.out.println("Document IRI: " + documentIRI); + System.out.println("Ontology : " + ontology.getOntologyID()); + System.out.println("Format : " + ontology.getFormat()); + // / Create a new SimpleHierarchy object with the given reasoner. + SimpleHierarchyExample simpleHierarchy = + new SimpleHierarchyExample((OWLReasonerFactory) Class.forName(reasonerFactoryClassName) + .getConstructor().newInstance(), ontology); + // Get Thing + OWLClass clazz = manager.getOWLDataFactory().getOWLThing(); + System.out.println("Class : " + clazz); + // Print the hierarchy below thing + simpleHierarchy.printHierarchy(clazz); + } +} diff --git a/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/examples/package-info.java b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/examples/package-info.java new file mode 100644 index 0000000000..76bc04e0c7 --- /dev/null +++ b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/examples/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package uk.ac.manchester.owl.owlapi.tutorial.examples; diff --git a/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/package-info.java b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/package-info.java new file mode 100644 index 0000000000..88feda5029 --- /dev/null +++ b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/package-info.java @@ -0,0 +1,17 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/** + * Test classes. + */ +@javax.annotation.ParametersAreNonnullByDefault +package uk.ac.manchester.owl.owlapi.tutorial; diff --git a/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/LabelExtractor.java b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/LabelExtractor.java new file mode 100644 index 0000000000..aaade12637 --- /dev/null +++ b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/LabelExtractor.java @@ -0,0 +1,27 @@ +package uk.ac.manchester.owl.owlapi.tutorialowled2011; + +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationObjectVisitorEx; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObjectVisitorEx; + +class LabelExtractor implements OWLObjectVisitorEx, OWLAnnotationObjectVisitorEx { + + @Override + public String visit(OWLAnnotation node) { + /* + * If it's a label, grab it as the result. Note that if there are multiple labels, the last + * one will be used. + */ + if (node.getProperty().isLabel()) { + OWLLiteral c = (OWLLiteral) node.getValue(); + return c.getLiteral(); + } + return ""; + } + + @Override + public String doDefault(Object individual) { + return ""; + } +} diff --git a/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/TutorialSnippetsTestCase.java b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/TutorialSnippetsTestCase.java new file mode 100644 index 0000000000..8e8fcabbd1 --- /dev/null +++ b/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/TutorialSnippetsTestCase.java @@ -0,0 +1,875 @@ +/* This file is part of the OWL API. + * The contents of this file are subject to the LGPL License, Version 3.0. + * Copyright 2014, The University of Manchester + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +package uk.ac.manchester.owl.owlapi.tutorialowled2011; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.semanticweb.owlapi.search.EntitySearcher.getAnnotationObjects; +import static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asUnorderedSet; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.function.Predicate; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.apitest.TestFiles; +import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; +import org.semanticweb.owlapi.formats.OWLXMLDocumentFormat; +import org.semanticweb.owlapi.io.StreamDocumentTarget; +import org.semanticweb.owlapi.io.StringDocumentSource; +import org.semanticweb.owlapi.io.StringDocumentTarget; +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.AddOntologyAnnotation; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLClassExpressionVisitor; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLException; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyIRIMapper; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.PrefixManager; +import org.semanticweb.owlapi.model.RemoveAxiom; +import org.semanticweb.owlapi.model.SWRLAtom; +import org.semanticweb.owlapi.model.SWRLClassAtom; +import org.semanticweb.owlapi.model.SWRLObjectPropertyAtom; +import org.semanticweb.owlapi.model.SWRLRule; +import org.semanticweb.owlapi.model.SWRLVariable; +import org.semanticweb.owlapi.profiles.OWL2DLProfile; +import org.semanticweb.owlapi.profiles.OWLProfileReport; +import org.semanticweb.owlapi.profiles.OWLProfileViolation; +import org.semanticweb.owlapi.reasoner.InferenceType; +import org.semanticweb.owlapi.reasoner.Node; +import org.semanticweb.owlapi.reasoner.NodeSet; +import org.semanticweb.owlapi.reasoner.OWLReasoner; +import org.semanticweb.owlapi.reasoner.OWLReasonerConfiguration; +import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; +import org.semanticweb.owlapi.reasoner.ReasonerProgressMonitor; +import org.semanticweb.owlapi.reasoner.SimpleConfiguration; +import org.semanticweb.owlapi.reasoner.structural.StructuralReasonerFactory; +import org.semanticweb.owlapi.util.AutoIRIMapper; +import org.semanticweb.owlapi.util.DefaultPrefixManager; +import org.semanticweb.owlapi.util.InferredAxiomGenerator; +import org.semanticweb.owlapi.util.InferredOntologyGenerator; +import org.semanticweb.owlapi.util.InferredSubClassAxiomGenerator; +import org.semanticweb.owlapi.util.OWLEntityRemover; +import org.semanticweb.owlapi.util.OWLOntologyMerger; +import org.semanticweb.owlapi.util.OWLOntologyWalker; +import org.semanticweb.owlapi.util.OWLOntologyWalkerVisitorEx; +import org.semanticweb.owlapi.util.PriorityCollection; +import org.semanticweb.owlapi.util.SimpleIRIMapper; +import org.semanticweb.owlapi.vocab.OWL2Datatype; +import org.semanticweb.owlapi.vocab.OWLFacet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import uk.ac.manchester.cs.owlapi.modularity.ModuleType; +import uk.ac.manchester.cs.owlapi.modularity.SyntacticLocalityModuleExtractor; + +class TutorialSnippetsTestCase { + + static final IRI KOALA_IRI = + IRI.create("http://protege.stanford.edu/plugins/owl/owl-library/", "koala.owl"); + static final IRI EXAMPLE_IRI = IRI.create("http://www.semanticweb.org/ontologies/", "ont.owl"); + static final IRI EXAMPLE_SAVE_IRI = + IRI.create("file:materializedOntologies/", "ont1290535967123.owl"); + @TempDir + public File temporaryFolder; + protected OWLDataFactory df = OWLManager.getOWLDataFactory(); + private static final Logger LOG = LoggerFactory.getLogger(TutorialSnippetsTestCase.class); + protected OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory(); + // a visitor to extract label annotations + protected LabelExtractor le = new LabelExtractor(); + + private static OWLOntology loadPizzaOntology(OWLOntologyManager m) + throws OWLOntologyCreationException { + return m.loadOntologyFromOntologyDocument(new StringDocumentSource(TestFiles.KOALA)); + } + + OWLOntologyManager create() { + OWLOntologyManager m = OWLManager.createOWLOntologyManager(); + PriorityCollection iriMappers = m.getIRIMappers(); + iriMappers.add(new AutoIRIMapper(new File("materializedOntologies"), true)); + return m; + } + + @Test + void testOntologyLoading() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = loadPizzaOntology(m); + assertNotNull(o); + } + + @Test + void testOntologyLoadingFromStringSource() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = loadPizzaOntology(m); + // save an ontology to a document target which holds all data in memory + StringDocumentTarget target = new StringDocumentTarget(); + o.saveOntology(target); + // remove the ontology from the manager, so it can be loaded again + m.removeOntology(o); + // create a document source from a string + StringDocumentSource documentSource = new StringDocumentSource(target); + // load the ontology from a document source + OWLOntology o2 = m.loadOntologyFromOntologyDocument(documentSource); + assertNotNull(o2); + } + + @Test + void testOntologyCreation() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = m.createOntology(EXAMPLE_IRI); + assertNotNull(o); + } + + @Test + void testShowClasses() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = loadPizzaOntology(m); + assertNotNull(o); + // These are the named classes referenced by axioms in the ontology. + o.classesInSignature().forEach(cls -> + // use the class for whatever purpose + assertNotNull(cls)); + } + + @Test + void testSaveOntology() throws Exception { + OWLOntologyManager m = create(); + OWLOntology o = loadPizzaOntology(m); + assertNotNull(o); + File output = new File(temporaryFolder, "saved_pizza.owl"); + // Output will be deleted on exit; to keep temporary file replace + // previous line with the following + // File output = File.createTempFile("saved_pizza", ".owl"); + IRI documentIRI2 = IRI.create(output); + // save in OWL/XML format + o.saveOntology(new OWLXMLDocumentFormat(), documentIRI2); + // save in RDF/XML + o.saveOntology(documentIRI2); + // print out the ontology + StringDocumentTarget target = new StringDocumentTarget(); + o.saveOntology(target); + // Remove the ontology from the manager + m.removeOntology(o); + } + + @Test + void testIRIMapper() throws Exception { + OWLOntologyManager m = OWLManager.createOWLOntologyManager(); + // map the ontology IRI to a physical IRI (files for example) + // Create the document IRI for our ontology + File output = new File(temporaryFolder, "saved_pizza.owl"); + // Output will be deleted on exit; to keep temporary file replace + // previous line with the following + // File output = File.createTempFile("saved_pizza", ".owl"); + IRI documentIRI = IRI.create(output); + // Set up a mapping, which maps the ontology to the document IRI + SimpleIRIMapper mapper = new SimpleIRIMapper(EXAMPLE_SAVE_IRI, documentIRI); + m.getIRIMappers().add(mapper); + // set up a mapper to read local copies of ontologies + File localFolder = new File("materializedOntologies"); + // the manager will look up an ontology IRI by checking + // localFolder first for a local copy, checking its subfolders as well + m.getIRIMappers().add(new AutoIRIMapper(localFolder, true)); + // Create the ontology - we use the ontology IRI (not the physical URI) + OWLOntology o = m.createOntology(EXAMPLE_SAVE_IRI); + // save the ontology to its physical location - documentIRI + o.saveOntology(); + } + + @Test + void testAddAxioms() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = m.createOntology(KOALA_IRI); + // class A and class B + OWLClass clsA = df.getOWLClass(KOALA_IRI + "#", "A"); + OWLClass clsB = df.getOWLClass(KOALA_IRI + "#", "B"); + // Now create the axiom + OWLAxiom axiom = df.getOWLSubClassOfAxiom(clsA, clsB); + // add the axiom to the ontology. + AddAxiom addAxiom = new AddAxiom(o, axiom); + // We now use the manager to apply the change + o.applyChange(addAxiom); + // remove the axiom from the ontology + RemoveAxiom removeAxiom = new RemoveAxiom(o, axiom); + o.applyChange(removeAxiom); + } + + @Test + void testAssertedSuperclasses() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = loadPizzaOntology(m); + OWLClass quokkaCls = df.getOWLClass(KOALA_IRI + "#", "Quokka"); + // for each superclass there will be a corresponding axiom + // the ontology indexes axioms in a variety of ways + assertEquals(2, o.subClassAxiomsForSubClass(quokkaCls).count()); + } + + @Test + void testSWRL() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = m.createOntology(EXAMPLE_IRI); + // Get hold of references to class A and class B. + OWLClass clsA = df.getOWLClass(EXAMPLE_IRI + "#", "A"); + OWLClass clsB = df.getOWLClass(EXAMPLE_IRI + "#", "B"); + SWRLVariable var = df.getSWRLVariable(EXAMPLE_IRI + "#", "x"); + Set body = Collections.singleton(df.getSWRLClassAtom(clsA, var)); + Set head = Collections.singleton(df.getSWRLClassAtom(clsB, var)); + SWRLRule rule = df.getSWRLRule(body, head); + o.applyChange(new AddAxiom(o, rule)); + OWLObjectProperty prop = df.getOWLObjectProperty(EXAMPLE_IRI + "#", "propA"); + OWLObjectProperty propB = df.getOWLObjectProperty(EXAMPLE_IRI + "#", "propB"); + SWRLObjectPropertyAtom propAtom = df.getSWRLObjectPropertyAtom(prop, var, var); + SWRLObjectPropertyAtom propAtom2 = df.getSWRLObjectPropertyAtom(propB, var, var); + Set antecedent = new HashSet<>(); + antecedent.add(propAtom); + antecedent.add(propAtom2); + SWRLRule rule2 = df.getSWRLRule(antecedent, Collections.singleton(propAtom)); + o.applyChange(new AddAxiom(o, rule2)); + } + + @Test + void testIndividualAssertions() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = m.createOntology(EXAMPLE_IRI); + // We want to state that matthew has a father who is peter. + OWLIndividual matthew = df.getOWLNamedIndividual(EXAMPLE_IRI + "#", "matthew"); + OWLIndividual peter = df.getOWLNamedIndividual(EXAMPLE_IRI + "#", "peter"); + // We need the hasFather property + OWLObjectProperty hasFather = df.getOWLObjectProperty(EXAMPLE_IRI + "#", "hasFather"); + // matthew --> hasFather --> peter + OWLObjectPropertyAssertionAxiom assertion = + df.getOWLObjectPropertyAssertionAxiom(hasFather, matthew, peter); + // Finally, add the axiom to our ontology and save + AddAxiom addAxiomChange = new AddAxiom(o, assertion); + o.applyChange(addAxiomChange); + // matthew is an instance of Person + OWLClass personClass = df.getOWLClass(EXAMPLE_IRI + "#", "Person"); + OWLClassAssertionAxiom ax = df.getOWLClassAssertionAxiom(personClass, matthew); + // Add this axiom to our ontology - with a convenience method + o.addAxiom(ax); + } + + @Test + void testDelete() throws OWLException { + // Delete individuals representing countries + OWLOntologyManager m = create(); + OWLOntology o = loadPizzaOntology(m); + // Ontologies don't directly contain entities but axioms + // OWLEntityRemover will remove an entity (class, property or + // individual) + // from a set of ontologies by removing all referencing axioms + OWLEntityRemover remover = new OWLEntityRemover(Collections.singleton(o)); + long previousNumberOfIndividuals = o.individualsInSignature().count(); + // Visit all individuals with the remover + // Changes needed for removal will be prepared + o.individualsInSignature().forEach(i -> i.accept(remover)); + // Now apply the changes + o.applyChanges(remover.getChanges()); + long size = o.individualsInSignature().count(); + assertTrue(previousNumberOfIndividuals > size, + previousNumberOfIndividuals + " supposed to be larger than " + size); + } + + @Test + void testAddSomeRestriction() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = m.createOntology(EXAMPLE_IRI); + // all Heads have parts that are noses (at least one) + // We do this by creating an existential (some) restriction + OWLObjectProperty hasPart = df.getOWLObjectProperty(EXAMPLE_IRI + "#", "hasPart"); + OWLClass nose = df.getOWLClass(EXAMPLE_IRI + "#", "Nose"); + // Now let's describe the class of individuals that have at + // least one part that is a kind of nose + OWLClassExpression hasPartSomeNose = df.getOWLObjectSomeValuesFrom(hasPart, nose); + OWLClass head = df.getOWLClass(EXAMPLE_IRI + "#", "Head"); + // Head subclass of our restriction + OWLSubClassOfAxiom ax = df.getOWLSubClassOfAxiom(head, hasPartSomeNose); + // Add the axiom to our ontology + AddAxiom addAx = new AddAxiom(o, ax); + o.applyChange(addAx); + } + + @Test + void testDatatypeRestriction() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = m.createOntology(EXAMPLE_IRI); + // Adults have an age greater than 18. + OWLDataProperty hasAge = df.getOWLDataProperty(EXAMPLE_IRI + "#", "hasAge"); + // Create the restricted data range by applying the facet restriction + // with a value of 18 to int + OWLDataRange greaterThan18 = df.getOWLDatatypeRestriction(df.getIntegerOWLDatatype(), + OWLFacet.MIN_INCLUSIVE, df.getOWLLiteral(18)); + // Now we can use this in our datatype restriction on hasAge + OWLClassExpression adultDefinition = df.getOWLDataSomeValuesFrom(hasAge, greaterThan18); + OWLClass adult = df.getOWLClass(EXAMPLE_IRI + "#", "Adult"); + OWLSubClassOfAxiom ax = df.getOWLSubClassOfAxiom(adult, adultDefinition); + o.applyChange(new AddAxiom(o, ax)); + } + + @Test + void testUnsatisfiableClasses() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = loadPizzaOntology(m); + // Create a console progress monitor. This will print the reasoner + // progress out to the console. + ReasonerProgressMonitor progressMonitor = + new LoggingReasonerProgressMonitor(LOG, "testUnsatisfiableClasses"); + OWLReasonerConfiguration config = new SimpleConfiguration(progressMonitor); + // Create a reasoner that will reason over our ontology and its imports + // closure. Pass in the configuration. + // not using it in tests, we don't need the output + // OWLReasoner reasoner = reasonerFactory.createReasoner(o, config); + OWLReasoner reasoner = reasonerFactory.createReasoner(o, config); + // Ask the reasoner to precompute some inferences + reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY); + // We can determine if the ontology is actually consistent (in this + // case, it should be). + assertTrue(reasoner.isConsistent()); + // get a list of unsatisfiable classes + Node bottomNode = reasoner.getUnsatisfiableClasses(); + // leave owl:Nothing out + Set unsatisfiable = bottomNode.getEntitiesMinusBottom(); + if (!unsatisfiable.isEmpty()) { + for (OWLClass cls : unsatisfiable) { + assertNotNull(cls); + // deal with unsatisfiable classes + } + } + } + + @Test + void testDescendants() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = loadPizzaOntology(m); + // Create a console progress monitor. This will print the reasoner + // progress out to the console. + ReasonerProgressMonitor progressMonitor = + new LoggingReasonerProgressMonitor(LOG, "testDescendants"); + OWLReasonerConfiguration config = new SimpleConfiguration(progressMonitor); + // Create a reasoner that will reason over our ontology and its imports + // closure. Pass in the configuration. + // not using it in tests, we don't need the output + // OWLReasoner reasoner = reasonerFactory.createReasoner(o, config); + OWLReasoner reasoner = reasonerFactory.createReasoner(o, config); + // Ask the reasoner to precompute some inferences + reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY); + // Look up and print all direct subclasses for all classes + o.classesInSignature().forEach(c -> { + // the boolean argument specifies direct subclasses; false would + // specify all subclasses + // a NodeSet represents a set of Nodes. + // a Node represents a set of equivalent classes + NodeSet subClasses = reasoner.getSubClasses(c, true); + subClasses.entities().forEach(subClass -> assertNotNull(subClass)); + // process all subclasses no matter what node they're in + }); + } + + @Test + void testPetInstances() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = loadPizzaOntology(m); + // Create a console progress monitor. This will print the reasoner + // progress out to the console. + ReasonerProgressMonitor progressMonitor = + new LoggingReasonerProgressMonitor(LOG, "testPetInstances"); + OWLReasonerConfiguration config = new SimpleConfiguration(progressMonitor); + // Create a reasoner that will reason over our ontology and its imports + // closure. Pass in the configuration. + // not using it in tests, we don't need the output + // OWLReasoner reasoner = reasonerFactory.createReasoner(o, config); + OWLReasoner reasoner = reasonerFactory.createReasoner(o, config); + // Ask the reasoner to precompute some inferences + reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY); + // for each class, look up the instances + o.classesInSignature().forEach(c -> { + // the boolean argument specifies direct subclasses; false + // would + // specify all subclasses + // a NodeSet represents a set of Nodes. + // a Node represents a set of equivalent classes/or sameAs + // individuals + NodeSet instances = reasoner.getInstances(c, true); + instances.entities().forEach(i -> + // look up all property assertions + o.objectPropertiesInSignature().forEach(op -> reasoner.getObjectPropertyValues(i, op) + .nodes().forEach(value -> assertNotNull(value)))); + // use the value individuals + }); + } + + @Test + void testLookupRestrictions() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = loadPizzaOntology(m); + // We want to examine the restrictions on all classes. + o.classesInSignature().forEach(c -> { + // collect the properties which are used in existential restrictions + RestrictionVisitor visitor = new RestrictionVisitor(Collections.singleton(o)); + o.subClassAxiomsForSubClass(c).forEach(ax -> + // Ask our superclass to accept a visit from the + // RestrictionVisitor + ax.getSuperClass().accept(visitor)); + // Our RestrictionVisitor has now collected all of the + // properties + // that have been restricted in existential + // restrictions - print them out. + Set restrictedProperties = + visitor.getRestrictedProperties(); + // System.out.println("Restricted properties for " + labelFor(c, + // o) + // + ": " + restrictedProperties.size()); + for (OWLObjectPropertyExpression prop : restrictedProperties) { + assertNotNull(prop); + // System.out.println(" " + prop); + } + }); + } + + @Test + void testComment() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = loadPizzaOntology(m); + // We want to add a comment to the pizza class. + OWLClass quokkaCls = df.getOWLClass(KOALA_IRI + "#", "Quokka"); + // the content of our comment: a string and a language tag + OWLAnnotation commentAnno = + df.getRDFSComment(df.getOWLLiteral("A class which represents Quokkas", "en")); + // Specify that the pizza class has an annotation + OWLAxiom ax = df.getOWLAnnotationAssertionAxiom(quokkaCls.getIRI(), commentAnno); + // Add the axiom to the ontology + o.applyChange(new AddAxiom(o, ax)); + // add a version info annotation to the ontology + } + + @Test + void testVersionInfo() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = loadPizzaOntology(m); + // We want to add a comment to the pizza class. + OWLLiteral lit = df.getOWLLiteral("Added a comment to the pizza class"); + // create an annotation to pair a URI with the constant + OWLAnnotationProperty owlAnnotationProperty = df.getOWLVersionInfo(); + OWLAnnotation anno = df.getOWLAnnotation(owlAnnotationProperty, lit); + // Now we can add this as an ontology annotation + // Apply the change in the usual way + o.applyChange(new AddOntologyAnnotation(o, anno)); + } + + @Test + void testReadAnnotations() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = loadPizzaOntology(m); + // Get the annotations on the class that use the label property + Predicate portugueseLabelsOnly = + a -> a.getValue().asLiteral().isPresent() + && a.getValue().asLiteral().get().hasLang("pt"); + o.classesInSignature().flatMap(c -> getAnnotationObjects(c, o, df.getRDFSLabel())) + .filter(portugueseLabelsOnly) + .forEach(a -> assertNotNull(a.getValue().asLiteral().get().getLiteral())); + } + + @Test + void testInferredOntology() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = loadPizzaOntology(m); + // Create the reasoner and classify the ontology + OWLReasoner reasoner = reasonerFactory.createNonBufferingReasoner(o); + reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY); + // To generate an inferred ontology, use implementations of inferred + // axiom generators + List> gens = new ArrayList<>(); + gens.add(new InferredSubClassAxiomGenerator()); + OWLOntology infOnt = m.createOntology(); + // create the inferred ontology generator + InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens); + iog.fillOntology(m.getOWLDataFactory(), infOnt); + } + + @Test + void testMergedOntology() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o1 = loadPizzaOntology(m); + OWLOntology o2 = m.createOntology(EXAMPLE_IRI); + o2.addAxiom(df.getOWLDeclarationAxiom(df.getOWLClass(EXAMPLE_IRI + "#", "Weasel"))); + // Create our ontology merger + OWLOntologyMerger merger = new OWLOntologyMerger(m); + // We merge all of the loaded ontologies. Since an OWLOntologyManager is + // an OWLOntologySetProvider we + // just pass this in. We also need to specify the URI of the new + // ontology that will be created. + IRI mergedOntologyIRI = IRI.create("http://www.semanticweb.com/", "mymergedont"); + OWLOntology merged = merger.createMergedOntology(m, mergedOntologyIRI); + assertTrue(merged.getAxiomCount() > o1.getAxiomCount()); + assertTrue(merged.getAxiomCount() > o2.getAxiomCount()); + } + + @Test + void testOntologyWalker() throws OWLException { + // How to use an ontology walker to walk the asserted structure of an + // ontology. + OWLOntologyManager m = create(); + OWLOntology o = loadPizzaOntology(m); + // Create the walker + OWLOntologyWalker walker = new OWLOntologyWalker(Collections.singleton(o)); + // Now ask our walker to walk over the ontology + OWLOntologyWalkerVisitorEx visitor = + new OWLOntologyWalkerVisitorEx(walker) { + + @Override + public Object visit(OWLObjectSomeValuesFrom ce) { + assertNotNull(ce); + // Print out the restriction + // System.out.println(desc); + // Print out the axiom where the restriction is used + // System.out.println(" " + getCurrentAxiom()); + // System.out.println(); + // We don't need to return anything here. + return ""; + } + }; + // Now ask the walker to walk over the ontology structure using our + // visitor instance. + walker.walkStructure(visitor); + } + + @Test + void testMargherita() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = loadPizzaOntology(m); + // For this particular ontology, we know that all class, properties + // names etc. have + // URIs that is made up of the ontology IRI plus # plus the local name + String prefix = KOALA_IRI + "#"; + OWLReasoner reasoner = reasonerFactory.createNonBufferingReasoner(o); + // Now we can query the reasoner, suppose we want to determine the + // properties that + // instances of Margherita pizza must have + OWLClass margherita = df.getOWLClass(prefix, "Margherita"); + printProperties(o, reasoner, margherita); + } + + /** + * Prints out the properties that instances of a class expression must have. + * + * @param o The ontology + * @param reasoner The reasoner + * @param cls The class expression + */ + private void printProperties(OWLOntology o, OWLReasoner reasoner, OWLClass cls) { + o.objectPropertiesInSignature().forEach(prop -> { + // To test whether an instance of A MUST have a property p with a + // filler, check for the satisfiability of A and not (some p Thing) + // if this is satisfiable, then there might be instances with no + // p-filler + OWLClassExpression restriction = df.getOWLObjectSomeValuesFrom(prop, df.getOWLThing()); + OWLClassExpression intersection = + df.getOWLObjectIntersectionOf(cls, df.getOWLObjectComplementOf(restriction)); + boolean sat = !reasoner.isSatisfiable(intersection); + if (sat) { + assertNotNull(prop); + // System.out.println("Instances of " + cls + + // " necessarily have the property " + prop); + } + }); + } + + @Test + void testModularization() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = loadPizzaOntology(m); + // extract a module for all toppings. + // start by creating a signature that consists of "Quokka". + OWLClass quokkaCls = df.getOWLClass(KOALA_IRI + "#", "Quokka"); + Set sig = new HashSet<>(); + sig.add(quokkaCls); + // We now add all subclasses (direct and indirect) of the chosen + // classes. + OWLReasoner reasoner = reasonerFactory.createNonBufferingReasoner(o); + Set seedSig = asUnorderedSet(sig.stream().filter(e -> e.isOWLClass()) + .flatMap(e -> reasoner.getSubClasses(e.asOWLClass(), false).entities())); + seedSig.addAll(sig); + // We now extract a locality-based module. STAR provides the smallest + // ones + SyntacticLocalityModuleExtractor sme = + new SyntacticLocalityModuleExtractor(m, o, ModuleType.STAR); + Set mod = sme.extract(seedSig); + assertNotNull(mod); + } + + @Test + void testIndividual() throws OWLException { + // :Mary is an instance of the class :Person. + OWLOntologyManager m = create(); + // The IRIs used here are taken from the OWL 2 Primer + String base = "http://example.com/owl/families/"; + PrefixManager pm = new DefaultPrefixManager(null, null, base); + OWLClass person = df.getOWLClass(":Person", pm); + OWLNamedIndividual mary = df.getOWLNamedIndividual(":Mary", pm); + // create a ClassAssertion to specify that :Mary is an instance of + // :Person + OWLClassAssertionAxiom classAssertion = df.getOWLClassAssertionAxiom(person, mary); + OWLOntology o = m.createOntology(IRI.create(base, "")); + // Add the class assertion + o.addAxiom(classAssertion); + // Dump the ontology + StreamDocumentTarget target = new StreamDocumentTarget(new ByteArrayOutputStream()); + o.saveOntology(target); + } + + @Test + @SuppressWarnings("unused") + void testDataRanges() throws OWLException { + // Data ranges are used as the types of literals, as the ranges for data + // properties + OWLOntologyManager m = create(); + // OWLDatatype represents named datatypes in OWL + // The OWL2Datatype enum defines built in OWL 2 Datatypes + OWLDatatype integer = df.getOWLDatatype(OWL2Datatype.XSD_INTEGER); + // For common data types there are some convenience methods of + // OWLDataFactory + OWLDatatype integerDatatype = df.getIntegerOWLDatatype(); + OWLDatatype floatDatatype = df.getFloatOWLDatatype(); + OWLDatatype doubleDatatype = df.getDoubleOWLDatatype(); + OWLDatatype booleanDatatype = df.getBooleanOWLDatatype(); + // The top datatype is rdfs:Literal + OWLDatatype rdfsLiteral = df.getTopDatatype(); + // Custom data ranges can be built up from these basic datatypes + // Get hold of a literal that is an integer value 18 + OWLLiteral eighteen = df.getOWLLiteral(18); + OWLDatatypeRestriction integerGE18 = + df.getOWLDatatypeRestriction(integer, OWLFacet.MIN_INCLUSIVE, eighteen); + OWLDataProperty hasAge = + df.getOWLDataProperty("http://www.semanticweb.org/ontologies/", "dataranges#hasAge"); + OWLDataPropertyRangeAxiom rangeAxiom = df.getOWLDataPropertyRangeAxiom(hasAge, integerGE18); + OWLOntology o = + m.createOntology(IRI.create("http://www.semanticweb.org/ontologies/", "dataranges")); + // Add the range axiom to our ontology + o.addAxiom(rangeAxiom); + // Now create a datatype definition axiom + OWLDatatypeDefinitionAxiom datatypeDef = df.getOWLDatatypeDefinitionAxiom( + df.getOWLDatatype("http://www.semanticweb.org/ontologies/dataranges#", "age"), + integerGE18); + // Add the definition to our ontology + o.addAxiom(datatypeDef); + // Dump our ontology + StreamDocumentTarget target = new StreamDocumentTarget(new ByteArrayOutputStream()); + o.saveOntology(target); + } + + @Test + void testPropertyAssertions() throws OWLException { + // how to specify various property assertions for individuals + OWLOntologyManager m = create(); + IRI ontologyIRI = IRI.create("http://example.com/owl/families/", ""); + OWLOntology o = m.createOntology(ontologyIRI); + PrefixManager pm = new DefaultPrefixManager(null, null, ontologyIRI.toString()); + // Let's specify the :John has a wife :Mary + // Get hold of the necessary individuals and object property + OWLNamedIndividual john = df.getOWLNamedIndividual(":John", pm); + OWLNamedIndividual mary = df.getOWLNamedIndividual(":Mary", pm); + OWLObjectProperty hasWife = df.getOWLObjectProperty(":hasWife", pm); + // To specify that :John is related to :Mary via the :hasWife property + // we create an object property + // assertion and add it to the ontology + OWLObjectPropertyAssertionAxiom propertyAssertion = + df.getOWLObjectPropertyAssertionAxiom(hasWife, john, mary); + o.addAxiom(propertyAssertion); + // Now let's specify that :John is aged 51. + // Get hold of a data property called :hasAge + OWLDataProperty hasAge = df.getOWLDataProperty(":hasAge", pm); + // To specify that :John has an age of 51 we create a data property + // assertion and add it to the ontology + OWLDataPropertyAssertionAxiom dataPropertyAssertion = + df.getOWLDataPropertyAssertionAxiom(hasAge, john, 51); + o.addAxiom(dataPropertyAssertion); + } + + /** + * Print the class hierarchy for the given ontology from this class down, assuming this class is + * at the given level. Makes no attempt to deal sensibly with multiple inheritance. + */ + public void printHierarchy(OWLOntology o, OWLClass clazz) { + OWLReasoner reasoner = reasonerFactory.createNonBufferingReasoner(o); + printHierarchy(reasoner, clazz, 0, new HashSet()); + /* Now print out any unsatisfiable classes */ + o.classesInSignature().filter(cl -> !reasoner.isSatisfiable(cl)) + .forEach(cl -> assertNotNull(labelFor(cl, o))); + reasoner.dispose(); + } + + private String labelFor(OWLEntity clazz, OWLOntology o) { + return getAnnotationObjects(clazz, o).map(a -> a.accept(le)).filter(v -> !v.isEmpty()) + .findAny().orElseGet(() -> clazz.getIRI().toString()); + } + + public void printHierarchy(OWLReasoner reasoner, OWLClass clazz, int level, + Set visited) { + // Only print satisfiable classes to skip Nothing + if (!visited.contains(clazz) && reasoner.isSatisfiable(clazz)) { + visited.add(clazz); + // for (int i = 0; i < level * 4; i++) { + // System.out.print(" "); + // } + // System.out.println(labelFor(clazz, reasoner.getRootOntology())); + /* Find the children and recurse */ + NodeSet subClasses = reasoner.getSubClasses(clazz, true); + subClasses.entities() + .forEach(child -> printHierarchy(reasoner, child, level + 1, visited)); + } + } + + @Test + void testHierarchy() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = loadPizzaOntology(m); + // Get Thing + OWLClass clazz = df.getOWLThing(); + // System.out.println("Class : " + clazz); + // Print the hierarchy below thing + printHierarchy(o, clazz); + } + + @Test + void testRendering() throws OWLException { + // Simple Rendering Example. Reads an ontology and then renders it. + OWLOntologyManager m = create(); + OWLOntology o = loadPizzaOntology(m); + // Save using a different format + StreamDocumentTarget target = new StreamDocumentTarget(new ByteArrayOutputStream()); + o.saveOntology(new FunctionalSyntaxDocumentFormat(), target); + } + + @Test + void testCheckProfile() throws OWLException { + OWLOntologyManager m = create(); + OWLOntology o = m.createOntology(KOALA_IRI); + // Available profiles: DL, EL, QL, RL, OWL2 (Full) + OWL2DLProfile profile = new OWL2DLProfile(); + OWLProfileReport report = profile.checkOntology(o); + for (OWLProfileViolation v : report.getViolations()) { + // deal with violations + System.out.println(v); + } + } + + /** + * Visits existential restrictions and collects the properties which are restricted. + */ + private static class RestrictionVisitor implements OWLClassExpressionVisitor { + + private final Set processedClasses; + private final Set restrictedProperties; + private final Set onts; + + RestrictionVisitor(Set onts) { + restrictedProperties = new HashSet<>(); + processedClasses = new HashSet<>(); + this.onts = onts; + } + + public Set getRestrictedProperties() { + return restrictedProperties; + } + + @Override + public void visit(OWLClass ce) { + // avoid cycles + if (!processedClasses.contains(ce)) { + // If we are processing inherited restrictions then + // we recursively visit named supers. + processedClasses.add(ce); + for (OWLOntology ont : onts) { + ont.subClassAxiomsForSubClass(ce) + .forEach(ax -> ax.getSuperClass().accept(this)); + } + } + } + + @Override + public void visit(OWLObjectSomeValuesFrom ce) { + // This method gets called when a class expression is an + // existential (someValuesFrom) restriction and it asks us to visit + // it + restrictedProperties.add(ce.getProperty()); + } + } + + public static class LoggingReasonerProgressMonitor implements ReasonerProgressMonitor { + + private static Logger logger; + + public LoggingReasonerProgressMonitor(Logger log) { + logger = log; + } + + public LoggingReasonerProgressMonitor(Logger log, String methodName) { + String loggerName = log.getName() + '.' + methodName; + logger = LoggerFactory.getLogger(loggerName); + } + + @Override + public void reasonerTaskStarted(String taskName) { + logger.info("Reasoner Task Started: {}.", taskName); + } + + @Override + public void reasonerTaskStopped() { + logger.info("Task stopped."); + } + + @Override + public void reasonerTaskProgressChanged(int value, int max) { + logger.info("Reasoner Task made progress: {}/{}", Integer.valueOf(value), + Integer.valueOf(max)); + } + + @Override + public void reasonerTaskBusy() { + logger.info("Reasoner Task is busy"); + } + } +} diff --git a/contract/src/test/resources/AnnotatedPropertyAssertions.rdf b/contract/src/test/resources/AnnotatedPropertyAssertions.rdf new file mode 100644 index 0000000000..3ae20b0ee2 --- /dev/null +++ b/contract/src/test/resources/AnnotatedPropertyAssertions.rdf @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + annotation value + + + + + + + diff --git a/contract/src/test/resources/AnonymousInverses.rdf b/contract/src/test/resources/AnonymousInverses.rdf new file mode 100644 index 0000000000..188f3949f9 --- /dev/null +++ b/contract/src/test/resources/AnonymousInverses.rdf @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/contract/src/test/resources/ComplexSubProperty.rdf b/contract/src/test/resources/ComplexSubProperty.rdf new file mode 100644 index 0000000000..2b573485b6 --- /dev/null +++ b/contract/src/test/resources/ComplexSubProperty.rdf @@ -0,0 +1,17 @@ + + + + + + + + + + + + diff --git a/contract/src/test/resources/DataAllValuesFrom.rdf b/contract/src/test/resources/DataAllValuesFrom.rdf new file mode 100644 index 0000000000..cc1fe3efa3 --- /dev/null +++ b/contract/src/test/resources/DataAllValuesFrom.rdf @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + diff --git a/contract/src/test/resources/DataComplementOf.rdf b/contract/src/test/resources/DataComplementOf.rdf new file mode 100644 index 0000000000..7be4004074 --- /dev/null +++ b/contract/src/test/resources/DataComplementOf.rdf @@ -0,0 +1,22 @@ + + + + + + + + + + + + + diff --git a/contract/src/test/resources/DataHasValue.rdf b/contract/src/test/resources/DataHasValue.rdf new file mode 100644 index 0000000000..ca5eb3e6fc --- /dev/null +++ b/contract/src/test/resources/DataHasValue.rdf @@ -0,0 +1,25 @@ + + + + + + + + 3 + + + + + + A + + + + + + diff --git a/contract/src/test/resources/DataIntersectionOf.rdf b/contract/src/test/resources/DataIntersectionOf.rdf new file mode 100644 index 0000000000..0345161005 --- /dev/null +++ b/contract/src/test/resources/DataIntersectionOf.rdf @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/contract/src/test/resources/DataMaxCardinality.rdf b/contract/src/test/resources/DataMaxCardinality.rdf new file mode 100644 index 0000000000..976de14a42 --- /dev/null +++ b/contract/src/test/resources/DataMaxCardinality.rdf @@ -0,0 +1,19 @@ + + + + + + + 3 + + + + + + + diff --git a/contract/src/test/resources/DataMinCardinality.rdf b/contract/src/test/resources/DataMinCardinality.rdf new file mode 100644 index 0000000000..d193a4ca90 --- /dev/null +++ b/contract/src/test/resources/DataMinCardinality.rdf @@ -0,0 +1,19 @@ + + + + + + + 3 + + + + + + + diff --git a/contract/src/test/resources/DataOneOf.rdf b/contract/src/test/resources/DataOneOf.rdf new file mode 100644 index 0000000000..64122fe1fb --- /dev/null +++ b/contract/src/test/resources/DataOneOf.rdf @@ -0,0 +1,32 @@ + + + + + + + + + + 30 + + + 31.0 + + + + + + + + + + diff --git a/contract/src/test/resources/DataSomeValuesFrom.rdf b/contract/src/test/resources/DataSomeValuesFrom.rdf new file mode 100644 index 0000000000..acd3d4ac3b --- /dev/null +++ b/contract/src/test/resources/DataSomeValuesFrom.rdf @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + diff --git a/contract/src/test/resources/DataUnionOf.rdf b/contract/src/test/resources/DataUnionOf.rdf new file mode 100644 index 0000000000..d1871bb48e --- /dev/null +++ b/contract/src/test/resources/DataUnionOf.rdf @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/contract/src/test/resources/DatatypeRestriction.rdf b/contract/src/test/resources/DatatypeRestriction.rdf new file mode 100644 index 0000000000..3dfa99fafe --- /dev/null +++ b/contract/src/test/resources/DatatypeRestriction.rdf @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 18 + + + + + + + 30 + + + + + + + + + + + + diff --git a/contract/src/test/resources/Deprecated.rdf b/contract/src/test/resources/Deprecated.rdf new file mode 100644 index 0000000000..6494fe122b --- /dev/null +++ b/contract/src/test/resources/Deprecated.rdf @@ -0,0 +1,22 @@ + + + + + + + + + + + + + diff --git a/contract/src/test/resources/DisjointClasses.rdf b/contract/src/test/resources/DisjointClasses.rdf new file mode 100644 index 0000000000..38f1fe8a5c --- /dev/null +++ b/contract/src/test/resources/DisjointClasses.rdf @@ -0,0 +1,16 @@ + + + + + + + + + + + diff --git a/contract/src/test/resources/EquivalentClassesUntypedOWLClass.rdf b/contract/src/test/resources/EquivalentClassesUntypedOWLClass.rdf new file mode 100644 index 0000000000..66e9bee937 --- /dev/null +++ b/contract/src/test/resources/EquivalentClassesUntypedOWLClass.rdf @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/contract/src/test/resources/HasKey.rdf b/contract/src/test/resources/HasKey.rdf new file mode 100644 index 0000000000..7599e570b1 --- /dev/null +++ b/contract/src/test/resources/HasKey.rdf @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/contract/src/test/resources/ImportsTestOntologyA.owl b/contract/src/test/resources/ImportsTestOntologyA.owl new file mode 100644 index 0000000000..f47f69a5b3 --- /dev/null +++ b/contract/src/test/resources/ImportsTestOntologyA.owl @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/contract/src/test/resources/ImportsTestOntologyAEmpty.owl b/contract/src/test/resources/ImportsTestOntologyAEmpty.owl new file mode 100644 index 0000000000..51c975be2c --- /dev/null +++ b/contract/src/test/resources/ImportsTestOntologyAEmpty.owl @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/contract/src/test/resources/InverseOf.rdf b/contract/src/test/resources/InverseOf.rdf new file mode 100644 index 0000000000..e20453581e --- /dev/null +++ b/contract/src/test/resources/InverseOf.rdf @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/contract/src/test/resources/ObjectAllValuesFrom.rdf b/contract/src/test/resources/ObjectAllValuesFrom.rdf new file mode 100644 index 0000000000..4674a3eebb --- /dev/null +++ b/contract/src/test/resources/ObjectAllValuesFrom.rdf @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + diff --git a/contract/src/test/resources/ObjectCardinality.rdf b/contract/src/test/resources/ObjectCardinality.rdf new file mode 100644 index 0000000000..f9dc715131 --- /dev/null +++ b/contract/src/test/resources/ObjectCardinality.rdf @@ -0,0 +1,20 @@ + + + + + + + + + 3 + + + + + + diff --git a/contract/src/test/resources/ObjectComplementOf.rdf b/contract/src/test/resources/ObjectComplementOf.rdf new file mode 100644 index 0000000000..6904f0838e --- /dev/null +++ b/contract/src/test/resources/ObjectComplementOf.rdf @@ -0,0 +1,21 @@ + + + + + + + + + + + + diff --git a/contract/src/test/resources/ObjectHasSelf.rdf b/contract/src/test/resources/ObjectHasSelf.rdf new file mode 100644 index 0000000000..b24d6e7c79 --- /dev/null +++ b/contract/src/test/resources/ObjectHasSelf.rdf @@ -0,0 +1,20 @@ + + + + + + + + + true + + + + + + diff --git a/contract/src/test/resources/ObjectHasValue.rdf b/contract/src/test/resources/ObjectHasValue.rdf new file mode 100644 index 0000000000..26c424db29 --- /dev/null +++ b/contract/src/test/resources/ObjectHasValue.rdf @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + diff --git a/contract/src/test/resources/ObjectIntersectionOf.rdf b/contract/src/test/resources/ObjectIntersectionOf.rdf new file mode 100644 index 0000000000..3dc8723e36 --- /dev/null +++ b/contract/src/test/resources/ObjectIntersectionOf.rdf @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/contract/src/test/resources/ObjectMaxCardinality.rdf b/contract/src/test/resources/ObjectMaxCardinality.rdf new file mode 100644 index 0000000000..b854cb4453 --- /dev/null +++ b/contract/src/test/resources/ObjectMaxCardinality.rdf @@ -0,0 +1,19 @@ + + + + + + + + 3 + + + + + + diff --git a/contract/src/test/resources/ObjectMaxQualifiedCardinality.rdf b/contract/src/test/resources/ObjectMaxQualifiedCardinality.rdf new file mode 100644 index 0000000000..5a23a23304 --- /dev/null +++ b/contract/src/test/resources/ObjectMaxQualifiedCardinality.rdf @@ -0,0 +1,22 @@ + + + + + + + + + + 3 + + + + + + + diff --git a/contract/src/test/resources/ObjectMinCardinality.rdf b/contract/src/test/resources/ObjectMinCardinality.rdf new file mode 100644 index 0000000000..dfad62a509 --- /dev/null +++ b/contract/src/test/resources/ObjectMinCardinality.rdf @@ -0,0 +1,20 @@ + + + + + + + + + 3 + + + + + + diff --git a/contract/src/test/resources/ObjectMinQualifiedCardinality.rdf b/contract/src/test/resources/ObjectMinQualifiedCardinality.rdf new file mode 100644 index 0000000000..53ee612ec7 --- /dev/null +++ b/contract/src/test/resources/ObjectMinQualifiedCardinality.rdf @@ -0,0 +1,21 @@ + + + + + + + + + 3 + + + + + + + diff --git a/contract/src/test/resources/ObjectOneOf.rdf b/contract/src/test/resources/ObjectOneOf.rdf new file mode 100644 index 0000000000..535cc31ff7 --- /dev/null +++ b/contract/src/test/resources/ObjectOneOf.rdf @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/contract/src/test/resources/ObjectQualifiedCardinality.rdf b/contract/src/test/resources/ObjectQualifiedCardinality.rdf new file mode 100644 index 0000000000..f684828028 --- /dev/null +++ b/contract/src/test/resources/ObjectQualifiedCardinality.rdf @@ -0,0 +1,22 @@ + + + + + + + + + 3 + + + + + + + + diff --git a/contract/src/test/resources/ObjectSomeValuesFrom.rdf b/contract/src/test/resources/ObjectSomeValuesFrom.rdf new file mode 100644 index 0000000000..f4912f5eb0 --- /dev/null +++ b/contract/src/test/resources/ObjectSomeValuesFrom.rdf @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + diff --git a/contract/src/test/resources/ObjectUnionOf.rdf b/contract/src/test/resources/ObjectUnionOf.rdf new file mode 100644 index 0000000000..9d5ec81dcc --- /dev/null +++ b/contract/src/test/resources/ObjectUnionOf.rdf @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/contract/src/test/resources/RDFSClass.rdf b/contract/src/test/resources/RDFSClass.rdf new file mode 100644 index 0000000000..8643b5737b --- /dev/null +++ b/contract/src/test/resources/RDFSClass.rdf @@ -0,0 +1,50 @@ + + + + + + + + + + diff --git a/contract/src/test/resources/SubClassOf.rdf b/contract/src/test/resources/SubClassOf.rdf new file mode 100644 index 0000000000..978d66de7b --- /dev/null +++ b/contract/src/test/resources/SubClassOf.rdf @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/contract/src/test/resources/SubClassOfUntypedOWLClass.rdf b/contract/src/test/resources/SubClassOfUntypedOWLClass.rdf new file mode 100644 index 0000000000..7d761483df --- /dev/null +++ b/contract/src/test/resources/SubClassOfUntypedOWLClass.rdf @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/contract/src/test/resources/SubClassOfUntypedSomeValuesFrom.rdf b/contract/src/test/resources/SubClassOfUntypedSomeValuesFrom.rdf new file mode 100644 index 0000000000..be799a4f92 --- /dev/null +++ b/contract/src/test/resources/SubClassOfUntypedSomeValuesFrom.rdf @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + diff --git a/contract/src/test/resources/TestDeclarations.rdf b/contract/src/test/resources/TestDeclarations.rdf new file mode 100644 index 0000000000..b7fa630971 --- /dev/null +++ b/contract/src/test/resources/TestDeclarations.rdf @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/contract/src/test/resources/TestParser06.rdf b/contract/src/test/resources/TestParser06.rdf new file mode 100644 index 0000000000..2312a036b3 --- /dev/null +++ b/contract/src/test/resources/TestParser06.rdf @@ -0,0 +1,66 @@ + + + + + + + + + ]> + + + + + + + + + + + Something something + + A categorization scheme + + + + + 1 + + + + 1 + + + + + + + + + + + + + + eta gamma + + + + eta beta + + + + diff --git a/contract/src/test/resources/TestParser07.rdf b/contract/src/test/resources/TestParser07.rdf new file mode 100644 index 0000000000..6981989d2f --- /dev/null +++ b/contract/src/test/resources/TestParser07.rdf @@ -0,0 +1,35 @@ + + + +]> + + + + + + + + + + + + + + + + + + + + + + + diff --git a/contract/src/test/resources/TestParser08.rdf b/contract/src/test/resources/TestParser08.rdf new file mode 100644 index 0000000000..45b99e027d --- /dev/null +++ b/contract/src/test/resources/TestParser08.rdf @@ -0,0 +1,20 @@ + + + + + + + definition + + + + A definition here + + diff --git a/contract/src/test/resources/TestParser10.rdf b/contract/src/test/resources/TestParser10.rdf new file mode 100644 index 0000000000..74ed9ddfc6 --- /dev/null +++ b/contract/src/test/resources/TestParser10.rdf @@ -0,0 +1,89 @@ + + + + + + + + + + ]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/contract/src/test/resources/UntypedSubClassOf.rdf b/contract/src/test/resources/UntypedSubClassOf.rdf new file mode 100644 index 0000000000..328d56ed32 --- /dev/null +++ b/contract/src/test/resources/UntypedSubClassOf.rdf @@ -0,0 +1,12 @@ + + + + + + + diff --git a/contract/src/test/resources/VersionIRITestCase.rdf b/contract/src/test/resources/VersionIRITestCase.rdf new file mode 100644 index 0000000000..2711a74f10 --- /dev/null +++ b/contract/src/test/resources/VersionIRITestCase.rdf @@ -0,0 +1,44 @@ + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + diff --git a/contract/src/test/resources/XMLLiteral.rdf b/contract/src/test/resources/XMLLiteral.rdf new file mode 100644 index 0000000000..6352411ba2 --- /dev/null +++ b/contract/src/test/resources/XMLLiteral.rdf @@ -0,0 +1,18 @@ + + + + + + + ClassA + Role_Has_Parent&testPTNCI + + \ No newline at end of file diff --git a/contract/src/test/resources/all.rdf b/contract/src/test/resources/all.rdf new file mode 100644 index 0000000000..c83c3e70e5 --- /dev/null +++ b/contract/src/test/resources/all.rdf @@ -0,0 +1,41595 @@ + + + + + +]> + + + + + + + + + + + + + + + + + bnode2somevaluesfrom + Bijan Parsia + Shows that a BNode is an existential variable. + + + + + + + + <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:ex="http://example.org/" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://example.org/"> + <owl:Ontology/> + <owl:ObjectProperty rdf:about="p"/> + <owl:Thing rdf:about="a"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="p"/> + <owl:someValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#Thing"/> + </owl:Restriction> + </rdf:type> + </owl:Thing> +</rdf:RDF> + <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" +xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:ex="http://example.org/" + xml:base="http://example.org/"> + <owl:Ontology/> + <owl:ObjectProperty rdf:about="p"/> + + <owl:Thing rdf:about="a"> + <ex:p><rdf:Description rdf:nodeID="x"/></ex:p> + </owl:Thing> +</rdf:RDF> + + + + + + + + + + + + + + + + + + chain2trans1 + Bijan Parsia + A role chain can be a synonym for transitivity. + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base="http://example.org/ontology" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#"> + <owl:Ontology rdf:about=""/> + <owl:TransitiveProperty rdf:about="#p"/> +</rdf:RDF> + <rdf:RDF + xml:base="http://example.org/ontology" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#"> + + <owl:Ontology rdf:about=""/> + <owl:ObjectProperty rdf:about="#p"/> + + <rdf:Description rdf:about="#p"> + <owl:propertyChainAxiom rdf:parseType="Collection"> + <rdf:Description rdf:about="#p"/> + <rdf:Description rdf:about="#p"/> + </owl:propertyChainAxiom> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + Consistent Datatype restrictions with Different Types + Birte Glimm + The individual a must have dp fillers that are in the sets {3, 4} and {2, 3} (different types are used, but shorts and ints are integers). Furthermore, the dp filler must be 3, but since 3 is in both sets, the ontology is consistent. + + + + + + + Prefix(:=<http://example.org/>) +Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>) +Ontology( + Declaration(NamedIndividual(:a)) + Declaration(DataProperty(:dp)) + Declaration(Class(:A)) + SubClassOf(:A DataAllValuesFrom(:dp + DataOneOf("3"^^xsd:integer "4"^^xsd:int)) + ) + SubClassOf(:A DataAllValuesFrom(:dp + DataOneOf("2"^^xsd:short "3"^^xsd:int)) + ) + ClassAssertion(:A :a) + ClassAssertion(DataSomeValuesFrom(:dp + DataOneOf("3"^^xsd:integer)) :a + ) +) + + + + + + + + + + + + + + + + + + + + + + consistent-dataproperty-disjointness + Birte Glimm + The datatype properties dp1 and dp2 are disjoint, but the individual a can have 10 as a filler for dp1 and 18 as filler for dp2, which satisfies the disjointness. + + + + + + + Prefix(:=<http://example.org/>) +Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>) +Ontology( + Declaration(NamedIndividual(:a)) + Declaration(DataProperty(:dp1)) + Declaration(DataProperty(:dp2)) + Declaration(Class(:A)) + DisjointDataProperties(:dp1 :dp2) + DataPropertyAssertion(:dp1 :a "10"^^xsd:integer) + SubClassOf(:A DataSomeValuesFrom(:dp2 + DatatypeRestriction(xsd:integer + xsd:minInclusive "18"^^xsd:integer + xsd:maxInclusive "18"^^xsd:integer) + ) + ) + ClassAssertion(:A :a) +) + + + + + + + + + + + + + + + + + + + + + + consistent-integer-filler + Birte Glimm + The individual a is in the extension of the class A, which implies that it has a hasAge filler of 18 as integer, which is consistent with the all values from integer assertion for a. + + + + + + + Prefix(:=<http://example.org/>) +Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>) +Ontology( + Declaration(NamedIndividual(:a)) + Declaration(DataProperty(:dp)) + Declaration(Class(:A)) + SubClassOf(:A DataHasValue(:dp "18"^^xsd:integer)) + ClassAssertion(:A :a) + ClassAssertion(DataAllValuesFrom(:dp xsd:integer) :a) +) + + + + + + + + + + + + + + + + + + + + + + Contradicting datatype Restrictions + Birte Glimm + The individual a is in A and thus must have a dp filler that is an integer >= 4. Furthermore the dp fillers must be in the set {3, 4} and in the set {2, 3}. Although 3 is in both sets, 3 is not >= 4, which causes the inconsistency. + + + + + + + Prefix(:=<http://example.org/>) +Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>) +Ontology( + Declaration(NamedIndividual(:a)) + Declaration(DataProperty(:dp)) + Declaration(Class(:A)) + SubClassOf(:A DataAllValuesFrom(:dp + DataOneOf("3"^^xsd:integer "4"^^xsd:integer)) + ) + SubClassOf(:A DataAllValuesFrom(:dp + DataOneOf("2"^^xsd:integer "3"^^xsd:integer)) + ) + SubClassOf(:A DataSomeValuesFrom(:dp + DatatypeRestriction(xsd:integer + xsd:minInclusive "4"^^xsd:integer) + ) + ) + ClassAssertion(:A :a) +) + + + + + + + + + + + + + + + + + + + + + + Contradicting-dateTime-restrictions + Birte Glimm + The individual a must have a dp filler that is a date from 2007, but the restrictions on dp allow only values from 2008, which makes the ontology inconsistent. + + + + + + + Prefix(:=<http://example.org/>) +Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>) +Ontology( + Declaration(NamedIndividual(:a)) + Declaration(DataProperty(:dp)) + Declaration(Class(:A)) + SubClassOf(:A + DataHasValue(:dp "2007-10-08T20:44:11.656+01:00"^^xsd:dateTime)) + SubClassOf(:A + DataAllValuesFrom(:dp DatatypeRestriction( + xsd:dateTime + xsd:minInclusive "2008-07-08T20:44:11.656+01:00"^^xsd:dateTime + xsd:maxInclusive "2008-10-08T20:44:11.656+01:00"^^xsd:dateTime) + ) + ) + ClassAssertion(:A :a) +) + + + + + + + + + + + + + + + + + + + + + + Datatype-DataComplementOf-001 + Mike Smith + Demonstrates that the complement of a datatype contains literals from other datatypes. + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs= "http://www.w3.org/2000/01/rdf-schema#" > + +<owl:Ontology/> + +<owl:DatatypeProperty rdf:about="p" /> + +<rdf:Description rdf:about="p"> + <rdfs:range> + <rdfs:Datatype> + <owl:datatypeComplementOf rdf:resource="http://www.w3.org/2001/XMLSchema#positiveInteger" /> + </rdfs:Datatype> + </rdfs:range> +</rdf:Description> + +<rdf:Description rdf:about="i"> + <p rdf:datatype="http://www.w3.org/2001/XMLSchema#negativeInteger">-1</p> + <p rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A string</p> +</rdf:Description> + +</rdf:RDF> + Prefix( xsd: = <http://www.w3.org/2001/XMLSchema#> ) +Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( DataProperty( :p ) ) + + DataPropertyRange( :p DataComplementOf( xsd:positiveInteger ) ) + + DataPropertyAssertion( :p :i "-1"^^xsd:negativeInteger ) + DataPropertyAssertion( :p :i "A string"^^xsd:string ) +) + + + + + + + + + + + + + + + + + + + + + + Datatype-Float-Discrete-001 + Michael Smith + The value space of xsd:float is discrete, shown with range defined on 0x00000000 and 0x00000001 + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/ontology/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs= "http://www.w3.org/2000/01/rdf-schema#" + xmlns:xsd = "http://www.w3.org/2001/XMLSchema#" > + +<owl:Ontology/> + +<owl:DatatypeProperty rdf:about="dp" /> + +<rdf:Description rdf:about="a"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="dp" /> + <owl:someValuesFrom> + <rdfs:Datatype> + <owl:onDatatype rdf:resource="http://www.w3.org/2001/XMLSchema#float" /> + <owl:withRestrictions rdf:parseType="Collection"> + <rdf:Description> + <xsd:minExclusive rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.0</xsd:minExclusive> + </rdf:Description> + <rdf:Description> + <xsd:maxExclusive rdf:datatype="http://www.w3.org/2001/XMLSchema#float">1.401298464324817e-45</xsd:maxExclusive> + </rdf:Description> + </owl:withRestrictions> + </rdfs:Datatype> + </owl:someValuesFrom> + </owl:Restriction> + </rdf:type> +</rdf:Description> + +</rdf:RDF> + Prefix( xsd: = <http://www.w3.org/2001/XMLSchema#> ) +Prefix( ex: = <http://example.org/ontology/> ) + +Ontology( + + Declaration( DataProperty( ex:dp ) ) + + ClassAssertion( + DataSomeValuesFrom( ex:dp + DatatypeRestriction( xsd:float + xsd:minExclusive "0.0"^^xsd:float + xsd:maxExclusive "1.401298464324817e-45"^^xsd:float + ) + ) + ex:a + ) + +) + + + + + + + + + + + + + + + + + + + + + + datatype-restriction-min-max-inconsistency + Birte Glimm + The individual a is supposed to have an integer dp-successor >= 18, but all dp-successors must be <= 10, which is impossible. + + + + + + + Prefix(:=<http://example.org/>) +Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>) +Ontology( + Declaration(NamedIndividual(:a)) + Declaration(DataProperty(:dp)) + Declaration(Class(:A)) + SubClassOf(:A DataSomeValuesFrom(:dp + DatatypeRestriction(xsd:integer xsd:minInclusive "18"^^xsd:integer)) + ) + SubClassOf(:A DataAllValuesFrom(:dp + DatatypeRestriction(xsd:integer xsd:maxInclusive "10"^^xsd:integer)) + ) + ClassAssertion(:A :a) +) + + + + + + + + + + + + + + + + + + + + + + + Different types in Datatype Restrictions and Complement + Birte Glimm + The individual a must have dp fillers that are in the sets {3, 4} and {2, 3} (different types are used, but shorts and ints are integers), but at the same time 3 is not allowed as a dp filler for a, which causes the inconsistency. + + + + + + + Prefix(:=<http://example.org/>) +Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>) +Ontology( + Declaration(NamedIndividual(:a)) + Declaration(DataProperty(:dp)) + Declaration(Class(:A)) + SubClassOf(:A DataAllValuesFrom(:dp + DataOneOf("3"^^xsd:integer "4"^^xsd:int)) + ) + SubClassOf(:A DataAllValuesFrom(:dp + DataOneOf("2"^^xsd:short "3"^^xsd:integer)) + ) + ClassAssertion(:A :a) + ClassAssertion(DataSomeValuesFrom(:dp + DataComplementOf(DataOneOf("3"^^xsd:integer))) :a + ) +) + + + + + + + + + + + + + + + + + + + + + + + DisjointClasses-001 + Mike Smith + Demonstrates a binary disjoint classes axiom based on example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:Class rdf:about="Girl" /> + +<rdf:Description rdf:about="Stewie"> + <rdf:type> + <owl:Class> + <owl:complementOf rdf:resource="Girl" /> + </owl:Class> + </rdf:type> +</rdf:Description> + +</rdf:RDF> + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:Class rdf:about="Boy" /> +<owl:Class rdf:about="Girl" /> + +<rdf:Description rdf:about="Boy"> + <owl:disjointWith rdf:resource="Girl" /> +</rdf:Description> + +<Boy rdf:about="Stewie" /> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( Class( :Girl ) ) + + ClassAssertion( ObjectComplementOf( :Girl ) :Stewie ) +) + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( Class( :Boy ) ) + Declaration( Class( :Girl ) ) + + DisjointClasses( :Boy :Girl ) + ClassAssertion( :Boy :Stewie ) +) + + + + + + + + + + + + + + + + + DisjointClasses-002 + Mike Smith + Demonstrates a binary disjoint classes axiom and class assertions causing an inconsistency based on example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:Class rdf:about="Boy" /> +<owl:Class rdf:about="Girl" /> + +<rdf:Description rdf:about="Boy"> + <owl:disjointWith rdf:resource="Girl" /> +</rdf:Description> + +<Boy rdf:about="Stewie" /> +<Girl rdf:about="Stewie" /> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( Class( :Boy ) ) + Declaration( Class( :Girl ) ) + + DisjointClasses( :Boy :Girl ) + ClassAssertion( :Boy :Stewie ) + ClassAssertion( :Girl :Stewie ) +) + + + + + + + + DisjointClasses-003 + Mike Smith + A modification of test DisjointClasses-001 to demonstrate a ternary disjoint classes axiom. + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:Class rdf:about="Girl" /> +<owl:Class rdf:about="Dog" /> + +<rdf:Description rdf:about="Stewie"> + <rdf:type> + <owl:Class> + <owl:complementOf rdf:resource="Girl" /> + </owl:Class> + </rdf:type> +</rdf:Description> + +<rdf:Description rdf:about="Stewie"> + <rdf:type> + <owl:Class> + <owl:complementOf rdf:resource="Dog" /> + </owl:Class> + </rdf:type> +</rdf:Description> + +</rdf:RDF> + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:Class rdf:about="Boy" /> +<owl:Class rdf:about="Girl" /> +<owl:Class rdf:about="Dog" /> + +<owl:AllDisjointClasses> + <owl:members rdf:parseType="Collection"> + <rdf:Description rdf:about="Boy" /> + <rdf:Description rdf:about="Girl" /> + <rdf:Description rdf:about="Dog" /> + </owl:members> +</owl:AllDisjointClasses> + +<Boy rdf:about="Stewie" /> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( Class( :Girl ) ) + Declaration( Class( :Dog ) ) + + ClassAssertion( ObjectComplementOf( :Girl ) :Stewie ) + ClassAssertion( ObjectComplementOf( :Dog ) :Stewie ) +) + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( Class( :Boy ) ) + Declaration( Class( :Girl ) ) + Declaration( Class( :Dog ) ) + + DisjointClasses( :Boy :Girl :Dog ) + ClassAssertion( :Boy :Stewie ) +) + + + + + + + + + + + + + + + + + functionality-clash + Birte Glimm + The property hasAge is functional, but the individual a has two distinct hasAge fillers. + + + + + + + + Prefix(:=<http://example.org/>) +Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>) +Ontology( + Declaration(NamedIndividual(:a)) + Declaration(DataProperty(:hasAge)) + FunctionalDataProperty(:hasAge) + ClassAssertion(DataHasValue(:hasAge "18"^^xsd:integer) :a) + ClassAssertion(DataHasValue(:hasAge "19"^^xsd:integer) :a) +) + + + + + + + + + + + + + + + + + Inconsistent Byte Filler + Birte Glimm + The individual a must have the integer 6542145 as dp filler, but all fillers must also be bytes. Since 6542145 is not byte, the ontology is inconsistent. + + + + + + + Prefix(:=<http://example.org/>) +Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>) +Ontology( + Declaration(NamedIndividual(:a)) + Declaration(DataProperty(:dp)) + Declaration(Class(:A)) + SubClassOf(:A DataAllValuesFrom(:dp xsd:byte)) + ClassAssertion(:A :a) + ClassAssertion( + DataSomeValuesFrom(:dp DataOneOf("6542145"^^xsd:integer)) :a + ) +) + + + + + + + + + + + + + + + + + + + + + + Inconsistent Data Complement with the Restrictions + Birte Glimm + The individual a must have dp fillers that are in the sets {3, 4} and {2, 3}, but at the same time 3 is not allowed as a dp filler for a, which causes the inconsistency. + + + + + + + Prefix(:=<http://example.org/>) +Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>) +Ontology( + Declaration(NamedIndividual(:a)) + Declaration(DataProperty(:dp)) + Declaration(Class(:A)) + SubClassOf(:A DataAllValuesFrom(:dp + DataOneOf("3"^^xsd:integer "4"^^xsd:integer)) + ) + SubClassOf(:A DataAllValuesFrom(:dp + DataOneOf("2"^^xsd:integer "3"^^xsd:integer)) + ) + ClassAssertion(:A :a) + ClassAssertion(DataSomeValuesFrom(:dp + DataComplementOf(DataOneOf("3"^^xsd:integer))) :a) +) + + + + + + + + + + + + + + + + + + + + + + inconsistent-integer-filler + Birte Glimm + The individual has an asserted hasAge filler of 18 as integer. At the same time it is an instance of the negation of the class Eighteen, which implies that all hasAge fillers for a are not 18. + + + + + + + Prefix(:=<http://example.org/>) +Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>) +Ontology( + Declaration(NamedIndividual(:a)) + Declaration(DataProperty(:hasAge)) + Declaration(Class(:Eighteen)) + SubClassOf(DataHasValue(:hasAge "18"^^xsd:integer) :Eighteen) + ClassAssertion(DataHasValue(:hasAge "18"^^xsd:integer) :a) + ClassAssertion(ObjectComplementOf(:Eighteen) :a) +) + + + + + + + + + + + + + + + + + + + + + + inconsistent_datatypes + Birte Glimm + The individual a is in the extension of the class A and is thus required to have a dp-successor that is an integer and at the same time all dp-successors are required to be strings, which causes the inconsistency. + + + + + + + Prefix(:=<http://example.org/>) +Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>) +Ontology( + Declaration(NamedIndividual(:a)) + Declaration(DataProperty(:dp)) + Declaration(Class(:A)) + SubClassOf(:A DataAllValuesFrom(:dp xsd:string)) + SubClassOf(:A DataSomeValuesFrom(:dp xsd:integer)) + ClassAssertion(:A :a) +) + + + + + + + + + + + + + + + + + + + + + + Minus Infinity is not in owl:real + Birte Glimm + The individual a must have either negative Infinity or 0 (-0 as integer is 0) as dp fillers and all dp successors must be from owl:real, which excludes negative infinity. Since 0 is excluded by the negative property assertion, the ontology is inconsistent. + + + + + + + Prefix(:=<http://example.org/>) +Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>) +Prefix(owl:=<http://www.w3.org/2002/07/owl#>) +Ontology( + Declaration(NamedIndividual(:a)) + Declaration(DataProperty(:dp)) + Declaration(Class(:A)) + SubClassOf(:A DataAllValuesFrom(:dp owl:real)) + SubClassOf(:A + DataSomeValuesFrom(:dp DataOneOf("-INF"^^xsd:float "-0"^^xsd:integer)) + ) + ClassAssertion(:A :a) + NegativeDataPropertyAssertion(:dp :a "0"^^xsd:unsignedInt) +) + + + + + + + + + + + + + + + + + + + + + + + New-Feature-AsymmetricProperty-001 + Mike Smith + Demonstrates use of an asymmetric object property axiom to cause a trivial inconsistency based on the example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:ObjectProperty rdf:about="parentOf" /> +<owl:AsymmetricProperty rdf:about="parentOf" /> + +<rdf:Description rdf:about="Peter"> + <parentOf rdf:resource="Stewie" /> +</rdf:Description> + +<rdf:Description rdf:about="Stewie"> + <parentOf rdf:resource="Peter" /> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( ObjectProperty( :parentOf ) ) + AsymmetricObjectProperty( :parentOf ) + + ObjectPropertyAssertion( :parentOf :Peter :Stewie ) + + ObjectPropertyAssertion( :parentOf :Stewie :Peter ) +) + + + + + + + + + + + + New-Feature-DisjointDataProperties-001 + Mike Smith + Demonstrates use of a disjoint data properties axiom to create a trivial inconsistency based on the example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:DatatypeProperty rdf:about="hasName" /> +<owl:DatatypeProperty rdf:about="hasAddress" /> + +<rdf:Description rdf:about="hasName"> + <owl:propertyDisjointWith rdf:resource="hasAddress" /> +</rdf:Description> + +<rdf:Description rdf:about="Peter"> + <hasName>Peter Griffin</hasName> + <hasAddress>Peter Griffin</hasAddress> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( DataProperty( :hasName ) ) + Declaration( DataProperty( :hasAddress ) ) + + DisjointDataProperties( :hasName :hasAddress ) + + DataPropertyAssertion( :hasName :Peter "Peter Griffin" ) + DataPropertyAssertion( :hasAddress :Peter "Peter Griffin" ) +) + + + + + + + + + + + + + New-Feature-DisjointDataProperties-002 + Mike Smith + Demonstrates use of a ternary disjoint data properties axiom to infer different individuals. Adapted from test New-Feature-DisjointDataProperties-001. + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:AllDifferent> + <owl:members rdf:parseType="Collection"> + <rdf:Description rdf:about="Peter" /> + <rdf:Description rdf:about="Peter_Griffin" /> + <rdf:Description rdf:about="Petre" /> + </owl:members> +</owl:AllDifferent> + +</rdf:RDF> + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:DatatypeProperty rdf:about="hasName" /> +<owl:DatatypeProperty rdf:about="hasAddress" /> +<owl:DatatypeProperty rdf:about="hasZip" /> + +<owl:AllDisjointProperties> + <owl:members rdf:parseType="Collection"> + <rdf:Description rdf:about="hasName" /> + <rdf:Description rdf:about="hasAddress" /> + <rdf:Description rdf:about="hasZip" /> + </owl:members> +</owl:AllDisjointProperties> + +<rdf:Description rdf:about="Peter"> + <hasName>Peter Griffin</hasName> +</rdf:Description> + +<rdf:Description rdf:about="Peter_Griffin"> + <hasAddress>Peter Griffin</hasAddress> +</rdf:Description> + +<rdf:Description rdf:about="Petre"> + <hasZip>Peter Griffin</hasZip> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + DifferentIndividuals( :Peter :Peter_Griffin :Petre ) +) + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( DataProperty( :hasName ) ) + Declaration( DataProperty( :hasAddress ) ) + Declaration( DataProperty( :hasZip ) ) + + DisjointDataProperties( :hasName :hasAddress :hasZip ) + + DataPropertyAssertion( :hasName :Peter "Peter Griffin" ) + DataPropertyAssertion( :hasAddress :Peter_Griffin "Peter Griffin" ) + DataPropertyAssertion( :hasZip :Petre "Peter Griffin" ) +) + + + + + + + + + + + + + New-Feature-DisjointObjectProperties-001 + Mike Smith + Demonstrates use of a disjoint object properties axiom to infer that two individuals are different based on the example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<rdf:Description rdf:about="Peter"> + <owl:differentFrom rdf:resource="Lois" /> +</rdf:Description> + +</rdf:RDF> + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:ObjectProperty rdf:about="hasFather" /> +<owl:ObjectProperty rdf:about="hasMother" /> + +<rdf:Description rdf:about="hasFather"> + <owl:propertyDisjointWith rdf:resource="hasMother" /> +</rdf:Description> + +<rdf:Description rdf:about="Stewie"> + <hasFather rdf:resource="Peter" /> +</rdf:Description> + +<rdf:Description rdf:about="Stewie"> + <hasMother rdf:resource="Lois" /> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + DifferentIndividuals( :Peter :Lois ) +) + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( ObjectProperty( :hasFather ) ) + Declaration( ObjectProperty( :hasMother ) ) + + DisjointObjectProperties( :hasFather :hasMother ) + + ObjectPropertyAssertion( :hasFather :Stewie :Peter ) + ObjectPropertyAssertion( :hasMother :Stewie :Lois ) +) + + + + + + + + + + + + + New-Feature-DisjointObjectProperties-002 + Mike Smith + A modification of test New-Feature-DisjointObjectProperties-001 to demonstrate a ternary disjoint object properties axiom. + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:AllDifferent> + <owl:members rdf:parseType="Collection"> + <rdf:Description rdf:about="Peter" /> + <rdf:Description rdf:about="Lois" /> + <rdf:Description rdf:about="StewieJr" /> + </owl:members> +</owl:AllDifferent> + +</rdf:RDF> + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:ObjectProperty rdf:about="hasFather" /> +<owl:ObjectProperty rdf:about="hasMother" /> +<owl:ObjectProperty rdf:about="hasChild" /> + +<owl:AllDisjointProperties> + <owl:members rdf:parseType="Collection"> + <rdf:Description rdf:about="hasFather" /> + <rdf:Description rdf:about="hasMother" /> + <rdf:Description rdf:about="hasChild" /> + </owl:members> +</owl:AllDisjointProperties> + +<rdf:Description rdf:about="Stewie"> + <hasFather rdf:resource="Peter" /> +</rdf:Description> + +<rdf:Description rdf:about="Stewie"> + <hasMother rdf:resource="Lois" /> +</rdf:Description> + +<rdf:Description rdf:about="Stewie"> + <hasChild rdf:resource="StewieJr" /> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + DifferentIndividuals( :Peter :Lois :StewieJr ) +) + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( ObjectProperty( :hasFather ) ) + Declaration( ObjectProperty( :hasMother ) ) + Declaration( ObjectProperty( :hasChild ) ) + + DisjointObjectProperties( :hasFather :hasMother :hasChild ) + + ObjectPropertyAssertion( :hasFather :Stewie :Peter ) + ObjectPropertyAssertion( :hasMother :Stewie :Lois ) + ObjectPropertyAssertion( :hasChild :Stewie :StewieJr ) +) + + + + + + + + + + + + + New-Feature-DisjointUnion-001 + Mike Smith + Demonstrates a disjoint union axiom based on the example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:Class rdf:about="Boy" /> + +<Boy rdf:about="Stewie" /> + +</rdf:RDF> + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:Class rdf:about="Child" /> +<owl:Class rdf:about="Boy" /> +<owl:Class rdf:about="Girl" /> + +<rdf:Description rdf:about="Child"> + <owl:disjointUnionOf rdf:parseType="Collection"> + <rdf:Description rdf:about="Boy" /> + <rdf:Description rdf:about="Girl" /> + </owl:disjointUnionOf> +</rdf:Description> + +<Child rdf:about="Stewie" /> +<rdf:Description rdf:about="Stewie"> + <rdf:type> + <owl:Class> + <owl:complementOf rdf:resource="Girl" /> + </owl:Class> + </rdf:type> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( Class( :Boy ) ) + + ClassAssertion( :Boy :Stewie ) +) + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( Class( :Child ) ) + Declaration( Class( :Boy ) ) + Declaration( Class( :Girl ) ) + + DisjointUnion( :Child :Boy :Girl ) + + ClassAssertion( :Child :Stewie ) + ClassAssertion( ObjectComplementOf( :Girl ) :Stewie ) +) + + + + + + + + + + + + + + + + + + + + + + New-Feature-IrreflexiveProperty-001 + Mike Smith + Demonstrates use of an irreflexive object property axiom to cause a trivial inconsistency based on the example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:ObjectProperty rdf:about="marriedTo" /> +<owl:IrreflexiveProperty rdf:about="marriedTo" /> + +<rdf:Description rdf:about="Peter"> + <marriedTo rdf:resource="Peter" /> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( ObjectProperty( :marriedTo ) ) + IrreflexiveObjectProperty( :marriedTo ) + + ObjectPropertyAssertion( :marriedTo :Peter :Peter ) +) + + + + + + + + + + + + + + + + + + New-Feature-Keys-001 + Mike Smith + Demonstrates use of a key axiom to merge individuals based on an example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<rdf:Description rdf:about="Peter"> + <owl:sameAs rdf:resource="Peter_Griffin" /> +</rdf:Description> + +</rdf:RDF> + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:DatatypeProperty rdf:about="hasSSN" /> + +<rdf:Description rdf:about="http://www.w3.org/2002/07/owl#Thing"> + <owl:hasKey rdf:parseType="Collection"> + <rdf:Description rdf:about="hasSSN" /> + </owl:hasKey> +</rdf:Description> + +<rdf:Description rdf:about="Peter"> + <hasSSN>123-45-6789</hasSSN> +</rdf:Description> + +<rdf:Description rdf:about="Peter_Griffin"> + <hasSSN>123-45-6789</hasSSN> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + SameIndividual( :Peter :Peter_Griffin ) +) + Prefix( owl: = <http://www.w3.org/2002/07/owl#> ) +Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( DataProperty( :hasSSN ) ) + + HasKey( owl:Thing () ( :hasSSN ) ) + + DataPropertyAssertion( :hasSSN :Peter "123-45-6789" ) + DataPropertyAssertion( :hasSSN :Peter_Griffin "123-45-6789" ) +) + + + + + + + + + + + + + + + + + New-Feature-Keys-002 + Mike Smith + Demonstrates use of a key axiom to cause a trivial inconsistency based on an example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:DatatypeProperty rdf:about="hasSSN" /> + +<rdf:Description rdf:about="http://www.w3.org/2002/07/owl#Thing"> + <owl:hasKey rdf:parseType="Collection"> + <rdf:Description rdf:about="hasSSN" /> + </owl:hasKey> +</rdf:Description> + +<rdf:Description rdf:about="Peter"> + <hasSSN>123-45-6789</hasSSN> +</rdf:Description> + +<rdf:Description rdf:about="Peter_Griffin"> + <hasSSN>123-45-6789</hasSSN> +</rdf:Description> + +<rdf:Description rdf:about="Peter"> + <owl:differentFrom rdf:resource="Peter_Griffin" /> +</rdf:Description> + +</rdf:RDF> + Prefix( owl: = <http://www.w3.org/2002/07/owl#> ) +Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( DataProperty( :hasSSN ) ) + + HasKey( owl:Thing () ( :hasSSN ) ) + + DataPropertyAssertion( :hasSSN :Peter "123-45-6789" ) + DataPropertyAssertion( :hasSSN :Peter_Griffin "123-45-6789" ) + + DifferentIndividuals( :Peter :Peter_Griffin ) +) + + + + + + + + + + + + + + + + + + New-Feature-Keys-003 + Mike Smith + Demonstrates use of a "localized" key axiom to merge individuals based on an example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<rdf:Description rdf:about="Peter"> + <owl:sameAs rdf:resource="Peter_Griffin" /> +</rdf:Description> + +</rdf:RDF> + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:Class rdf:about="GriffinFamilyMember" /> + +<owl:DatatypeProperty rdf:about="hasName" /> + +<rdf:Description rdf:about="GriffinFamilyMember"> + <owl:hasKey rdf:parseType="Collection"> + <rdf:Description rdf:about="hasName" /> + </owl:hasKey> +</rdf:Description> + +<rdf:Description rdf:about="Peter"> + <hasName>Peter</hasName> + <rdf:type rdf:resource="GriffinFamilyMember" /> +</rdf:Description> + +<rdf:Description rdf:about="Peter_Griffin"> + <hasName>Peter</hasName> + <rdf:type rdf:resource="GriffinFamilyMember" /> +</rdf:Description> + +<rdf:Description rdf:about="StPeter"> + <hasName>Peter</hasName> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + SameIndividual( :Peter :Peter_Griffin ) +) + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( Class( :GriffinFamilyMember ) ) + Declaration( DataProperty( :hasName ) ) + + HasKey( :GriffinFamilyMember () ( :hasName ) ) + + DataPropertyAssertion( :hasName :Peter "Peter" ) + ClassAssertion( :GriffinFamilyMember :Peter ) + + DataPropertyAssertion( :hasName :Peter_Griffin "Peter" ) + ClassAssertion( :GriffinFamilyMember :Peter_Griffin ) + + DataPropertyAssertion( :hasName :StPeter "Peter" ) +) + + + + + + + + + + + + + + New-Feature-Keys-004 + Mike Smith + Demonstrates that use of a "localized" key axiom only merges individuals that are instances of the given class expression. Based on an example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<rdf:Description rdf:about="Peter"> + <owl:sameAs rdf:resource="StPeter" /> +</rdf:Description> + +</rdf:RDF> + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:Class rdf:about="GriffinFamilyMember" /> + +<owl:DatatypeProperty rdf:about="hasName" /> + +<rdf:Description rdf:about="GriffinFamilyMember"> + <owl:hasKey rdf:parseType="Collection"> + <rdf:Description rdf:about="hasName" /> + </owl:hasKey> +</rdf:Description> + +<rdf:Description rdf:about="Peter"> + <hasName>Peter</hasName> + <rdf:type rdf:resource="GriffinFamilyMember" /> +</rdf:Description> + +<rdf:Description rdf:about="Peter_Griffin"> + <hasName>Peter</hasName> + <rdf:type rdf:resource="GriffinFamilyMember" /> +</rdf:Description> + +<rdf:Description rdf:about="StPeter"> + <hasName>Peter</hasName> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + SameIndividual( :Peter :StPeter ) +) + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( Class( :GriffinFamilyMember ) ) + Declaration( DataProperty( :hasName ) ) + + HasKey( :GriffinFamilyMember () ( :hasName ) ) + + DataPropertyAssertion( :hasName :Peter "Peter" ) + ClassAssertion( :GriffinFamilyMember :Peter ) + + DataPropertyAssertion( :hasName :Peter_Griffin "Peter" ) + ClassAssertion( :GriffinFamilyMember :Peter_Griffin ) + + DataPropertyAssertion( :hasName :StPeter "Peter" ) +) + + + + + + + + + + + + New-Feature-Keys-005 + Mike Smith + Demonstrates that a key axiom does not make all properties used in it functional. Based on an example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:Class rdf:about="GriffinFamilyMember" /> + +<owl:DatatypeProperty rdf:about="hasName" /> + +<rdf:Description rdf:about="GriffinFamilyMember"> + <owl:hasKey rdf:parseType="Collection"> + <rdf:Description rdf:about="hasName" /> + </owl:hasKey> +</rdf:Description> + +<rdf:Description rdf:about="Peter"> + <hasName>Peter</hasName> + <hasName>Kichwa-Tembo</hasName> + <rdf:type rdf:resource="GriffinFamilyMember" /> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( Class( :GriffinFamilyMember ) ) + Declaration( DataProperty( :hasName ) ) + + HasKey( :GriffinFamilyMember () ( :hasName ) ) + + DataPropertyAssertion( :hasName :Peter "Peter" ) + DataPropertyAssertion( :hasName :Peter "Kichwa-Tembo" ) + ClassAssertion( :GriffinFamilyMember :Peter ) +) + + + + + + + + + + + + New-Feature-Keys-006 + Mike Smith + Demonstrates that a key axiom does not make all properties used in it functional, but these properties may be made functional with other axioms. Based on an example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:Class rdf:about="GriffinFamilyMember" /> + +<owl:DatatypeProperty rdf:about="hasName" /> + +<rdf:Description rdf:about="GriffinFamilyMember"> + <owl:hasKey rdf:parseType="Collection"> + <rdf:Description rdf:about="hasName" /> + </owl:hasKey> +</rdf:Description> + +<rdf:Description rdf:about="Peter"> + <hasName>Peter</hasName> + <hasName>Kichwa-Tembo</hasName> + <rdf:type rdf:resource="GriffinFamilyMember" /> +</rdf:Description> + +<rdf:Description rdf:about="hasName"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty" /> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( Class( :GriffinFamilyMember ) ) + Declaration( DataProperty( :hasName ) ) + + HasKey( :GriffinFamilyMember () ( :hasName ) ) + + DataPropertyAssertion( :hasName :Peter "Peter" ) + DataPropertyAssertion( :hasName :Peter "Kichwa-Tembo" ) + ClassAssertion( :GriffinFamilyMember :Peter ) + + FunctionalDataProperty( :hasName ) +) + + + + + + + + + + + + + New-Feature-Keys-007 + Mike Smith + Demonstrates that a key axiom only applies to named individuals. Based on an example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:Class rdf:about="Man" /> + +<Man rdf:about="Peter" /> + +</rdf:RDF> + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:Class rdf:about="Person" /> + +<owl:Class rdf:about="Man" /> + +<owl:DatatypeProperty rdf:about="hasSSN" /> + +<owl:ObjectProperty rdf:about="marriedTo" /> + +<rdf:Description rdf:about="Person"> + <owl:hasKey rdf:parseType="Collection"> + <rdf:Description rdf:about="hasSSN" /> + </owl:hasKey> +</rdf:Description> + +<rdf:Description rdf:about="Peter"> + <hasSSN>123-45-6789</hasSSN> + <rdf:type rdf:resource="Person" /> +</rdf:Description> + +<rdf:Description rdf:about="Lois"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="marriedTo" /> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <rdf:Description rdf:about="Man" /> + <owl:Restriction> + <owl:onProperty rdf:resource="hasSSN" /> + <owl:hasValue>123-45-6789</owl:hasValue> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </rdf:type> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + ClassAssertion( :Man :Peter ) +) + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( Class( :Person ) ) + Declaration( Class( :Man ) ) + Declaration( DataProperty( :hasSSN ) ) + Declaration( ObjectProperty( :marriedTo ) ) + + HasKey( :Person () ( :hasSSN ) ) + + DataPropertyAssertion( :hasSSN :Peter "123-45-6789" ) + ClassAssertion( :Person :Peter ) + + ClassAssertion( + ObjectSomeValuesFrom( + :marriedTo + ObjectIntersectionOf( :Man DataHasValue( :hasSSN "123-45-6789" ) ) + ) + :Lois + ) + + SubClassOf( :Man :Person ) +) + + + + + + + + + + + + + + + + + New-Feature-NegativeDataPropertyAssertion-001 + Mike Smith + Demonstrates use of a negative data property assertion to create a trivial inconsistency based on an example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:DatatypeProperty rdf:about="hasAge" /> + +<owl:NegativePropertyAssertion> + <owl:sourceIndividual rdf:resource="Meg" /> + <owl:assertionProperty rdf:resource="hasAge" /> + <owl:targetValue rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">5</owl:targetValue> +</owl:NegativePropertyAssertion> + +<rdf:Description rdf:about="Meg"> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">5</hasAge> +</rdf:Description> + +</rdf:RDF> + Prefix( xsd: = <http://www.w3.org/2001/XMLSchema#> ) +Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( DataProperty( :hasAge ) ) + + NegativeDataPropertyAssertion( :hasAge :Meg "5"^^xsd:integer ) + DataPropertyAssertion( :hasAge :Meg "5"^^xsd:integer ) +) + + + + + + + + + + + + New-Feature-NegativeObjectPropertyAssertion-001 + Mike Smith + Demonstrates use of a negative object property assertion to create a trivial inconsistency based on an example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:ObjectProperty rdf:about="hasSon" /> + +<owl:NegativePropertyAssertion> + <owl:sourceIndividual rdf:resource="Peter" /> + <owl:assertionProperty rdf:resource="hasSon" /> + <owl:targetIndividual rdf:resource="Meg" /> +</owl:NegativePropertyAssertion> + +<rdf:Description rdf:about="Peter"> + <hasSon rdf:resource="Meg" /> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( ObjectProperty( :hasSon ) ) + + NegativeObjectPropertyAssertion( :hasSon :Peter :Meg ) + ObjectPropertyAssertion( :hasSon :Peter :Meg ) +) + + + + + + + + + + + + + New-Feature-ObjectPropertyChain-001 + Mike Smith + Demonstrates an object property chain in a subproperty axiom based on the example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<rdf:Description rdf:about="Stewie"> + <hasAunt rdf:resource="Carol" /> +</rdf:Description> + +</rdf:RDF> + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:ObjectProperty rdf:about="hasMother" /> +<owl:ObjectProperty rdf:about="hasSister" /> +<owl:ObjectProperty rdf:about="hasAunt" /> + +<rdf:Description rdf:about="hasAunt"> + <owl:propertyChainAxiom rdf:parseType="Collection"> + <rdf:Description rdf:about="hasMother" /> + <rdf:Description rdf:about="hasSister" /> + </owl:propertyChainAxiom> +</rdf:Description> + +<rdf:Description rdf:about="Stewie"> + <hasMother rdf:resource="Lois" /> +</rdf:Description> + +<rdf:Description rdf:about="Lois"> + <hasSister rdf:resource="Carol" /> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( ObjectProperty( :hasAunt ) ) + + ObjectPropertyAssertion( :hasAunt :Stewie :Carol ) +) + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( ObjectProperty( :hasMother ) ) + Declaration( ObjectProperty( :hasSister ) ) + Declaration( ObjectProperty( :hasAunt ) ) + + SubObjectPropertyOf( ObjectPropertyChain( :hasMother :hasSister ) :hasAunt ) + + ObjectPropertyAssertion( :hasMother :Stewie :Lois ) + ObjectPropertyAssertion( :hasSister :Lois :Carol ) +) + + + + + + + + + + + + + New-Feature-ObjectPropertyChain-BJP-003 + Bijan Parsia + A simple test of role chains and role hierarchy. + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + + <owl:Ontology/> + <rdf:Description rdf:about="a"> + <p rdf:resource="c"/> + </rdf:Description> + +</rdf:RDF> + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdfs= "http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + + <rdf:Description rdf:about="p"> + <owl:propertyChainAxiom rdf:parseType="Collection"> + <owl:ObjectProperty rdf:about="p"/> + <owl:ObjectProperty rdf:about="q"/> + </owl:propertyChainAxiom> + </rdf:Description> + + <rdf:Description rdf:about="a"> + <p rdf:resource="b"/> + </rdf:Description> + + <rdf:Description rdf:about="b"> + <q rdf:resource="c"/> + </rdf:Description> + +</rdf:RDF> + + + + + + + + + + + + + New-Feature-ObjectPropertyChain-BJP-004 + Bijan Parsia + A test of an interaction between a role chain +hierarchy and transitivity axioms. + + + + + + + + + <rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + + <owl:Ontology/> + <owl:ObjectProperty rdf:about="p"/> + <owl:TransitiveProperty rdf:about="p"/> +</rdf:RDF> + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdfs= "http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + + <rdf:Description rdf:about="p"> + <owl:propertyChainAxiom rdf:parseType="Collection"> + <owl:ObjectProperty rdf:about="p"/> + <owl:ObjectProperty rdf:about="q"/> + </owl:propertyChainAxiom> + </rdf:Description> + + <rdf:Description rdf:about="a"> + <q rdf:resource="b"/> + </rdf:Description> + + <rdf:Description rdf:about="b"> + <q rdf:resource="c"/> + </rdf:Description> + +</rdf:RDF> + + + + + + + + + + + + + New-Feature-ObjectQCR-001 + Mike Smith + Demonstrates a qualified minimum cardinality object property restriction based on example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:ObjectProperty rdf:about="fatherOf" /> +<owl:Class rdf:about="Man" /> + +<rdf:Description rdf:about="Peter"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="fatherOf" /> + <owl:minQualifiedCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">2</owl:minQualifiedCardinality> + <owl:onClass rdf:resource="Man" /> + </owl:Restriction> + </rdf:type> +</rdf:Description> + +</rdf:RDF> + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:ObjectProperty rdf:about="fatherOf" /> +<owl:Class rdf:about="Man" /> + +<rdf:Description rdf:about="Peter"> + <fatherOf rdf:resource="Stewie" /> + <fatherOf rdf:resource="Chris" /> +</rdf:Description> + +<Man rdf:about="Stewie" /> +<Man rdf:about="Chris" /> + +<rdf:Description rdf:about="Stewie"> + <owl:differentFrom rdf:resource="Chris" /> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( ObjectProperty( :fatherOf ) ) + Declaration( Class( :Man ) ) + + ClassAssertion( ObjectMinCardinality( 2 :fatherOf :Man ) :Peter ) +) + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( ObjectProperty( :fatherOf ) ) + Declaration( Class( :Man ) ) + + ObjectPropertyAssertion( :fatherOf :Peter :Stewie ) + ObjectPropertyAssertion( :fatherOf :Peter :Chris ) + + ClassAssertion( :Man :Stewie ) + ClassAssertion( :Man :Chris ) + + DifferentIndividuals( :Chris :Stewie ) +) + + + + + + + + + + + + + + + + + + + + + + + + New-Feature-ObjectQCR-002 + Mike Smith + Demonstrates a qualified maximum cardinality object property restriction adapted from example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:Class rdf:about="Woman" /> + +<rdf:Description rdf:about="Stewie"> + <rdf:type> + <owl:Class> + <owl:complementOf rdf:resource="Woman" /> + </owl:Class> + </rdf:type> +</rdf:Description> + +</rdf:RDF> + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:ObjectProperty rdf:about="fatherOf" /> +<owl:Class rdf:about="Woman" /> + +<rdf:Description rdf:about="Peter"> + <fatherOf rdf:resource="Stewie" /> + <fatherOf rdf:resource="Meg" /> +</rdf:Description> + +<Woman rdf:about="Meg" /> + +<rdf:Description rdf:about="Peter"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="fatherOf" /> + <owl:maxQualifiedCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:maxQualifiedCardinality> + <owl:onClass rdf:resource="Woman" /> + </owl:Restriction> + </rdf:type> +</rdf:Description> + +<rdf:Description rdf:about="Stewie"> + <owl:differentFrom rdf:resource="Meg" /> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( Class( :Woman ) ) + + ClassAssertion( ObjectComplementOf( :Woman ) :Stewie ) +) + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( ObjectProperty( :fatherOf ) ) + Declaration( Class( :Woman ) ) + + ObjectPropertyAssertion( :fatherOf :Peter :Stewie ) + ObjectPropertyAssertion( :fatherOf :Peter :Meg ) + + ClassAssertion( :Woman :Meg ) + ClassAssertion( ObjectMaxCardinality( 1 :fatherOf :Woman ) :Peter ) + + DifferentIndividuals( :Stewie :Meg ) +) + + + + + + + + + + + + + + + + + New-Feature-Rational-001 + Mike Smith + Birte Glimm + A consistent ontology using owl:rational + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:DatatypeProperty rdf:about="dp" /> + +<rdf:Description rdf:about="a"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="dp" /> + <owl:allValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#rational" /> + </owl:Restriction> + </rdf:type> +</rdf:Description> + +<rdf:Description rdf:about="a"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="dp" /> + <owl:minCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">2</owl:minCardinality> + </owl:Restriction> + </rdf:type> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) +Prefix( owl: = <http://www.w3.org/2002/07/owl#> ) + +Ontology( + Declaration( DataProperty( :dp ) ) + ClassAssertion( DataAllValuesFrom( :dp owl:rational ) :a ) + ClassAssertion( DataMinCardinality( 2 :dp ) :a ) +) + + + + + + + + + + + + + + + + + + + + + + New-Feature-Rational-002 + Mike Smith + Birte Glimm + An inconsistent ontology using owl:rational + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs= "http://www.w3.org/2000/01/rdf-schema#"> + +<owl:Ontology/> + +<owl:DatatypeProperty rdf:about="dp" /> + +<rdf:Description rdf:about="a"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="dp" /> + <owl:allValuesFrom> + <rdfs:Datatype> + <owl:oneOf> + <rdf:Description> + <rdf:first rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">0.5</rdf:first> + <rdf:rest> + <rdf:Description> + <rdf:first rdf:datatype="http://www.w3.org/2002/07/owl#rational">1/2</rdf:first> + <rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/> + </rdf:Description> + </rdf:rest> + </rdf:Description> + </owl:oneOf> + </rdfs:Datatype> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> +</rdf:Description> + +<rdf:Description rdf:about="a"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="dp" /> + <owl:minCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">2</owl:minCardinality> + </owl:Restriction> + </rdf:type> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) +Prefix( owl: = <http://www.w3.org/2002/07/owl#> ) +Prefix( xsd: = <http://www.w3.org/2001/XMLSchema#> ) + +Ontology( + Declaration( DataProperty( :dp ) ) + ClassAssertion( DataAllValuesFrom( :dp DataOneOf( "0.5"^^xsd:decimal "1/2"^^owl:rational ) ) :a ) + ClassAssertion( DataMinCardinality( 2 :dp ) :a ) +) + + + + + + + + + + + + + + + + + + + + + + New-Feature-Rational-003 + Mike Smith + Birte Glimm + A consistent ontology demonstrating owl:rational is different from xsd:decimal. The decimal literal requires 16 digits, the minimum required for conformance. + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs= "http://www.w3.org/2000/01/rdf-schema#"> + +<owl:Ontology/> + +<owl:DatatypeProperty rdf:about="dp" /> + +<rdf:Description rdf:about="a"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="dp" /> + <owl:allValuesFrom> + <rdfs:Datatype> + <owl:oneOf> + <rdf:Description> + <rdf:first rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">0.3333333333333333</rdf:first> + <rdf:rest> + <rdf:Description> + <rdf:first rdf:datatype="http://www.w3.org/2002/07/owl#rational">1/3</rdf:first> + <rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/> + </rdf:Description> + </rdf:rest> + </rdf:Description> + </owl:oneOf> + </rdfs:Datatype> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> +</rdf:Description> + +<rdf:Description rdf:about="a"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="dp" /> + <owl:minCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">2</owl:minCardinality> + </owl:Restriction> + </rdf:type> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) +Prefix( owl: = <http://www.w3.org/2002/07/owl#> ) +Prefix( xsd: = <http://www.w3.org/2001/XMLSchema#> ) + +Ontology( + Declaration( DataProperty( :dp ) ) + ClassAssertion( DataAllValuesFrom( :dp DataOneOf( "0.3333333333333333"^^xsd:decimal "1/3"^^owl:rational ) ) :a ) + ClassAssertion( DataMinCardinality( 2 :dp ) :a ) +) + + + + + + + + + + + + + + + + + + + + + + + New-Feature-ReflexiveProperty-001 + Mike Smith + Uses a reflexive object property axiom to infer a property value based on the example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:ObjectProperty rdf:about="knows" /> + +<rdf:Description rdf:about="Peter"> + <knows rdf:resource="Peter" /> +</rdf:Description> + +</rdf:RDF> + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:ObjectProperty rdf:about="knows" /> +<owl:NamedIndividual rdf:about="Peter" /> + +<owl:ReflexiveProperty rdf:about="knows" /> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( ObjectProperty( :knows ) ) + + ObjectPropertyAssertion( :knows :Peter :Peter ) +) + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( ObjectProperty( :knows ) ) + Declaration( NamedIndividual( :Peter ) ) + + ReflexiveObjectProperty( :knows ) +) + + + + + + + + New-Feature-SelfRestriction-001 + Mike Smith + Demonstrates use of a self-restriction to infer a property value based on example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:ObjectProperty rdf:about="likes" /> + +<rdf:Description rdf:about="Peter"> + <likes rdf:resource="Peter" /> +</rdf:Description> + +</rdf:RDF> + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:ObjectProperty rdf:about="likes" /> + +<rdf:Description rdf:about="Peter"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="likes" /> + <owl:hasSelf rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</owl:hasSelf> + </owl:Restriction> + </rdf:type> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( ObjectProperty( :likes ) ) + + ObjectPropertyAssertion( :likes :Peter :Peter ) +) + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( ObjectProperty( :likes ) ) + + ClassAssertion( ObjectHasSelf( :likes ) :Peter ) +) + + + + + + + + + + + + + + + + + + New-Feature-SelfRestriction-002 + Mike Smith + Demonstrates use of an object property assertion to infer membership in a self restriction based on example in the Structural Specification and Functional-Style Syntax document. + + + + + + + + + + + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:ObjectProperty rdf:about="likes" /> + +<rdf:Description rdf:about="Peter"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="likes" /> + <owl:hasSelf rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</owl:hasSelf> + </owl:Restriction> + </rdf:type> +</rdf:Description> + +</rdf:RDF> + <?xml version="1.0"?> +<rdf:RDF + xml:base = "http://example.org/" + xmlns = "http://example.org/" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<owl:Ontology/> + +<owl:ObjectProperty rdf:about="likes" /> + +<rdf:Description rdf:about="Peter"> + <likes rdf:resource="Peter" /> +</rdf:Description> + +</rdf:RDF> + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( ObjectProperty( :likes ) ) + + ClassAssertion( ObjectHasSelf( :likes ) :Peter ) +) + Prefix( : = <http://example.org/> ) + +Ontology( + Declaration( ObjectProperty( :likes ) ) + + ObjectPropertyAssertion( :likes :Peter :Peter ) +) + + + + + + + + + + + + + + + + + one=two + Alan Ruttenberg + Start with 3 classes, a,b,c and relate them so instances have to be in a 1:1 relationship with each other. + +The class b-and-c is the union of b and c. Therefore there have to be 2 instances of b-and-c for every instance of a. + +Relate the class 2a to b-and-c so that *their* instances are in 1:1 relationship. + +Now relate 2a to a so that *their* instances are in a 1:1 relationship. This should lead to a situation in which every instance +of 2a is 1:1 with an instance of a, and at the same time 2:1 with an instance of a. + +Unless all the classes have an infinite number of members or are empty this doesn't work. This example has a is the enumerated class {i,j,k} (i,j,k all different individuals). So it should be inconsistent. + + + + + + + <rdf:RDF xmlns="http://example.com/" + xml:base="http://example.com/" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + <owl:Ontology rdf:about=""/> + + <owl:ObjectProperty rdf:about="2a=a"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#InverseFunctionalProperty"/> + <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">2a-to-a</rdfs:label> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:about="2a=b-and-c"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#InverseFunctionalProperty"/> + <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">2a-to-b-and-c</rdfs:label> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:about="a=2a'"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#InverseFunctionalProperty"/> + <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">a-to-2a'</rdfs:label> + <owl:inverseOf rdf:resource="2a=a"/> + </owl:ObjectProperty> + + + <owl:ObjectProperty rdf:about="a=b"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#InverseFunctionalProperty"/> + <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">a-to-b</rdfs:label> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:about="b-and-c=2a'"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#InverseFunctionalProperty"/> + <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">b-and-c-to-2a'</rdfs:label> + <owl:inverseOf rdf:resource="2a=b-and-c"/> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:about="b=a'"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#InverseFunctionalProperty"/> + <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">b-to-a'</rdfs:label> + <owl:inverseOf rdf:resource="a=b"/> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:about="b=c"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#InverseFunctionalProperty"/> + <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">b-to-c</rdfs:label> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:about="c=b'"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#InverseFunctionalProperty"/> + <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">c-to-b'</rdfs:label> + <owl:inverseOf rdf:resource="b=c"/> + </owl:ObjectProperty> + + <owl:Class rdf:about="2a"> + <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">2a</rdfs:label> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="2a=b-and-c"/> + <owl:someValuesFrom rdf:resource="b-and-c"/> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="2a=a"/> + <owl:someValuesFrom rdf:resource="a"/> + </owl:Restriction> + </rdfs:subClassOf> + <owl:disjointWith rdf:resource="a"/> + <owl:disjointWith rdf:resource="b"/> + <owl:disjointWith rdf:resource="b-and-c"/> + <owl:disjointWith rdf:resource="c"/> + </owl:Class> + + <owl:Class rdf:about="a"> + <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">a</rdfs:label> + <owl:equivalentClass> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <rdf:Description rdf:about="http://example.com/j"/> + <rdf:Description rdf:about="http://example.com/k"/> + <rdf:Description rdf:about="http://example.com/i"/> + </owl:oneOf> + </owl:Class> + </owl:equivalentClass> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="a=b"/> + <owl:someValuesFrom rdf:resource="b"/> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="a=2a'"/> + <owl:someValuesFrom rdf:resource="2a"/> + </owl:Restriction> + </rdfs:subClassOf> + <owl:disjointWith rdf:resource="b"/> + <owl:disjointWith rdf:resource="c"/> + </owl:Class> + + <owl:Class rdf:about="b"> + <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">b</rdfs:label> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="b=a'"/> + <owl:someValuesFrom rdf:resource="a"/> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="b=c"/> + <owl:someValuesFrom rdf:resource="c"/> + </owl:Restriction> + </rdfs:subClassOf> + <owl:disjointWith rdf:resource="c"/> + </owl:Class> + + <owl:Class rdf:about="b-and-c"> + <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">b-and-c</rdfs:label> + <owl:equivalentClass> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <rdf:Description rdf:about="b"/> + <rdf:Description rdf:about="c"/> + </owl:unionOf> + </owl:Class> + </owl:equivalentClass> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="b-and-c=2a'"/> + <owl:someValuesFrom rdf:resource="2a"/> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:about="c"> + <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">c</rdfs:label> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="c=b'"/> + <owl:someValuesFrom rdf:resource="b"/> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <rdf:Description rdf:about="http://example.com/i"> + <rdfs:label>i</rdfs:label> + </rdf:Description> + + <rdf:Description rdf:about="http://example.com/j"> + <rdfs:label>j</rdfs:label> + </rdf:Description> + + <rdf:Description rdf:about="http://example.com/k"> + <rdfs:label>k</rdfs:label> + </rdf:Description> + + <rdf:Description> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#AllDifferent"/> + <owl:distinctMembers rdf:parseType="Collection"> + <rdf:Description rdf:about="http://example.com/j"/> + <rdf:Description rdf:about="http://example.com/k"/> + <rdf:Description rdf:about="http://example.com/i"/> + </owl:distinctMembers> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + owl2-rl-anonymous-individual + Zhe Wu + OWL 2 RL allows anonymous individual. + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:j.0="http://owl2.test/rules#"> + <owl:Ontology /> + <owl:ObjectProperty rdf:about="http://owl2.test/rules#op"/> + <owl:NamedIndividual rdf:about="http://owl2.test/rules#I"/> + <owl:NamedIndividual> + <j.0:op rdf:resource="http://owl2.test/rules#I"/> + </owl:NamedIndividual> +</rdf:RDF> + + + + + + + + + + + + + + + + + owl2-rl-invalid-leftside-allvaluesfrom + Zhe Wu + OWL 2 RL does not allow left side allValuesFrom in a subClassOf axiom. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:Ontology /> + <owl:Class rdf:about="http://owl2.test/rules#C"/> + <owl:Class rdf:about="http://owl2.test/rules#C1"/> + <owl:ObjectProperty rdf:about="http://owl2.test/rules#op"/> + <owl:Restriction> + <owl:allValuesFrom rdf:resource="http://owl2.test/rules#C1"/> + <owl:onProperty rdf:resource="http://owl2.test/rules#op"/> + <rdfs:subClassOf rdf:resource="http://owl2.test/rules#C"/> + </owl:Restriction> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + owl2-rl-invalid-leftside-maxcard + Zhe Wu + Invalid OWL 2 RL due to maxCardinality usage. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:Ontology /> + <owl:Class rdf:about="http://owl2.test/rules#C"/> + <owl:ObjectProperty rdf:about="http://owl2.test/rules#op"/> + <owl:Restriction> + <rdfs:subClassOf rdf:resource="http://owl2.test/rules#C"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >2</owl:maxCardinality> + <owl:onProperty rdf:resource="http://owl2.test/rules#op"/> + </owl:Restriction> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + owl2-rl-invalid-oneof + Zhe Wu + OWL 2 RL does not permit owl:oneOf to define a named class (it can be used as a subclass expression). + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#"> + <owl:Ontology /> + <owl:Class rdf:about="http://owl2.test/rules#Cb"> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="http://owl2.test/rules#X"/> + <owl:Thing rdf:about="http://owl2.test/rules#Y"/> + </owl:oneOf> + </owl:Class> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + owl2-rl-invalid-owlreal + Zhe Wu + Invalid OWL 2 RL because owl:real is used. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:Ontology /> + <owl:Class rdf:about="http://owl2.test/rules#C_Sub"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:allValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#real"/> + <owl:onProperty> + <owl:DatatypeProperty rdf:about="http://owl2.test/rules#p"/> + </owl:onProperty> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + owl2-rl-invalid-rightside-somevaluesfrom + Zhe Wu + This is not a valid OWL 2 RL because someValuesFrom shows up on the right hand side of a SubClassOf axiom. + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#"> + <owl:Ontology /> + <owl:Class rdf:about="http://owl2.test/rules#C_Sub"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:someValuesFrom> + <owl:Class rdf:about="http://owl2.test/rules#C1"/> + </owl:someValuesFrom> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://owl2.test/rules#p"/> + </owl:onProperty> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> +</rdf:RDF> + + + + + + + + + + + + owl2-rl-invalid-rightside-unionof + Zhe Wu + Incorrect OWL 2 RL syntax. unionOf shows up at the right hand side of a SubClassOf axiom. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:Ontology /> + <owl:Class rdf:about="http://owl2.test/rules#C_Sub"> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://owl2.test/rules#C1"/> + <owl:Class rdf:about="http://owl2.test/rules#C2"/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + owl2-rl-invalid-unionof + Zhe Wu + OWL 2 RL does not allow owl:unionOf to define a named class (it can be used as a subclass expression). + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#"> + <owl:Ontology /> + <owl:Class rdf:about="http://owl2.test/rules#C"> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://owl2.test/rules#C1"/> + <owl:Class rdf:about="http://owl2.test/rules#C2"/> + </owl:unionOf> + </owl:Class> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + owl2-rl-rules-fp-differentFrom + Zhe Wu + This test checks the interaction between an OWL functional property and differentFrom assertions. + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#"> + <owl:Ontology /> + <owl:NamedIndividual rdf:about="http://owl2.test/rules/Y2"/> + <owl:NamedIndividual rdf:about="http://owl2.test/rules/Y1"> + <owl:differentFrom rdf:resource="http://owl2.test/rules/Y2"/> + </owl:NamedIndividual> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:j.0="http://owl2.test/rules/"> + <owl:Ontology /> + <owl:FunctionalProperty rdf:about="http://owl2.test/rules/fp"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/> + </owl:FunctionalProperty> + <owl:NamedIndividual rdf:about="http://owl2.test/rules/Y2"> + <j.0:fp> + <owl:NamedIndividual rdf:about="http://owl2.test/rules/X2"/> + </j.0:fp> + </owl:NamedIndividual> + <owl:NamedIndividual rdf:about="http://owl2.test/rules/X1"> + <owl:differentFrom rdf:resource="http://owl2.test/rules/X2"/> + </owl:NamedIndividual> + <owl:NamedIndividual rdf:about="http://owl2.test/rules/Y1"> + <j.0:fp rdf:resource="http://owl2.test/rules/X1"/> + </owl:NamedIndividual> +</rdf:RDF> + + + + + + + + + + + + + + + + + + owl2-rl-rules-ifp-differentFrom + Zhe Wu + This test checks the interaction between inverse functional property and differentFrom assertions. + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#"> + <owl:Ontology /> + <owl:NamedIndividual rdf:about="http://owl2.test/rules/X1"> + <owl:differentFrom> + <owl:NamedIndividual rdf:about="http://owl2.test/rules/X2"/> + </owl:differentFrom> + </owl:NamedIndividual> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:j.0="http://owl2.test/rules/"> + <owl:Ontology /> + <owl:InverseFunctionalProperty rdf:about="http://owl2.test/rules/ifp"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/> + </owl:InverseFunctionalProperty> + <owl:NamedIndividual rdf:about="http://owl2.test/rules/Y2"> + <j.0:ifp> + <owl:NamedIndividual rdf:about="http://owl2.test/rules/X2"/> + </j.0:ifp> + </owl:NamedIndividual> + <owl:NamedIndividual rdf:about="http://owl2.test/rules/X1"/> + <owl:NamedIndividual rdf:about="http://owl2.test/rules/Y1"> + <owl:differentFrom rdf:resource="http://owl2.test/rules/Y2"/> + <j.0:ifp rdf:resource="http://owl2.test/rules/X1"/> + </owl:NamedIndividual> +</rdf:RDF> + + + + + + + + + + + + + + + + + owl2-rl-valid-mincard + Zhe Wu + OWL 2 RL does not allow min cardinality + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:j.0="http://owl2.test/rules#"> + <owl:Ontology rdf:about="http://org.semanticweb.ontologies/Ontology1232054810511161000"/> + <owl:Class rdf:about="http://owl2.test/rules#C"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:minCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://owl2.test/rules#OP"/> + </owl:onProperty> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"/> + <j.0:C rdf:about="http://owl2.test/rules#c"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing"/> + </j.0:C> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + owl2-rl-valid-oneof + Zhe Wu + A valid usage of oneOf in OWL 2 RL + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#"> + <owl:Ontology /> + <owl:Class rdf:about="http://owl2.test/rules#Cb"/> + <owl:NamedIndividual rdf:about="http://owl2.test/rules#X"/> + <owl:NamedIndividual rdf:about="http://owl2.test/rules#Y"/> + <rdf:Description> + <rdfs:subClassOf rdf:resource="http://owl2.test/rules#Cb"/> + <owl:oneOf rdf:parseType="Collection"> + <owl:NamedIndividual rdf:about="http://owl2.test/rules#X"/> + <owl:NamedIndividual rdf:about="http://owl2.test/rules#Y"/> + </owl:oneOf> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + owl2-rl-valid-rightside-allvaluesfrom + Zhe Wu + Valid RL usage of allValuesFrom. + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#"> + <owl:Ontology /> + <owl:Class rdf:about="http://owl2.test/rules#C"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://owl2.test/rules#op"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="http://owl2.test/rules#C1"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> +</rdf:RDF> + + + + + + + + + + + + + + + + + Plus and Minus Zero Integer + Birte Glimm + For integers 0 and -0 are the same value, so the ontology is consistent. + + + + + + + Prefix(:=<http://example.org/>) +Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>) +Ontology( + Declaration(NamedIndividual(:a)) + Declaration(DataProperty(:dp)) + Declaration(Class(:A)) + SubClassOf(:A DataAllValuesFrom(:dp + DataOneOf("0"^^xsd:integer)) + ) + ClassAssertion(:A :a) + ClassAssertion( + DataSomeValuesFrom(:dp DataOneOf("-0"^^xsd:integer)) :a + ) +) + + + + + + + + + + + + + + + + + + + + + + Plus and Minus Zero are Distinct + Birte Glimm + For floats and double, +0.0 and -0.0 are distinct values, which contradicts the functionality for numberOfChildren. + + + + + + + + + Prefix(:=<http://example.org/>) +Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>) +Ontology( + Declaration(NamedIndividual(:Meg)) + Declaration(DataProperty(:numberOfChildren)) + DataPropertyAssertion(:numberOfChildren :Meg "+0.0"^^xsd:float) + DataPropertyAssertion(:numberOfChildren :Meg "-0.0"^^xsd:float) + FunctionalDataProperty(:numberOfChildren) +) + + + + + + + + + + + + rdfbased-sem-bool-complement-inst + Michael Schneider + Kai Mainzer + An individual cannot be an instance of both a class and its complement. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:c1 rdf:about="http://www.example.org#x"> + <rdf:type rdf:resource="http://www.example.org#c2"/> + </ex:c1> + <rdf:Description rdf:about="http://www.example.org#c1"> + <owl:complementOf rdf:resource="http://www.example.org#c2"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-bool-intersection-inst-comp + Michael Schneider + Kai Mainzer + An individual, which is an instance of every component class of an intersection, is an instance of the intersection class expression. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:c rdf:about="http://www.example.org#z"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:x rdf:about="http://www.example.org#z"> + <rdf:type rdf:resource="http://www.example.org#y"/> + </ex:x> + <rdf:Description rdf:about="http://www.example.org#c"> + <owl:intersectionOf rdf:parseType="Collection"> + <rdf:Description rdf:about="http://www.example.org#x"/> + <rdf:Description rdf:about="http://www.example.org#y"/> + </owl:intersectionOf> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-bool-intersection-inst-expr + Michael Schneider + Kai Mainzer + An individual, which is an instance of an intersection class expression of two classes, is an instance of every component class. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:x rdf:about="http://www.example.org#z"> + <rdf:type rdf:resource="http://www.example.org#y"/> + </ex:x> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:c rdf:about="http://www.example.org#z"/> + <rdf:Description rdf:nodeID="A0"> + <rdf:first rdf:resource="http://www.example.org#x"/> + <rdf:rest rdf:parseType="Collection"> + <rdf:Description rdf:about="http://www.example.org#y"/> + </rdf:rest> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#c"> + <owl:intersectionOf rdf:nodeID="A0"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-bool-intersection-term + Michael Schneider + Kai Mainzer + If a class is an intersection of other classes, then the original class is a subclass of each of the other classes. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#c"> + <rdfs:subClassOf rdf:resource="http://www.example.org#x"/> + <rdfs:subClassOf rdf:resource="http://www.example.org#y"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#c"> + <owl:intersectionOf rdf:parseType="Collection"> + <rdf:Description rdf:about="http://www.example.org#x"/> + <rdf:Description rdf:about="http://www.example.org#y"/> + </owl:intersectionOf> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-bool-union-inst-comp + Michael Schneider + Kai Mainzer + An individual, which is an instance of one of the component classes of a union, is an instance of the union class expression. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:c rdf:about="http://www.example.org#z"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:x rdf:about="http://www.example.org#z"/> + <rdf:Description rdf:about="http://www.example.org#c"> + <owl:unionOf rdf:parseType="Collection"> + <rdf:Description rdf:about="http://www.example.org#x"/> + <rdf:Description rdf:about="http://www.example.org#y"/> + </owl:unionOf> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-bool-union-term + Michael Schneider + Kai Mainzer + If a class is a union of other classes, then each of the other classes are subclasses of the original class. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x"> + <rdfs:subClassOf rdf:resource="http://www.example.org#c"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#y"> + <rdfs:subClassOf rdf:resource="http://www.example.org#c"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#c"> + <owl:unionOf rdf:parseType="Collection"> + <rdf:Description rdf:about="http://www.example.org#x"/> + <rdf:Description rdf:about="http://www.example.org#y"/> + </owl:unionOf> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-chain-def + Michael Schneider + Kai Mainzer + For a sub property chain axiom with super property p and chain properties p1 and p2, from x p1 y and y p2 z follows x p z. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x"> + <ex:p rdf:resource="http://www.example.org#z"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x"> + <ex:p1> + <rdf:Description rdf:about="http://www.example.org#y"> + <ex:p2 rdf:resource="http://www.example.org#z"/> + </rdf:Description> + </ex:p1> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#p"> + <owl:propertyChainAxiom rdf:parseType="Collection"> + <rdf:Description rdf:about="http://www.example.org#p1"/> + <rdf:Description rdf:about="http://www.example.org#p2"/> + </owl:propertyChainAxiom> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-char-asymmetric-inst + Michael Schneider + Kai Mainzer + For a triple having an asymmetrical property as its predicate, the reverse triple must not exist. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:AsymmetricProperty rdf:about="http://www.example.org#p"/> + <rdf:Description rdf:about="http://www.example.org#x"> + <ex:p> + <rdf:Description rdf:about="http://www.example.org#y"> + <ex:p rdf:resource="http://www.example.org#x"/> + </rdf:Description> + </ex:p> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-char-asymmetric-term + Michael Schneider + Kai Mainzer + A non-empty property cannot be both symmetrical and asymmetrical. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:SymmetricProperty rdf:about="http://www.example.org#p"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#AsymmetricProperty"/> + </owl:SymmetricProperty> + <rdf:Description rdf:about="http://www.example.org#x"> + <ex:p rdf:resource="http://www.example.org#y"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-char-functional-inst + Michael Schneider + Kai Mainzer + For two triples with the same functional property as their predicates and with the same subject, the objects are the same. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#y1"> + <owl:sameAs rdf:resource="http://www.example.org#y2"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:FunctionalProperty rdf:about="http://www.example.org#p"/> + <rdf:Description rdf:about="http://www.example.org#x"> + <ex:p rdf:resource="http://www.example.org#y1"/> + <ex:p rdf:resource="http://www.example.org#y2"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-char-inversefunc-data + Michael Schneider + Kai Mainzer + For two triples with the same inverse functional data property as their predicates and with the same data object, the subjects are the same. This test shows that the OWL 2 RDF-Based Semantics allows for IFDPs. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x1"> + <owl:sameAs rdf:resource="http://www.example.org#x2"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:InverseFunctionalProperty rdf:about="http://www.example.org#p"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/> + </owl:InverseFunctionalProperty> + <rdf:Description rdf:about="http://www.example.org#x1"> + <ex:p>data</ex:p> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#x2"> + <ex:p>data</ex:p> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-char-inversefunc-inst + Michael Schneider + Kai Mainzer + For two triples with the same inverse functional property as their predicates and with the same object, the subjects are the same. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x1"> + <owl:sameAs rdf:resource="http://www.example.org#x2"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:InverseFunctionalProperty rdf:about="http://www.example.org#p"/> + <rdf:Description rdf:about="http://www.example.org#x1"> + <ex:p rdf:resource="http://www.example.org#y"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#x2"> + <ex:p rdf:resource="http://www.example.org#y"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-char-irreflexive-inst + Michael Schneider + Kai Mainzer + For an irreflexive property, there must not exist any reflexive triple. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:IrreflexiveProperty rdf:about="http://www.example.org#p"/> + <rdf:Description rdf:about="http://www.example.org#x"> + <ex:p rdf:resource="http://www.example.org#x"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-char-symmetric-inst + Michael Schneider + Kai Mainzer + For a triple having a symmetrical property as its predicate, the reverse triple also exists. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#y"> + <ex:p rdf:resource="http://www.example.org#x"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:SymmetricProperty rdf:about="http://www.example.org#p"/> + <rdf:Description rdf:about="http://www.example.org#x"> + <ex:p rdf:resource="http://www.example.org#y"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-char-transitive-inst + Michael Schneider + Kai Mainzer + For two chained triples having the same transitive property as their predicate, the transitive result triple also exists. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x"> + <ex:p rdf:resource="http://www.example.org#z"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:TransitiveProperty rdf:about="http://www.example.org#p"/> + <rdf:Description rdf:about="http://www.example.org#x"> + <ex:p> + <rdf:Description rdf:about="http://www.example.org#y"> + <ex:p rdf:resource="http://www.example.org#z"/> + </rdf:Description> + </ex:p> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-class-nothing-ext + Michael Schneider + Kai Mainzer + The extension of the vocabulary class owl:Nothing is empty. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:Nothing rdf:about="http://www.example.org#x"/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-class-nothing-term + Michael Schneider + Kai Mainzer + Every OWL class is a super class of the vocabulary class owl:Nothing. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.w3.org/2002/07/owl#Nothing"> + <rdfs:subClassOf rdf:resource="http://www.example.org#c"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:Class rdf:about="http://www.example.org#c"/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-class-nothing-type + Michael Schneider + Kai Mainzer + The type of the vocabulary class owl:Nothing is the class of OWL classes. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Nothing"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-class-thing-term + Michael Schneider + Kai Mainzer + Every OWL class is a sub class of the vocabulary class owl:Thing. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#c"> + <rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:Class rdf:about="http://www.example.org#c"/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-class-thing-type + Michael Schneider + Kai Mainzer + The type of the vocabulary class owl:Thing is the class of OWL classes. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-enum-inst-included + Michael Schneider + Kai Mainzer + If a class defines an enumeration class expression from two individuals, than both individuals are instances of the class. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:e rdf:about="http://www.example.org#x"/> + <ex:e rdf:about="http://www.example.org#y"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#e"> + <owl:oneOf rdf:parseType="Collection"> + <rdf:Description rdf:about="http://www.example.org#x"/> + <rdf:Description rdf:about="http://www.example.org#y"/> + </owl:oneOf> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-different-irrflxv + Michael Schneider + Kai Mainzer + Diversity of two individuals is irreflexive. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x"> + <owl:differentFrom rdf:resource="http://www.example.org#x"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-different-sameas + Michael Schneider + Kai Mainzer + Two individuals cannot both be the same and different. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x"> + <owl:sameAs rdf:resource="http://www.example.org#y"/> + <owl:differentFrom rdf:resource="http://www.example.org#y"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-disclass-eqclass + Michael Schneider + Kai Mainzer + Two non-empty classes cannot both be equivalent and disjoint. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:c1 rdf:about="http://www.example.org#x"/> + <ex:c2 rdf:about="http://www.example.org#y"/> + <rdf:Description rdf:about="http://www.example.org#c1"> + <owl:equivalentClass rdf:resource="http://www.example.org#c2"/> + <owl:disjointWith rdf:resource="http://www.example.org#c2"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-disclass-inst + Michael Schneider + Kai Mainzer + Individuals being instances of disjoint classes are different from each other. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:c1 rdf:about="http://www.example.org#w"> + <rdf:type rdf:resource="http://www.example.org#c2"/> + </ex:c1> + <rdf:Description rdf:about="http://www.example.org#c1"> + <owl:disjointWith rdf:resource="http://www.example.org#c2"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-disclass-irrflxv + Michael Schneider + Kai Mainzer + Disjointness of two non-empty classes is irreflexive. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:c rdf:about="http://www.example.org#x"/> + <rdf:Description rdf:about="http://www.example.org#c"> + <owl:disjointWith rdf:resource="http://www.example.org#c"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-disprop-eqprop + Michael Schneider + Kai Mainzer + Two non-empty properties cannot both be equivalent and disjoint. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#s2"> + <ex:p2 rdf:resource="http://www.example.org#o2"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#s1"> + <ex:p1 rdf:resource="http://www.example.org#o1"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#p1"> + <owl:equivalentProperty rdf:resource="http://www.example.org#p2"/> + <owl:propertyDisjointWith rdf:resource="http://www.example.org#p2"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-disprop-inst + Michael Schneider + Kai Mainzer + Triples with disjoint properties as their predicates have different subjects or different objects. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#s"> + <ex:p1 rdf:resource="http://www.example.org#o"/> + <ex:p2 rdf:resource="http://www.example.org#o"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#p1"> + <owl:propertyDisjointWith rdf:resource="http://www.example.org#p2"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-disprop-irrflxv + Michael Schneider + Kai Mainzer + Disjointness of two non-empty properties is irreflexive. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#s"> + <ex:p rdf:resource="http://www.example.org#o"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#p"> + <owl:propertyDisjointWith rdf:resource="http://www.example.org#p"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-eqclass-inst + Michael Schneider + Kai Mainzer + For two equivalent classes, any instance of one class is also an instance of the other class, and vice versa. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:c2 rdf:about="http://www.example.org#x"/> + <ex:c1 rdf:about="http://www.example.org#y"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:c1 rdf:about="http://www.example.org#x"/> + <ex:c2 rdf:about="http://www.example.org#y"/> + <rdf:Description rdf:about="http://www.example.org#c1"> + <owl:equivalentClass rdf:resource="http://www.example.org#c2"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-eqclass-rflxv + Michael Schneider + Kai Mainzer + Equivalence of two classes is reflexive. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#c"> + <owl:equivalentClass rdf:resource="http://www.example.org#c"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:Class rdf:about="http://www.example.org#c"/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-eqclass-subclass-1 + Michael Schneider + Kai Mainzer + Two equivalent classes are sub classes of each other. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#c2"> + <rdfs:subClassOf> + <rdf:Description rdf:about="http://www.example.org#c1"> + <rdfs:subClassOf rdf:resource="http://www.example.org#c2"/> + </rdf:Description> + </rdfs:subClassOf> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#c1"> + <owl:equivalentClass rdf:resource="http://www.example.org#c2"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-eqclass-subclass-2 + Michael Schneider + Kai Mainzer + Two classes that are sub classes of each other are equivalent classes. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#c1"> + <owl:equivalentClass rdf:resource="http://www.example.org#c2"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#c2"> + <rdfs:subClassOf> + <rdf:Description rdf:about="http://www.example.org#c1"> + <rdfs:subClassOf rdf:resource="http://www.example.org#c2"/> + </rdf:Description> + </rdfs:subClassOf> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-eqclass-subst + Michael Schneider + Kai Mainzer + Equivalence of two classes allows for substituting one class for the other in a sub class axiom. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#c1"> + <rdfs:subClassOf rdf:resource="http://www.example.org#d2"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#d1"> + <rdfs:subClassOf rdf:resource="http://www.example.org#c2"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#c1"> + <rdfs:subClassOf> + <rdf:Description rdf:about="http://www.example.org#c2"> + <owl:equivalentClass rdf:resource="http://www.example.org#d2"/> + </rdf:Description> + </rdfs:subClassOf> + <owl:equivalentClass rdf:resource="http://www.example.org#d1"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-eqclass-sym + Michael Schneider + Kai Mainzer + Equivalence of two classes is symmetrical. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#c2"> + <owl:equivalentClass rdf:resource="http://www.example.org#c1"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#c1"> + <owl:equivalentClass rdf:resource="http://www.example.org#c2"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-eqclass-trans + Michael Schneider + Kai Mainzer + Equivalence of two classes is transitive. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#c1"> + <owl:equivalentClass rdf:resource="http://www.example.org#c3"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#c1"> + <owl:equivalentClass> + <rdf:Description rdf:about="http://www.example.org#c2"> + <owl:equivalentClass rdf:resource="http://www.example.org#c3"/> + </rdf:Description> + </owl:equivalentClass> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-eqprop-inst + Michael Schneider + Kai Mainzer + For two equivalent properties and any triple having one property as its predicate, the corresponding triple having the other property as its predicate also exists, and vice versa. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#s2"> + <ex:p1 rdf:resource="http://www.example.org#o2"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#s1"> + <ex:p2 rdf:resource="http://www.example.org#o1"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#s2"> + <ex:p2 rdf:resource="http://www.example.org#o2"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#s1"> + <ex:p1 rdf:resource="http://www.example.org#o1"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#p1"> + <owl:equivalentProperty rdf:resource="http://www.example.org#p2"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-eqprop-rflxv + Michael Schneider + Kai Mainzer + Equivalence of two properties is reflexive. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#dp"> + <owl:equivalentProperty rdf:resource="http://www.example.org#dp"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#op"> + <owl:equivalentProperty rdf:resource="http://www.example.org#op"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:ObjectProperty rdf:about="http://www.example.org#op"/> + <owl:DatatypeProperty rdf:about="http://www.example.org#dp"/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-eqprop-subprop-1 + Michael Schneider + Kai Mainzer + Two equivalent properties are sub properties of each other. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#p2"> + <rdfs:subPropertyOf> + <rdf:Description rdf:about="http://www.example.org#p1"> + <rdfs:subPropertyOf rdf:resource="http://www.example.org#p2"/> + </rdf:Description> + </rdfs:subPropertyOf> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#p1"> + <owl:equivalentProperty rdf:resource="http://www.example.org#p2"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-eqprop-subprop-2 + Michael Schneider + Kai Mainzer + Two properties that are sub properties of each other are equivalent properties. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#p1"> + <owl:equivalentProperty rdf:resource="http://www.example.org#p2"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#p2"> + <rdfs:subPropertyOf> + <rdf:Description rdf:about="http://www.example.org#p1"> + <rdfs:subPropertyOf rdf:resource="http://www.example.org#p2"/> + </rdf:Description> + </rdfs:subPropertyOf> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-eqprop-subst + Michael Schneider + Kai Mainzer + Equivalence of two properties allows for substituting one property for the other in a sub property axiom. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#q1"> + <rdfs:subPropertyOf rdf:resource="http://www.example.org#p2"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#p1"> + <rdfs:subPropertyOf rdf:resource="http://www.example.org#q2"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#p1"> + <rdfs:subPropertyOf> + <rdf:Description rdf:about="http://www.example.org#p2"> + <owl:equivalentProperty rdf:resource="http://www.example.org#q2"/> + </rdf:Description> + </rdfs:subPropertyOf> + <owl:equivalentProperty rdf:resource="http://www.example.org#q1"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-eqprop-sym + Michael Schneider + Kai Mainzer + Equivalence of two properties is symmetrical. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#p2"> + <owl:equivalentProperty rdf:resource="http://www.example.org#p1"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#p1"> + <owl:equivalentProperty rdf:resource="http://www.example.org#p2"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-eqprop-trans + Michael Schneider + Kai Mainzer + Equivalence of two properties is transitive. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#p1"> + <owl:equivalentProperty rdf:resource="http://www.example.org#p3"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#p1"> + <owl:equivalentProperty> + <rdf:Description rdf:about="http://www.example.org#p2"> + <owl:equivalentProperty rdf:resource="http://www.example.org#p3"/> + </rdf:Description> + </owl:equivalentProperty> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-sameas-rflxv + Michael Schneider + Kai Mainzer + Equality of two individuals is reflexive. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#s"> + <owl:sameAs rdf:resource="http://www.example.org#s"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#o"> + <owl:sameAs rdf:resource="http://www.example.org#o"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#p"> + <owl:sameAs rdf:resource="http://www.example.org#p"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#s"> + <ex:p rdf:resource="http://www.example.org#o"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-sameas-subst + Michael Schneider + Kai Mainzer + Equality of two individuals allows for substituting the subject, predicate and object of an RDF triple by an equal individual. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#s2"> + <ex:p1 rdf:resource="http://www.example.org#o1"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#s1"> + <ex:p2 rdf:resource="http://www.example.org#o1"/> + <ex:p1 rdf:resource="http://www.example.org#o2"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#s2"> + <owl:sameAs> + <rdf:Description rdf:about="http://www.example.org#s1"> + <ex:p1 rdf:resource="http://www.example.org#o1"/> + </rdf:Description> + </owl:sameAs> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#o2"> + <owl:sameAs rdf:resource="http://www.example.org#o1"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#p2"> + <owl:sameAs rdf:resource="http://www.example.org#p1"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-sameas-sym + Michael Schneider + Kai Mainzer + Equality of two individuals is symmetrical. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#y"> + <owl:sameAs rdf:resource="http://www.example.org#x"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x"> + <owl:sameAs rdf:resource="http://www.example.org#y"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-eqdis-sameas-trans + Michael Schneider + Kai Mainzer + Equality of two individuals is transitive. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x"> + <owl:sameAs rdf:resource="http://www.example.org#z"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x"> + <owl:sameAs> + <rdf:Description rdf:about="http://www.example.org#y"> + <owl:sameAs rdf:resource="http://www.example.org#z"/> + </rdf:Description> + </owl:sameAs> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-inv-inst + Michael Schneider + Kai Mainzer + The subject and object of a triple are reversed by an inverse property. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#o1"> + <ex:q rdf:resource="http://www.example.org#s1"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#o2"> + <ex:p rdf:resource="http://www.example.org#s2"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#s2"> + <ex:q rdf:resource="http://www.example.org#o2"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#s1"> + <ex:p rdf:resource="http://www.example.org#o1"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#q"> + <owl:inverseOf rdf:resource="http://www.example.org#p"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-key-def + Michael Schneider + Kai Mainzer + For two triples matching the conditions of a key axiom the subjects are identified. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x"> + <owl:sameAs rdf:resource="http://www.example.org#y"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:c rdf:about="http://www.example.org#x"> + <ex:p1 rdf:resource="http://www.example.org#z"/> + <ex:p2>data</ex:p2> + </ex:c> + <ex:c rdf:about="http://www.example.org#y"> + <ex:p1 rdf:resource="http://www.example.org#z"/> + <ex:p2>data</ex:p2> + </ex:c> + <rdf:Description rdf:about="http://www.example.org#c"> + <owl:hasKey rdf:parseType="Collection"> + <rdf:Description rdf:about="http://www.example.org#p1"/> + <rdf:Description rdf:about="http://www.example.org#p2"/> + </owl:hasKey> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-ndis-alldifferent-fw + Michael Schneider + Kai Mainzer + All the members of an owl:AllDifferent construct are mutually different individuals. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:AllDifferent rdf:about="http://www.example.org#z"> + <owl:members rdf:parseType="Collection"> + <rdf:Description rdf:about="http://www.example.org#w1"> + <owl:sameAs rdf:resource="http://www.example.org#w2"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#w2"/> + <rdf:Description rdf:about="http://www.example.org#w3"/> + </owl:members> + </owl:AllDifferent> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-ndis-alldifferent-fw-distinctmembers + Michael Schneider + Kai Mainzer + All the members of an owl:AllDifferent construct are mutually different from each other. This test applies the legacy property owl:distinctMembers. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:AllDifferent rdf:about="http://www.example.org#z"> + <owl:distinctMembers rdf:parseType="Collection"> + <rdf:Description rdf:about="http://www.example.org#w1"> + <owl:sameAs rdf:resource="http://www.example.org#w2"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#w2"/> + <rdf:Description rdf:about="http://www.example.org#w3"/> + </owl:distinctMembers> + </owl:AllDifferent> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-ndis-alldisjointclasses-fw + Michael Schneider + Kai Mainzer + All the members of an owl:AllDisjointClasses construct are mutually disjoint classes. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:AllDisjointClasses rdf:about="http://www.example.org#z"> + <owl:members rdf:parseType="Collection"> + <rdf:Description rdf:about="http://www.example.org#c1"/> + <rdf:Description rdf:about="http://www.example.org#c2"/> + <rdf:Description rdf:about="http://www.example.org#c3"/> + </owl:members> + </owl:AllDisjointClasses> + <ex:c1 rdf:about="http://www.example.org#w"> + <rdf:type rdf:resource="http://www.example.org#c2"/> + </ex:c1> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-ndis-alldisjointproperties-fw + Michael Schneider + Kai Mainzer + All the members of an owl:AllDisjointProperties construct are mutually disjoint properties. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:AllDisjointProperties rdf:about="http://www.example.org#z"> + <owl:members rdf:parseType="Collection"> + <rdf:Description rdf:about="http://www.example.org#p1"/> + <rdf:Description rdf:about="http://www.example.org#p2"/> + <rdf:Description rdf:about="http://www.example.org#p3"/> + </owl:members> + </owl:AllDisjointProperties> + <rdf:Description rdf:about="http://www.example.org#s"> + <ex:p1 rdf:resource="http://www.example.org#o"/> + <ex:p2 rdf:resource="http://www.example.org#o"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-npa-dat-fw + Michael Schneider + Kai Mainzer + A negative data property assertion DNPA(s p "data") must not occur together with the corresponding positive data property assertion s p "data". + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#z"> + <owl:sourceIndividual> + <rdf:Description rdf:about="http://www.example.org#s"> + <ex:p>data</ex:p> + </rdf:Description> + </owl:sourceIndividual> + <owl:assertionProperty rdf:resource="http://www.example.org#p"/> + <owl:targetValue>data</owl:targetValue> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-npa-ind-fw + Michael Schneider + Kai Mainzer + A negative property assertion NPA(s p o) must not occur together with the corresponding positive property assertion s p o. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#z"> + <owl:sourceIndividual> + <rdf:Description rdf:about="http://www.example.org#s"> + <ex:p rdf:resource="http://www.example.org#o"/> + </rdf:Description> + </owl:sourceIndividual> + <owl:assertionProperty rdf:resource="http://www.example.org#p"/> + <owl:targetIndividual rdf:resource="http://www.example.org#o"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-prop-backwardcompatiblewith-type-annot + Michael Schneider + Kai Mainzer + The type of the vocabulary property owl:backwardCompatibleWith is the class of annotation properties. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:AnnotationProperty rdf:about="http://www.w3.org/2002/07/owl#backwardCompatibleWith"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-prop-comment-type + Michael Schneider + Kai Mainzer + The type of the vocabulary property rdfs:comment is the class of annotation properties. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:AnnotationProperty rdf:about="http://www.w3.org/2000/01/rdf-schema#comment"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-prop-deprecated-type + Michael Schneider + Kai Mainzer + The type of the vocabulary property owl:deprecated is the class of annotation properties. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:AnnotationProperty rdf:about="http://www.w3.org/2002/07/owl#deprecated"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-prop-incompatiblewith-type-annot + Michael Schneider + Kai Mainzer + The type of the vocabulary property owl:incompatibleWith is the class of annotation properties. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:AnnotationProperty rdf:about="http://www.w3.org/2002/07/owl#incompatibleWith"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-prop-isdefinedby-type + Michael Schneider + Kai Mainzer + The type of the vocabulary property rdfs:isDefinedBy is the class of annotation properties. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:AnnotationProperty rdf:about="http://www.w3.org/2000/01/rdf-schema#isDefinedBy"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-prop-label-type + Michael Schneider + Kai Mainzer + The type of the vocabulary property rdfs:label is the class of annotation properties. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:AnnotationProperty rdf:about="http://www.w3.org/2000/01/rdf-schema#label"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-prop-priorversion-type-annot + Michael Schneider + Kai Mainzer + The type of the vocabulary property owl:priorVersion is the class of annotation properties. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:AnnotationProperty rdf:about="http://www.w3.org/2002/07/owl#priorVersion"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-prop-seealso-type + Michael Schneider + Kai Mainzer + The type of the vocabulary property rdfs:seeAlso is the class of annotation properties. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:AnnotationProperty rdf:about="http://www.w3.org/2000/01/rdf-schema#seeAlso"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-prop-versioninfo-type + Michael Schneider + Kai Mainzer + The type of the vocabulary property owl:versionInfo is the class of annotation properties. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <owl:AnnotationProperty rdf:about="http://www.w3.org/2002/07/owl#versionInfo"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-rdfs-domain-cond + Michael Schneider + Kai Mainzer + The left hand side individual in a given triple is entailed to be an instance of the domain of the predicate. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:c rdf:about="http://www.example.org#u"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#u"> + <ex:p rdf:resource="http://www.example.org#v"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#p"> + <rdfs:domain rdf:resource="http://www.example.org#c"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-rdfs-range-cond + Michael Schneider + Kai Mainzer + The right hand side individual in a given triple is entailed to be an instance of the range of the predicate. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:c rdf:about="http://www.example.org#v"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#u"> + <ex:p rdf:resource="http://www.example.org#v"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#p"> + <rdfs:range rdf:resource="http://www.example.org#c"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-rdfs-subclass-cond + Michael Schneider + Kai Mainzer + The extensions of two classes related by rdfs:subClassOf are in a subsumption relationship. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:c2 rdf:about="http://www.example.org#w"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:c1 rdf:about="http://www.example.org#w"/> + <rdf:Description rdf:about="http://www.example.org#c1"> + <rdfs:subClassOf rdf:resource="http://www.example.org#c2"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-rdfs-subclass-trans + Michael Schneider + Kai Mainzer + The property rdfs:subClassOf is transitive. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#c1"> + <rdfs:subClassOf rdf:resource="http://www.example.org#c3"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#c1"> + <rdfs:subClassOf> + <rdf:Description rdf:about="http://www.example.org#c2"> + <rdfs:subClassOf rdf:resource="http://www.example.org#c3"/> + </rdf:Description> + </rdfs:subClassOf> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-rdfs-subprop-cond + Michael Schneider + Kai Mainzer + The extensions of two properties related by rdfs:subPropertyOf are in a subsumption relationship. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#s"> + <ex:p2 rdf:resource="http://www.example.org#o"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#s"> + <ex:p1 rdf:resource="http://www.example.org#o"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#p1"> + <rdfs:subPropertyOf rdf:resource="http://www.example.org#p2"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-rdfs-subprop-trans + Michael Schneider + Kai Mainzer + The property rdfs:subPropertyOf is transitive. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#p1"> + <rdfs:subPropertyOf rdf:resource="http://www.example.org#p3"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#p1"> + <rdfs:subPropertyOf> + <rdf:Description rdf:about="http://www.example.org#p2"> + <rdfs:subPropertyOf rdf:resource="http://www.example.org#p3"/> + </rdf:Description> + </rdfs:subPropertyOf> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-rdfsext-domain-subprop + Michael Schneider + Kai Mainzer + Every sub property of a given property with a given domain also has this domain. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#p1"> + <rdfs:domain rdf:resource="http://www.example.org#c"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#p1"> + <rdfs:subPropertyOf> + <rdf:Description rdf:about="http://www.example.org#p2"> + <rdfs:domain rdf:resource="http://www.example.org#c"/> + </rdf:Description> + </rdfs:subPropertyOf> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-rdfsext-domain-superclass + Michael Schneider + Kai Mainzer + Every super class of a domain for a given property is itself a domain for that property. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#p"> + <rdfs:domain rdf:resource="http://www.example.org#c2"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#p"> + <rdfs:domain> + <rdf:Description rdf:about="http://www.example.org#c1"> + <rdfs:subClassOf rdf:resource="http://www.example.org#c2"/> + </rdf:Description> + </rdfs:domain> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-rdfsext-range-subprop + Michael Schneider + Kai Mainzer + Every sub property of a given property with a given range also has this range. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#p1"> + <rdfs:range rdf:resource="http://www.example.org#c"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#p1"> + <rdfs:subPropertyOf> + <rdf:Description rdf:about="http://www.example.org#p2"> + <rdfs:range rdf:resource="http://www.example.org#c"/> + </rdf:Description> + </rdfs:subPropertyOf> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-rdfsext-range-superclass + Michael Schneider + Kai Mainzer + Every super class of a range for a given property is itself a range for that property. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#p"> + <rdfs:range rdf:resource="http://www.example.org#c2"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#p"> + <rdfs:range> + <rdf:Description rdf:about="http://www.example.org#c1"> + <rdfs:subClassOf rdf:resource="http://www.example.org#c2"/> + </rdf:Description> + </rdfs:range> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-restrict-allvalues-cmp-class + Michael Schneider + Kai Mainzer + A universal restriction on some property and some class is a sub class of another universal restriction on the same property but on a super class. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x1"> + <rdfs:subClassOf rdf:resource="http://www.example.org#x2"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x1"> + <owl:allValuesFrom> + <rdf:Description rdf:about="http://www.example.org#c1"> + <rdfs:subClassOf rdf:resource="http://www.example.org#c2"/> + </rdf:Description> + </owl:allValuesFrom> + <owl:onProperty rdf:resource="http://www.example.org#p"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#x2"> + <owl:allValuesFrom rdf:resource="http://www.example.org#c2"/> + <owl:onProperty rdf:resource="http://www.example.org#p"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-restrict-allvalues-cmp-prop + Michael Schneider + Kai Mainzer + A universal restriction on some property and some class is a sub class of another universal restriction on the same class but on a sub property. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x2"> + <rdfs:subClassOf rdf:resource="http://www.example.org#x1"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x1"> + <owl:allValuesFrom rdf:resource="http://www.example.org#c"/> + <owl:onProperty> + <rdf:Description rdf:about="http://www.example.org#p1"> + <rdfs:subPropertyOf rdf:resource="http://www.example.org#p2"/> + </rdf:Description> + </owl:onProperty> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#x2"> + <owl:allValuesFrom rdf:resource="http://www.example.org#c"/> + <owl:onProperty rdf:resource="http://www.example.org#p2"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-restrict-allvalues-inst-obj + Michael Schneider + Kai Mainzer + If an individual w is an instance of the universal restriction on property p and class c, then for any triple w p x follows that x is an instance of c. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:c rdf:about="http://www.example.org#x"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:z rdf:about="http://www.example.org#w"> + <ex:p rdf:resource="http://www.example.org#x"/> + </ex:z> + <rdf:Description rdf:about="http://www.example.org#z"> + <owl:allValuesFrom rdf:resource="http://www.example.org#c"/> + <owl:onProperty rdf:resource="http://www.example.org#p"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-restrict-hasvalue-cmp-prop + Michael Schneider + Kai Mainzer + A has-value restriction on some property and some value is a sub class of another has-value restriction on the same value but on a super property. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x1"> + <rdfs:subClassOf rdf:resource="http://www.example.org#x2"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x1"> + <owl:hasValue rdf:resource="http://www.example.org#v"/> + <owl:onProperty> + <rdf:Description rdf:about="http://www.example.org#p1"> + <rdfs:subPropertyOf rdf:resource="http://www.example.org#p2"/> + </rdf:Description> + </owl:onProperty> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#x2"> + <owl:hasValue rdf:resource="http://www.example.org#v"/> + <owl:onProperty rdf:resource="http://www.example.org#p2"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-restrict-hasvalue-inst-obj + Michael Schneider + Kai Mainzer + If an individual w is an instance of the has-value restriction on property p to value u, then the triple w p u can be entailed. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#w"> + <ex:p rdf:resource="http://www.example.org#u"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:z rdf:about="http://www.example.org#w"/> + <rdf:Description rdf:about="http://www.example.org#z"> + <owl:hasValue rdf:resource="http://www.example.org#u"/> + <owl:onProperty rdf:resource="http://www.example.org#p"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-restrict-hasvalue-inst-subj + Michael Schneider + Kai Mainzer + For a triple w p u, the individual w is an instance of the has-value restriction on p to u. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:z rdf:about="http://www.example.org#w"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#z"> + <owl:hasValue rdf:resource="http://www.example.org#u"/> + <owl:onProperty rdf:resource="http://www.example.org#p"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#w"> + <ex:p rdf:resource="http://www.example.org#u"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-restrict-maxcard-inst-obj-one + Michael Schneider + Kai Mainzer + If an individual w is an instance of the max-1-cardinality restriction on property p, and if there are triples w p x1 and w p x2, then x1 equals x2. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x1"> + <owl:sameAs rdf:resource="http://www.example.org#x2"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:z rdf:about="http://www.example.org#w"> + <ex:p rdf:resource="http://www.example.org#x1"/> + <ex:p rdf:resource="http://www.example.org#x2"/> + </ex:z> + <rdf:Description rdf:about="http://www.example.org#z"> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + <owl:onProperty rdf:resource="http://www.example.org#p"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-restrict-maxcard-inst-obj-zero + Michael Schneider + Kai Mainzer + If an individual w is an instance of the max-0-cardinality restriction on property p, then there cannot be any triple w p x. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:z rdf:about="http://www.example.org#w"> + <ex:p rdf:resource="http://www.example.org#x"/> + </ex:z> + <rdf:Description rdf:about="http://www.example.org#z"> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >0</owl:maxCardinality> + <owl:onProperty rdf:resource="http://www.example.org#p"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-restrict-maxqcr-inst-obj-one + Michael Schneider + Kai Mainzer + If an individual w is an instance of the max-1-QCR on property p to class c, and if there are triples w p x1 and w p x2, with x1 and x2 being in c, then x1 equals x2. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x1"> + <owl:sameAs rdf:resource="http://www.example.org#x2"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:z rdf:about="http://www.example.org#w"> + <ex:p> + <ex:c rdf:about="http://www.example.org#x1"/> + </ex:p> + <ex:p> + <ex:c rdf:about="http://www.example.org#x2"/> + </ex:p> + </ex:z> + <rdf:Description rdf:about="http://www.example.org#z"> + <owl:maxQualifiedCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxQualifiedCardinality> + <owl:onProperty rdf:resource="http://www.example.org#p"/> + <owl:onClass rdf:resource="http://www.example.org#c"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-restrict-maxqcr-inst-obj-zero + Michael Schneider + Kai Mainzer + If an individual w is an instance of the max-0-QCR on property p to class c, then there cannot be any triple w p x with x in c. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:z rdf:about="http://www.example.org#w"> + <ex:p> + <ex:c rdf:about="http://www.example.org#x"/> + </ex:p> + </ex:z> + <rdf:Description rdf:about="http://www.example.org#z"> + <owl:maxQualifiedCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >0</owl:maxQualifiedCardinality> + <owl:onProperty rdf:resource="http://www.example.org#p"/> + <owl:onClass rdf:resource="http://www.example.org#c"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-restrict-somevalues-cmp-class + Michael Schneider + Kai Mainzer + An existential restriction on some property and some class is a sub class of another existential restriction on the same property but on a super class. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x1"> + <rdfs:subClassOf rdf:resource="http://www.example.org#x2"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x1"> + <owl:someValuesFrom> + <rdf:Description rdf:about="http://www.example.org#c1"> + <rdfs:subClassOf rdf:resource="http://www.example.org#c2"/> + </rdf:Description> + </owl:someValuesFrom> + <owl:onProperty rdf:resource="http://www.example.org#p"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#x2"> + <owl:someValuesFrom rdf:resource="http://www.example.org#c2"/> + <owl:onProperty rdf:resource="http://www.example.org#p"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-restrict-somevalues-cmp-prop + Michael Schneider + Kai Mainzer + An existential restriction on some property and some class is a sub class of another existential restriction on the same class but on a super property. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x1"> + <rdfs:subClassOf rdf:resource="http://www.example.org#x2"/> + </rdf:Description> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#x1"> + <owl:someValuesFrom rdf:resource="http://www.example.org#c"/> + <owl:onProperty> + <rdf:Description rdf:about="http://www.example.org#p1"> + <rdfs:subPropertyOf rdf:resource="http://www.example.org#p2"/> + </rdf:Description> + </owl:onProperty> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#x2"> + <owl:someValuesFrom rdf:resource="http://www.example.org#c"/> + <owl:onProperty rdf:resource="http://www.example.org#p2"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + rdfbased-sem-restrict-somevalues-inst-subj + Michael Schneider + Kai Mainzer + For a triple w p x, with x being an instance of a class c, the individual w is an instance of the existential restriction on p to c. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <ex:z rdf:about="http://www.example.org#w"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:ex="http://www.example.org#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> + <rdf:Description rdf:about="http://www.example.org#z"> + <owl:someValuesFrom rdf:resource="http://www.example.org#c"/> + <owl:onProperty rdf:resource="http://www.example.org#p"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.example.org#w"> + <ex:p> + <ex:c rdf:about="http://www.example.org#x"/> + </ex:p> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + + + + string-integer-clash + Birte Glimm + The range of hasAge is integer, but a has an asserted string hasAge filler. + + + + + + + + + Prefix(:=<http://example.org/>) +Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>) +Ontology( + Declaration(NamedIndividual(:a)) + Declaration(DataProperty(:hasAge)) + DataPropertyRange(:hasAge xsd:integer) + ClassAssertion(DataHasValue(:hasAge "aString"^^xsd:string) :a) +) + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-AnnotationProperty-002 + Jeremy J. Carroll + In OWL 1, this test was used to expose differences between the RDF Based and Direct semantics. In OWL 2, the entailment ontology holds under both semantics. Under the OWL 2 Direct Semantics, annotations in the conclusion ontology are ignored, so the only axiom evaluated in ClassAssertion(owl:Thing _:x). Under the OWL 2 RDF Based semantics, annotations are relevant, and in this test, the entailment holds. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/AnnotationProperty/premises002#" + xml:base="http://www.w3.org/2002/03owlt/AnnotationProperty/conclusions002" > + + <owl:Ontology/> + <owl:Class rdf:about="premises002#A"> + <first:ap> + <owl:Thing /> + </first:ap> + </owl:Class> + <owl:AnnotationProperty rdf:about="premises002#ap"/> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/AnnotationProperty/premises002#" + xml:base="http://www.w3.org/2002/03owlt/AnnotationProperty/premises002" > + + <owl:Ontology/> + <owl:Class rdf:ID="A"> + <first:ap> + <owl:Class rdf:ID="B"/> + </first:ap> + </owl:Class> + <owl:AnnotationProperty rdf:ID="ap"/> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-AnnotationProperty-003 + Jeremy J. Carroll + URI references used in annotations don't need to be typed. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/AnnotationProperty/consistent003#" + xml:base="http://www.w3.org/2002/03owlt/AnnotationProperty/consistent003" > + + <owl:Ontology/> + <owl:AnnotationProperty rdf:ID="ap"/> + + <owl:Class rdf:ID="A"> + <first:ap> + <rdf:Description rdf:ID="B"/> + </first:ap> + </owl:Class> + +</rdf:RDF> + + + + + + + WebOnt-AnnotationProperty-004 + Sean Bechhofer + AnnotationProperty's in OWL Lite and OWL DL, may not have range constraints. They are permitted in OWL 2 DL. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base= +"http://www.w3.org/2002/03owlt/AnnotationProperty/consistent004" > + + <owl:Ontology /> + + <owl:AnnotationProperty rdf:ID="ap"> + <rdfs:range rdf:resource= + "http://www.w3.org/2001/XMLSchema#string"/> + </owl:AnnotationProperty> +</rdf:RDF> + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-I4.5-001 + Charles White + An example combinging owl:oneOf and owl:inverseOf. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:first="http://www.w3.org/2002/03owlt/I4.5/premises001#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I4.5/conclusions001" > + + <owl:Ontology/> + <first:EuroMP rdf:about="premises001#Kinnock" /> + <owl:Class rdf:about="premises001#EuroMP"/> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/I4.5/premises001#" + xml:base="http://www.w3.org/2002/03owlt/I4.5/premises001" > + + <owl:Ontology/> + + <owl:Class rdf:ID="EuropeanCountry" /> + <owl:Class rdf:ID="Person" /> + + <owl:Class rdf:ID="EUCountry"> + <owl:oneOf rdf:parseType="Collection"> + <first:EuropeanCountry rdf:ID="UK"/> + <first:EuropeanCountry rdf:ID="BE"/> + <first:EuropeanCountry rdf:ID="ES"/> + <first:EuropeanCountry rdf:ID="FR"/> + <first:EuropeanCountry rdf:ID="NL"/> + <first:EuropeanCountry rdf:ID="PT"/> + </owl:oneOf> + </owl:Class> + + <owl:ObjectProperty rdf:ID="hasEuroMP" > + <rdfs:domain rdf:resource="#EUCountry"/> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="isEuroMPFrom" > + <owl:inverseOf rdf:resource="#hasEuroMP"/> + </owl:ObjectProperty> + + <owl:Class rdf:ID="EuroMP"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#isEuroMPFrom" /> + <owl:someValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#Thing" /> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + + <first:Person rdf:ID="Kinnock" /> + + <first:EuropeanCountry rdf:about="#UK"> + <first:hasEuroMP rdf:resource="#Kinnock" /> + </first:EuropeanCountry> + + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-I4.5-002 + Charles White + An example combining owl:oneOf and owl:inverseOf. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/I4.5/inconsistent002#" + xml:base="http://www.w3.org/2002/03owlt/I4.5/inconsistent002" > + + <owl:Ontology/> + + <owl:Class rdf:ID="EuropeanCountry" /> + <owl:Class rdf:ID="Person" /> + + <owl:Class rdf:ID="EUCountry"> + <owl:oneOf rdf:parseType="Collection"> + <first:EuropeanCountry rdf:ID="UK"/> + <first:EuropeanCountry rdf:ID="BE"/> + <first:EuropeanCountry rdf:ID="ES"/> + <first:EuropeanCountry rdf:ID="FR"/> + <first:EuropeanCountry rdf:ID="NL"/> + <first:EuropeanCountry rdf:ID="PT"/> + </owl:oneOf> + </owl:Class> + + <owl:ObjectProperty rdf:ID="hasEuroMP" > + <rdfs:domain rdf:resource="#EUCountry"/> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="isEuroMPFrom" > + <owl:inverseOf rdf:resource="#hasEuroMP"/> + </owl:ObjectProperty> + + <owl:Class rdf:ID="EuroMP"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#isEuroMPFrom" /> + <owl:someValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#Thing" /> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + + <first:Person rdf:ID="Kinnock" > + <rdf:type> + <owl:Class> + <owl:complementOf rdf:resource="#EuroMP"/> + </owl:Class> + </rdf:type> + </first:Person> + + <first:EuropeanCountry rdf:about="#UK"> + <first:hasEuroMP rdf:resource="#Kinnock" /> + </first:EuropeanCountry> + + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-I4.6-004 + Jeremy J. Carroll + <code>owl:sameAs</code> is stronger than <code>owl:equivalentClass</code>. + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I4.6/nonconclusions004" > + <owl:Ontology/> + <owl:Class rdf:ID="C1"> + <owl:sameAs> + <owl:Class rdf:ID="C2"/> + </owl:sameAs> + </owl:Class> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I4.6/premises004" > + <owl:Ontology/> + <owl:Class rdf:about="nonconclusions004#C1"> + <owl:equivalentClass> + <owl:Class rdf:about="nonconclusions004#C2"/> + </owl:equivalentClass> + </owl:Class> +</rdf:RDF> + + + + + + + + + + + + + + + + + + WebOnt-I4.6-005-Direct + Jeremy J. Carroll + Mike Smith + Under the direct semantics, test WebOnt-I4.6-005 must be treated as a positive entailment test because the direct semantics ignore annotations in the conclusion ontology. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xml:base="http://www.w3.org/2002/03owlt/I4.6/nonconclusions005" > + <owl:Ontology/> + <owl:Class rdf:ID="C2"> + <rdfs:comment>An example class.</rdfs:comment> + </owl:Class> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xml:base="http://www.w3.org/2002/03owlt/I4.6/premises005" > + <owl:Ontology/> + <owl:Class rdf:about="nonconclusions005#C1"> + <rdfs:comment>An example class.</rdfs:comment> + <owl:equivalentClass> + <owl:Class rdf:about="nonconclusions005#C2"/> + </owl:equivalentClass> + </owl:Class> +</rdf:RDF> + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-I5.2-001 + Ian Horrocks + A class like <code>owl:Nothing</code> can be defined using OWL Lite restrictions. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/I5.2/consistent001#" + xml:base="http://www.w3.org/2002/03owlt/I5.2/consistent001" > + <owl:Ontology/> + <owl:Class rdf:ID="Nothing"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#p"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype= +"http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#p"/> + </owl:onProperty> + <owl:maxCardinality rdf:datatype= +"http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >0</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-I5.2-002 + Ian Horrocks + A class like <code>owl:Nothing</code> can be defined using OWL Lite restrictions. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.2/conclusions002" > + <owl:Ontology/> + <owl:Class rdf:about="premises002#Nothing"> + <owl:equivalentClass> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Nothing" /> + </owl:equivalentClass> + </owl:Class> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.2/premises002" > + + <owl:Ontology/> + <owl:Class rdf:ID="Nothing"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#p"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype= +"http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#p"/> + </owl:onProperty> + <owl:maxCardinality rdf:datatype= +"http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >0</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-I5.2-003 + Ian Horrocks + The complement of a class can be defined using OWL Lite restrictions. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/I5.2/consistent003#" + xml:base="http://www.w3.org/2002/03owlt/I5.2/consistent003" > + <owl:Ontology/> + <owl:Class rdf:ID="Nothing"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#p"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype= +"http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#p"/> + </owl:onProperty> + <owl:maxCardinality rdf:datatype= +"http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >0</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:ID="A"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#q"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="notA"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#q"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="#Nothing"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-I5.2-004 + Ian Horrocks + The complement of a class can be defined using OWL Lite restrictions. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.2/conclusions004" > + <owl:Ontology/> + <owl:Class rdf:about="premises004#notA"> + <owl:complementOf> + <owl:Class rdf:about="premises004#A"/> + </owl:complementOf> + </owl:Class> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/I5.2/premises004#" + xmlns:second="http://www.w3.org/2002/03owlt/I5.2/conclusions004#" + xml:base="http://www.w3.org/2002/03owlt/I5.2/premises004" > + + <owl:Ontology/> + <owl:Class rdf:ID="Nothing"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#p"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype= +"http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#p"/> + </owl:onProperty> + <owl:maxCardinality rdf:datatype= +"http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >0</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:ID="A"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#q"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="notA"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#q"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="#Nothing"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-I5.2-005 + Ian Horrocks + The union of two classes can be defined using OWL Lite restrictions, and <code>owl:intersectionOf</code>. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/I5.2/consistent005#" + xml:base="http://www.w3.org/2002/03owlt/I5.2/consistent005" > + + <owl:Ontology/> + <owl:Class rdf:ID="Nothing"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#p"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype= +"http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#p"/> + </owl:onProperty> + <owl:maxCardinality rdf:datatype= +"http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >0</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:ID="A"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#q"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="notA"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#q"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="#Nothing"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="B"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#r"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="notB"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#r"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="#Nothing"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="notAorB"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#notA"/> + <owl:Class rdf:about="#notB"/> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="AorB"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#s"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="#notAorB"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#s"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="#Nothing"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-I5.2-006 + Ian Horrocks + The union of two classes can be defined using OWL Lite restrictions, and <code>owl:intersectionOf</code>. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.2/conclusions006" > + <owl:Ontology/> + <owl:Class rdf:about="premises006#AorB"> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="premises006#A"/> + <owl:Class rdf:about="premises006#B"/> + </owl:unionOf> + </owl:Class> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.2/premises006" > + + <owl:Ontology/> + <owl:Class rdf:ID="Nothing"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#p"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype= +"http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#p"/> + </owl:onProperty> + <owl:maxCardinality rdf:datatype= +"http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >0</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:ID="A"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#q"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="notA"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#q"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="#Nothing"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="B"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#r"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="notB"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#r"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="#Nothing"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="notAorB"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#notA"/> + <owl:Class rdf:about="#notB"/> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="AorB"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#s"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="#notAorB"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#s"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="#Nothing"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-I5.21-002 + Ian Horrocks + The construct used here shows how to express mutual disjointness between classes with O(N) triples. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.21/conclusions002" > + + <owl:Ontology/> + <owl:Class rdf:about="premises002#Amphisbaenidae"> + <owl:disjointWith rdf:resource="premises002#Agamidae"/> + <owl:disjointWith rdf:resource="premises002#Anomalepidae"/> + <owl:disjointWith rdf:resource="premises002#Emydidae"/> + <owl:disjointWith rdf:resource="premises002#Crocodylidae"/> + <owl:disjointWith rdf:resource="premises002#Gekkonidae"/> + <owl:disjointWith rdf:resource="premises002#Sphenodontidae"/> + <owl:disjointWith rdf:resource="premises002#Cordylidae"/> + <owl:disjointWith rdf:resource="premises002#Bipedidae"/> + <owl:disjointWith rdf:resource="premises002#Leptotyphlopidae"/> + <owl:disjointWith rdf:resource="premises002#Xantusiidae"/> + <owl:disjointWith rdf:resource="premises002#Loxocemidae"/> + </owl:Class> + + <owl:Class rdf:about="premises002#Agamidae"> + <owl:disjointWith rdf:resource="premises002#Anomalepidae"/> + <owl:disjointWith rdf:resource="premises002#Emydidae"/> + <owl:disjointWith rdf:resource="premises002#Crocodylidae"/> + <owl:disjointWith rdf:resource="premises002#Gekkonidae"/> + <owl:disjointWith rdf:resource="premises002#Sphenodontidae"/> + <owl:disjointWith rdf:resource="premises002#Cordylidae"/> + <owl:disjointWith rdf:resource="premises002#Bipedidae"/> + <owl:disjointWith rdf:resource="premises002#Leptotyphlopidae"/> + <owl:disjointWith rdf:resource="premises002#Xantusiidae"/> + <owl:disjointWith rdf:resource="premises002#Loxocemidae"/> + </owl:Class> + + <owl:Class rdf:about="premises002#Anomalepidae"> + <owl:disjointWith rdf:resource="premises002#Emydidae"/> + <owl:disjointWith rdf:resource="premises002#Crocodylidae"/> + <owl:disjointWith rdf:resource="premises002#Gekkonidae"/> + <owl:disjointWith rdf:resource="premises002#Sphenodontidae"/> + <owl:disjointWith rdf:resource="premises002#Cordylidae"/> + <owl:disjointWith rdf:resource="premises002#Bipedidae"/> + <owl:disjointWith rdf:resource="premises002#Leptotyphlopidae"/> + <owl:disjointWith rdf:resource="premises002#Xantusiidae"/> + <owl:disjointWith rdf:resource="premises002#Loxocemidae"/> + </owl:Class> + + <owl:Class rdf:about="premises002#Emydidae"> + <owl:disjointWith rdf:resource="premises002#Crocodylidae"/> + <owl:disjointWith rdf:resource="premises002#Gekkonidae"/> + <owl:disjointWith rdf:resource="premises002#Sphenodontidae"/> + <owl:disjointWith rdf:resource="premises002#Cordylidae"/> + <owl:disjointWith rdf:resource="premises002#Bipedidae"/> + <owl:disjointWith rdf:resource="premises002#Leptotyphlopidae"/> + <owl:disjointWith rdf:resource="premises002#Xantusiidae"/> + <owl:disjointWith rdf:resource="premises002#Loxocemidae"/> + </owl:Class> + + <owl:Class rdf:about="premises002#Crocodylidae"> + <owl:disjointWith rdf:resource="premises002#Gekkonidae"/> + <owl:disjointWith rdf:resource="premises002#Sphenodontidae"/> + <owl:disjointWith rdf:resource="premises002#Cordylidae"/> + <owl:disjointWith rdf:resource="premises002#Bipedidae"/> + <owl:disjointWith rdf:resource="premises002#Leptotyphlopidae"/> + <owl:disjointWith rdf:resource="premises002#Xantusiidae"/> + <owl:disjointWith rdf:resource="premises002#Loxocemidae"/> + </owl:Class> + + <owl:Class rdf:about="premises002#Gekkonidae"> + <owl:disjointWith rdf:resource="premises002#Sphenodontidae"/> + <owl:disjointWith rdf:resource="premises002#Cordylidae"/> + <owl:disjointWith rdf:resource="premises002#Bipedidae"/> + <owl:disjointWith rdf:resource="premises002#Leptotyphlopidae"/> + <owl:disjointWith rdf:resource="premises002#Xantusiidae"/> + <owl:disjointWith rdf:resource="premises002#Loxocemidae"/> + </owl:Class> + + <owl:Class rdf:about="premises002#Sphenodontidae"> + <owl:disjointWith rdf:resource="premises002#Cordylidae"/> + <owl:disjointWith rdf:resource="premises002#Bipedidae"/> + <owl:disjointWith rdf:resource="premises002#Leptotyphlopidae"/> + <owl:disjointWith rdf:resource="premises002#Xantusiidae"/> + <owl:disjointWith rdf:resource="premises002#Loxocemidae"/> + </owl:Class> + + <owl:Class rdf:about="premises002#Cordylidae"> + <owl:disjointWith rdf:resource="premises002#Bipedidae"/> + <owl:disjointWith rdf:resource="premises002#Leptotyphlopidae"/> + <owl:disjointWith rdf:resource="premises002#Xantusiidae"/> + <owl:disjointWith rdf:resource="premises002#Loxocemidae"/> + </owl:Class> + + <owl:Class rdf:about="premises002#Bipedidae"> + <owl:disjointWith rdf:resource="premises002#Leptotyphlopidae"/> + <owl:disjointWith rdf:resource="premises002#Xantusiidae"/> + <owl:disjointWith rdf:resource="premises002#Loxocemidae"/> + </owl:Class> + + <owl:Class rdf:about="premises002#Leptotyphlopidae"> + <owl:disjointWith rdf:resource="premises002#Xantusiidae"/> + <owl:disjointWith rdf:resource="premises002#Loxocemidae"/> + </owl:Class> + + <owl:Class rdf:about="premises002#Xantusiidae"> + <owl:disjointWith rdf:resource="premises002#Loxocemidae"/> + </owl:Class> + + <owl:Class rdf:about="premises002#Loxocemidae"> + </owl:Class> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/I5.21/premises002#" + xml:base="http://www.w3.org/2002/03owlt/I5.21/premises002" > + + <owl:Ontology/> + <owl:Class rdf:ID="Reptile"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="family-name"/> + </owl:onProperty> + <owl:cardinality rdf:datatype= + "http://www.w3.org/2001/XMLSchema#int">1</owl:cardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:about="#Amphisbaenidae"> + <rdfs:subClassOf rdf:resource="#Reptile" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#family-name"/> + <owl:hasValue>Amphisbaenidae</owl:hasValue> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:about="#Agamidae"> + <rdfs:subClassOf rdf:resource="#Reptile" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#family-name"/> + <owl:hasValue>Agamidae</owl:hasValue> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:about="#Anomalepidae"> + <rdfs:subClassOf rdf:resource="#Reptile" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#family-name"/> + <owl:hasValue>Anomalepidae</owl:hasValue> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:about="#Emydidae"> + <rdfs:subClassOf rdf:resource="#Reptile" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#family-name"/> + <owl:hasValue>Emydidae</owl:hasValue> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:about="#Crocodylidae"> + <rdfs:subClassOf rdf:resource="#Reptile" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#family-name"/> + <owl:hasValue>Crocodylidae</owl:hasValue> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:about="#Gekkonidae"> + <rdfs:subClassOf rdf:resource="#Reptile" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#family-name"/> + <owl:hasValue>Gekkonidae</owl:hasValue> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:about="#Sphenodontidae"> + <rdfs:subClassOf rdf:resource="#Reptile" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#family-name"/> + <owl:hasValue>Sphenodontidae</owl:hasValue> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:about="#Cordylidae"> + <rdfs:subClassOf rdf:resource="#Reptile" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#family-name"/> + <owl:hasValue>Cordylidae</owl:hasValue> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:about="#Bipedidae"> + <rdfs:subClassOf rdf:resource="#Reptile" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#family-name"/> + <owl:hasValue>Bipedidae</owl:hasValue> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:about="#Leptotyphlopidae"> + <rdfs:subClassOf rdf:resource="#Reptile" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#family-name"/> + <owl:hasValue>Leptotyphlopidae</owl:hasValue> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:about="#Xantusiidae"> + <rdfs:subClassOf rdf:resource="#Reptile" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#family-name"/> + <owl:hasValue>Xantusiidae</owl:hasValue> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:about="#Loxocemidae"> + <rdfs:subClassOf rdf:resource="#Reptile" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#family-name"/> + <owl:hasValue>Loxocemidae</owl:hasValue> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-I5.24-003 + Ian Horrocks + This is a typical definition of range from description logic. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.24/conclusions003" > + + <owl:Ontology/> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="premises003#prop"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="premises003#A"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.24/premises003" > + <owl:Ontology/> + <owl:ObjectProperty rdf:ID="prop"> + <rdfs:range> + <owl:Class rdf:about="#A"/> + </rdfs:range> + </owl:ObjectProperty> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-I5.24-004 + Ian Horrocks + This is a typical definition of range from description logic. +It works both ways. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.24/conclusions004" > + <owl:Ontology/> + <owl:ObjectProperty rdf:ID="prop"> + <rdfs:range> + <owl:Class rdf:about="#A"/> + </rdfs:range> + </owl:ObjectProperty> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.24/premises004" > + <owl:Ontology/> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="conclusions004#prop"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="conclusions004#A"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-I5.26-001 + Jeremy J. Carroll + Structure sharing was not permitted in OWL DL, between a class description +and a type triple, but is permitted in OWL 2 DL. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.26/consistent001" > + <owl:Ontology/> + <owl:Class rdf:nodeID="B"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="B"/> + </owl:intersectionOf> + </owl:Class> + <rdf:Description> + <rdf:type rdf:nodeID="B"/> + </rdf:Description> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="C"/> + <rdf:Description rdf:nodeID="B"/> + </owl:intersectionOf> + </owl:Class> + +</rdf:RDF> + + + + + + + WebOnt-I5.26-002 + Jeremy J. Carroll + Structure sharing was not permitted in OWL DL, between an +owl:equivalentClass triple +and a type triple, but is permitted in OWL 2 DL. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.26/consistent002" > + <owl:Ontology/> + <owl:Class rdf:nodeID="B"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="B"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Class rdf:ID="A"/> + </owl:equivalentClass> + </owl:Class> + <rdf:Description> + <rdf:type rdf:nodeID="B"/> + </rdf:Description> + +</rdf:RDF> + + + + + + + WebOnt-I5.26-003 + Jeremy J. Carroll + Structure sharing was not permitted in OWL DL, between two class descriptions, but is permitted in OWL 2 DL. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.26/consistent003" > + <owl:Ontology/> + <owl:Class rdf:nodeID="B"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="B"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="notB"> + <owl:complementOf rdf:nodeID="B"/> + </owl:Class> + <owl:Class rdf:ID="u"> + <owl:unionOf rdf:parseType="Collection"> + <rdf:Description rdf:nodeID="B"/> + <owl:Class rdf:ID="A"/> + </owl:unionOf> + </owl:Class> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + WebOnt-I5.26-004 + Jeremy J. Carroll + Structure sharing was not permitted in OWL DL, between a class description and an +owl:disjointWith triple, but is permitted in OWL 2 DL. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.26/consistent004" > + <owl:Ontology/> + <owl:Class rdf:nodeID="B"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="B"/> + </owl:intersectionOf> + <owl:disjointWith> + <owl:Class rdf:ID="C"/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:ID="notB"> + <owl:complementOf rdf:nodeID="B"/> + </owl:Class> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-I5.26-005 + Jeremy J. Carroll + Structure sharing was not permitted in OWL DL, between an owl:equivalentClass triple and an +owl:disjointWith triple, but is permitted in OWL 2 DL. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.26/consistent005" > + <owl:Ontology/> + <owl:Class rdf:nodeID="B"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="B"/> + </owl:intersectionOf> + <owl:disjointWith> + <owl:Class rdf:ID="C"/> + </owl:disjointWith> + <owl:equivalentClass> + <owl:Class rdf:ID="D"/> + </owl:equivalentClass> + </owl:Class> + +</rdf:RDF> + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-I5.26-009 + Jeremy J. Carroll + The abstract syntax form of the conclusions is: + + EquivalentClasses( restriction( first:p, minCardinality(1) ) ) + ObjectProperty( first:p ) + +This is trivially true given that first:p is an +<code>individualvaluedPropertyID</code>. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.26/conclusions009" > + + <owl:Ontology/> + <owl:Restriction rdf:nodeID="n"> + <owl:onProperty> + <owl:ObjectProperty rdf:about="premises009#p" /> + </owl:onProperty> + <owl:minCardinality rdf:datatype= + "http://www.w3.org/2001/XMLSchema#int" + >1</owl:minCardinality> + <owl:equivalentClass rdf:nodeID="n"/> + </owl:Restriction> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/I5.26/premises009#" + xml:base="http://www.w3.org/2002/03owlt/I5.26/premises009" > + <owl:Ontology/> + <owl:ObjectProperty rdf:ID="p" /> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-I5.26-010 + Jeremy J. Carroll + The abstract syntax form of the conclusions is: + + EquivalentClasses( restriction( first:p, minCardinality(1) ) ) + ObjectProperty( first:p ) + +This is trivially true given that first:p is an +<code>individualvaluedPropertyID</code>. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.26/conclusions010" > + + <owl:Ontology/> + <owl:Restriction rdf:nodeID="n"> + <owl:onProperty> + <owl:ObjectProperty rdf:about="premises010#p" /> + </owl:onProperty> + <owl:minCardinality rdf:datatype= + "http://www.w3.org/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/I5.26/premises010#" + xml:base="http://www.w3.org/2002/03owlt/I5.26/premises010" > + <owl:Ontology/> + <owl:ObjectProperty rdf:ID="p" /> + +</rdf:RDF> + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-I5.3-006 + Jeremy J. Carroll + A minimal OWL Lite version of <a xmlns="http://www.w3.org/1999/xhtml" href="#I5.3-005">test 005</a>. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/I5.3/consistent006#" + xml:base="http://www.w3.org/2002/03owlt/I5.3/consistent006" > + <owl:Ontology/> + <owl:Thing> + <first:p> + <owl:Thing/> + </first:p> + </owl:Thing> + <owl:ObjectProperty rdf:ID="p" /> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-I5.3-008 + Jeremy J. Carroll + An OWL Lite version of <a xmlns="http://www.w3.org/1999/xhtml" href="#I5.3-007">test 007</a>. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/I5.3/consistent008#" + xml:base="http://www.w3.org/2002/03owlt/I5.3/consistent008" > + <owl:Ontology/> + <owl:Thing> + <first:dp>value</first:dp> + </owl:Thing> + <owl:DatatypeProperty rdf:ID="dp" /> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-I5.3-010 + Jeremy J. Carroll + Classes could not be the object of regular properties in OWL DL. This ontology is permissible in OWL 2 DL due to class / individual punning. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/I5.3/consistent010#" + xml:base="http://www.w3.org/2002/03owlt/I5.3/consistent010" > + <owl:Ontology/> + <owl:ObjectProperty rdf:ID="p"/> + <owl:Thing> + <first:p> + <owl:Class rdf:ID="c"/> + </first:p> + </owl:Thing> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-I5.3-011 + Jeremy J. Carroll + Classes can be the object of annotation properties in OWL Lite and DL. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/I5.3/consistent011#" + xml:base="http://www.w3.org/2002/03owlt/I5.3/consistent011" > + <owl:Ontology/> + <owl:AnnotationProperty rdf:ID="p"/> + <owl:Thing> + <first:p> + <owl:Class rdf:ID="c"/> + </first:p> + </owl:Thing> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + WebOnt-I5.5-005 + Jeremy J. Carroll + This test exhibits the effect of the comprehension principles in OWL Full. The conclusion ontology only contains a class declaration, ObjectUnionOf class expression does not appear in an axiom. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.5/conclusions005" > + + <owl:Class> + <owl:unionOf> + <rdf:List> + <rdf:first> + <owl:Class rdf:about="premises005#a"/> + </rdf:first> + <rdf:rest rdf:resource = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/> + </rdf:List> + </owl:unionOf> + </owl:Class> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.5/premises005" > + <owl:Class rdf:ID="a" /> +</rdf:RDF> + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-I5.8-006 + Jeremy J. Carroll + All <code>xsd:byte</code> +are <code>xsd:short</code>. + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/I5.8/premises006#" + xmlns:second="http://www.w3.org/2002/03owlt/I5.8/conclusions006#" + xml:base="http://www.w3.org/2002/03owlt/I5.8/conclusions006" > + <owl:Ontology/> + <owl:DatatypeProperty rdf:about="premises006#p"> + <rdfs:range rdf:resource= + "http://www.w3.org/2001/XMLSchema#short" /> + </owl:DatatypeProperty> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/I5.8/premises006#" + xmlns:second="http://www.w3.org/2002/03owlt/I5.8/conclusions006#" + xml:base="http://www.w3.org/2002/03owlt/I5.8/premises006" > + <owl:Ontology/> + <owl:DatatypeProperty rdf:ID="p"> + <rdfs:range rdf:resource= + "http://www.w3.org/2001/XMLSchema#byte" /> + </owl:DatatypeProperty> +</rdf:RDF> + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-I5.8-007 + Jeremy J. Carroll + -1 is an <code>xsd:short</code> +that is not an + <code>xsd:unsignedByte</code>. + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.8/nonconclusions007" > + <owl:Ontology/> + <owl:DatatypeProperty rdf:about="premises007#p"> + <rdfs:range rdf:resource= + "http://www.w3.org/2001/XMLSchema#unsignedByte" /> + </owl:DatatypeProperty> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.8/premises007" > + <owl:Ontology/> + <owl:DatatypeProperty rdf:ID="p"> + <rdfs:range rdf:resource= + "http://www.w3.org/2001/XMLSchema#short" /> + </owl:DatatypeProperty> +</rdf:RDF> + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-I5.8-008 + Jeremy J. Carroll + -1 is an <code>xsd:short</code> that is not an +<code>xsd:unsignedShort</code>; +100000 is an <code>xsd:unsignedInt</code> that is not +an <code>xsd:unsignedShort</code>; but there are no +<code>xsd:unsignedShort</code> which are neither +<code>xsd:short</code> nor +<code>xsd:unsignedInt</code> + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.8/conclusions008" > + <owl:Ontology/> + <owl:DatatypeProperty rdf:about="premises008#p"> + <rdfs:range rdf:resource= + "http://www.w3.org/2001/XMLSchema#unsignedShort" /> + </owl:DatatypeProperty> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.8/premises008" > + <owl:Ontology/> + <owl:DatatypeProperty rdf:ID="p"> + <rdfs:range rdf:resource= + "http://www.w3.org/2001/XMLSchema#short" /> + <rdfs:range rdf:resource= + "http://www.w3.org/2001/XMLSchema#unsignedInt" /> + </owl:DatatypeProperty> +</rdf:RDF> + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-I5.8-009 + Jeremy J. Carroll + 0 is the only <code>xsd:nonNegativeInteger</code> which is +also an <code>xsd:nonPositiveInteger</code>. 0 is an +<code>xsd:short</code>. + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.8/conclusions009" > + <owl:Ontology/> + <owl:DatatypeProperty rdf:about="premises009#p"> + <rdfs:range rdf:resource= + "http://www.w3.org/2001/XMLSchema#short" /> + </owl:DatatypeProperty> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.8/premises009" > + <owl:Ontology/> + <owl:DatatypeProperty rdf:ID="p"> + <rdfs:range rdf:resource= + "http://www.w3.org/2001/XMLSchema#nonNegativeInteger" /> + <rdfs:range rdf:resource= + "http://www.w3.org/2001/XMLSchema#nonPositiveInteger" /> + </owl:DatatypeProperty> +</rdf:RDF> + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-I5.8-010 + Jeremy J. Carroll + 0 is the only <code>xsd:nonNegativeInteger</code> which is +also an <code>xsd:nonPositiveInteger</code>. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/I5.8/premises010#" + xml:base="http://www.w3.org/2002/03owlt/I5.8/conclusions010" > + + <owl:Ontology/> + + <owl:DatatypeProperty rdf:about="premises010#p"/> + + <owl:Thing rdf:about="premises010#john"> + <first:p rdf:datatype= + "http://www.w3.org/2001/XMLSchema#int">0</first:p> + </owl:Thing> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.8/premises010" > + <owl:Ontology/> + <owl:DatatypeProperty rdf:ID="p"> + <rdfs:range rdf:resource= + "http://www.w3.org/2001/XMLSchema#nonNegativeInteger" /> + </owl:DatatypeProperty> + <rdf:Description rdf:ID="john"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="#p"/> + <owl:someValuesFrom rdf:resource= + "http://www.w3.org/2001/XMLSchema#nonPositiveInteger" /> + </owl:Restriction> + </rdf:type> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-I5.8-011 + Jos De Roo + The empty graph entails that <code>xsd:integer</code> and <code>xsd:string</code> +are a <code>rdfs:Datatype</code> + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/I5.8/conclusions011" > + + <owl:Ontology/> + <rdfs:Datatype rdf:about="http://www.w3.org/2001/XMLSchema#integer"/> + <rdfs:Datatype rdf:about="http://www.w3.org/2001/XMLSchema#string"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#"> + <owl:Ontology/> +</rdf:RDF> + + + + + + + + WebOnt-InverseFunctionalProperty-001 + Jeremy J. Carroll + If <code>prop</code> belongs to <code>owl:InverseFunctionalProperty</code>, +and <code>object</code> denotes a resource +which is the object of two <code>prop</code> triples, then the <code>subject</code>s +of these triples have the same denotation. + + + + + + <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl ="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/InverseFunctionalProperty/conclusions001" > + <owl:Ontology/> + <rdf:Description rdf:about="premises001#subject1"> + <owl:sameAs rdf:resource="premises001#subject2" /> + </rdf:Description> +</rdf:RDF> + <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl ="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/InverseFunctionalProperty/premises001#" + xml:base="http://www.w3.org/2002/03owlt/InverseFunctionalProperty/premises001" > + <owl:Ontology/> + <owl:InverseFunctionalProperty rdf:ID="prop"/> + <rdf:Description rdf:ID="subject1"> + <first:prop rdf:resource="#object" /> + </rdf:Description> + <rdf:Description rdf:ID="subject2"> + <first:prop rdf:resource="#object" /> + </rdf:Description> + <rdf:Description rdf:about="http://www.w3.org/2002/03owlt/InverseFunctionalProperty/premises001#object"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.w3.org/2002/03owlt/InverseFunctionalProperty/premises001#subject2"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing"/> + </rdf:Description> + <rdf:Description rdf:about="http://www.w3.org/2002/03owlt/InverseFunctionalProperty/premises001#subject1"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-Nothing-001 + Jeremy J. Carroll + The triple asserts something of type <code>owl:Nothing</code>, however +that is the empty class. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/Nothing/inconsistent001" > + + <owl:Ontology/> + <owl:Nothing/> + +</rdf:RDF> + + + + + + + + WebOnt-Ontology-001 + Jeremy J. Carroll + This is a variation of <a xmlns="http://www.w3.org/1999/xhtml" href="#equivalentClass-001">equivalentClass-001</a>, +showing the use of <code>owl:Ontology</code> triples in the premises and conclusions. + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/Ontology/premises001#" + xml:base="http://www.w3.org/2002/03owlt/Ontology/conclusions001" > + <owl:Ontology /> + <first:Car rdf:about="premises001#auto"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing" /> + </first:Car> + <first:Automobile rdf:about="premises001#car"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing" /> + </first:Automobile> + <owl:Class rdf:about="premises001#Car"/> + <owl:Class rdf:about="premises001#Automobile"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/Ontology/premises001#" + xml:base="http://www.w3.org/2002/03owlt/Ontology/premises001" > + <owl:Ontology rdf:about="" /> + <owl:Class rdf:ID="Car"> + <owl:equivalentClass> + <owl:Class rdf:ID="Automobile"/> + </owl:equivalentClass> + </owl:Class> + <first:Car rdf:ID="car"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing" /> + </first:Car> + <first:Automobile rdf:ID="auto"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing" /> + </first:Automobile> +</rdf:RDF> + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-Restriction-001 + Jeremy J. Carroll + This test shows the syntax for using the same restriction twice in OWL Lite. + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/Restriction/inconsistent001#" + xml:base="http://www.w3.org/2002/03owlt/Restriction/inconsistent001" > + <owl:Ontology/> + <owl:ObjectProperty rdf:ID="op"/> + <rdf:Description rdf:ID="a"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="#op"/> + <owl:someValuesFrom rdf:resource= + "http://www.w3.org/2002/07/owl#Nothing" /> + </owl:Restriction> + </rdf:type> + </rdf:Description> + <rdf:Description rdf:ID="b"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="#op"/> + <owl:someValuesFrom rdf:resource= + "http://www.w3.org/2002/07/owl#Nothing" /> + </owl:Restriction> + </rdf:type> + </rdf:Description> + + + +</rdf:RDF> + + + + + + + + + + + + + + + + + WebOnt-Restriction-002 + Jeremy J. Carroll + This test shows syntax that was not permitted in OWL Lite or OWL DL for using the same restriction twice, but is permitted in OWL 2 DL. + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/Restriction/inconsistent002" > + <owl:Ontology/> + <owl:ObjectProperty rdf:ID="op"/> + <rdf:Description rdf:ID="a"> + <rdf:type> + <owl:Restriction rdf:nodeID="r"> + <owl:onProperty rdf:resource="#op"/> + <owl:someValuesFrom rdf:resource= + "http://www.w3.org/2002/07/owl#Nothing" /> + </owl:Restriction> + </rdf:type> + </rdf:Description> + <rdf:Description rdf:ID="b"> + <rdf:type rdf:nodeID="r"/> + </rdf:Description> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + WebOnt-Restriction-003 + Jeremy J. Carroll + This test shows syntax that was not permitted in OWL Lite or OWL DL for using the same restriction twice, but is permitted in OWL 2 DL. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/Restriction/consistent003#" + xml:base="http://www.w3.org/2002/03owlt/Restriction/consistent003" > + <owl:Ontology/> + <owl:DatatypeProperty rdf:ID="dp"/> + <owl:Class rdf:ID="C"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="superC"/> + <owl:Restriction rdf:nodeID="r"> + <owl:onProperty rdf:resource="#dp"/> + <owl:someValuesFrom rdf:resource= + "http://www.w3.org/2001/XMLSchema#byte" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="D"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="superD"/> + <rdf:Description rdf:nodeID="r"/> + </owl:intersectionOf> + </owl:Class> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-Restriction-004 + Jeremy J. Carroll + This test shows OWL Lite syntax for using two equivalent restrictions. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/Restriction/consistent004" > + <owl:Ontology/> + <owl:DatatypeProperty rdf:ID="dp"/> + <owl:Class rdf:ID="C"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="superC"/> + <owl:Restriction> + <owl:onProperty rdf:resource="#dp"/> + <owl:someValuesFrom rdf:resource= + "http://www.w3.org/2001/XMLSchema#byte" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="D"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="superD"/> + <owl:Restriction> + <owl:onProperty rdf:resource="#dp"/> + <owl:someValuesFrom rdf:resource= + "http://www.w3.org/2001/XMLSchema#byte" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-SymmetricProperty-002 + Jeremy J. Carroll + Test illustrating extensional semantics of <code>owl:SymmetricProperty</code>. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/SymmetricProperty/premises002#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xml:base="http://www.w3.org/2002/03owlt/SymmetricProperty/conclusions002" > + + <owl:Ontology/> + + <owl:SymmetricProperty rdf:about="premises002#equalityOnA"> + <rdfs:domain> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="premises002#a"/> + <owl:Thing rdf:about="premises002#b"/> + <owl:Thing rdf:about="premises002#c"/> + </owl:oneOf> + </owl:Class> + </rdfs:domain> + </owl:SymmetricProperty> + + <owl:Thing rdf:about="premises002#a"> + <first:equalityOnA rdf:resource="premises002#a"/> + </owl:Thing> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/SymmetricProperty/premises002#" + xml:base="http://www.w3.org/2002/03owlt/SymmetricProperty/premises002" > + + <owl:Ontology/> + + <owl:InverseFunctionalProperty rdf:about="#equalityOnA"> + <rdfs:range> + <owl:Class rdf:ID="A"> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:ID="a"/> + <owl:Thing rdf:ID="b"/> + </owl:oneOf> + </owl:Class> + </rdfs:range> + </owl:InverseFunctionalProperty> + + <owl:Thing rdf:about="#a"> + <first:equalityOnA rdf:resource="#a"/> + </owl:Thing> + <owl:Thing rdf:about="#b"> + <first:equalityOnA rdf:resource="#b"/> + </owl:Thing> + + <owl:Thing rdf:ID="c"/> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-SymmetricProperty-003 + Jos De Roo + A Lite version of test <a xmlns="http://www.w3.org/1999/xhtml" href="#SymmetricProperty-001">001</a>. + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/SymmetricProperty/premises003#" + xml:base="http://www.w3.org/2002/03owlt/SymmetricProperty/conclusions003" > + + <owl:Ontology/> + + <owl:Thing rdf:about="premises003#Antwerp"> + <first:path> + <owl:Thing rdf:about="premises003#Ghent"/> + </first:path> + </owl:Thing> + + <owl:ObjectProperty rdf:about="premises003#path"/> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/SymmetricProperty/premises003#" + xml:base="http://www.w3.org/2002/03owlt/SymmetricProperty/premises003" > + + <owl:Ontology/> + + <owl:Thing rdf:about="premises003#Ghent"> + <first:path> + <owl:Thing rdf:about="premises003#Antwerp"/> + </first:path> + </owl:Thing> + + <owl:SymmetricProperty rdf:about="premises003#path"/> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-Thing-003 + Jeremy J. Carroll + The extension of OWL Thing may not be empty. + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/Thing/inconsistent003" > + + <owl:Ontology/> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"> + <owl:equivalentClass rdf:resource + ="http://www.w3.org/2002/07/owl#Nothing"/> + </owl:Class> + +</rdf:RDF> + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-Thing-004 + Jeremy J. Carroll + The extension of OWL Thing may be a singleton in OWL DL. + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/Thing/consistent004" > + + <owl:Ontology/> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#s"/> + </owl:oneOf> + </owl:Class> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-TransitiveProperty-002 + Jeremy J. Carroll + Test illustrating extensional semantics of <code>owl:TransitiveProperty</code>. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/TransitiveProperty/premises002#" + xmlns:second="http://www.w3.org/2002/03owlt/TransitiveProperty/conclusions002#" + xml:base="http://www.w3.org/2002/03owlt/TransitiveProperty/conclusions002" > + <owl:Ontology/> + <owl:TransitiveProperty rdf:about="premises002#symProp"/> + <rdf:Description rdf:about="premises002#a"> + <rdf:type> + <owl:Restriction> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/> + <owl:onProperty rdf:resource="premises002#symProp"/> + <owl:someValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#Thing"/> + </owl:Restriction> + </rdf:type> + </rdf:Description> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/TransitiveProperty/premises002#" + xmlns:second="http://www.w3.org/2002/03owlt/TransitiveProperty/conclusions002#" + xml:base="http://www.w3.org/2002/03owlt/TransitiveProperty/premises002" > + <owl:Ontology/> + <owl:SymmetricProperty rdf:ID="symProp"> + <rdfs:range> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:ID="a"/> + <owl:Thing rdf:ID="b"/> + </owl:oneOf> + </owl:Class> + </rdfs:range> + </owl:SymmetricProperty> + <owl:Thing rdf:about="#a"> + <first:symProp rdf:resource="#a"/> + </owl:Thing> + <owl:Thing rdf:about="#b"> + <first:symProp rdf:resource="#b"/> + </owl:Thing> + + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-allValuesFrom-001 + Jeremy J. Carroll + A simple example. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:first="http://www.w3.org/2002/03owlt/allValuesFrom/premises001#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/allValuesFrom/conclusions001" > + <owl:Ontology/> + <first:c rdf:about="premises001#o"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing"/> + </first:c> + <owl:Class rdf:about="premises001#c"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/allValuesFrom/premises001#" + xml:base="http://www.w3.org/2002/03owlt/allValuesFrom/premises001" > + <owl:Ontology/> + <owl:Class rdf:ID="r"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#p"/> + <owl:allValuesFrom rdf:resource="#c"/> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:ObjectProperty rdf:ID="p"/> + <owl:Class rdf:ID="c"/> + <first:r rdf:ID="i"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing"/> + <first:p> + <owl:Thing rdf:ID="o" /> + </first:p> + </first:r> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-allValuesFrom-002 + Jeremy J. Carroll + Another simple example; contrast with <code>owl:someValuesFrom</code>. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/allValuesFrom/premises002#" + xmlns:second="http://www.w3.org/2002/03owlt/allValuesFrom/nonconclusions002#" + xml:base="http://www.w3.org/2002/03owlt/allValuesFrom/nonconclusions002" > + <owl:Ontology/> + <owl:Thing rdf:about="premises002#i"> + <first:p> + <first:c rdf:nodeID="o" /> + </first:p> + </owl:Thing> + <owl:Thing rdf:nodeID="o" /> + <owl:ObjectProperty rdf:about="premises002#p"/> + <owl:Class rdf:about="premises002#c"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/allValuesFrom/premises002#" + xml:base="http://www.w3.org/2002/03owlt/allValuesFrom/premises002" > + <owl:Ontology/> + <owl:Class rdf:ID="r"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#p"/> + <owl:allValuesFrom rdf:resource="#c"/> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:ObjectProperty rdf:ID="p"/> + + <owl:Class rdf:ID="c"/> + <first:r rdf:ID="i"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing"/> + </first:r> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-backwardCompatibleWith-002 + Jeremy J. Carroll + In OWL Lite and DL the subject and object of a triple with predicate <code>owl:backwardCompatibleWith</code> must both be explicitly typed as <code>owl:Ontology</code>. In OWL 2, this RDF graph parses to a single ontology with URI http://www.example.org/ and an annotation assertion between a blank node and that URI. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/backwardCompatibleWith/consistent002#" + xml:base="http://www.w3.org/2002/03owlt/backwardCompatibleWith/consistent002" > + <rdf:Description> + <owl:backwardCompatibleWith> + <owl:Ontology rdf:about="http://www.example.org/"/> + </owl:backwardCompatibleWith> + </rdf:Description> + +</rdf:RDF> + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-cardinality-001 + Jeremy J. Carroll + An <code>owl:cardinality</code> constraint is simply shorthand for a pair of <code>owl:minCardinality</code> and <code>owl:maxCardinality</code> constraints. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/cardinality/conclusions001" > + <owl:Ontology/> + <owl:Class rdf:about="premises001#c"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="premises001#p"/> + <owl:maxCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="premises001#p"/> + <owl:minCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:ObjectProperty rdf:about="premises001#p"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/cardinality/premises001" > + <owl:Ontology/> + <owl:Class rdf:ID="c"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#p"/> + <owl:cardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:cardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:ObjectProperty rdf:ID="p"/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-cardinality-002 + Jeremy J. Carroll + An <code>owl:cardinality</code> constraint is simply shorthand for a pair of <code>owl:minCardinality</code> and <code>owl:maxCardinality</code> constraints. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/cardinality/conclusions002" > + <owl:Ontology/> + <owl:Class rdf:ID="c"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#p"/> + <owl:cardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:cardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:ObjectProperty rdf:ID="p"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/cardinality/premises002" > + <owl:Ontology/> + <owl:Class rdf:about="conclusions002#c"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="conclusions002#p"/> + <owl:maxCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="conclusions002#p"/> + <owl:minCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:ObjectProperty rdf:about="conclusions002#p"/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-cardinality-003 + Jeremy J. Carroll + An <code>owl:cardinality</code> constraint is simply shorthand for a pair of <code>owl:minCardinality</code> and <code>owl:maxCardinality</code> constraints. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/cardinality/conclusions003" > + <owl:Ontology/> + <owl:Class rdf:about="premises003#c"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="premises003#p"/> + <owl:maxCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >2</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="premises003#p"/> + <owl:minCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >2</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:ObjectProperty rdf:about="premises003#p"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/cardinality/premises003" > + <owl:Ontology/> + <owl:Class rdf:ID="c"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#p"/> + <owl:cardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >2</owl:cardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:ObjectProperty rdf:ID="p"/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-cardinality-004 + Jeremy J. Carroll + An <code>owl:cardinality</code> constraint is simply shorthand for a pair of <code>owl:minCardinality</code> and <code>owl:maxCardinality</code> constraints. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/cardinality/conclusions004" > + <owl:Ontology/> + <owl:Class rdf:ID="c"> + <rdfs:subClassOf> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="#p"/> + <owl:cardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >2</owl:cardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:ObjectProperty rdf:ID="p"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/cardinality/premises004" > + <owl:Ontology/> + <owl:Class rdf:about="conclusions004#c"> + <rdfs:subClassOf> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="conclusions004#p"/> + <owl:maxCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >2</owl:maxCardinality> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="conclusions004#p"/> + <owl:minCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >2</owl:minCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:ObjectProperty rdf:about="conclusions004#p"/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-001 + Sean Bechhofer + DL Test: fact1.1 + +If a, b and c are disjoint, then: + +(a and b) or (b and c) or (c and a) + +is unsatisfiable. + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent001" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#b"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#b"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:intersectionOf> + </owl:Class> + </owl:unionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#b"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#b"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-002 + Sean Bechhofer + DL Test: fact2.1 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent002" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:allValuesFrom> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </rdfs:subClassOf> + </owl:Restriction> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-003 + Sean Bechhofer + DL Test: fact3.1 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent003" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f2"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f3"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#f1"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f2"/> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#f2"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f3"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f2"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f1"/> + </owl:ObjectProperty> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#f3"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-004 + Sean Bechhofer + DL Test: fact4.1 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent004" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#rx3"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#c1"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c2"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:complementOf> + </owl:Class> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#rx3"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#c1"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#rx4"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#c2"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c1"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c2"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx1"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx2"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx3"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rx1"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rx"/> + </owl:ObjectProperty> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#rx3"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx4"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rx2"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rx"/> + </owl:ObjectProperty> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#rx4"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rxa"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx1a"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx2a"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx3a"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rx1a"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rxa"/> + </owl:ObjectProperty> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#rx3a"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx4a"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rx2a"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rxa"/> + </owl:ObjectProperty> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#rx4a"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx"/> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#rx"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-005 + Sean Bechhofer + DL Test: fact4.2 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent005" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#rx3a"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#c1"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c2"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:complementOf> + </owl:Class> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#rx3a"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#c1"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#rx4a"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#c2"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c1"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c2"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx1"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx2"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx3"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rx1"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rx"/> + </owl:ObjectProperty> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#rx3"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx4"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rx2"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rx"/> + </owl:ObjectProperty> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#rx4"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rxa"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx1a"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx2a"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx3a"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rx1a"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rxa"/> + </owl:ObjectProperty> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#rx3a"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx4a"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rx2a"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rxa"/> + </owl:ObjectProperty> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#rx4a"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx"/> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#rx"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Satisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-006 + Sean Bechhofer + DL Test: t1.1 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent006" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invR"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Satisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-007 + Sean Bechhofer + DL Test: t1.2 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent007" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">2</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-008 + Sean Bechhofer + DL Test: t1.3 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent008" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invR"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-009 + Sean Bechhofer + DL Test: t10.1 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent009" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invS"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#s"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF1"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f1"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f1"/> + </owl:ObjectProperty> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#s"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#f1"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Satisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-010 + Sean Bechhofer + DL Test: t10.2 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent010" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:complementOf> + </owl:Class> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invS"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:allValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invF"/> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#s"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invS"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#s"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF1"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f1"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f1"/> + </owl:ObjectProperty> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#s"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#f1"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-011 + Sean Bechhofer + DL Test: t10.3 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent011" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#s"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#s"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invS"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invS"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#s"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF1"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f1"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f1"/> + </owl:ObjectProperty> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#s"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#f1"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-012 + Sean Bechhofer + DL Test: t10.4 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent012" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#s"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invS"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#s"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF1"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f1"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f1"/> + </owl:ObjectProperty> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#s"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#f1"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-013 + Sean Bechhofer + DL Test: t10.5 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent013" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:complementOf> + </owl:Class> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invF1"/> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#s"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invS"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#s"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF1"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f1"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f1"/> + </owl:ObjectProperty> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#s"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#f1"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-014 + Sean Bechhofer + DL Test: t11.1 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent014" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:complementOf> + </owl:Class> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invS"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#s"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invS"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#s"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-015 + Sean Bechhofer + DL Test: t12.1 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent015" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#s"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#q"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invR"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invR"/> + <owl:someValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#s"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#q"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-016 + Sean Bechhofer + DL Test: t2.1 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent016" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f2"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f2"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f1"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f2"/> +<rdf:Description rdf:about='http://www.w3.org/2002/07/owl#Thing' > + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f1"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> +</rdf:Description> +<rdf:Description rdf:about='http://www.w3.org/2002/07/owl#Thing' > + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f2"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> +</rdf:Description> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Satisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-017 + Sean Bechhofer + DL Test: t2.2 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent017" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f2"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f2"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f1"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f2"/> +<rdf:Description rdf:about='http://www.w3.org/2002/07/owl#Thing' > + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f1"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> +</rdf:Description> +<rdf:Description rdf:about='http://www.w3.org/2002/07/owl#Thing' > + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f2"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> +</rdf:Description> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-018 + Sean Bechhofer + DL Test: t3.1 +There are 90 possible partitions in the satisfiable case + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent018" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">3</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Satisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-019 + Sean Bechhofer + DL Test: t3.2 +There are 301 possible partitions in the unsatisfiable case + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent019" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">3</owl:maxCardinality> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-020 + Sean Bechhofer + DL Test: t3a.1 +there are 1,701 possible partitions in the satisfiable case + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent020" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">4</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Satisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-021 + Sean Bechhofer + DL Test: t3a.2 +There are 7,770 possible partitions in the unsatisfiable case + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent021" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">5</owl:maxCardinality> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Satisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-022 + Sean Bechhofer + DL Test: t3a.3 +There are 42,525 possible partitions in the satisfiable case + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent022" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">4</owl:maxCardinality> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-023 + Sean Bechhofer + DL Test: t4.1 +Dynamic blocking example + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent023" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#s"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#p"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:allValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#p"/> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#p"/> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#p"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#p"/> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invR"/> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invP"/> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invS"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invP"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#p"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invS"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#s"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#p"/> + <owl:TransitiveProperty rdf:about="http://oiled.man.example.net/test#p"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-024 + Sean Bechhofer + DL Test: t5.1 +Non-finite model example from paper + +The concept should be coherent but has no finite model + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent024" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + </owl:complementOf> + </owl:Class> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invF"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invR"/> + <owl:someValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invF"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <owl:TransitiveProperty rdf:about="http://oiled.man.example.net/test#r"/> +<rdf:Description rdf:about='http://www.w3.org/2002/07/owl#Thing' > + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> +</rdf:Description> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Satisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-025 + Sean Bechhofer + DL Test: t5f.1 +Non-finite model example from paper + +The concept should be coherent but has no finite model + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent025" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + </owl:complementOf> + </owl:Class> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invF"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invR"/> + <owl:someValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invF"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <owl:TransitiveProperty rdf:about="http://oiled.man.example.net/test#r"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Satisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-026 + Sean Bechhofer + DL Test: t6.1 +Double blocking example. + +The concept should be incoherent but needs double blocking + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent026" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:complementOf> + </owl:Class> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invF"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invR"/> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invF"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <owl:TransitiveProperty rdf:about="http://oiled.man.example.net/test#r"/> +<rdf:Description rdf:about='http://www.w3.org/2002/07/owl#Thing' > + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> +</rdf:Description> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-027 + Sean Bechhofer + DL Test: t6f.1 +Double blocking example. + +The concept should be incoherent but needs double blocking + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent027" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:complementOf> + </owl:Class> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invF"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invR"/> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invF"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <owl:TransitiveProperty rdf:about="http://oiled.man.example.net/test#r"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-028 + Sean Bechhofer + DL Test: t7.1 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent028" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invR"/> + <owl:allValuesFrom> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:complementOf> + </owl:Class> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:unionOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <owl:TransitiveProperty rdf:about="http://oiled.man.example.net/test#r"/> +<rdf:Description rdf:about='http://www.w3.org/2002/07/owl#Thing' > + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> +</rdf:Description> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Satisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-029 + Sean Bechhofer + DL Test: t7.2 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent029" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invR"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <owl:TransitiveProperty rdf:about="http://oiled.man.example.net/test#r"/> +<rdf:Description rdf:about='http://www.w3.org/2002/07/owl#Thing' > + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> +</rdf:Description> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-030 + Sean Bechhofer + DL Test: t7.3 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent030" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invF"/> + <owl:someValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <owl:TransitiveProperty rdf:about="http://oiled.man.example.net/test#r"/> +<rdf:Description rdf:about='http://www.w3.org/2002/07/owl#Thing' > + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> +</rdf:Description> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-031 + Sean Bechhofer + DL Test: t7f.1 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent031" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invR"/> + <owl:allValuesFrom> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:complementOf> + </owl:Class> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:unionOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <owl:TransitiveProperty rdf:about="http://oiled.man.example.net/test#r"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Satisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-032 + Sean Bechhofer + DL Test: t7f.2 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent032" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invR"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <owl:TransitiveProperty rdf:about="http://oiled.man.example.net/test#r"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-033 + Sean Bechhofer + DL Test: t7f.3 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent033" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invF"/> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:FunctionalProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <owl:TransitiveProperty rdf:about="http://oiled.man.example.net/test#r"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-034 + Sean Bechhofer + DL Test: t8.1 + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent034" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invR"/> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invR"/> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r1"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Satisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-035 + Sean Bechhofer + A test for the interaction of one-of and inverse using the idea of a spy point. +Everything is related to the spy via the property p and we know that the spy +has at most two invP successors, thus limiting the cardinality of the domain +to being at most 2. + + + + + + + <rdf:RDF + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent035" + xmlns:oiled="http://oiled.man.example.net/test#"> + +<owl:Ontology rdf:about=""> + <rdfs:comment>An ontology illustrating the use of a spy point that +limits the cardinality of the interpretation domain to having only two +objects.</rdfs:comment> +</owl:Ontology> + +<owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:minCardinality +rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">3</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> +</owl:Class> + +<owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#p"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#invP"/> +</owl:ObjectProperty> +<owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + +<owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invP"/> + +<owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#p"/> + <owl:someValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="http://oiled.man.example.net/test#spy"/> + </owl:oneOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> +</owl:Class> + +<rdf:Description rdf:about="http://oiled.man.example.net/test#spy"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#invP"/> + <owl:maxCardinality +rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">2</owl:maxCardinality> + </owl:Restriction> + </rdf:type> +</rdf:Description> + +<oiled:Unsatisfiable/> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-040 + Ian Horrocks + This kind of pattern comes up a lot in more complex ontologies. +Failure to cope with this kind of pattern is one +of the reasons that many reasoners have been unable to +cope with such ontologies. + + + + + + + <rdf:RDF xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:eg="http://example.org/factkb#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent040" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://example.org/factkb#A"/> + <owl:Class rdf:about="http://example.org/factkb#B"/> + <owl:Class rdf:about="http://example.org/factkb#A0"/> + <owl:Class rdf:about="http://example.org/factkb#A1"/> + <owl:Class rdf:about="http://example.org/factkb#A2"/> + <owl:Class rdf:about="http://example.org/factkb#A3"/> + <owl:Class rdf:about="http://example.org/factkb#A4"/> + <owl:Class rdf:about="http://example.org/factkb#A5"/> + <owl:Class rdf:about="http://example.org/factkb#A6"/> + <owl:Class rdf:about="http://example.org/factkb#A7"/> + <owl:Class rdf:about="http://example.org/factkb#A8"/> + <owl:Class rdf:about="http://example.org/factkb#A9"/> + <owl:Class rdf:about="http://example.org/factkb#B0"/> + <owl:Class rdf:about="http://example.org/factkb#B1"/> + <owl:Class rdf:about="http://example.org/factkb#B2"/> + <owl:Class rdf:about="http://example.org/factkb#B3"/> + <owl:Class rdf:about="http://example.org/factkb#B4"/> + <owl:Class rdf:about="http://example.org/factkb#B5"/> + <owl:Class rdf:about="http://example.org/factkb#B6"/> + <owl:Class rdf:about="http://example.org/factkb#B7"/> + <owl:Class rdf:about="http://example.org/factkb#B8"/> + <owl:Class rdf:about="http://example.org/factkb#B9"/> + <owl:Class rdf:about="http://example.org/factkb#C1"> + <rdfs:subClassOf> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A0"/> + <owl:Class rdf:about="http://example.org/factkb#B0"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A1"/> + <owl:Class rdf:about="http://example.org/factkb#B1"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A2"/> + <owl:Class rdf:about="http://example.org/factkb#B2"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A3"/> + <owl:Class rdf:about="http://example.org/factkb#B3"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A4"/> + <owl:Class rdf:about="http://example.org/factkb#B4"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A5"/> + <owl:Class rdf:about="http://example.org/factkb#B5"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A6"/> + <owl:Class rdf:about="http://example.org/factkb#B6"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A7"/> + <owl:Class rdf:about="http://example.org/factkb#B7"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A8"/> + <owl:Class rdf:about="http://example.org/factkb#B8"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A9"/> + <owl:Class rdf:about="http://example.org/factkb#B9"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A10"/> + <owl:Class rdf:about="http://example.org/factkb#B10"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A11"/> + <owl:Class rdf:about="http://example.org/factkb#B11"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A12"/> + <owl:Class rdf:about="http://example.org/factkb#B12"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A13"/> + <owl:Class rdf:about="http://example.org/factkb#B13"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A14"/> + <owl:Class rdf:about="http://example.org/factkb#B14"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A15"/> + <owl:Class rdf:about="http://example.org/factkb#B15"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A16"/> + <owl:Class rdf:about="http://example.org/factkb#B16"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A17"/> + <owl:Class rdf:about="http://example.org/factkb#B17"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A18"/> + <owl:Class rdf:about="http://example.org/factkb#B18"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A19"/> + <owl:Class rdf:about="http://example.org/factkb#B19"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A20"/> + <owl:Class rdf:about="http://example.org/factkb#B20"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A21"/> + <owl:Class rdf:about="http://example.org/factkb#B21"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A22"/> + <owl:Class rdf:about="http://example.org/factkb#B22"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A23"/> + <owl:Class rdf:about="http://example.org/factkb#B23"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A24"/> + <owl:Class rdf:about="http://example.org/factkb#B24"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A25"/> + <owl:Class rdf:about="http://example.org/factkb#B25"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A26"/> + <owl:Class rdf:about="http://example.org/factkb#B26"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A27"/> + <owl:Class rdf:about="http://example.org/factkb#B27"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A28"/> + <owl:Class rdf:about="http://example.org/factkb#B28"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A29"/> + <owl:Class rdf:about="http://example.org/factkb#B29"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A30"/> + <owl:Class rdf:about="http://example.org/factkb#B30"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A31"/> + <owl:Class rdf:about="http://example.org/factkb#B31"/> + </owl:unionOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://example.org/factkb#C2"> + <rdfs:subClassOf> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A"/> + <owl:Class rdf:about="http://example.org/factkb#B"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#A"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://example.org/factkb#B"/> + </owl:complementOf> + </owl:Class> + </owl:unionOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://example.org/factkb#C3"> + <rdfs:subClassOf> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://example.org/factkb#A"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://example.org/factkb#B"/> + </owl:unionOf> + </owl:Class> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://example.org/factkb#A"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://example.org/factkb#B"/> + </owl:complementOf> + </owl:Class> + </owl:unionOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://example.org/factkb#C4"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://example.org/factkb#R"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://example.org/factkb#C2"/> + </owl:someValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://example.org/factkb#C5"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://example.org/factkb#R"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://example.org/factkb#C3"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://example.org/factkb#A10"/> + <owl:Class rdf:about="http://example.org/factkb#A11"/> + <owl:Class rdf:about="http://example.org/factkb#A12"/> + <owl:Class rdf:about="http://example.org/factkb#A13"/> + <owl:Class rdf:about="http://example.org/factkb#A14"/> + <owl:Class rdf:about="http://example.org/factkb#A15"/> + <owl:Class rdf:about="http://example.org/factkb#A16"/> + <owl:Class rdf:about="http://example.org/factkb#A17"/> + <owl:Class rdf:about="http://example.org/factkb#A18"/> + <owl:Class rdf:about="http://example.org/factkb#A19"/> + <owl:Class rdf:about="http://example.org/factkb#A20"/> + <owl:Class rdf:about="http://example.org/factkb#A21"/> + <owl:Class rdf:about="http://example.org/factkb#A22"/> + <owl:Class rdf:about="http://example.org/factkb#A23"/> + <owl:Class rdf:about="http://example.org/factkb#A24"/> + <owl:Class rdf:about="http://example.org/factkb#A25"/> + <owl:Class rdf:about="http://example.org/factkb#A26"/> + <owl:Class rdf:about="http://example.org/factkb#A27"/> + <owl:Class rdf:about="http://example.org/factkb#A28"/> + <owl:Class rdf:about="http://example.org/factkb#A29"/> + <owl:Class rdf:about="http://example.org/factkb#A30"/> + <owl:Class rdf:about="http://example.org/factkb#A31"/> + <owl:Class rdf:about="http://example.org/factkb#B10"/> + <owl:Class rdf:about="http://example.org/factkb#B11"/> + <owl:Class rdf:about="http://example.org/factkb#B12"/> + <owl:Class rdf:about="http://example.org/factkb#B13"/> + <owl:Class rdf:about="http://example.org/factkb#B14"/> + <owl:Class rdf:about="http://example.org/factkb#B15"/> + <owl:Class rdf:about="http://example.org/factkb#B16"/> + <owl:Class rdf:about="http://example.org/factkb#B17"/> + <owl:Class rdf:about="http://example.org/factkb#B18"/> + <owl:Class rdf:about="http://example.org/factkb#B19"/> + <owl:Class rdf:about="http://example.org/factkb#B20"/> + <owl:Class rdf:about="http://example.org/factkb#B21"/> + <owl:Class rdf:about="http://example.org/factkb#B22"/> + <owl:Class rdf:about="http://example.org/factkb#B23"/> + <owl:Class rdf:about="http://example.org/factkb#B24"/> + <owl:Class rdf:about="http://example.org/factkb#B25"/> + <owl:Class rdf:about="http://example.org/factkb#B26"/> + <owl:Class rdf:about="http://example.org/factkb#B27"/> + <owl:Class rdf:about="http://example.org/factkb#B28"/> + <owl:Class rdf:about="http://example.org/factkb#B29"/> + <owl:Class rdf:about="http://example.org/factkb#B30"/> + <owl:Class rdf:about="http://example.org/factkb#B31"/> + <owl:Class rdf:about="http://example.org/factkb#TEST"> + <rdfs:subClassOf> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://example.org/factkb#C1"/> + <owl:Class rdf:about="http://example.org/factkb#C4"/> + <owl:Class rdf:about="http://example.org/factkb#C5"/> + </owl:intersectionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:ObjectProperty rdf:about="http://example.org/factkb#R"/> + <eg:TEST/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-101 + Sean Bechhofer + DL Test: heinsohn1.1 +Tbox tests from Heinsohn et al. + +Tests incoherency caused by disjoint concept + + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent101" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#f"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c1"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1"/> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#e3"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </rdfs:subClassOf> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + WebOnt-description-logic-102 + Sean Bechhofer + DL Test: heinsohn1.2 +Tbox tests from Heinsohn et al. + +Tests incoherency caused by disjoint concept + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent102" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:allValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:intersectionOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#f"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c1"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1"/> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#e3"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </rdfs:subClassOf> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-103 + Sean Bechhofer + DL Test: heinsohn1.3 +Tbox tests from Heinsohn et al. + +Tests incoherency caused by disjoint concept + + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent103" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#e3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#f"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#f"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c1"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1"/> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#e3"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </rdfs:subClassOf> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + WebOnt-description-logic-104 + Sean Bechhofer + DL Test: heinsohn1.4 +Tbox tests from Heinsohn et al. + +Tests incoherency caused by disjoint concept + + + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent104" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class rdf:about="http://oiled.man.example.net/test#c1"/> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#f"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c1"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1"/> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#e3"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </rdfs:subClassOf> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + WebOnt-description-logic-105 + Sean Bechhofer + DL Test: heinsohn2.1 +Tbox tests from Heinsohn et al. + +Tests incoherency caused by number restrictions + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent105" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:minCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >2</owl:minCardinality> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:maxCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-106 + Sean Bechhofer + DL Test: heinsohn2.2 +Tbox tests from Heinsohn et al. + +Tests incoherency caused by number restrictions + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent106" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:maxCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-107 + Sean Bechhofer + DL Test: heinsohn3.1 +Tbox tests from Heinsohn et al. + +Tests incoherency caused by number restrictions and role hierarchy + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent107" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:minCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >2</owl:minCardinality> + </owl:Restriction> + </owl:complementOf> + </owl:Class> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:minCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"> + <owl:equivalentClass> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:unionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#e"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r1"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r2"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r3"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#t1"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#tt"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#t2"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#tt"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#t3"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#tt"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#tt"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <owl:disjointWith> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <owl:disjointWith> + <owl:Class rdf:about="http://oiled.man.example.net/test#e"/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"> + <owl:disjointWith> + <owl:Class rdf:about="http://oiled.man.example.net/test#e"/> + </owl:disjointWith> + </owl:Class> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-108 + Sean Bechhofer + DL Test: heinsohn3.2 +Tbox tests from Heinsohn et al. + +Tests incoherency caused by number restrictions and role hierarchy + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent108" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:minCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >2</owl:minCardinality> + </owl:Restriction> + </owl:complementOf> + </owl:Class> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#tt"/> + <owl:maxCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#t1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r2"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#tt"/> + <owl:maxCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#t2"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r3"/> + <owl:someValuesFrom> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#tt"/> + <owl:maxCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#t3"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#e"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"> + <owl:equivalentClass> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:unionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#e"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r1"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r2"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r3"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#t1"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#tt"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#t2"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#tt"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#t3"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#tt"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#tt"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <owl:disjointWith> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <owl:disjointWith> + <owl:Class rdf:about="http://oiled.man.example.net/test#e"/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"> + <owl:disjointWith> + <owl:Class rdf:about="http://oiled.man.example.net/test#e"/> + </owl:disjointWith> + </owl:Class> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-109 + Sean Bechhofer + DL Test: heinsohn3c.1 +Tbox tests from Heinsohn et al. + +Tests incoherency caused by number restrictions and role hierarchy + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent109" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#tt"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + </owl:allValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#tt"/> + <owl:minCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >3</owl:minCardinality> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#tt"/> + <owl:maxCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#tt"/> + <owl:maxCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#tt"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-110 + Sean Bechhofer + DL Test: heinsohn4.1 +Tbox tests from Heinsohn et al. + +Tests role restrictions + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent110" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#e"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:allValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:allValuesFrom> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#e"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:complementOf> + </owl:Class> + </owl:unionOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#e"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-111 + Sean Bechhofer + DL Test: heinsohn4.2 +Tbox tests from Heinsohn et al. + +Tests role restrictions + + + + + + + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent111" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#s"/> + <owl:maxCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:allValuesFrom> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + <owl:Class> + <owl:complementOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#s"/> + <owl:minCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >2</owl:minCardinality> + </owl:Restriction> + </owl:complementOf> + </owl:Class> + </owl:unionOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <rdfs:subClassOf> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:complementOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#e"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"/> + <rdf:Description> + <rdf:type rdf:resource="http://oiled.man.example.net/test#Unsatisfiable"/> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-description-logic-201 + Sean Bechhofer + DL Test: +ABox test from DL98 systems comparison. + + + + + + + <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/conclusions201" +> +<owl:Ontology/> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V822576"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C110"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V822576"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C94"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V822576"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C136"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V822576"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C58"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V822576"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C80"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V822576"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C56"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V822576"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C116"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V822576"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C114"/> +</rdf:type> +</owl:Thing> +</rdf:RDF> + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/premises201" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C14"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C18"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C20"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C18"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C22"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C20"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C24"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C26"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C24"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C28"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C26"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C30"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C22"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C28"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C32"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C30"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C36"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C38"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C36"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C40"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C38"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C42"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C44"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C42"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C46"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C44"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C48"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C40"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C46"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C50"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C48"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C32"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C50"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C54"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C14"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C56"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C58"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C56"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C60"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C58"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C62"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C64"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C62"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C66"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C64"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C68"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C60"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C66"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C72"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C68"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C74"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C54"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C72"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C76"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C78"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C80"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C76"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C78"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C82"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C84"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C82"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C86"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C84"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C88"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C88"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C94"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C86"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C96"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C94"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C98"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C100"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C98"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C102"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C100"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C104"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C106"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C104"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C108"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C106"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C110"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C102"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C108"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C112"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C110"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C114"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C96"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C112"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C116"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C80"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C114"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C118"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C120"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C118"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C122"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C120"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C124"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C126"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C124"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C128"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C126"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C130"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C122"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C128"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C132"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C134"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C130"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C132"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C136"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C116"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C134"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C138"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C136"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C140"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C74"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C138"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#TEST"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C140"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#R1"/> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V822576"> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + </rdf:type> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </rdf:type> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </rdf:type> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C132"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C100"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C108"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C102"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C84"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C86"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C18"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C78"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C96"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C76"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C134"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C112"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C98"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C88"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C82"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + </owl:Thing> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-description-logic-205 + Sean Bechhofer + DL Test: k_lin +ABox test from DL98 systems comparison. + + + + + + + <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/conclusions205" +> +<owl:Ontology/> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16560"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C18"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16560"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16560"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16560"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C14"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16561"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C6"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16562"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> +</rdf:type> +</owl:Thing> +</rdf:RDF> + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/premises205" + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C14"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C14"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C18"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#TEST"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C18"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#R1"/> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16560"> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#TEST"/> + </rdf:type> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + </rdf:type> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16562"/> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16561"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16561"> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16562"> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + </owl:Thing> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-description-logic-207 + Sean Bechhofer + DL Test: k_ph +ABox test from DL98 systems comparison. + + + + + + + <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/conclusions207" +> +<owl:Ontology/> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V21080"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V21081"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> +</rdf:type> +</owl:Thing> +</rdf:RDF> + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/premises207" + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#TEST"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#R1"/> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V21080"> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#TEST"/> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V21081"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V21081"> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </rdf:type> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + </owl:Thing> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-description-logic-208 + Sean Bechhofer + DL Test: k_poly +ABox test from DL98 systems comparison. + + + + + + + <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/conclusions208" +> +<owl:Ontology/> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16457"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C38"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16440"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C98"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16440"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C82"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16440"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C80"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16461"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C56"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16461"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C44"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16461"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C42"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16464"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C56"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16464"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C44"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16464"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C42"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16455"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C56"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16455"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C44"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16455"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C42"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16462"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C38"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16453"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C76"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16453"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C62"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16453"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C60"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16465"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C38"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16460"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C38"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16463"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C76"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16463"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C62"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16463"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C60"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16459"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16459"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C68"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16459"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C88"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16459"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C50"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16448"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C38"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16439"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C130"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16439"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C28"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16439"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C108"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16439"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C106"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16439"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C104"/> +</rdf:type> +</owl:Thing> +</rdf:RDF> + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/premises208" + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C14"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C18"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C14"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C20"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C18"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C22"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C20"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C24"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C22"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C26"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C24"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C28"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C26"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C30"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C32"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C30"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C32"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C36"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C38"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C36"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C40"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C38"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C42"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C44"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C40"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C42"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C46"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C48"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C50"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C46"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C48"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C50"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C54"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C56"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C44"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C54"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C58"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C56"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C60"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C62"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C58"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C60"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C64"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C66"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C68"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C64"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C66"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C68"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C72"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C74"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C72"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C76"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C62"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C74"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C78"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C76"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C80"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C82"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C78"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C80"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C84"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C86"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C88"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C84"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C86"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C88"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C94"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C96"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C94"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C98"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C82"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C96"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C100"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C98"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C102"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C104"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C102"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C106"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C100"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C104"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C108"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C28"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C106"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C110"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C112"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C110"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C102"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C114"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C116"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C112"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C114"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C118"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C120"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C116"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C118"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C122"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C120"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C124"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C122"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C126"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C124"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C128"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C126"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C130"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C128"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#TEST"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C108"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C130"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#R1"/> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16439"> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#TEST"/> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C100"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C98"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16440"/> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16442"/> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16441"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16440"> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C102"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C96"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C78"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C94"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C76"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16463"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16441"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16442"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16448"> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C36"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C50"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C88"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C68"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16449"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16449"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16453"> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C94"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C74"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C58"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C72"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C56"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16461"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16455"> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C72"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C54"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C40"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C38"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16460"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16457"> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C36"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C50"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C88"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C68"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16459"> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </rdf:type> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C14"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C18"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C48"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C86"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C84"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C66"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C64"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C46"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C32"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C30"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16460"> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C36"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C50"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C88"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C68"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16461"> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C72"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C54"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C40"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C38"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16462"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16462"> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C36"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C50"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C88"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C68"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16463"> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C94"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C74"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C58"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C72"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C56"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16464"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16464"> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C72"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C54"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C40"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C38"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16465"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16465"> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C36"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C50"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C88"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C68"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + </owl:Thing> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-description-logic-209 + Sean Bechhofer + DL Test: k_poly +ABox test from DL98 systems comparison. +(Modified in light of implementation feedback, see test description-logic-208). + + + + + + + <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/nonconclusions209" +> +<owl:Ontology/> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16448"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C122"/> +</rdf:type> +</owl:Thing> +</rdf:RDF> + <rdf:RDF + xml:base="http://www.w3.org/2002/03owlt/description-logic/premises209" + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C14"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C18"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C14"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C20"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C18"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C22"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C20"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C24"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C22"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C26"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C24"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C28"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C26"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C30"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C32"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C30"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C32"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C36"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C38"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C36"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C40"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C38"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C42"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C44"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C40"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C42"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C46"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C48"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C50"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C46"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C48"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C50"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C54"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C56"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C44"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C54"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C58"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C56"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C60"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C62"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C58"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C60"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C64"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C66"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C68"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C64"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C66"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C68"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C72"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C74"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C72"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C76"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C62"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C74"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C78"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C76"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C80"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C82"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C78"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C80"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C84"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C86"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C88"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C84"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C86"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C88"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C94"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C96"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C94"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C98"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C82"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C96"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C100"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C98"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C102"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C104"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C102"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C106"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C100"/> + </owl:complementOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C104"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C108"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C28"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C106"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C110"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:complementOf> + </owl:Class> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C112"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C110"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C102"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C114"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C116"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C112"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C114"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C118"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C120"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C116"/> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C118"/> + </owl:complementOf> + </owl:Class> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C122"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C120"/> + </owl:complementOf> + </owl:Class> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C124"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C122"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C126"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C124"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C128"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C126"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C130"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C128"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#TEST"> + <owl:equivalentClass> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C108"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C130"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#R1"/> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16439"> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#TEST"/> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C100"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C98"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16440"/> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16442"/> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16441"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16440"> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C102"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C96"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C78"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C94"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C76"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16463"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16441"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16442"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16448"> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C36"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C50"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C88"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C68"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16449"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16449"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16453"> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C94"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C74"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C58"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C72"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C56"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16461"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16455"> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C72"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C54"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C40"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C38"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16460"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16457"> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C36"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C50"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C88"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C68"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16459"> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </rdf:type> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C14"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C18"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C48"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C86"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C84"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C66"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C64"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C46"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C32"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C30"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16460"> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C36"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C50"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C88"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C68"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16461"> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C72"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C54"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C40"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C38"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16462"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16462"> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C36"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C50"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C88"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C68"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16463"> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C94"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C74"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C58"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C72"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C56"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16464"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16464"> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C72"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C54"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C40"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:complementOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C38"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16465"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16465"> + <rdf:type> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Class> + <owl:complementOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#C36"/> + </owl:complementOf> + </owl:Class> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C50"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C88"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C68"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:allValuesFrom> + </owl:Restriction> + </rdf:type> + </owl:Thing> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-description-logic-501 + Jeremy J. Carroll + This is the classic 3 SAT problem. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent501" > +<owl:Ontology/> +<owl:Class rdf:ID='TorF'> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:ID='T'> + <owl:differentFrom rdf:resource='#F'/> + </owl:Thing> + <owl:Thing rdf:ID='F'/> + </owl:oneOf> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:about='#plus1'/> + <owl:Thing rdf:about='#minus1'/> + </owl:oneOf> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:about='#plus2'/> + <owl:Thing rdf:about='#minus2'/> + </owl:oneOf> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:about='#plus3'/> + <owl:Thing rdf:about='#minus3'/> + </owl:oneOf> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:about='#plus4'/> + <owl:Thing rdf:about='#minus4'/> + </owl:oneOf> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:about='#plus5'/> + <owl:Thing rdf:about='#minus5'/> + </owl:oneOf> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:about='#plus6'/> + <owl:Thing rdf:about='#minus6'/> + </owl:oneOf> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:about='#plus7'/> + <owl:Thing rdf:about='#minus7'/> + </owl:oneOf> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:about='#plus8'/> + <owl:Thing rdf:about='#minus8'/> + </owl:oneOf> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:about='#plus9'/> + <owl:Thing rdf:about='#minus9'/> + </owl:oneOf> +</owl:Class> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus9'/> + <rdf:Description rdf:about='#minus8'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#minus8'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus4'/> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus5'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#minus1'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus1'/> + <rdf:Description rdf:about='#plus5'/> + <rdf:Description rdf:about='#plus8'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#minus6'/> + <rdf:Description rdf:about='#minus3'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus3'/> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#plus7'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus3'/> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#plus8'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#minus6'/> + <rdf:Description rdf:about='#plus8'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#plus3'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#minus9'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus5'/> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#plus3'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus5'/> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#plus2'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#minus3'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus6'/> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#minus5'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus3'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus9'/> + <rdf:Description rdf:about='#minus1'/> + <rdf:Description rdf:about='#minus2'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus6'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#plus9'/> + <rdf:Description rdf:about='#minus3'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#minus9'/> + <rdf:Description rdf:about='#minus2'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus9'/> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#plus2'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus5'/> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#plus4'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#plus5'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus1'/> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus4'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#plus4'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus3'/> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#minus6'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#minus9'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#minus2'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#plus4'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#minus5'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus5'/> + <rdf:Description rdf:about='#plus4'/> + <rdf:Description rdf:about='#minus3'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus1'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus1'/> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus9'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#plus6'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#minus7'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus1'/> + <rdf:Description rdf:about='#plus9'/> + <rdf:Description rdf:about='#minus8'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus5'/> + <rdf:Description rdf:about='#minus9'/> + <rdf:Description rdf:about='#minus7'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#minus9'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#minus1'/> + <rdf:Description rdf:about='#minus2'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#plus4'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#plus5'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#minus6'/> + <rdf:Description rdf:about='#plus3'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus5'/> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#plus6'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#minus5'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#minus9'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-description-logic-502 + Jeremy J. Carroll + This is the classic 3 SAT problem. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/description-logic/inconsistent502#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent502" > +<owl:Ontology/> +<owl:Class rdf:ID='TorF'> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:ID='T'> + <owl:differentFrom rdf:resource='#F'/> + </owl:Thing> + <owl:Thing rdf:ID='F'/> + </owl:oneOf> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:about='#plus1'/> + <owl:Thing rdf:about='#minus1'/> + </owl:oneOf> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:about='#plus2'/> + <owl:Thing rdf:about='#minus2'/> + </owl:oneOf> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:about='#plus3'/> + <owl:Thing rdf:about='#minus3'/> + </owl:oneOf> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:about='#plus4'/> + <owl:Thing rdf:about='#minus4'/> + </owl:oneOf> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:about='#plus5'/> + <owl:Thing rdf:about='#minus5'/> + </owl:oneOf> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:about='#plus6'/> + <owl:Thing rdf:about='#minus6'/> + </owl:oneOf> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:about='#plus7'/> + <owl:Thing rdf:about='#minus7'/> + </owl:oneOf> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:about='#plus8'/> + <owl:Thing rdf:about='#minus8'/> + </owl:oneOf> + <owl:oneOf rdf:parseType='Collection'> + <owl:Thing rdf:about='#plus9'/> + <owl:Thing rdf:about='#minus9'/> + </owl:oneOf> +</owl:Class> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#minus4'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus3'/> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#minus4'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus9'/> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#plus5'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus4'/> + <rdf:Description rdf:about='#minus6'/> + <rdf:Description rdf:about='#minus2'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#minus3'/> + <rdf:Description rdf:about='#plus1'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus3'/> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#plus7'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#plus3'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#minus6'/> + <rdf:Description rdf:about='#plus9'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#minus6'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#minus5'/> + <rdf:Description rdf:about='#minus3'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus4'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#plus6'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#minus1'/> + <rdf:Description rdf:about='#plus4'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus3'/> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#plus2'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#plus9'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus9'/> + <rdf:Description rdf:about='#minus2'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#minus5'/> + <rdf:Description rdf:about='#minus7'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus5'/> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#plus9'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#minus7'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus9'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#minus2'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#plus4'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#plus9'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#minus6'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#plus9'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus5'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#minus9'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#plus9'/> + <rdf:Description rdf:about='#minus8'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus4'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#plus9'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#plus9'/> + <rdf:Description rdf:about='#plus5'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus4'/> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#plus3'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus5'/> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#plus7'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#plus3'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus4'/> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#plus6'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus4'/> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#minus5'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus6'/> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#minus9'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#plus9'/> + <rdf:Description rdf:about='#minus6'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus9'/> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#plus3'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#minus4'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#plus6'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus3'/> + <rdf:Description rdf:about='#plus5'/> + <rdf:Description rdf:about='#minus8'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus9'/> + <rdf:Description rdf:about='#plus4'/> + <rdf:Description rdf:about='#plus3'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#plus2'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus5'/> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#minus9'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#minus3'/> + <rdf:Description rdf:about='#minus4'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus9'/> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#minus8'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#minus1'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +<rdf:Description rdf:about='#T'> + <rdf:type> + <owl:Class> + <owl:oneOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#minus8'/> + </owl:oneOf> + </owl:Class> + </rdf:type> +</rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-description-logic-503 + Ian Horrocks + This is a different encoding of test 501. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/description-logic/consistent503#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent503" > + <owl:Ontology/> + <first:Test /> + <owl:Class rdf:about='#plus1'> + <owl:disjointWith> + <owl:Class rdf:about='#minus1'/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about='#plus2'> + <owl:disjointWith> + <owl:Class rdf:about='#minus2'/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about='#plus3'> + <owl:disjointWith> + <owl:Class rdf:about='#minus3'/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about='#plus4'> + <owl:disjointWith> + <owl:Class rdf:about='#minus4'/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about='#plus5'> + <owl:disjointWith> + <owl:Class rdf:about='#minus5'/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about='#plus6'> + <owl:disjointWith> + <owl:Class rdf:about='#minus6'/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about='#plus7'> + <owl:disjointWith> + <owl:Class rdf:about='#minus7'/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about='#plus8'> + <owl:disjointWith> + <owl:Class rdf:about='#minus8'/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about='#plus9'> + <owl:disjointWith> + <owl:Class rdf:about='#minus9'/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus9'/> + <rdf:Description rdf:about='#minus8'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#minus8'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus4'/> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus5'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#minus1'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus1'/> + <rdf:Description rdf:about='#plus5'/> + <rdf:Description rdf:about='#plus8'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#minus6'/> + <rdf:Description rdf:about='#minus3'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus3'/> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#plus7'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus3'/> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#plus8'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#minus6'/> + <rdf:Description rdf:about='#plus8'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#plus3'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#minus9'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus5'/> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#plus3'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus5'/> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#plus2'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#minus3'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus6'/> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#minus5'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus3'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus9'/> + <rdf:Description rdf:about='#minus1'/> + <rdf:Description rdf:about='#minus2'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus6'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#plus9'/> + <rdf:Description rdf:about='#minus3'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#minus9'/> + <rdf:Description rdf:about='#minus2'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus9'/> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#plus2'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus5'/> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#plus4'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#plus5'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus1'/> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus4'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#plus4'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus3'/> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#minus6'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#minus9'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#minus2'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#plus4'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#minus5'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus5'/> + <rdf:Description rdf:about='#plus4'/> + <rdf:Description rdf:about='#minus3'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus1'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus1'/> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus9'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#plus6'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#minus7'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus1'/> + <rdf:Description rdf:about='#plus9'/> + <rdf:Description rdf:about='#minus8'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus5'/> + <rdf:Description rdf:about='#minus9'/> + <rdf:Description rdf:about='#minus7'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#minus9'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#minus1'/> + <rdf:Description rdf:about='#minus2'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#plus4'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#plus5'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#minus6'/> + <rdf:Description rdf:about='#plus3'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus5'/> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#plus6'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#minus5'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#minus9'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-description-logic-504 + Ian Horrocks + This is a different encoding of test 502. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/description-logic/inconsistent504#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent504" > + <owl:Ontology/> + <first:Test /> + <owl:Class rdf:about='#plus1'> + <owl:disjointWith> + <owl:Class rdf:about='#minus1'/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about='#plus2'> + <owl:disjointWith> + <owl:Class rdf:about='#minus2'/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about='#plus3'> + <owl:disjointWith> + <owl:Class rdf:about='#minus3'/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about='#plus4'> + <owl:disjointWith> + <owl:Class rdf:about='#minus4'/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about='#plus5'> + <owl:disjointWith> + <owl:Class rdf:about='#minus5'/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about='#plus6'> + <owl:disjointWith> + <owl:Class rdf:about='#minus6'/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about='#plus7'> + <owl:disjointWith> + <owl:Class rdf:about='#minus7'/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about='#plus8'> + <owl:disjointWith> + <owl:Class rdf:about='#minus8'/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about='#plus9'> + <owl:disjointWith> + <owl:Class rdf:about='#minus9'/> + </owl:disjointWith> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#minus4'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus3'/> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#minus4'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus9'/> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#plus5'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus4'/> + <rdf:Description rdf:about='#minus6'/> + <rdf:Description rdf:about='#minus2'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#minus3'/> + <rdf:Description rdf:about='#plus1'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus3'/> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#plus7'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#plus3'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#minus6'/> + <rdf:Description rdf:about='#plus9'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#minus6'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#minus5'/> + <rdf:Description rdf:about='#minus3'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus4'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#plus6'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#minus1'/> + <rdf:Description rdf:about='#plus4'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus3'/> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#plus2'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#plus9'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus9'/> + <rdf:Description rdf:about='#minus2'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#minus5'/> + <rdf:Description rdf:about='#minus7'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus5'/> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#plus9'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#minus7'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus9'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#minus2'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#plus4'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#plus9'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus2'/> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#minus6'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus7'/> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#plus9'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus5'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#minus9'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#plus9'/> + <rdf:Description rdf:about='#minus8'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus4'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#plus9'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#plus9'/> + <rdf:Description rdf:about='#plus5'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus4'/> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#plus3'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus5'/> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#plus7'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#plus3'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus4'/> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#plus6'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus4'/> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#minus5'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus6'/> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#minus9'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus1'/> + <rdf:Description rdf:about='#plus9'/> + <rdf:Description rdf:about='#minus6'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus9'/> + <rdf:Description rdf:about='#minus8'/> + <rdf:Description rdf:about='#plus3'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#plus3'/> + <rdf:Description rdf:about='#minus4'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#plus6'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus3'/> + <rdf:Description rdf:about='#plus5'/> + <rdf:Description rdf:about='#minus8'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus9'/> + <rdf:Description rdf:about='#plus4'/> + <rdf:Description rdf:about='#plus3'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus8'/> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#plus2'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus5'/> + <rdf:Description rdf:about='#minus2'/> + <rdf:Description rdf:about='#minus9'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#minus3'/> + <rdf:Description rdf:about='#minus4'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#minus9'/> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#minus8'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#minus4'/> + <rdf:Description rdf:about='#minus1'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about='#Test'> + <rdfs:subClassOf> + <owl:Class> + <owl:unionOf rdf:parseType='Collection'> + <rdf:Description rdf:about='#plus6'/> + <rdf:Description rdf:about='#minus7'/> + <rdf:Description rdf:about='#minus8'/> + </owl:unionOf> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-601 + Sean Bechhofer + DL Test: fact1.1 +If a, b and c are disjoint, then: + +(a and b) or (b and c) or (c and a) + +is unsatisfiable. + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent601"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:ID="C.1.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#b.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.3"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.2"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#short" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.5"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#decimal" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#C.6"/> + <owl:Class rdf:about="#C.7"/> + <owl:Class rdf:about="#C.8"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="C.6.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.6"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#byte" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#b"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="C.8"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.8"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="C.7.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.7"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#integer" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="C.7"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.7"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#integer" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="C.8.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.8"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#b"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="C.6"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.6"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#byte" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.5"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#decimal" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.2"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#short" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#b"> + <rdfs:subClassOf rdf:resource="http://oiled.man.example.net/test#c.comp"/> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.3"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"> + <rdfs:subClassOf> + <owl:Class rdf:about="#C.1"/> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:ID="C.1"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#b.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c.comp"/> + </owl:intersectionOf> + </owl:Class> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-602 + Sean Bechhofer + DL Test: fact2.1 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent602"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#d.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </rdfs:subClassOf> + <rdfs:subClassOf rdf:resource="http://oiled.man.example.net/test#d.comp"/> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:allValuesFrom rdf:resource="http://oiled.man.example.net/test#c"/> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:ID="A.2"> + <rdfs:subClassOf rdf:resource="http://oiled.man.example.net/test#d"/> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:allValuesFrom rdf:resource="http://oiled.man.example.net/test#c"/> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-603 + Sean Bechhofer + DL Test: fact3.1 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent603"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f2"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="http://oiled.man.example.net/test#p1.comp"/> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f3"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f3"> + <rdfs:subPropertyOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f2"/> + </rdfs:subPropertyOf> + <rdfs:subPropertyOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + </rdfs:subPropertyOf> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f2"> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-604 + Sean Bechhofer + DL Test: fact4.1 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent604"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c1"/> + <owl:Class rdf:ID="C.1.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx3"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="#A.2"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#C.1"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx3"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="http://oiled.man.example.net/test#c1"/> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx4"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="http://oiled.man.example.net/test#c2"/> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="C.1"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="A.2"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#c1"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c2"/> + </owl:intersectionOf> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx4"> + <rdfs:subPropertyOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx2"/> + </rdfs:subPropertyOf> + <rdfs:subPropertyOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx"/> + </rdfs:subPropertyOf> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx3"> + <rdfs:subPropertyOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx1"/> + </rdfs:subPropertyOf> + <rdfs:subPropertyOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx"/> + </rdfs:subPropertyOf> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rxa"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx"> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx1a"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx2a"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx3a"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rx1a"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rxa"/> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx4a"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rx2a"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rxa"/> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-605 + Sean Bechhofer + DL Test: fact4.2 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent605"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#C.1"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx3a"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#c1"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx4a"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="http://oiled.man.example.net/test#c2"/> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="C.1"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="A.2"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#c1"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c2"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="C.1.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx3a"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="#A.2"/> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx4"> + <rdfs:subPropertyOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx2"/> + </rdfs:subPropertyOf> + <rdfs:subPropertyOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx"/> + </rdfs:subPropertyOf> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx3"> + <rdfs:subPropertyOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx1"/> + </rdfs:subPropertyOf> + <rdfs:subPropertyOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx"/> + </rdfs:subPropertyOf> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rxa"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx"> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx1a"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx2a"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx3a"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rx1a"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rxa"/> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#rx4a"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rx2a"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#rxa"/> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <oiled:Satisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-606 + Sean Bechhofer + DL Test: t1.1 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent606"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.5"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#decimal" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.6"/> + </owl:onProperty> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#byte" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.7"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#integer" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.4"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="C.1.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="C.2.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.2"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#short" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="C.3.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.3"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="#A.14"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="A.14"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="C.3"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.3"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="C.2"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.2"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#short" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="C.1"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.4"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"> + <rdfs:subClassOf rdf:resource="http://oiled.man.example.net/test#p5.comp"/> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.7"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#integer" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"> + <rdfs:subClassOf rdf:resource="#C.3"/> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.6"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#byte" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"> + <rdfs:subClassOf rdf:resource="#C.2"/> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.5"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#decimal" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <rdfs:subClassOf rdf:resource="#C.1"/> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <oiled:Satisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-608 + Sean Bechhofer + DL Test: t1.3 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent608"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.5"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#decimal" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.6"/> + </owl:onProperty> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#byte" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.7"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#integer" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.4"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="C.1.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="C.2.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.2"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#short" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="#A.14"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="C.3.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.3"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="A.14"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="C.3"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.3"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="C.2"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.2"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#short" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="C.1"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p5"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.4"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p4"> + <rdfs:subClassOf rdf:resource="http://oiled.man.example.net/test#p5.comp"/> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.7"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#integer" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p3"> + <rdfs:subClassOf rdf:resource="#C.3"/> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.6"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#byte" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"> + <rdfs:subClassOf rdf:resource="#C.2"/> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.5"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#decimal" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <rdfs:subClassOf rdf:resource="#C.1"/> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-609 + Sean Bechhofer + DL Test: t10.1 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent609"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p.comp"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF1"> + <owl:inverseOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + </owl:inverseOf> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f1"/> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invS"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#s"/> + </owl:ObjectProperty> + <oiled:Satisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-610 + Sean Bechhofer + DL Test: t10.2 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent610"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:ID="A.2"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invS"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:allValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="#V.3"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p.comp"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="#A.2"/> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="V.3"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF1"> + <owl:inverseOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + </owl:inverseOf> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f1"/> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invS"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#s"/> + </owl:ObjectProperty> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-611 + Sean Bechhofer + DL Test: t10.3 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent611"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:ID="A.2"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invS"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"/> + </owl:onProperty> + <owl:allValuesFrom rdf:resource="http://oiled.man.example.net/test#p.comp"/> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="#A.2"/> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF1"> + <owl:inverseOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + </owl:inverseOf> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f1"/> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invS"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#s"/> + </owl:ObjectProperty> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-612 + Sean Bechhofer + DL Test: t10.4 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent612"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="http://oiled.man.example.net/test#p.comp"/> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF1"> + <owl:inverseOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + </owl:inverseOf> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f1"/> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invS"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#s"/> + </owl:ObjectProperty> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-613 + Sean Bechhofer + DL Test: t10.5 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent613"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="V.3"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="#A.2"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="A.2"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p.comp"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF1"/> + </owl:onProperty> + <owl:allValuesFrom rdf:resource="#V.3"/> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF1"> + <owl:inverseOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + </owl:inverseOf> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f1"/> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invS"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#s"/> + </owl:ObjectProperty> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-614 + Sean Bechhofer + DL Test: t11.1 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent614"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="V.2"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invS"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p.comp"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom rdf:resource="#V.2"/> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invS"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#s"/> + </owl:ObjectProperty> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-615 + Sean Bechhofer + DL Test: t12.1 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent615"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#q.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.2"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#short" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="V.5"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#s"/> + <owl:someValuesFrom> + <owl:Class rdf:about="#A.3"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="#A.4"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="A.4"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"/> + </owl:onProperty> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="#V.5"/> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="A.3"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#q.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#q"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.2"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#short" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-616 + Sean Bechhofer + DL Test: t2.1 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent616"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f2"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <rdfs:subClassOf rdf:resource="http://oiled.man.example.net/test#p2.comp"/> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f2"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f1"/> + </owl:ObjectProperty> + <oiled:Satisfiable/> + <rdf:Description rdf:about="/2002/07/owl#Thing"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f2"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-617 + Sean Bechhofer + DL Test: t2.2 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent617"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f1"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f2"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="/2002/07/owl#Thing"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f2"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p2"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <rdfs:subClassOf rdf:resource="http://oiled.man.example.net/test#p2.comp"/> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f2"/> + <rdfs:subPropertyOf rdf:resource="http://oiled.man.example.net/test#f1"/> + </owl:ObjectProperty> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-623 + Sean Bechhofer + DL Test: t4.1 +Dynamic blocking example + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent623"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:ID="A.2"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#p"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="/2002/07/owl#Thing"/> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:allValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#p"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="#V.3"/> + </owl:allValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#p"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="#V.4"/> + </owl:allValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#p"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="#V.5"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#a.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="V.7"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invP"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="#V.6"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="V.6"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invS"/> + </owl:onProperty> + <owl:allValuesFrom rdf:resource="http://oiled.man.example.net/test#a.comp"/> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="V.5"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="V.4"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#p"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="/2002/07/owl#Thing"/> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="V.3"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom rdf:resource="/2002/07/owl#Thing"/> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="#A.2"/> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"/> + </owl:onProperty> + <owl:allValuesFrom rdf:resource="#V.7"/> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invP"> + <owl:inverseOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#p"/> + </owl:inverseOf> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invS"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#s"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#p"> + <rdf:type rdf:resource="/2002/07/owl#TransitiveProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-624 + Sean Bechhofer + DL Test: t5.1 +Non-finite model example from paper + +The concept should be coherent but has no finite model + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent624"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#a.comp"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="#V.2"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#a.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="V.2"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"> + <rdfs:subPropertyOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </rdfs:subPropertyOf> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"> + <rdf:type rdf:resource="/2002/07/owl#TransitiveProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <oiled:Satisfiable/> + <rdf:Description rdf:about="/2002/07/owl#Thing"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-625 + Sean Bechhofer + DL Test: t5f.1 +Non-finite model example from paper + +The concept should be coherent but has no finite model + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent625"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#a.comp"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="#V.2"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="V.2"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#a.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#a"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"> + <rdfs:subPropertyOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </rdfs:subPropertyOf> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"> + <rdf:type rdf:resource="/2002/07/owl#TransitiveProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <oiled:Satisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-626 + Sean Bechhofer + DL Test: t6.1 +Double blocking example. + +The concept should be incoherent but needs double blocking + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent626"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="V.3"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#c.comp"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"/> + </owl:onProperty> + <owl:allValuesFrom rdf:resource="#V.3"/> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="http://oiled.man.example.net/test#c.comp"/> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"> + <rdfs:subPropertyOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </rdfs:subPropertyOf> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"> + <rdf:type rdf:resource="/2002/07/owl#TransitiveProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <rdf:Description rdf:about="/2002/07/owl#Thing"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </rdf:Description> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-627 + Sean Bechhofer + DL Test: t6f.1 +Double blocking example. + +The concept should be incoherent but needs double blocking + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent627"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="V.3"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="http://oiled.man.example.net/test#c.comp"/> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#c.comp"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="http://oiled.man.example.net/test#d"/> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"/> + </owl:onProperty> + <owl:allValuesFrom rdf:resource="#V.3"/> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"> + <rdfs:subPropertyOf> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </rdfs:subPropertyOf> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"> + <rdf:type rdf:resource="/2002/07/owl#TransitiveProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-628 + Sean Bechhofer + DL Test: t7.1 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent628"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="#V.5"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="C.3"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.3"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="C.2"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.2"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#short" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="A.4"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"/> + </owl:onProperty> + <owl:allValuesFrom rdf:resource="#C.2"/> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="C.2.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.2"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#short" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Class rdf:about="#C.3"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="V.5"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="#A.4"/> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="C.3.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.3"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"> + <rdf:type rdf:resource="/2002/07/owl#TransitiveProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <oiled:Satisfiable/> + <rdf:Description rdf:about="/2002/07/owl#Thing"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-629 + Sean Bechhofer + DL Test: t7.2 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent629"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="V.3"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="#A.2"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="A.2"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"/> + </owl:onProperty> + <owl:allValuesFrom rdf:resource="http://oiled.man.example.net/test#p1.comp"/> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="#V.3"/> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"> + <rdf:type rdf:resource="/2002/07/owl#TransitiveProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <oiled:Unsatisfiable/> + <rdf:Description rdf:about="/2002/07/owl#Thing"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-630 + Sean Bechhofer + DL Test: t7.3 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent630"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="A.2"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="#V.3"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="#A.2"/> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="V.3"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:someValuesFrom rdf:resource="http://oiled.man.example.net/test#p1.comp"/> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"> + <rdf:type rdf:resource="/2002/07/owl#TransitiveProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <oiled:Unsatisfiable/> + <rdf:Description rdf:about="/2002/07/owl#Thing"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#f"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </rdf:Description> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-631 + Sean Bechhofer + DL Test: t7f.1 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent631"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="#V.5"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="C.2.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.2"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#short" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Class rdf:about="#C.3"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="C.3.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.3"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="V.5"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="#A.4"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="C.3"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.3"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="C.2"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.2"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#short" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="A.4"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"/> + </owl:onProperty> + <owl:allValuesFrom rdf:resource="#C.2"/> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"> + <rdf:type rdf:resource="/2002/07/owl#TransitiveProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <oiled:Satisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-632 + Sean Bechhofer + DL Test: t7f.2 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent632"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="A.2"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"/> + </owl:onProperty> + <owl:allValuesFrom rdf:resource="http://oiled.man.example.net/test#p1.comp"/> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="#V.3"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="V.3"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="#A.2"/> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"> + <rdf:type rdf:resource="/2002/07/owl#TransitiveProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-633 + Sean Bechhofer + DL Test: t7f.3 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent633"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:ID="A.2"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"/> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="#V.3"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="#A.2"/> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="V.3"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="http://oiled.man.example.net/test#p1.comp"/> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p1"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#f"> + <rdf:type rdf:resource="/2002/07/owl#FunctionalProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invF"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#f"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"> + <rdf:type rdf:resource="/2002/07/owl#TransitiveProperty"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-634 + Sean Bechhofer + DL Test: t8.1 + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent634"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#Satisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="#V.4"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="#V.5"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="V.5"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="#V.3"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="V.4"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:about="#V.2"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="V.3"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r1"/> + </owl:onProperty> + <owl:allValuesFrom rdf:resource="http://oiled.man.example.net/test#p.comp"/> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="V.2"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r1"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"/> + </owl:allValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#p"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#invR"> + <owl:inverseOf rdf:resource="http://oiled.man.example.net/test#r"/> + </owl:ObjectProperty> + <oiled:Satisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-641 + Sean Bechhofer + DL Test: heinsohn1.1 +Tbox tests from Heinsohn et al. + +Tests incoherency caused by disjoint concept + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent641"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c1"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1"/> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1.comp"/> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#e3"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.2"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#short" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#f"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <rdfs:subClassOf rdf:resource="http://oiled.man.example.net/test#d.comp"/> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.2"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#short" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-642 + Sean Bechhofer + DL Test: heinsohn1.2 +Tbox tests from Heinsohn et al. + +Tests incoherency caused by disjoint concept + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent642"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#e3"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c1"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1"/> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1.comp"/> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:ID="A.3"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.2"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#short" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#f"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:allValuesFrom rdf:resource="#A.3"/> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="/2002/07/owl#Thing"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <rdfs:subClassOf rdf:resource="http://oiled.man.example.net/test#d.comp"/> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.2"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#short" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-643 + Sean Bechhofer + DL Test: heinsohn1.3 +Tbox tests from Heinsohn et al. + +Tests incoherency caused by disjoint concept + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent643"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#c1"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1"/> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1.comp"/> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#e3"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.2"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#short" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#f"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#e3"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#f"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <rdfs:subClassOf rdf:resource="http://oiled.man.example.net/test#d.comp"/> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.2"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#short" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-644 + Sean Bechhofer + DL Test: heinsohn1.4 +Tbox tests from Heinsohn et al. + +Tests incoherency caused by disjoint concept + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent644"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#e3"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.2"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#short" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#f"> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <rdfs:subClassOf rdf:resource="http://oiled.man.example.net/test#d1"/> + <rdfs:subClassOf> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1.comp"/> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <rdfs:subClassOf rdf:resource="http://oiled.man.example.net/test#d.comp"/> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d1.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.2"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#short" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-646 + Sean Bechhofer + DL Test: heinsohn2.2 +Tbox tests from Heinsohn et al. + +Tests incoherency caused by number restrictions + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent646"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#d.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:maxCardinality> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"/> + </owl:someValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <rdfs:subClassOf rdf:resource="http://oiled.man.example.net/test#d.comp"/> + </owl:Class> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-description-logic-650 + Sean Bechhofer + DL Test: heinsohn4.1 +Tbox tests from Heinsohn et al. + +Tests role restrictions + + + + + + + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/inconsistent650"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:ID="C.4"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.4"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.2"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#short" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#e.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#e"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#Unsatisfiable"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#r"/> + </owl:onProperty> + <owl:someValuesFrom rdf:resource="http://oiled.man.example.net/test#e.comp"/> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:allValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:allValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#r"/> + <owl:allValuesFrom rdf:resource="#C.4"/> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.2"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#short" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#c"> + <rdfs:subClassOf rdf:resource="http://oiled.man.example.net/test#d.comp"/> + </owl:Class> + <owl:Class rdf:ID="C.4.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.4"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#e.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#d"/> + </owl:intersectionOf> + </owl:Class> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#s"/> + <oiled:Unsatisfiable/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-description-logic-661 + Sean Bechhofer + DL Test: k_branch +ABox test from DL98 systems comparison. + + + + + + + <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/conclusions661" +> +<owl:Ontology/> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V822576"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C110"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V822576"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C94"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V822576"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C136"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V822576"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C58"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V822576"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C80"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V822576"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C56"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V822576"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C116"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V822576"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C114"/> +</rdf:type> +</owl:Thing> +</rdf:RDF> + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/premises661"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C82.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.65"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#short" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C94.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.30"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#short" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C30.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.8"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C78.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.25"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C132.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.48"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#byte" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C140"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C74"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C138.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C78"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.25"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C76"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.24"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C74"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C54"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C72.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C72"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C68.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.21"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#integer" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C70"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C28"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C26"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16.comp"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.7"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#integer" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C26"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#R1"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C24"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C24"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C22"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C20"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.6"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#byte" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C20"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C18"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.29"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C40.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.11"/> + </owl:onProperty> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C76.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.24"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C88.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.64"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.3"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C48.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.13"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#byte" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C128"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C126"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C130.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.44"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#short" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C126"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C124"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C124"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C102.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.35"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#integer" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C122"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C120"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C138.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.47"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#decimal" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C120"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C118"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C58"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C56"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C56"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C54"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C14"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C52"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C32.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C50.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C50"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C48.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.15"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C88"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.64"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.52"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C86"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C84"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.28"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#integer" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C84"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C82"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.53"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C50.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.15"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C82"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.65"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#short" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C80"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C76.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C78.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C86.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.28"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#integer" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C98.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.63"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#integer" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.16"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#short" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C22.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.6"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#byte" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.9"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#short" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C46.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.12"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#decimal" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C108"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C106"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34.comp"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.36"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C106"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C104"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C18.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.56"/> + </owl:onProperty> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#integer" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C104"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C100.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.49"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#integer" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C112.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.39"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C102"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C100"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.35"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#integer" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C136.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.46"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C100"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C98"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.49"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#integer" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C38"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C36"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C108.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.36"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C36"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.9"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#short" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C32"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C30.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.14"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#integer" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C30"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C22.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C28.comp"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.8"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C138"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom rdf:resource="http://oiled.man.example.net/test#C136.comp"/> + </owl:Restriction> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.47"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#decimal" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C136"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C116"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C134.comp"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.46"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.22"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C134"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C130.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C132"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.45"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C132"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4.comp"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.48"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#byte" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C130"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C122"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C128"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.44"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#short" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C68"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C60"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C66"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.20"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#byte" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C66"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C64"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C64"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C62"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C62"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C72.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.21"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#integer" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C60"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom rdf:resource="http://oiled.man.example.net/test#C58"/> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C84.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.53"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C96.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.38"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C32.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.14"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#integer" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C68.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.20"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#byte" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.2"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#short" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.4"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C28.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.7"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#integer" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#TEST"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C140"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C110.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.37"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#short" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C134.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.45"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.22"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C18"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.56"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#integer" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.4"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C14"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.3"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C98"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.63"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#integer" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.16"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#short" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C96"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C94.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.38"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C94"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C86.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92.comp"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.30"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#short" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C92"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16.comp"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.29"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C90"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom rdf:resource="http://oiled.man.example.net/test#C88"/> + </owl:Restriction> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.52"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C118"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C116"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C80"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C114"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C114"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C96.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C112.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C112"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C110.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.39"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C110"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C102.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C108.comp"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.37"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#short" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.2"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#short" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C48"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C40.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C46.comp"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.13"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#byte" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C46"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C44"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34.comp"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.12"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#decimal" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C44"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C42"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C42"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C40"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C38"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C34"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.11"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V822576"> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C16"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C2"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C34"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C4"/> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom rdf:resource="http://oiled.man.example.net/test#C98.comp"/> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom rdf:resource="http://oiled.man.example.net/test#C88.comp"/> + </owl:Restriction> + </rdf:type> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom rdf:resource="http://oiled.man.example.net/test#C82.comp"/> + </owl:Restriction> + </rdf:type> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C132.comp"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C100.comp"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C108.comp"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C102.comp"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C90.comp"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C84.comp"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C92.comp"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C86.comp"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C18.comp"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C78.comp"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C96.comp"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C76.comp"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C134.comp"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C10.comp"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C112.comp"/> + </owl:Thing> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-description-logic-665 + Sean Bechhofer + DL Test: k_lin +ABox test from DL98 systems comparison. + + + + + + + <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/conclusions665" +> +<owl:Ontology/> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16560"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C18"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16560"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16560"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16560"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C14"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16561"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C6"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V16562"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> +</rdf:type> +</owl:Thing> +</rdf:RDF> + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/premises665"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.6"/> + </owl:onProperty> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#byte" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C18"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.3"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C16"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C14"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C14"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#R1"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom rdf:resource="http://oiled.man.example.net/test#C2.comp"/> + </owl:Restriction> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.3"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#unsignedByte" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4.comp"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#TEST"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C18"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#TOP"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom rdf:resource="http://oiled.man.example.net/test#C2.comp"/> + </owl:Restriction> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.6"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#byte" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16562"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom rdf:resource="http://oiled.man.example.net/test#C2"/> + </owl:Restriction> + </rdf:type> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C10.comp"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C2.comp"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16561"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom rdf:resource="http://oiled.man.example.net/test#C2"/> + </owl:Restriction> + </rdf:type> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C4.comp"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C2.comp"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V16560"> + <rdf:type rdf:resource="http://oiled.man.example.net/test#TEST"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#TOP"/> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16562"/> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V16561"/> + </owl:Thing> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-description-logic-667 + Sean Bechhofer + DL Test: k_ph +ABox test from DL98 systems comparison. + + + + + + + <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/conclusions667" +> +<owl:Ontology/> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V21080"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> +</rdf:type> +</owl:Thing> +<owl:Thing rdf:about="http://oiled.man.example.net/test#V21081"> + <rdf:type> +<owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> +</rdf:type> +</owl:Thing> +</rdf:RDF> + <rdf:RDF + xmlns:oiled="http://oiled.man.example.net/test#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/premises667"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:DatatypeProperty rdf:ID="P.1"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#int" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.1"/> + <owl:maxCardinality rdf:datatype="/2001/XMLSchema#int" + >0</owl:maxCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.4"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8.comp"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="P.2"/> + </owl:onProperty> + <owl:cardinality rdf:datatype="/2001/XMLSchema#short" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="http://oiled.man.example.net/test#R1"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:someValuesFrom> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.2"/> + <owl:minCardinality rdf:datatype="/2001/XMLSchema#short" + >1</owl:minCardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C10"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#C6"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C2.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C4"/> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#P.4"/> + <owl:cardinality rdf:datatype="/2001/XMLSchema#nonNegativeInteger" + >0</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="http://oiled.man.example.net/test#TEST"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="http://oiled.man.example.net/test#C8.comp"/> + <owl:Class rdf:about="http://oiled.man.example.net/test#C12"/> + </owl:intersectionOf> + </owl:Class> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V21081"> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C4"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C2"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C6.comp"/> + </owl:Thing> + <owl:Thing rdf:about="http://oiled.man.example.net/test#V21080"> + <rdf:type rdf:resource="http://oiled.man.example.net/test#TEST"/> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="http://oiled.man.example.net/test#R1"/> + <owl:allValuesFrom rdf:resource="http://oiled.man.example.net/test#C6.comp"/> + </owl:Restriction> + </rdf:type> + <oiled:R1 rdf:resource="http://oiled.man.example.net/test#V21081"/> + <rdf:type rdf:resource="http://oiled.man.example.net/test#C8.comp"/> + </owl:Thing> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-description-logic-901 + Jeremy J. Carroll + This entailment can be replicated for any three natural numbers i, j, k such that i+j >= k. In this example, they are chosen as 2, 3 and 5. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/description-logic/premises901#" + xmlns:second="http://www.w3.org/2002/03owlt/description-logic/conclusions901#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/conclusions901" > + <owl:Ontology/> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="premises901#p"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype= +"http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >2</owl:minCardinality> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="premises901#q"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype= +"http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >3</owl:minCardinality> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="premises901#r"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype= +"http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >5</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/premises901" > + <owl:Ontology/> + <owl:ObjectProperty rdf:ID="r"/> + <owl:ObjectProperty rdf:ID="p"> + <rdfs:subPropertyOf rdf:resource="#r"/> + <rdfs:range> + <owl:Class rdf:ID="A"/> + </rdfs:range> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:ID="q"> + <rdfs:subPropertyOf rdf:resource="#r"/> + <rdfs:range> + <owl:Class rdf:ID="B"/> + </rdfs:range> + </owl:ObjectProperty> + <owl:Class rdf:about="#A"> + <owl:disjointWith rdf:resource="#B"/> + </owl:Class> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-description-logic-902 + Jeremy J. Carroll + This non-entailment can be replicated for any three natural numbers i, j, k such that i+j < k. In this example, they are chosen as 2, 3 and 6. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/nonconclusions902" > + <owl:Ontology/> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="premises902#p"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype= +"http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >2</owl:minCardinality> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="premises902#q"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype= +"http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >3</owl:minCardinality> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="premises902#r"/> + </owl:onProperty> + <owl:minCardinality rdf:datatype= +"http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >6</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/premises902" > + <owl:Ontology/> + <owl:ObjectProperty rdf:ID="r"/> + <owl:ObjectProperty rdf:ID="p"> + <rdfs:subPropertyOf rdf:resource="#r"/> + <rdfs:range> + <owl:Class rdf:ID="A"/> + </rdfs:range> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:ID="q"> + <rdfs:subPropertyOf rdf:resource="#r"/> + <rdfs:range> + <owl:Class rdf:ID="B"/> + </rdfs:range> + </owl:ObjectProperty> + <owl:Class rdf:about="#A"> + <owl:disjointWith rdf:resource="#B"/> + </owl:Class> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-description-logic-905 + Jeremy J. Carroll + This test shows integer multiplication in OWL DL. + +N is 2. M is 3. N times M is 6. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs= "http://www.w3.org/2000/01/rdf-schema#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent905" > + <owl:Ontology/> + <owl:FunctionalProperty rdf:ID="p-N-to-1" > + <owl:inverseOf> + <owl:ObjectProperty rdf:ID="invP-1-to-N" /> + </owl:inverseOf> + <rdfs:domain rdf:resource="#cardinality-N" /> + <rdfs:range rdf:resource="#only-d" /> + </owl:FunctionalProperty> + <owl:ObjectProperty rdf:about="#p-N-to-1" /> + <owl:FunctionalProperty rdf:ID="q-M-to-1" > + <owl:inverseOf> + <owl:ObjectProperty rdf:ID="invQ-1-to-M" /> + </owl:inverseOf> + <rdfs:domain rdf:resource="#cardinality-N-times-M" /> + <rdfs:range rdf:resource="#cardinality-N" /> + </owl:FunctionalProperty> + <owl:ObjectProperty rdf:about="#q-M-to-1" /> + <owl:FunctionalProperty rdf:ID="r-N-times-M-to-1"> + <owl:inverseOf> + <owl:ObjectProperty rdf:ID="invR-N-times-M-to-1" /> + </owl:inverseOf> + <rdfs:domain rdf:resource="#cardinality-N-times-M" /> + <rdfs:range rdf:resource="#only-d" /> + </owl:FunctionalProperty> + <owl:ObjectProperty rdf:about="#r-N-times-M-to-1"/> + <owl:Class rdf:ID="only-d"> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:ID="d"/> + </owl:oneOf> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#invP-1-to-N"/> + <owl:cardinality rdf:datatype= + "http://www.w3.org/2001/XMLSchema#integer" + >2</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#invR-N-times-M-to-1"/> + <owl:cardinality rdf:datatype= + "http://www.w3.org/2001/XMLSchema#integer" + >6</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="cardinality-N"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#p-N-to-1"/> + <owl:someValuesFrom rdf:resource="#only-d"/> + </owl:Restriction> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#invQ-1-to-M"/> + <owl:cardinality rdf:datatype= + "http://www.w3.org/2001/XMLSchema#integer" + >3</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="cardinality-N-times-M"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#q-M-to-1"/> + <owl:someValuesFrom rdf:resource="#cardinality-N"/> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="#cardinality-N-times-M"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#r-N-times-M-to-1"/> + <owl:someValuesFrom rdf:resource="#only-d"/> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-description-logic-908 + Jeremy J. Carroll + This test shows integer multiplication in OWL DL, interacting with infinity. + +N times infinity is 2 times infinity. +M times infinity is 3 times infinity. +N times M times infinity is 5 times infinity. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs= "http://www.w3.org/2000/01/rdf-schema#" + xml:base="http://www.w3.org/2002/03owlt/description-logic/consistent908" > + <owl:Ontology/> + <owl:FunctionalProperty rdf:ID="p-N-to-1" > + <owl:inverseOf> + <owl:ObjectProperty rdf:ID="invP-1-to-N" /> + </owl:inverseOf> + <rdfs:domain rdf:resource="#cardinality-N" /> + <rdfs:range rdf:resource="#infinite" /> + </owl:FunctionalProperty> + <owl:ObjectProperty rdf:about="#p-N-to-1" /> + <owl:FunctionalProperty rdf:ID="q-M-to-1" > + <owl:inverseOf> + <owl:ObjectProperty rdf:ID="invQ-1-to-M" /> + </owl:inverseOf> + <rdfs:domain rdf:resource="#cardinality-N-times-M" /> + <rdfs:range rdf:resource="#cardinality-N" /> + </owl:FunctionalProperty> + <owl:ObjectProperty rdf:about="#q-M-to-1" /> + <owl:FunctionalProperty rdf:ID="r-N-times-M-to-1"> + <owl:inverseOf> + <owl:ObjectProperty rdf:ID="invR-N-times-M-to-1" /> + </owl:inverseOf> + <rdfs:domain rdf:resource="#cardinality-N-times-M" /> + <rdfs:range rdf:resource="#infinite" /> + </owl:FunctionalProperty> + <owl:ObjectProperty rdf:about="#r-N-times-M-to-1"/> + <owl:Class rdf:ID="infinite"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#invP-1-to-N"/> + <owl:cardinality rdf:datatype= + "http://www.w3.org/2001/XMLSchema#integer" + >2</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#invR-N-times-M-to-1"/> + <owl:cardinality rdf:datatype= + "http://www.w3.org/2001/XMLSchema#integer" + >5</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="cardinality-N"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#p-N-to-1"/> + <owl:someValuesFrom rdf:resource="#infinite"/> + </owl:Restriction> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#invQ-1-to-M"/> + <owl:cardinality rdf:datatype= + "http://www.w3.org/2001/XMLSchema#integer" + >3</owl:cardinality> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:ID="cardinality-N-times-M"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#q-M-to-1"/> + <owl:someValuesFrom rdf:resource="#cardinality-N"/> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="#cardinality-N-times-M"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#r-N-times-M-to-1"/> + <owl:someValuesFrom rdf:resource="#infinite"/> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + WebOnt-differentFrom-001 + Jos De Roo + <code>differentFrom</code> is a <code>SymmetricProperty</code>. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/differentFrom/premises001#" + xmlns:second="http://www.w3.org/2002/03owlt/differentFrom/conclusions001#" + xml:base="http://www.w3.org/2002/03owlt/differentFrom/conclusions001" > + + <owl:Ontology/> + <rdf:Description rdf:about="premises001#b"> + <owl:differentFrom rdf:resource="premises001#a"/> + </rdf:Description> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/differentFrom/premises001#" + xmlns:second="http://www.w3.org/2002/03owlt/differentFrom/conclusions001#" + xml:base="http://www.w3.org/2002/03owlt/differentFrom/premises001" > + + <owl:Ontology/> + <rdf:Description rdf:about="premises001#a"> + <owl:differentFrom rdf:resource="premises001#b"/> + </rdf:Description> + +</rdf:RDF> + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-disjointWith-001 + Jeremy J. Carroll + Disjoint classes have different members. + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/disjointWith/premises001#" + xml:base="http://www.w3.org/2002/03owlt/disjointWith/conclusions001" > + <owl:Ontology/> + <owl:Thing rdf:about="premises001#a"> + <owl:differentFrom> + <owl:Thing rdf:about="premises001#b"/> + </owl:differentFrom> + </owl:Thing> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:first="http://www.w3.org/2002/03owlt/disjointWith/premises001#" + xml:base="http://www.w3.org/2002/03owlt/disjointWith/premises001" > + <owl:Ontology/> + <owl:Class rdf:ID="A"> + <owl:disjointWith> + <owl:Class rdf:ID="B"/> + </owl:disjointWith> + </owl:Class> + <first:A rdf:ID="a"/> + <owl:Thing rdf:about="#a"/> + <first:B rdf:ID="b"/> + <owl:Thing rdf:about="#b"/> +</rdf:RDF> + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-disjointWith-003 + Jeremy J. Carroll + If the owl:disjointWith edges in the graph form an undirected complete subgraph +then this may be within OWL DL. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/disjointWith/consistent003" > + <owl:Ontology/> + <owl:Class rdf:nodeID="A"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="A"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="B"/> + <owl:disjointWith rdf:nodeID="D"/> + <owl:disjointWith rdf:nodeID="E"/> + </owl:Class> + <owl:Class rdf:nodeID="B"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="B"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="A"/> + <owl:disjointWith rdf:nodeID="C"/> + <owl:disjointWith rdf:nodeID="E"/> + </owl:Class> + <owl:Class rdf:nodeID="C"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="C"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="A"/> + <owl:disjointWith rdf:nodeID="D"/> + <owl:disjointWith rdf:nodeID="E"/> + </owl:Class> + <owl:Class rdf:nodeID="D"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="D"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="C"/> + <owl:disjointWith rdf:nodeID="B"/> + <owl:disjointWith rdf:nodeID="E"/> + </owl:Class> + <owl:Class rdf:nodeID="E"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="E"/> + </owl:intersectionOf> + </owl:Class> + +</rdf:RDF> + + + + + + + WebOnt-disjointWith-004 + Jeremy J. Carroll + This example has owl:disjointWith edges in the graph which cannot be generated +by the mapping rules for DisjointClasses. Consider the lack of owl:disjointWith edge +between nodes C and D. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/disjointWith/consistent004" > + <owl:Ontology/> + <owl:Class rdf:nodeID="A"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="A"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="B"/> + <owl:disjointWith rdf:nodeID="D"/> + <owl:disjointWith rdf:nodeID="E"/> + </owl:Class> + <owl:Class rdf:nodeID="B"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="B"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="A"/> + <owl:disjointWith rdf:nodeID="C"/> + <owl:disjointWith rdf:nodeID="E"/> + </owl:Class> + <owl:Class rdf:nodeID="C"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="C"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="A"/> + <owl:disjointWith rdf:nodeID="E"/> + </owl:Class> + <owl:Class rdf:nodeID="D"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="D"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="B"/> + <owl:disjointWith rdf:nodeID="E"/> + </owl:Class> + <owl:Class rdf:nodeID="E"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="E"/> + </owl:intersectionOf> + </owl:Class> + +</rdf:RDF> + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-disjointWith-005 + Jeremy J. Carroll + If the owl:disjointWith edges in the graph form unconnected +undirected complete subgraphs +then this may be within OWL DL. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/disjointWith/consistent005" > + <owl:Ontology/> + <owl:Class rdf:nodeID="A"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="A"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="D"/> + <owl:disjointWith rdf:nodeID="E"/> + </owl:Class> + <owl:Class rdf:nodeID="B"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="B"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="C"/> + </owl:Class> + <owl:Class rdf:nodeID="C"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="C"/> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:nodeID="D"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="D"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="E"/> + </owl:Class> + <owl:Class rdf:nodeID="E"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="E"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="D"/> + </owl:Class> + +</rdf:RDF> + + + + + + + WebOnt-disjointWith-006 + Jeremy J. Carroll + If the owl:disjointWith edges in the graph form +undirected complete subgraphs which share blank nodes +then this was not within OWL DL, but is permissible in OWL 2 DL. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/disjointWith/consistent006" > + <owl:Ontology/> + <owl:Class rdf:nodeID="A"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="A"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="D"/> + <owl:disjointWith rdf:nodeID="E"/> + </owl:Class> + <owl:Class rdf:nodeID="B"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="B"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="C"/> + <owl:disjointWith rdf:nodeID="A"/> + </owl:Class> + <owl:Class rdf:nodeID="C"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="C"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="A"/> + </owl:Class> + <owl:Class rdf:nodeID="D"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="D"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="E"/> + </owl:Class> + <owl:Class rdf:nodeID="E"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="E"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="D"/> + </owl:Class> + +</rdf:RDF> + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-disjointWith-007 + Jeremy J. Carroll + If the owl:disjointWith edges in the graph form +undirected complete subgraphs which share URIref nodes +but do not share blank node +then this may be within OWL DL. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/disjointWith/consistent007" > + <owl:Ontology/> + <owl:Class rdf:ID="A"> + <owl:disjointWith rdf:nodeID="D"/> + <owl:disjointWith rdf:nodeID="E"/> + </owl:Class> + <owl:Class rdf:nodeID="B"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="B"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="C"/> + <owl:disjointWith rdf:resource="#A"/> + </owl:Class> + <owl:Class rdf:nodeID="C"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="C"/> + </owl:intersectionOf> + <owl:disjointWith rdf:resource="#A"/> + </owl:Class> + <owl:Class rdf:nodeID="D"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="D"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="E"/> + </owl:Class> + <owl:Class rdf:nodeID="E"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="E"/> + </owl:intersectionOf> + <owl:disjointWith rdf:nodeID="D"/> + </owl:Class> + +</rdf:RDF> + + + + + + + WebOnt-disjointWith-008 + Jeremy J. Carroll + A further example that cannot be generated from the mapping rule +for DisjointClasses. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/disjointWith/consistent008" > + <owl:Ontology/> + <owl:Class rdf:ID="A"/> + <owl:Class rdf:nodeID="B"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="B"/> + </owl:intersectionOf> + <owl:disjointWith rdf:resource="#A"/> + </owl:Class> + <owl:Class rdf:nodeID="C"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="C"/> + </owl:intersectionOf> + <owl:disjointWith rdf:resource="#A"/> + </owl:Class> + <owl:Class rdf:ID="D"> + <owl:disjointWith rdf:nodeID="B"/> + <owl:disjointWith rdf:nodeID="C"/> + </owl:Class> + +</rdf:RDF> + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-disjointWith-009 + Jeremy J. Carroll + If the owl:disjointWith edges in the graph form +undirected complete subgraphs which share URIref nodes +but do not share blank node +then this may be within OWL DL. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/disjointWith/consistent009" > + <owl:Ontology/> + <owl:Class rdf:ID="A"/> + <owl:Class rdf:nodeID="B"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="B"/> + </owl:intersectionOf> + <owl:disjointWith rdf:resource="#A"/> + </owl:Class> + <owl:Class rdf:nodeID="C"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="C"/> + </owl:intersectionOf> + <owl:disjointWith rdf:resource="#A"/> + </owl:Class> + <owl:Class rdf:ID="D"> + <owl:disjointWith rdf:nodeID="B"/> + <owl:disjointWith rdf:nodeID="C"/> + <owl:disjointWith rdf:resource="#A"/> + </owl:Class> + +</rdf:RDF> + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-equivalentClass-001 + Jeremy J. Carroll + Two classes may have the same class extension. + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/equivalentClass/premises001#" + xml:base="http://www.w3.org/2002/03owlt/equivalentClass/conclusions001" > + <owl:Ontology/> + <first:Car rdf:about="premises001#auto"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing" /> + </first:Car> + <first:Automobile rdf:about="premises001#car"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing" /> + </first:Automobile> + <owl:Class rdf:about="premises001#Car"/> + <owl:Class rdf:about="premises001#Automobile"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/equivalentClass/premises001#" + xml:base="http://www.w3.org/2002/03owlt/equivalentClass/premises001" > + <owl:Ontology/> + <owl:Class rdf:ID="Car"> + <owl:equivalentClass> + <owl:Class rdf:ID="Automobile"/> + </owl:equivalentClass> + </owl:Class> + <first:Car rdf:ID="car"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing" /> + </first:Car> + <first:Automobile rdf:ID="auto"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing" /> + </first:Automobile> +</rdf:RDF> + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-equivalentClass-002 + Jeremy J. Carroll + Two classes may be different names for the same set of individuals + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/equivalentClass/conclusions002" > + <owl:Ontology/> + <owl:Class rdf:about="premises002#Car"> + <rdfs:subClassOf> + <owl:Class rdf:about="premises002#Automobile"> + <rdfs:subClassOf rdf:resource="premises002#Car" /> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/equivalentClass/premises002" > + <owl:Ontology/> + <owl:Class rdf:ID="Car"> + <owl:equivalentClass> + <owl:Class rdf:ID="Automobile"/> + </owl:equivalentClass> + </owl:Class> +</rdf:RDF> + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-equivalentClass-003 + Jeremy J. Carroll + Two classes may be different names for the same set of individuals + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/equivalentClass/conclusions003" > + <owl:Ontology/> + <owl:Class rdf:ID="Car"> + <owl:equivalentClass> + <owl:Class rdf:ID="Automobile"/> + </owl:equivalentClass> + </owl:Class> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/equivalentClass/premises003" > + <owl:Ontology/> + <owl:Class rdf:about="conclusions003#Car"> + <rdfs:subClassOf> + <owl:Class rdf:about="conclusions003#Automobile"> + <rdfs:subClassOf rdf:resource="conclusions003#Car" /> + </owl:Class> + </rdfs:subClassOf> + </owl:Class> +</rdf:RDF> + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-equivalentClass-004 + Jeremy J. Carroll + Two classes with the same complete description are equivalent. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/equivalentClass/conclusions004" > + <owl:Ontology/> + <owl:Class rdf:about="premises004#c1"> + <owl:equivalentClass> + <owl:Class rdf:about="premises004#c2"/> + </owl:equivalentClass> + </owl:Class> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/equivalentClass/premises004" > + <owl:Ontology/> + <owl:Class rdf:ID="c1"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="#p"/> + <owl:cardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:cardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:Class rdf:ID="c2"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty rdf:resource="#p"/> + <owl:cardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:cardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + <owl:ObjectProperty rdf:ID="p"/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-equivalentClass-005 + Jeremy J. Carroll + Two classes with the same partial description are not equivalent. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/equivalentClass/nonconclusions005" > + <owl:Ontology/> +<owl:Class rdf:about="premises005#c1"> + <owl:equivalentClass> + <owl:Class rdf:about="premises005#c2"/> + </owl:equivalentClass> + </owl:Class> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/equivalentClass/premises005" > + <owl:Ontology/> + <owl:Class rdf:ID="c1"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#p"/> + <owl:cardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:cardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:Class rdf:ID="c2"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#p"/> + <owl:cardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >1</owl:cardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + <owl:ObjectProperty rdf:ID="p"/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-equivalentClass-006 + Jeremy J. Carroll + De Morgan's law. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/equivalentClass/conclusions006" > + <owl:Ontology/> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class> + <owl:complementOf rdf:resource="premises006#A"/> + </owl:Class> + <owl:Class> + <owl:complementOf rdf:resource="premises006#B"/> + </owl:Class> + </owl:intersectionOf> + <owl:equivalentClass> + <owl:Class> + <owl:complementOf> + <owl:Class> + <owl:unionOf rdf:parseType="Collection"> + <rdf:Description rdf:about="premises006#A"/> + <rdf:Description rdf:about="premises006#B"/> + </owl:unionOf> + </owl:Class> + </owl:complementOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:Class rdf:about="premises006#A"/> + <owl:Class rdf:about="premises006#B"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/equivalentClass/premises006" > + <owl:Ontology/> + <owl:Class rdf:ID="A"/> + <owl:Class rdf:ID="B"/> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + WebOnt-equivalentClass-008-Direct + Jeremy J. Carroll + Mike Smith + A version of WebOnt-equivalentClass-008 modified for the Direct Semantics, under which annotations in the entailed ontology are ignored. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/equivalentClass/premises008#" + xml:base="http://www.w3.org/2002/03owlt/equivalentClass/nonconclusions008" > + <owl:Ontology/> + <owl:Class rdf:about="premises008#c2"> + <first:annotate>description of c1</first:annotate> + </owl:Class> + <owl:AnnotationProperty rdf:about="premises008#annotate" /> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/equivalentClass/premises008#" + xml:base="http://www.w3.org/2002/03owlt/equivalentClass/premises008" > + + <owl:Ontology/> + <owl:Class rdf:ID="c1"> + <owl:equivalentClass> + <owl:Class rdf:ID="c2"/> + </owl:equivalentClass> + <first:annotate>description of c1</first:annotate> + </owl:Class> + + <owl:AnnotationProperty rdf:ID="annotate" /> + +</rdf:RDF> + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-equivalentClass-009 + Jeremy J. Carroll + A possible mapping of the EquivalentClasses axiom, +which is connected but without a Hamiltonian path. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/equivalentClass/consistent009" > + + <owl:Ontology/> + <owl:Class rdf:nodeID="a"> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:ID="A"/> + </owl:oneOf> + <owl:equivalentClass> + <owl:Class rdf:nodeID="b"> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="B"/> + </owl:unionOf> + </owl:Class> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Class rdf:nodeID="c"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:ID="C"/> + </owl:intersectionOf> + </owl:Class> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Class rdf:nodeID="d"> + <owl:complementOf> + <owl:Class rdf:ID="D"/> + </owl:complementOf> + </owl:Class> + </owl:equivalentClass> + + </owl:Class> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-equivalentProperty-001 + Jeremy J. Carroll + <code>hasLeader</code> may be stated to be the <code>owl:equivalentProperty</code> of <code>hasHead</code>. + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/equivalentProperty/premises001#" + xml:base="http://www.w3.org/2002/03owlt/equivalentProperty/conclusions001" > + <owl:Ontology/> + <owl:Thing rdf:about="premises001#X"> + <first:hasHead> + <owl:Thing rdf:about="premises001#Y"/> + </first:hasHead> + </owl:Thing> + <owl:ObjectProperty rdf:about="premises001#hasHead"/> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/equivalentProperty/premises001#" + xml:base="http://www.w3.org/2002/03owlt/equivalentProperty/premises001" > + <owl:Ontology/> + <owl:ObjectProperty rdf:ID="hasHead"> + <owl:equivalentProperty> + <owl:ObjectProperty rdf:ID="hasLeader"/> + </owl:equivalentProperty> + </owl:ObjectProperty> + <owl:Thing rdf:ID="X"> + <first:hasLeader> + <owl:Thing rdf:ID="Y"/> + </first:hasLeader> + </owl:Thing> +</rdf:RDF> + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-equivalentProperty-002 + Jeremy J. Carroll + A reasoner can also deduce that <code>hasLeader</code> is a <code>subProperty</code> of <code>hasHead</code> and <code>hasHead</code> is a <code>subProperty</code> of <code>hasLeader</code>. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/equivalentProperty/premises002#" + xml:base="http://www.w3.org/2002/03owlt/equivalentProperty/conclusions002" > + <owl:Ontology/> + <owl:ObjectProperty rdf:about="premises002#hasHead"> + <rdfs:subPropertyOf rdf:resource="premises002#hasLeader"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="premises002#hasLeader"> + <rdfs:subPropertyOf rdf:resource="premises002#hasHead"/> + </owl:ObjectProperty> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/equivalentProperty/premises002#" + xml:base="http://www.w3.org/2002/03owlt/equivalentProperty/premises002" > + <owl:Ontology/> + <owl:ObjectProperty rdf:ID="hasHead"> + <owl:equivalentProperty> + <owl:ObjectProperty rdf:ID="hasLeader"/> + </owl:equivalentProperty> + </owl:ObjectProperty> +</rdf:RDF> + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-equivalentProperty-003 + Jeremy J. Carroll + The inverse entailment of test 002 also holds. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/equivalentProperty/conclusions003" > + <owl:Ontology/> + <owl:ObjectProperty rdf:ID="hasHead"> + <owl:equivalentProperty> + <owl:ObjectProperty rdf:ID="hasLeader"/> + </owl:equivalentProperty> + </owl:ObjectProperty> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/equivalentProperty/premises003" > + <owl:Ontology/> + <owl:ObjectProperty rdf:about="conclusions003#hasHead"> + <rdfs:subPropertyOf rdf:resource="conclusions003#hasLeader"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:about="conclusions003#hasLeader"> + <rdfs:subPropertyOf rdf:resource="conclusions003#hasHead"/> + </owl:ObjectProperty> +</rdf:RDF> + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-equivalentProperty-004 + Jeremy J. Carroll + If <code>p</code> and <code>q</code> have the same property extension then <code>p</code> <code>equivalentProperty</code> <code>q</code>. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/equivalentProperty/conclusions004" > + <owl:Ontology/> + <owl:ObjectProperty rdf:about="premises004#p"> + <owl:equivalentProperty> + <owl:ObjectProperty rdf:about="premises004#q"/> + </owl:equivalentProperty> + </owl:ObjectProperty> +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/equivalentProperty/premises004" > + <owl:Ontology/> + <owl:ObjectProperty rdf:ID="p"> + <rdfs:domain rdf:resource="#d"/> + </owl:ObjectProperty> + <owl:ObjectProperty rdf:ID="q"> + <rdfs:domain rdf:resource="#d"/> + </owl:ObjectProperty> + <owl:FunctionalProperty rdf:about="#q"/> + <owl:FunctionalProperty rdf:about="#p"/> + <owl:Thing rdf:ID="v"/> + <owl:Class rdf:ID="d"> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#p"/> + <owl:hasValue rdf:resource="#v"/> + </owl:Restriction> + </owl:equivalentClass> + <owl:equivalentClass> + <owl:Restriction> + <owl:onProperty rdf:resource="#q"/> + <owl:hasValue rdf:resource="#v"/> + </owl:Restriction> + </owl:equivalentClass> + </owl:Class> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-imports-011 + Jeff Heflin + A Lite version of test <a xmlns="http://www.w3.org/1999/xhtml" href="#imports-001">imports-001</a>. + + + + + + + + + + <rdf:RDF + xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' + xmlns:rdfs='http://www.w3.org/2000/01/rdf-schema#' + xmlns:owl='http://www.w3.org/2002/07/owl#' + xml:base='http://www.w3.org/2002/03owlt/imports/conclusions011' > + + <owl:Ontology/> + <rdf:Description rdf:about='http://example.org/data#Socrates'> + <rdf:type> + <owl:Class rdf:about='support011-A#Mortal'/> + </rdf:type> + </rdf:Description> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' + xmlns:rdfs='http://www.w3.org/2000/01/rdf-schema#' + xmlns:owl='http://www.w3.org/2002/07/owl#' + xmlns:ont='http://www.w3.org/2002/03owlt/imports/support011-A#' + xml:base='http://www.w3.org/2002/03owlt/imports/premises011' > + + <owl:Ontology rdf:about=''> + <owl:imports + rdf:resource="http://www.w3.org/2002/03owlt/imports/support011-A"/> + </owl:Ontology> + + <ont:Man rdf:about='http://example.org/data#Socrates'/> + +</rdf:RDF> + + + + + + <rdf:RDF + xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' + xmlns:rdfs='http://www.w3.org/2000/01/rdf-schema#' + xmlns:owl='http://www.w3.org/2002/07/owl#' + xml:base='http://www.w3.org/2002/03owlt/imports/support011-A' > + + <owl:Ontology rdf:about=''/> + + <owl:Class rdf:ID='Man'> + <rdfs:subClassOf rdf:resource='#Mortal'/> + </owl:Class> + + <owl:Class rdf:ID='Mortal'/> + +</rdf:RDF> + + + + + + + WebOnt-maxCardinality-001 + Jos De Roo + A property with maximum cardinality of two cannot take +three distinct values on some subject node. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/maxCardinality/inconsistent001#" + xml:base="http://www.w3.org/2002/03owlt/maxCardinality/inconsistent001" > + + <owl:Ontology/> + + <rdf:Description rdf:about="inconsistent001#sb1"> + <rdf:type rdf:parseType="Resource"> + <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Restriction"/> + <owl:maxCardinality + rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" + >2</owl:maxCardinality> + <owl:onProperty rdf:resource="inconsistent001#prop"/> + </rdf:type> + <first:prop rdf:resource="inconsistent001#ob1"/> + <first:prop rdf:resource="inconsistent001#ob2"/> + <first:prop rdf:resource="inconsistent001#ob3"/> + </rdf:Description> + + <rdf:Description rdf:about="inconsistent001#ob1"> + <owl:differentFrom rdf:resource="inconsistent001#ob2"/> + <owl:differentFrom rdf:resource="inconsistent001#ob3"/> + </rdf:Description> + + <rdf:Description rdf:about="inconsistent001#ob2"> + <owl:differentFrom rdf:resource="inconsistent001#ob3"/> + </rdf:Description> + + <owl:ObjectProperty rdf:about="inconsistent001#prop"/> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + WebOnt-miscellaneous-001 + Michael K. Smith + Chris Welty + Deborah L. McGuinness + Wine example taken from the guide. Note that this is the same as the ontology http://www.w3.org/2002/03owlt/miscellaneous/consistent002 imported in other tests. + + + + + + + <!DOCTYPE owl [ + <!ENTITY vin "http://www.w3.org/2002/03owlt/miscellaneous/consistent001#" > + <!ENTITY food "http://www.w3.org/2002/03owlt/miscellaneous/consistent002#" > + <!ENTITY owl "http://www.w3.org/2002/07/owl#" > + <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" > + ]> + +<rdf:RDF + xmlns = "&vin;" + xmlns:vin = "&vin;" + xml:base = "&vin;" + xmlns:food= "&food;" + xmlns:owl = "&owl;" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs= "http://www.w3.org/2000/01/rdf-schema#" + > + + <owl:Ontology rdf:about=""> + <rdfs:comment>An example OWL ontology</rdfs:comment> + <owl:priorVersion> + <owl:Ontology rdf:about="http://www.example.org/wine-020303"/> + </owl:priorVersion> + <owl:imports rdf:resource="http://www.w3.org/2002/03owlt/miscellaneous/consistent002"/> + <rdfs:comment>Derived from the DAML Wine ontology at + http://ontolingua.stanford.edu/doc/chimaera/ontologies/wines.daml + Substantially changed, in particular the Region based relations. + </rdfs:comment> + <rdfs:label>Wine Ontology</rdfs:label> + </owl:Ontology> + + <owl:Class rdf:ID="Wine"> + <rdfs:subClassOf rdf:resource="&food;PotableLiquid" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasMaker" /> + <owl:cardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:cardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasMaker" /> + <owl:allValuesFrom rdf:resource="#Winery" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:minCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:cardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:cardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:cardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:cardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:cardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:cardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:cardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:cardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn"/> + <owl:someValuesFrom rdf:resource="&vin;Region"/> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:label xml:lang="en">wine</rdfs:label> + <rdfs:label xml:lang="fr">vin</rdfs:label> + </owl:Class> + + <owl:Class rdf:ID="Vintage"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasVintageYear"/> + <owl:cardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:cardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="WineGrape"> + <rdfs:subClassOf rdf:resource="&food;Grape" /> + </owl:Class> + + <owl:Class rdf:ID="WhiteWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="WhiteTableWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#TableWine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="WhiteNonSweetWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#WhiteWine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Dry" /> + <owl:Thing rdf:about="#OffDry" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="WhiteLoire"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Loire" /> + <owl:Class rdf:about="#WhiteWine" /> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:about="#WhiteLoire"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#CheninBlancGrape" /> + <owl:Thing rdf:about="#PinotBlancGrape" /> + <owl:Thing rdf:about="#SauvignonBlancGrape" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="WhiteBurgundy"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Burgundy" /> + <owl:Class rdf:about="#WhiteWine" /> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:about="#WhiteBurgundy"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#ChardonnayGrape" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="WhiteBordeaux"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Bordeaux" /> + <owl:Class rdf:about="#WhiteWine" /> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:about="#WhiteBordeaux"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#SemillonGrape" /> + <owl:Thing rdf:about="#SauvignonBlancGrape" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="Region" /> + + <owl:ObjectProperty rdf:ID="locatedIn"> + <rdf:type rdf:resource="&owl;TransitiveProperty" /> + <rdfs:domain rdf:resource="http://www.w3.org/2002/07/owl#Thing" /> + <rdfs:range rdf:resource="#Region" /> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="adjacentRegion"> + <rdf:type rdf:resource="&owl;SymmetricProperty" /> + <rdfs:domain rdf:resource="#Region" /> + <rdfs:range rdf:resource="#Region" /> + </owl:ObjectProperty> + + <owl:Class rdf:ID="VintageYear" /> + + <owl:DatatypeProperty rdf:ID="yearValue"> + <rdfs:domain rdf:resource="#VintageYear" /> + <rdfs:range rdf:resource="&xsd;positiveInteger" /> + </owl:DatatypeProperty> + + <VintageYear rdf:ID="Year1998"> + <yearValue rdf:datatype="&xsd;positiveInteger">1998</yearValue> + </VintageYear> + + <owl:ObjectProperty rdf:ID="hasVintageYear"> + <rdf:type rdf:resource="&owl;FunctionalProperty" /> + <rdfs:domain rdf:resource="#Vintage" /> + <rdfs:range rdf:resource="#VintageYear" /> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="madeFromGrape"> + <rdfs:subPropertyOf rdf:resource="&food;madeFromFruit" /> + <rdfs:domain rdf:resource="#Wine" /> + <rdfs:range rdf:resource="#WineGrape" /> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="madeIntoWine"> + <owl:inverseOf rdf:resource="#madeFromGrape" /> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="hasWineDescriptor"> + <rdfs:domain rdf:resource="#Wine" /> + <rdfs:range rdf:resource="#WineDescriptor" /> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="hasSugar"> + <rdf:type rdf:resource="&owl;FunctionalProperty" /> + <rdfs:subPropertyOf rdf:resource="#hasWineDescriptor" /> + <rdfs:range rdf:resource="#WineSugar" /> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="hasBody"> + <rdf:type rdf:resource="&owl;FunctionalProperty" /> + <rdfs:subPropertyOf rdf:resource="#hasWineDescriptor" /> + <rdfs:range rdf:resource="#WineBody" /> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="hasFlavor"> + <rdf:type rdf:resource="&owl;FunctionalProperty" /> + <rdfs:subPropertyOf rdf:resource="#hasWineDescriptor" /> + <rdfs:range rdf:resource="#WineFlavor" /> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="hasColor"> + <rdf:type rdf:resource="&owl;FunctionalProperty" /> + <rdfs:subPropertyOf rdf:resource="#hasWineDescriptor" /> + <rdfs:domain rdf:resource="#Wine" /> + <rdfs:range rdf:resource="#WineColor" /> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="hasMaker"> + <rdf:type rdf:resource="&owl;FunctionalProperty" /> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="producesWine"> + <owl:inverseOf rdf:resource="#hasMaker" /> + </owl:ObjectProperty> + + <owl:Class rdf:ID="Zinfandel"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#ZinfandelGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:about="#Zinfandel"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Full" /> + <owl:Thing rdf:about="#Medium" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Moderate" /> + <owl:Thing rdf:about="#Strong" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="Winery" /> + + <owl:Class rdf:ID="WineDescriptor"> + <rdfs:comment>Made WineDescriptor unionType of tastes and color</rdfs:comment> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#WineTaste" /> + <owl:Class rdf:about="#WineColor" /> + </owl:unionOf> + </owl:Class> + + <owl:Class rdf:ID="WineTaste"> + <rdfs:subClassOf rdf:resource="#WineDescriptor" /> + </owl:Class> + + <owl:Class rdf:ID="WineColor"> + <rdfs:subClassOf rdf:resource="#WineDescriptor" /> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#White" /> + <owl:Thing rdf:about="#Rose" /> + <owl:Thing rdf:about="#Red" /> + </owl:oneOf> + </owl:Class> + + <owl:Class rdf:ID="WineSugar"> + <rdfs:subClassOf rdf:resource="#WineTaste" /> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Sweet" /> + <owl:Thing rdf:about="#OffDry" /> + <owl:Thing rdf:about="#Dry" /> + </owl:oneOf> + </owl:Class> + + <owl:Class rdf:ID="WineFlavor"> + <rdfs:subClassOf rdf:resource="#WineTaste" /> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Delicate" /> + <owl:Thing rdf:about="#Moderate" /> + <owl:Thing rdf:about="#Strong" /> + </owl:oneOf> + </owl:Class> + + <owl:Class rdf:ID="WineBody"> + <rdfs:subClassOf rdf:resource="#WineTaste" /> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Light" /> + <owl:Thing rdf:about="#Medium" /> + <owl:Thing rdf:about="#Full" /> + </owl:oneOf> + </owl:Class> + + <Region rdf:ID="USRegion" /> + + <owl:Class rdf:ID="Tours"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Loire" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#ToursRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:about="#Tours"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#CheninBlancGrape" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="TableWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="SweetWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Sweet" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="SweetRiesling"> + <rdfs:subClassOf rdf:resource="#DessertWine" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Full" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Moderate" /> + <owl:Thing rdf:about="#Strong" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Riesling" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Sweet" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="StEmilion"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Strong" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#CabernetSauvignonGrape" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Bordeaux" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#StEmilionRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="SemillonOrSauvignonBlanc"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Medium" /> + <owl:Thing rdf:about="#Full" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#SemillonGrape" /> + <owl:Thing rdf:about="#SauvignonBlancGrape" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Semillon"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#SemillonOrSauvignonBlanc" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#SemillonGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="SauvignonBlanc"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#SemillonOrSauvignonBlanc" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#SauvignonBlancGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Sauterne"> + <rdfs:subClassOf rdf:resource="#LateHarvest" /> + <rdfs:subClassOf rdf:resource="#Bordeaux" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#SauterneRegion" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="Sancerre"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#OffDry" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Delicate" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#SauvignonBlancGrape" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Loire" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#SancerreRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="RoseWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Rose" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Riesling"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#RieslingGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="RedWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="RedTableWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#TableWine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="RedBurgundy"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#PinotNoirGrape" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Burgundy" /> + <owl:Class rdf:about="#RedWine" /> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="RedBordeaux"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#CabernetSauvignonGrape" /> + <owl:Thing rdf:about="#MerlotGrape" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Bordeaux" /> + <owl:Class rdf:about="#RedWine" /> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Port"> + <rdfs:subClassOf rdf:resource="#RedWine" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#PortugalRegion" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Full" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Strong" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Sweet" /> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="PinotNoir"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#PinotNoirGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="PinotBlanc"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#PinotBlancGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="PetiteSyrah"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Moderate" /> + <owl:Thing rdf:about="#Strong" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Medium" /> + <owl:Thing rdf:about="#Full" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#PetiteSyrahGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Pauillac"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Full" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Strong" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#CabernetSauvignonGrape" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Medoc" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#PauillacRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Muscadet"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Light" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Delicate" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#PinotBlancGrape" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Loire" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#MuscadetRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Meursault"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Full" /> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#WhiteBurgundy" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#MeursaultRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Merlot"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Moderate" /> + <owl:Thing rdf:about="#Delicate" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Light" /> + <owl:Thing rdf:about="#Medium" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#MerlotGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Meritage"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#CabernetSauvignonGrape" /> + <owl:Thing rdf:about="#CabernetFrancGrape" /> + <owl:Thing rdf:about="#MalbecGrape" /> + <owl:Thing rdf:about="#PetiteVerdotGrape" /> + <owl:Thing rdf:about="#MerlotGrape" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:minCardinality rdf:datatype="&xsd;nonNegativeInteger">2</owl:minCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <Region rdf:ID="MedocRegion"> + <locatedIn rdf:resource="#BordeauxRegion" /> + </Region> + + <owl:Class rdf:ID="Medoc"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Bordeaux" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#MedocRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Margaux"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Delicate" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#MerlotGrape" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Medoc" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#MargauxRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <Region rdf:ID="LoireRegion"> + <locatedIn rdf:resource="#FrenchRegion" /> + </Region> + + <owl:Class rdf:ID="Loire"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#LoireRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="LateHarvest"> + <rdfs:subClassOf rdf:resource="#Wine" /> + <owl:disjointWith rdf:resource="#EarlyHarvest" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Sweet" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Moderate" /> + <owl:Thing rdf:about="#Strong" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="ItalianWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#ItalianRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <Region rdf:ID="ItalianRegion" /> + + <owl:Class rdf:ID="IceWine"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Medium" /> + <owl:Thing rdf:about="#Full" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Moderate" /> + <owl:Thing rdf:about="#Strong" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#LateHarvest" /> + <owl:Class rdf:about="#DessertWine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="GermanWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#GermanyRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Gamay"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#GamayGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="FullBodiedWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Full" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <Region rdf:ID="FrenchRegion" /> + + <owl:Class rdf:ID="FrenchWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#FrenchRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="EarlyHarvest"> + <rdfs:subClassOf rdf:resource="#Wine" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Dry" /> + <owl:Thing rdf:about="#OffDry" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="DryWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="DryWhiteWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#DryWine" /> + <owl:Class rdf:about="#WhiteWine" /> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="DryRiesling"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Delicate" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Light" /> + <owl:Thing rdf:about="#Medium" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Riesling" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="DryRedWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#DryWine" /> + <owl:Class rdf:about="#RedWine" /> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="DessertWine"> + <rdfs:subClassOf rdf:resource="#Wine" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#OffDry" /> + <owl:Thing rdf:about="#Sweet" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="CotesDOr"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#RedBurgundy" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#CotesDOrRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Chianti"> + <rdfs:subClassOf rdf:resource="#ItalianWine" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#ChiantiRegion" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#SangioveseGrape" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Light" /> + <owl:Thing rdf:about="#Medium" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="CheninBlanc"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Full" /> + <owl:Thing rdf:about="#Medium" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Dry" /> + <owl:Thing rdf:about="#OffDry" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#CheninBlancGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Chardonnay"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Full" /> + <owl:Thing rdf:about="#Medium" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Strong" /> + <owl:Thing rdf:about="#Moderate" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#ChardonnayGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <Region rdf:ID="CaliforniaRegion"> + <locatedIn rdf:resource="#USRegion" /> + </Region> + + <Region rdf:ID="TexasRegion"> + <locatedIn rdf:resource="#USRegion" /> + </Region> + + <owl:Class rdf:ID="CaliforniaWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#CaliforniaRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="TexasWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#TexasRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="CabernetSauvignon"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Moderate" /> + <owl:Thing rdf:about="#Strong" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Medium" /> + <owl:Thing rdf:about="#Full" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#CabernetSauvignonGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="CabernetFranc"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#CabernetFrancGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Burgundy"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#BourgogneRegion" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <Region rdf:ID="BourgogneRegion"> + <locatedIn rdf:resource="#FrenchRegion" /> + </Region> + + <Region rdf:ID="BordeauxRegion"> + <locatedIn rdf:resource="#FrenchRegion" /> + </Region> + + <owl:Class rdf:ID="Bordeaux"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#BordeauxRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Beaujolais"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Light" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Delicate" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#GamayGrape" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#BeaujolaisRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <Region rdf:ID="AustralianRegion" /> + + <owl:Class rdf:ID="Anjou"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Rose" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Light" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Delicate" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#OffDry" /> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Loire" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#AnjouRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="AmericanWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#USRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="AlsatianWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#AlsaceRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <WineBody rdf:ID="Full" /> + + <WineBody rdf:ID="Medium" /> + + <WineBody rdf:ID="Light" /> + + <WineColor rdf:ID="Red" /> + + <WineColor rdf:ID="Rose" /> + + <WineColor rdf:ID="White" /> + + <WineFlavor rdf:ID="Strong" /> + + <WineFlavor rdf:ID="Moderate" /> + + <WineFlavor rdf:ID="Delicate" /> + + <WineSugar rdf:ID="Dry" /> + + <WineSugar rdf:ID="OffDry"> + <owl:differentFrom rdf:resource="#Dry"/> + <owl:differentFrom rdf:resource="#Sweet"/> + </WineSugar> + + <WineSugar rdf:ID="Sweet"> + <owl:differentFrom rdf:resource="#Dry"/> + </WineSugar> + + <owl:AllDifferent> + <owl:distinctMembers rdf:parseType="Collection"> + <vin:WineColor rdf:about="#Red" /> + <vin:WineColor rdf:about="#White" /> + <vin:WineColor rdf:about="#Rose" /> + </owl:distinctMembers> + </owl:AllDifferent> + + <owl:AllDifferent> + <owl:distinctMembers rdf:parseType="Collection"> + <vin:WineBody rdf:about="#Light" /> + <vin:WineBody rdf:about="#Medium" /> + <vin:WineBody rdf:about="#Full" /> + </owl:distinctMembers> + </owl:AllDifferent> + + <owl:AllDifferent> + <owl:distinctMembers rdf:parseType="Collection"> + <vin:WineFlavor rdf:about="#Delicate" /> + <vin:WineFlavor rdf:about="#Moderate" /> + <vin:WineFlavor rdf:about="#Strong" /> + </owl:distinctMembers> + </owl:AllDifferent> + + <owl:AllDifferent> + <owl:distinctMembers rdf:parseType="Collection"> + <vin:WineSugar rdf:about="#Sweet" /> + <vin:WineSugar rdf:about="#OffDry" /> + <vin:WineSugar rdf:about="#Dry" /> + </owl:distinctMembers> + </owl:AllDifferent> + + <Region rdf:ID="AlsaceRegion"> + <locatedIn rdf:resource="#FrenchRegion" /> + </Region> + + <Region rdf:ID="AnjouRegion"> + <locatedIn rdf:resource="#LoireRegion" /> + </Region> + + <Region rdf:ID="ArroyoGrandeRegion"> + <locatedIn rdf:resource="#CaliforniaRegion" /> + </Region> + + <Winery rdf:ID="Beringer" /> + + <Winery rdf:ID="Bancroft" /> + + <Chardonnay rdf:ID="BancroftChardonnay"> + <locatedIn rdf:resource="#NapaRegion" /> + <hasMaker rdf:resource="#Bancroft" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </Chardonnay> + + <Region rdf:ID="BeaujolaisRegion"> + <locatedIn rdf:resource="#FrenchRegion" /> + </Region> + + <WineGrape rdf:ID="CabernetFrancGrape" /> + + <WineGrape rdf:ID="CabernetSauvignonGrape" /> + + <Region rdf:ID="CentralCoastRegion"> + <locatedIn rdf:resource="#CaliforniaRegion" /> + </Region> + + <WineGrape rdf:ID="ChardonnayGrape" /> + + <Winery rdf:ID="ChateauChevalBlanc" /> + + <StEmilion rdf:ID="ChateauChevalBlancStEmilion"> + <hasMaker rdf:resource="#ChateauChevalBlanc" /> + </StEmilion> + + <Winery rdf:ID="ChateauDYchem" /> + + <Sauterne rdf:ID="ChateauDYchemSauterne"> + <madeFromGrape rdf:resource="#SauvignonBlancGrape" /> + <madeFromGrape rdf:resource="#SemillonGrape" /> + <hasFlavor rdf:resource="#Strong" /> + <hasMaker rdf:resource="#ChateauDYchem" /> + </Sauterne> + + <Winery rdf:ID="ChateauDeMeursault" /> + + <Meursault rdf:ID="ChateauDeMeursaultMeursault"> + <hasFlavor rdf:resource="#Moderate" /> + <hasMaker rdf:resource="#ChateauDeMeursault" /> + </Meursault> + + <Winery rdf:ID="ChateauLafiteRothschild" /> + + <Pauillac rdf:ID="ChateauLafiteRothschildPauillac"> + <hasMaker rdf:resource="#ChateauLafiteRothschild" /> + </Pauillac> + + <Margaux rdf:ID="ChateauMargaux"> + <hasMaker rdf:resource="#ChateauMargauxWinery" /> + </Margaux> + + <Winery rdf:ID="ChateauMargauxWinery" /> + + <Winery rdf:ID="ChateauMorgon" /> + + <Beaujolais rdf:ID="ChateauMorgonBeaujolais"> + <hasMaker rdf:resource="#ChateauMorgon" /> + </Beaujolais> + + <WineGrape rdf:ID="CheninBlancGrape" /> + + <WineGrape rdf:ID="ZinfandelGrape" /> + + <Chianti rdf:ID="ChiantiClassico"> + <hasBody rdf:resource="#Medium" /> + <hasMaker rdf:resource="#McGuinnesso" /> + </Chianti> + + <Region rdf:ID="ChiantiRegion"> + <locatedIn rdf:resource="#ItalianRegion" /> + </Region> + + <Winery rdf:ID="ClosDeLaPoussie" /> + + <Sancerre rdf:ID="ClosDeLaPoussieSancerre"> + <hasMaker rdf:resource="#ClosDeLaPoussie" /> + </Sancerre> + + <Winery rdf:ID="ClosDeVougeot" /> + + <CotesDOr rdf:ID="ClosDeVougeotCotesDOr"> + <hasMaker rdf:resource="#ClosDeVougeot" /> + </CotesDOr> + + <Winery rdf:ID="CongressSprings" /> + + <Semillon rdf:ID="CongressSpringsSemillon"> + <hasMaker rdf:resource="#CongressSprings" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </Semillon> + + <Winery rdf:ID="Corbans" /> + + <Riesling rdf:ID="CorbansDryWhiteRiesling"> + <locatedIn rdf:resource="#NewZealandRegion" /> + <hasMaker rdf:resource="#Corbans" /> + <hasSugar rdf:resource="#OffDry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </Riesling> + + <SauvignonBlanc rdf:ID="CorbansPrivateBinSauvignonBlanc"> + <locatedIn rdf:resource="#NewZealandRegion" /> + <hasMaker rdf:resource="#Corbans" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Full" /> + </SauvignonBlanc> + + <SauvignonBlanc rdf:ID="CorbansSauvignonBlanc"> + <locatedIn rdf:resource="#NewZealandRegion" /> + <hasMaker rdf:resource="#Corbans" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Medium" /> + </SauvignonBlanc> + + <Winery rdf:ID="CortonMontrachet" /> + + <WhiteBurgundy rdf:ID="CortonMontrachetWhiteBurgundy"> + <hasMaker rdf:resource="#CortonMontrachet" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Full" /> + </WhiteBurgundy> + + <Region rdf:ID="CotesDOrRegion"> + <locatedIn rdf:resource="#BourgogneRegion" /> + </Region> + + <Winery rdf:ID="Cotturi" /> + + <Zinfandel rdf:ID="CotturiZinfandel"> + <locatedIn rdf:resource="#SonomaRegion" /> + <hasMaker rdf:resource="#Cotturi" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Full" /> + </Zinfandel> + + <Winery rdf:ID="DAnjou" /> + + <Region rdf:ID="EdnaValleyRegion"> + <locatedIn rdf:resource="#CaliforniaRegion" /> + </Region> + + <Winery rdf:ID="Elyse" /> + + <Zinfandel rdf:ID="ElyseZinfandel"> + <locatedIn rdf:resource="#NapaRegion" /> + <hasMaker rdf:resource="#Elyse" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Full" /> + </Zinfandel> + + <Winery rdf:ID="Forman" /> + + <CabernetSauvignon rdf:ID="FormanCabernetSauvignon"> + <locatedIn rdf:resource="#NapaRegion" /> + <hasMaker rdf:resource="#Forman" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Medium" /> + </CabernetSauvignon> + + <Chardonnay rdf:ID="FormanChardonnay"> + <locatedIn rdf:resource="#NapaRegion" /> + <hasMaker rdf:resource="#Forman" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Full" /> + </Chardonnay> + + <Winery rdf:ID="Foxen" /> + + <CheninBlanc rdf:ID="FoxenCheninBlanc"> + <locatedIn rdf:resource="#SantaBarbaraRegion" /> + <hasMaker rdf:resource="#Foxen" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Full" /> + </CheninBlanc> + + <WineGrape rdf:ID="GamayGrape" /> + + <Winery rdf:ID="GaryFarrell" /> + + <Merlot rdf:ID="GaryFarrellMerlot"> + <locatedIn rdf:resource="#SonomaRegion" /> + <hasMaker rdf:resource="#GaryFarrell" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </Merlot> + + <Region rdf:ID="GermanyRegion" /> + + <Winery rdf:ID="Handley" /> + + <Winery rdf:ID="KalinCellars" /> + + <Semillon rdf:ID="KalinCellarsSemillon"> + <hasMaker rdf:resource="#KalinCellars" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Full" /> + </Semillon> + + <Winery rdf:ID="KathrynKennedy" /> + + <Meritage rdf:ID="KathrynKennedyLateral"> + <hasMaker rdf:resource="#KathrynKennedy" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Delicate" /> + <hasBody rdf:resource="#Medium" /> + </Meritage> + + <Winery rdf:ID="LaneTanner" /> + + <PinotNoir rdf:ID="LaneTannerPinotNoir"> + <locatedIn rdf:resource="#SantaBarbaraRegion" /> + <hasMaker rdf:resource="#LaneTanner" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Delicate" /> + <hasBody rdf:resource="#Light" /> + </PinotNoir> + + <Winery rdf:ID="Longridge" /> + + <Merlot rdf:ID="LongridgeMerlot"> + <locatedIn rdf:resource="#NewZealandRegion" /> + <hasMaker rdf:resource="#Longridge" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Light" /> + </Merlot> + + <WineGrape rdf:ID="MalbecGrape" /> + + <Region rdf:ID="MargauxRegion"> + <locatedIn rdf:resource="#MedocRegion" /> + </Region> + + <Winery rdf:ID="Marietta" /> + + <CabernetSauvignon rdf:ID="MariettaCabernetSauvignon"> + <locatedIn rdf:resource="#SonomaRegion" /> + <hasMaker rdf:resource="#Marietta" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </CabernetSauvignon> + + <RedTableWine rdf:ID="MariettaOldVinesRed"> + <locatedIn rdf:resource="#SonomaRegion" /> + <hasMaker rdf:resource="#Marietta" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </RedTableWine> + + <PetiteSyrah rdf:ID="MariettaPetiteSyrah"> + <locatedIn rdf:resource="#SonomaRegion" /> + <hasMaker rdf:resource="#Marietta" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </PetiteSyrah> + + <Zinfandel rdf:ID="MariettaZinfandel"> + <locatedIn rdf:resource="#SonomaRegion" /> + <hasMaker rdf:resource="#Marietta" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </Zinfandel> + + <Winery rdf:ID="McGuinnesso" /> + + <Region rdf:ID="MendocinoRegion"> + <locatedIn rdf:resource="#CaliforniaRegion" /> + <adjacentRegion rdf:resource="#SonomaRegion" /> + </Region> + + <WineGrape rdf:ID="MerlotGrape" /> + + <Region rdf:ID="MeursaultRegion"> + <locatedIn rdf:resource="#BourgogneRegion" /> + </Region> + + <Winery rdf:ID="MountEdenVineyard" /> + + <Chardonnay rdf:ID="MountEdenVineyardEdnaValleyChardonnay"> + <locatedIn rdf:resource="#EdnaValleyRegion" /> + <hasMaker rdf:resource="#MountEdenVineyard" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </Chardonnay> + + <PinotNoir rdf:ID="MountEdenVineyardEstatePinotNoir"> + <locatedIn rdf:resource="#EdnaValleyRegion" /> + <hasMaker rdf:resource="#MountEdenVineyard" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Full" /> + </PinotNoir> + + <Winery rdf:ID="Mountadam" /> + + <Chardonnay rdf:ID="MountadamChardonnay"> + <locatedIn rdf:resource="#SouthAustraliaRegion" /> + <hasMaker rdf:resource="#Mountadam" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Full" /> + </Chardonnay> + + <PinotNoir rdf:ID="MountadamPinotNoir"> + <locatedIn rdf:resource="#SouthAustraliaRegion" /> + <hasMaker rdf:resource="#Mountadam" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </PinotNoir> + + <DryRiesling rdf:ID="MountadamRiesling"> + <locatedIn rdf:resource="#SouthAustraliaRegion" /> + <hasMaker rdf:resource="#Mountadam" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Delicate" /> + <hasBody rdf:resource="#Medium" /> + </DryRiesling> + + <Region rdf:ID="MuscadetRegion"> + <locatedIn rdf:resource="#LoireRegion" /> + </Region> + + <Region rdf:ID="NapaRegion"> + <locatedIn rdf:resource="#CaliforniaRegion" /> + </Region> + + <Region rdf:ID="NewZealandRegion" /> + + <Winery rdf:ID="PageMillWinery" /> + + <CabernetSauvignon rdf:ID="PageMillWineryCabernetSauvignon"> + <locatedIn rdf:resource="#NapaRegion" /> + <hasMaker rdf:resource="#PageMillWinery" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </CabernetSauvignon> + + <Region rdf:ID="PauillacRegion"> + <locatedIn rdf:resource="#MedocRegion" /> + </Region> + + <Winery rdf:ID="PeterMccoy" /> + + <Chardonnay rdf:ID="PeterMccoyChardonnay"> + <locatedIn rdf:resource="#SonomaRegion" /> + <hasMaker rdf:resource="#PeterMccoy" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </Chardonnay> + + <WineGrape rdf:ID="PetiteSyrahGrape" /> + + <WineGrape rdf:ID="PetiteVerdotGrape" /> + + <WineGrape rdf:ID="PinotBlancGrape" /> + + <WineGrape rdf:ID="PinotNoirGrape" /> + + <Region rdf:ID="PortugalRegion" /> + + <Winery rdf:ID="PulignyMontrachet" /> + + <WhiteBurgundy rdf:ID="PulignyMontrachetWhiteBurgundy"> + <hasMaker rdf:resource="#PulignyMontrachet" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </WhiteBurgundy> + + <WineGrape rdf:ID="RieslingGrape" /> + + <Anjou rdf:ID="RoseDAnjou"> + <hasMaker rdf:resource="#DAnjou" /> + </Anjou> + + <Region rdf:ID="SancerreRegion"> + <locatedIn rdf:resource="#LoireRegion" /> + </Region> + + <WineGrape rdf:ID="SangioveseGrape" /> + + <Region rdf:ID="SantaBarbaraRegion"> + <locatedIn rdf:resource="#CaliforniaRegion" /> + </Region> + + <Winery rdf:ID="SantaCruzMountainVineyard" /> + + <CabernetSauvignon rdf:ID="SantaCruzMountainVineyardCabernetSauvignon"> + <locatedIn rdf:resource="#SantaCruzMountainsRegion" /> + <hasMaker rdf:resource="#SantaCruzMountainVineyard" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Full" /> + </CabernetSauvignon> + + <Region rdf:ID="CentralTexasRegion"> + <locatedIn rdf:resource="#TexasRegion" /> + </Region> + + <Winery rdf:ID="StGenevieve" /> + + <WhiteWine rdf:ID="StGenevieveTexasWhite"> + <locatedIn rdf:resource="#CentralTexasRegion" /> + <hasMaker rdf:resource="#StGenevieve" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + </WhiteWine> + + <Region rdf:ID="SantaCruzMountainsRegion"> + <locatedIn rdf:resource="#CaliforniaRegion" /> + </Region> + + <Winery rdf:ID="SaucelitoCanyon" /> + + <Zinfandel rdf:ID="SaucelitoCanyonZinfandel"> + <locatedIn rdf:resource="#ArroyoGrandeRegion" /> + <hasMaker rdf:resource="#SaucelitoCanyon" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </Zinfandel> + + <Zinfandel rdf:ID="SaucelitoCanyonZinfandel1998"> + <locatedIn rdf:resource="#ArroyoGrandeRegion" /> + <hasVintageYear rdf:resource="#Year1998" /> + <hasMaker rdf:resource="#SaucelitoCanyon" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </Zinfandel> + + <Region rdf:ID="SauterneRegion"> + <locatedIn rdf:resource="#BordeauxRegion" /> + </Region> + + <WineGrape rdf:ID="SauvignonBlancGrape" /> + + <Winery rdf:ID="SchlossRothermel" /> + + <SweetRiesling rdf:ID="SchlossRothermelTrochenbierenausleseRiesling"> + <locatedIn rdf:resource="#GermanyRegion" /> + <hasMaker rdf:resource="#SchlossRothermel" /> + <hasSugar rdf:resource="#Sweet" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Full" /> + </SweetRiesling> + + <Winery rdf:ID="SchlossVolrad" /> + + <SweetRiesling rdf:ID="SchlossVolradTrochenbierenausleseRiesling"> + <locatedIn rdf:resource ="#GermanyRegion" /> + <hasMaker rdf:resource="#SchlossVolrad" /> + <hasSugar rdf:resource="#Sweet" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Full" /> + </SweetRiesling> + + <Winery rdf:ID="SeanThackrey" /> + + <PetiteSyrah rdf:ID="SeanThackreySiriusPetiteSyrah"> + <locatedIn rdf:resource="#NapaRegion" /> + <hasMaker rdf:resource="#SeanThackrey" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Full" /> + </PetiteSyrah> + + <Winery rdf:ID="Selaks" /> + + <IceWine rdf:ID="SelaksIceWine"> + <locatedIn rdf:resource="#NewZealandRegion" /> + <hasMaker rdf:resource="#Selaks" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + <hasColor rdf:resource="#White" /> + </IceWine> + + <SauvignonBlanc rdf:ID="SelaksSauvignonBlanc"> + <locatedIn rdf:resource="#NewZealandRegion" /> + <hasMaker rdf:resource="#Selaks" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </SauvignonBlanc> + + <WineGrape rdf:ID="SemillonGrape" /> + + <Winery rdf:ID="SevreEtMaine" /> + + <Muscadet rdf:ID="SevreEtMaineMuscadet"> + <hasMaker rdf:resource="#SevreEtMaine" /> + </Muscadet> + + <Region rdf:ID="SonomaRegion"> + <locatedIn rdf:resource="#CaliforniaRegion" /> + </Region> + + <Region rdf:ID="SouthAustraliaRegion"> + <locatedIn rdf:resource="#AustralianRegion" /> + </Region> + + <Region rdf:ID="StEmilionRegion"> + <locatedIn rdf:resource="#BordeauxRegion" /> + </Region> + + <Winery rdf:ID="Stonleigh" /> + + <SauvignonBlanc rdf:ID="StonleighSauvignonBlanc"> + <locatedIn rdf:resource="#NewZealandRegion" /> + <hasMaker rdf:resource="#Stonleigh" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Delicate" /> + <hasBody rdf:resource="#Medium" /> + </SauvignonBlanc> + + <Winery rdf:ID="Taylor" /> + + <Port rdf:ID="TaylorPort"> + <hasMaker rdf:resource="#Taylor" /> + </Port> + + <Region rdf:ID="ToursRegion"> + <locatedIn rdf:resource="#LoireRegion" /> + </Region> + + <Winery rdf:ID="Ventana" /> + + <CheninBlanc rdf:ID="VentanaCheninBlanc"> + <locatedIn rdf:resource="#CentralCoastRegion" /> + <hasMaker rdf:resource="#Ventana" /> + <hasSugar rdf:resource="#OffDry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </CheninBlanc> + + <Winery rdf:ID="WhitehallLane" /> + + <CabernetFranc rdf:ID="WhitehallLaneCabernetFranc"> + <locatedIn rdf:resource="#NapaRegion" /> + <hasMaker rdf:resource="#WhitehallLane" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </CabernetFranc> + + <DessertWine rdf:ID="WhitehallLanePrimavera"> + <locatedIn rdf:resource="#NapaRegion" /> + <hasSugar rdf:resource="#Sweet" /> + <hasFlavor rdf:resource="#Delicate" /> + <hasBody rdf:resource="#Light" /> + </DessertWine> + + <owl:AllDifferent> + <owl:distinctMembers rdf:parseType="Collection"> + <vin:Winery rdf:about="#Bancroft" /> + <vin:Winery rdf:about="#ChateauChevalBlanc" /> + <vin:Winery rdf:about="#ChateauDYchem" /> + <vin:Winery rdf:about="#ChateauDeMeursault" /> + <vin:Winery rdf:about="#ChateauLafiteRothschild" /> + <vin:Winery rdf:about="#ChateauMargauxWinery" /> + <vin:Winery rdf:about="#ChateauMorgon" /> + <vin:Winery rdf:about="#ClosDeLaPoussie" /> + <vin:Winery rdf:about="#ClosDeVougeot" /> + <vin:Winery rdf:about="#CongressSprings" /> + <vin:Winery rdf:about="#Corbans" /> + <vin:Winery rdf:about="#CortonMontrachet" /> + <vin:Winery rdf:about="#Cotturi" /> + <vin:Winery rdf:about="#DAnjou" /> + <vin:Winery rdf:about="#Elyse" /> + <vin:Winery rdf:about="#Forman" /> + <vin:Winery rdf:about="#Foxen" /> + <vin:Winery rdf:about="#GaryFarrell" /> + <vin:Winery rdf:about="#KalinCellars" /> + <vin:Winery rdf:about="#KathrynKennedy" /> + <vin:Winery rdf:about="#LaneTanner" /> + <vin:Winery rdf:about="#Longridge" /> + <vin:Winery rdf:about="#Marietta" /> + <vin:Winery rdf:about="#McGuinnesso" /> + <vin:Winery rdf:about="#MountEdenVineyard" /> + <vin:Winery rdf:about="#Mountadam" /> + <vin:Winery rdf:about="#PageMillWinery" /> + <vin:Winery rdf:about="#PeterMccoy" /> + <vin:Winery rdf:about="#PulignyMontrachet" /> + <vin:Winery rdf:about="#SantaCruzMountainVineyard" /> + <vin:Winery rdf:about="#SaucelitoCanyon" /> + <vin:Winery rdf:about="#SchlossRothermel" /> + <vin:Winery rdf:about="#SchlossVolrad" /> + <vin:Winery rdf:about="#SeanThackrey" /> + <vin:Winery rdf:about="#Selaks" /> + <vin:Winery rdf:about="#SevreEtMaine" /> + <vin:Winery rdf:about="#StGenevieve" /> + <vin:Winery rdf:about="#Stonleigh" /> + <vin:Winery rdf:about="#Taylor" /> + <vin:Winery rdf:about="#Ventana" /> + <vin:Winery rdf:about="#WhitehallLane" /> + </owl:distinctMembers> + </owl:AllDifferent> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + <!DOCTYPE owl [ + <!ENTITY vin "http://www.w3.org/2002/03owlt/miscellaneous/consistent001#" > + <!ENTITY food "http://www.w3.org/2002/03owlt/miscellaneous/consistent002#" > + <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" > + ]> + +<rdf:RDF + xmlns = "&food;" + xmlns:food= "&food;" + xml:base = "&food;" + xmlns:vin = "&vin;" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs= "http://www.w3.org/2000/01/rdf-schema#"> + + <owl:Ontology rdf:about=""> + <rdfs:comment> + Derived from the DAML Wine ontology at + http://ontolingua.stanford.edu/doc/chimaera/ontologies/wines.daml + Substantially modified. + </rdfs:comment> + <owl:imports rdf:resource="http://www.w3.org/2002/03owlt/miscellaneous/consistent001"/> + </owl:Ontology> + + <owl:Class rdf:ID="ConsumableThing" /> + + <owl:Class rdf:ID="NonConsumableThing"> + <owl:complementOf rdf:resource="#ConsumableThing" /> + </owl:Class> + + <owl:Class rdf:ID="EdibleThing"> + <rdfs:subClassOf rdf:resource="#ConsumableThing" /> + </owl:Class> + + <owl:Class rdf:ID="PotableLiquid"> + <rdfs:subClassOf rdf:resource="#ConsumableThing" /> + <owl:disjointWith rdf:resource="#EdibleThing" /> + </owl:Class> + + <owl:Class rdf:ID="Wine"> + <owl:equivalentClass rdf:resource="&vin;Wine"/> + </owl:Class> + + <owl:ObjectProperty rdf:ID="madeFromFruit"> + <rdfs:domain rdf:resource="#ConsumableThing" /> + <rdfs:range rdf:resource="#Fruit" /> + </owl:ObjectProperty> + + <owl:Class rdf:ID="Juice"> + <rdfs:subClassOf rdf:resource="#PotableLiquid" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromFruit" /> + <owl:minCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:ObjectProperty rdf:ID="hasDrink"> + <rdfs:domain rdf:resource="#MealCourse" /> + <rdfs:range rdf:resource="#PotableLiquid" /> + </owl:ObjectProperty> + + <owl:Thing rdf:ID="White"> + <owl:sameAs rdf:resource="&vin;White"/> + </owl:Thing> + + <owl:Thing rdf:ID="Rose"> + <owl:sameAs rdf:resource="&vin;Rose" /> + </owl:Thing> + + <owl:Thing rdf:ID="Red"> + <owl:sameAs rdf:resource="&vin;Red" /> + </owl:Thing> + + <owl:Thing rdf:ID="Sweet"> + <owl:sameAs rdf:resource="&vin;Sweet" /> + </owl:Thing> + + <owl:Thing rdf:ID="OffDry"> + <owl:sameAs rdf:resource="&vin;OffDry" /> + </owl:Thing> + + <owl:Thing rdf:ID="Dry"> + <owl:sameAs rdf:resource="&vin;Dry" /> + </owl:Thing> + + <owl:Thing rdf:ID="Delicate"> + <owl:sameAs rdf:resource="&vin;Delicate" /> + </owl:Thing> + + <owl:Thing rdf:ID="Moderate"> + <owl:sameAs rdf:resource="&vin;Moderate" /> + </owl:Thing> + + <owl:Thing rdf:ID="Strong"> + <owl:sameAs rdf:resource="&vin;Strong" /> + </owl:Thing> + + <owl:Thing rdf:ID="Light"> + <owl:sameAs rdf:resource="&vin;Light" /> + </owl:Thing> + + <owl:Thing rdf:ID="Medium"> + <owl:sameAs rdf:resource="&vin;Medium" /> + </owl:Thing> + + <owl:Thing rdf:ID="Full"> + <owl:sameAs rdf:resource="&vin;Full" /> + </owl:Thing> + + <owl:ObjectProperty rdf:ID="course"> + <rdfs:domain rdf:resource="#Meal" /> + <rdfs:range rdf:resource="#MealCourse" /> + </owl:ObjectProperty> + + <owl:Class rdf:ID="Grape"> + <rdfs:subClassOf rdf:resource="#SweetFruit" /> + </owl:Class> + + <owl:Class rdf:ID="Pasta"> + <rdfs:subClassOf rdf:resource="#EdibleThing" /> + <owl:disjointWith rdf:resource="#Meat" /> + <owl:disjointWith rdf:resource="#Fowl" /> + <owl:disjointWith rdf:resource="#Seafood" /> + <owl:disjointWith rdf:resource="#Dessert" /> + <owl:disjointWith rdf:resource="#Fruit" /> + </owl:Class> + + <owl:Class rdf:ID="PastaWithWhiteSauce"> + <rdfs:subClassOf rdf:resource="#Pasta" /> + <owl:disjointWith rdf:resource="#PastaWithRedSauce" /> + </owl:Class> + + <owl:Class rdf:ID="PastaWithSpicyRedSauceCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#PastaWithSpicyRedSauce" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Full" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Strong" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="PastaWithSpicyRedSauce"> + <rdfs:subClassOf rdf:resource="#PastaWithRedSauce" /> + </owl:Class> + + <owl:Class rdf:ID="PastaWithRedSauce"> + <rdfs:subClassOf rdf:resource="#Pasta" /> + </owl:Class> + + <owl:Class rdf:ID="PastaWithNonSpicyRedSauceCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#PastaWithNonSpicyRedSauce" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="PastaWithNonSpicyRedSauce"> + <rdfs:subClassOf rdf:resource="#PastaWithRedSauce" /> + <owl:disjointWith rdf:resource="#PastaWithSpicyRedSauce" /> + </owl:Class> + + <owl:Class rdf:ID="PastaWithLightCreamSauce"> + <rdfs:subClassOf rdf:resource="#PastaWithWhiteSauce" /> + <owl:disjointWith rdf:resource="#PastaWithHeavyCreamSauce" /> + </owl:Class> + + <owl:Class rdf:ID="PastaWithLightCreamCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#PastaWithLightCreamSauce" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Light" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Delicate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="PastaWithHeavyCreamSauce"> + <rdfs:subClassOf rdf:resource="#PastaWithWhiteSauce" /> + </owl:Class> + + <owl:Class rdf:ID="PastaWithHeavyCreamCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#PastaWithHeavyCreamSauce" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="OysterShellfishCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#OysterShellfish" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Sweet" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="OysterShellfish"> + <rdfs:subClassOf rdf:resource="#Shellfish" /> + </owl:Class> + + <owl:Class rdf:ID="OtherTomatoBasedFoodCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#OtherTomatoBasedFood" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="OtherTomatoBasedFood"> + <rdfs:subClassOf rdf:resource="#EdibleThing" /> + <owl:disjointWith rdf:resource="#Pasta" /> + <owl:disjointWith rdf:resource="#Meat" /> + <owl:disjointWith rdf:resource="#Fowl" /> + <owl:disjointWith rdf:resource="#Seafood" /> + <owl:disjointWith rdf:resource="#Dessert" /> + <owl:disjointWith rdf:resource="#Fruit" /> + </owl:Class> + + <owl:Class rdf:ID="NonSweetFruitCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#NonSweetFruit" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Delicate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#OffDry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="SweetFruitCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#SweetFruit" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Sweet" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + + <owl:Class rdf:ID="NonSweetFruit"> + <rdfs:subClassOf rdf:resource="#EdibleThing" /> + <owl:disjointWith rdf:resource="#SweetFruit" /> + </owl:Class> + + <owl:Class rdf:ID="NonSpicyRedMeatCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#NonSpicyRedMeat" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Strong" /> + <owl:Thing rdf:about="#Moderate" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="NonSpicyRedMeat"> + <rdfs:subClassOf rdf:resource="#RedMeat" /> + <owl:disjointWith rdf:resource="#SpicyRedMeat" /> + </owl:Class> + + <owl:Class rdf:ID="NonRedMeatCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#NonRedMeat" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Strong" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="NonRedMeat"> + <rdfs:subClassOf rdf:resource="#Meat" /> + <owl:disjointWith rdf:resource="#RedMeat" /> + </owl:Class> + + <owl:Class rdf:ID="NonOysterShellfishCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#NonOysterShellfish" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="NonOysterShellfish"> + <rdfs:subClassOf rdf:resource="#Shellfish" /> + <owl:disjointWith rdf:resource="#OysterShellfish" /> + </owl:Class> + + <owl:Class rdf:ID="NonBlandFishCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#NonBlandFish" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="NonBlandFish"> + <rdfs:subClassOf rdf:resource="#Fish" /> + </owl:Class> + + <owl:Class rdf:ID="Meat"> + <rdfs:subClassOf rdf:resource="#EdibleThing" /> + <owl:disjointWith rdf:resource="#Fowl" /> + <owl:disjointWith rdf:resource="#Seafood" /> + <owl:disjointWith rdf:resource="#Dessert" /> + <owl:disjointWith rdf:resource="#Fruit" /> + </owl:Class> + + <owl:Class rdf:ID="MealCourse"> + <rdfs:subClassOf rdf:resource="#ConsumableThing" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:minCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:minCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom rdf:resource="#Wine" /> + </owl:Restriction> + </rdfs:subClassOf> + <owl:disjointWith rdf:resource="#PotableLiquid" /> + <owl:disjointWith rdf:resource="#EdibleThing" /> + </owl:Class> + + <owl:Class rdf:ID="Meal"> + <rdfs:subClassOf rdf:resource="#ConsumableThing" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#course" /> + <owl:minCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#course" /> + <owl:allValuesFrom rdf:resource="#MealCourse" /> + </owl:Restriction> + </rdfs:subClassOf> + <owl:disjointWith rdf:resource="#MealCourse" /> + <owl:disjointWith rdf:resource="#PotableLiquid" /> + <owl:disjointWith rdf:resource="#EdibleThing" /> + </owl:Class> + + <owl:Class rdf:ID="LightMeatFowlCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#LightMeatFowl" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="LightMeatFowl"> + <rdfs:subClassOf rdf:resource="#Fowl" /> + </owl:Class> + + <owl:Class rdf:ID="FruitCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#Fruit" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + + + <owl:Class rdf:ID="Fruit"> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#SweetFruit" /> + <owl:Class rdf:about="#NonSweetFruit" /> + </owl:unionOf> + </owl:Class> + + <owl:Class rdf:ID="Fowl"> + <rdfs:subClassOf rdf:resource="#EdibleThing" /> + <owl:disjointWith rdf:resource="#Seafood" /> + <owl:disjointWith rdf:resource="#Dessert" /> + <owl:disjointWith rdf:resource="#Fruit" /> + </owl:Class> + + <owl:Class rdf:ID="FishCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#Fish" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="DessertCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#Dessert" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Full" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Strong" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Sweet" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="Dessert"> + <rdfs:subClassOf rdf:resource="#EdibleThing" /> + <owl:disjointWith rdf:resource="#Fruit" /> + </owl:Class> + + <owl:Class rdf:ID="SweetFruit"> + <rdfs:subClassOf rdf:resource="#EdibleThing" /> + </owl:Class> + + <owl:Class rdf:ID="SweetDessertCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#SweetDessert" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="SweetDessert"> + <rdfs:subClassOf rdf:resource="#Dessert" /> + </owl:Class> + + <owl:Class rdf:ID="DarkMeatFowlCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#DarkMeatFowl" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Light" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Delicate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="DarkMeatFowl"> + <rdfs:subClassOf rdf:resource="#Fowl" /> + <owl:disjointWith rdf:resource="#LightMeatFowl" /> + </owl:Class> + + <owl:Class rdf:ID="CheeseNutsDessertCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#CheeseNutsDessert" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="CheeseNutsDessert"> + <rdfs:subClassOf rdf:resource="#Dessert" /> + <owl:disjointWith rdf:resource="#SweetDessert" /> + </owl:Class> + + <owl:Class rdf:ID="BlandFishCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#BlandFish" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Delicate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="BlandFish"> + <rdfs:subClassOf rdf:resource="#Fish" /> + <owl:disjointWith rdf:resource="#NonBlandFish" /> + </owl:Class> + + <owl:ObjectProperty rdf:ID="hasFood"> + <rdfs:domain rdf:resource="#MealCourse" /> + <rdfs:range rdf:resource="#EdibleThing" /> + </owl:ObjectProperty> + + <owl:Class rdf:ID="Fish"> + <rdfs:subClassOf rdf:resource="#Seafood" /> + <owl:disjointWith rdf:resource="#Shellfish" /> + </owl:Class> + + <owl:Class rdf:ID="SpicyRedMeat"> + <rdfs:subClassOf rdf:resource="#RedMeat" /> + </owl:Class> + + <owl:Class rdf:ID="ShellfishCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#Shellfish" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Moderate" /> + <owl:Thing rdf:about="#Strong" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Full" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="Shellfish"> + <rdfs:subClassOf rdf:resource="#Seafood" /> + </owl:Class> + + <owl:Class rdf:ID="SeafoodCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#Seafood" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="Seafood"> + <rdfs:subClassOf rdf:resource="#EdibleThing" /> + <owl:disjointWith rdf:resource="#Dessert" /> + <owl:disjointWith rdf:resource="#Fruit" /> + </owl:Class> + + <owl:Class rdf:ID="RedMeatCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#RedMeat" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="RedMeat"> + <rdfs:subClassOf rdf:resource="#Meat" /> + </owl:Class> + + <SweetDessert rdf:ID="Cake" /> + + <SweetFruit rdf:ID="Bananas" /> + + <SweetFruit rdf:ID="MixedFruit" /> + + <NonOysterShellfish rdf:ID="Mussels" /> + + <CheeseNutsDessert rdf:ID="Nuts" /> + + <OysterShellfish rdf:ID="Oysters" /> + + <PastaWithLightCreamSauce rdf:ID="PastaWithWhiteClamSauce" /> + + <SweetFruit rdf:ID="Peaches" /> + + <SweetDessert rdf:ID="Pie" /> + + <OtherTomatoBasedFood rdf:ID="Pizza" /> + + <NonRedMeat rdf:ID="Pork" /> + + <NonSpicyRedMeat rdf:ID="RoastBeef" /> + + <BlandFish rdf:ID="Scrod" /> + + <PastaWithNonSpicyRedSauce rdf:ID="SpaghettiWithTomatoSauce" /> + + <NonSpicyRedMeat rdf:ID="Steak" /> + + <NonBlandFish rdf:ID="Swordfish" /> + + <EatingGrape rdf:ID="ThompsonSeedless" /> + + <owl:Class rdf:ID="EatingGrape"> + <rdfs:subClassOf rdf:resource="#Grape" /> + </owl:Class> + + <NonBlandFish rdf:ID="Tuna" /> + + <LightMeatFowl rdf:ID="Turkey" /> + + <NonSpicyRedMeat rdf:ID="Veal" /> + + <owl:Class rdf:ID="SpicyRedMeatCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#SpicyRedMeat" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Full" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <SpicyRedMeat rdf:ID="BeefCurry" /> + + <LightMeatFowl rdf:ID="Chicken" /> + + <NonOysterShellfish rdf:ID="Clams" /> + + <DarkMeatFowl rdf:ID="Duck" /> + + <SpicyRedMeat rdf:ID="GarlickyRoast" /> + + <DarkMeatFowl rdf:ID="Goose" /> + + <BlandFish rdf:ID="Halibut" /> + + <NonOysterShellfish rdf:ID="Crab" /> + + <BlandFish rdf:ID="Flounder" /> + + <NonOysterShellfish rdf:ID="Lobster" /> + + <PastaWithHeavyCreamSauce rdf:ID="FettucineAlfRedo" /> + + <PastaWithSpicyRedSauce rdf:ID="FraDiavolo" /> + + <CheeseNutsDessert rdf:ID="Cheese" /> + +</rdf:RDF> + + + + + + + WebOnt-miscellaneous-002 + Michael K. Smith + Chris Welty + Deborah L. McGuinness + Food example taken from the guide. Note that this is the same as the ontology http://www.w3.org/2002/03owlt/miscellaneous/consistent002 imported in other tests. + + + + + + + <!DOCTYPE owl [ + <!ENTITY vin "http://www.w3.org/2002/03owlt/miscellaneous/consistent001#" > + <!ENTITY food "http://www.w3.org/2002/03owlt/miscellaneous/consistent002#" > + <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" > + ]> + +<rdf:RDF + xmlns = "&food;" + xmlns:food= "&food;" + xml:base = "&food;" + xmlns:vin = "&vin;" + xmlns:owl = "http://www.w3.org/2002/07/owl#" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs= "http://www.w3.org/2000/01/rdf-schema#"> + + <owl:Ontology rdf:about=""> + <rdfs:comment> + Derived from the DAML Wine ontology at + http://ontolingua.stanford.edu/doc/chimaera/ontologies/wines.daml + Substantially modified. + </rdfs:comment> + <owl:imports rdf:resource="http://www.w3.org/2002/03owlt/miscellaneous/consistent001"/> + </owl:Ontology> + + <owl:Class rdf:ID="ConsumableThing" /> + + <owl:Class rdf:ID="NonConsumableThing"> + <owl:complementOf rdf:resource="#ConsumableThing" /> + </owl:Class> + + <owl:Class rdf:ID="EdibleThing"> + <rdfs:subClassOf rdf:resource="#ConsumableThing" /> + </owl:Class> + + <owl:Class rdf:ID="PotableLiquid"> + <rdfs:subClassOf rdf:resource="#ConsumableThing" /> + <owl:disjointWith rdf:resource="#EdibleThing" /> + </owl:Class> + + <owl:Class rdf:ID="Wine"> + <owl:equivalentClass rdf:resource="&vin;Wine"/> + </owl:Class> + + <owl:ObjectProperty rdf:ID="madeFromFruit"> + <rdfs:domain rdf:resource="#ConsumableThing" /> + <rdfs:range rdf:resource="#Fruit" /> + </owl:ObjectProperty> + + <owl:Class rdf:ID="Juice"> + <rdfs:subClassOf rdf:resource="#PotableLiquid" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromFruit" /> + <owl:minCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:ObjectProperty rdf:ID="hasDrink"> + <rdfs:domain rdf:resource="#MealCourse" /> + <rdfs:range rdf:resource="#PotableLiquid" /> + </owl:ObjectProperty> + + <owl:Thing rdf:ID="White"> + <owl:sameAs rdf:resource="&vin;White"/> + </owl:Thing> + + <owl:Thing rdf:ID="Rose"> + <owl:sameAs rdf:resource="&vin;Rose" /> + </owl:Thing> + + <owl:Thing rdf:ID="Red"> + <owl:sameAs rdf:resource="&vin;Red" /> + </owl:Thing> + + <owl:Thing rdf:ID="Sweet"> + <owl:sameAs rdf:resource="&vin;Sweet" /> + </owl:Thing> + + <owl:Thing rdf:ID="OffDry"> + <owl:sameAs rdf:resource="&vin;OffDry" /> + </owl:Thing> + + <owl:Thing rdf:ID="Dry"> + <owl:sameAs rdf:resource="&vin;Dry" /> + </owl:Thing> + + <owl:Thing rdf:ID="Delicate"> + <owl:sameAs rdf:resource="&vin;Delicate" /> + </owl:Thing> + + <owl:Thing rdf:ID="Moderate"> + <owl:sameAs rdf:resource="&vin;Moderate" /> + </owl:Thing> + + <owl:Thing rdf:ID="Strong"> + <owl:sameAs rdf:resource="&vin;Strong" /> + </owl:Thing> + + <owl:Thing rdf:ID="Light"> + <owl:sameAs rdf:resource="&vin;Light" /> + </owl:Thing> + + <owl:Thing rdf:ID="Medium"> + <owl:sameAs rdf:resource="&vin;Medium" /> + </owl:Thing> + + <owl:Thing rdf:ID="Full"> + <owl:sameAs rdf:resource="&vin;Full" /> + </owl:Thing> + + <owl:ObjectProperty rdf:ID="course"> + <rdfs:domain rdf:resource="#Meal" /> + <rdfs:range rdf:resource="#MealCourse" /> + </owl:ObjectProperty> + + <owl:Class rdf:ID="Grape"> + <rdfs:subClassOf rdf:resource="#SweetFruit" /> + </owl:Class> + + <owl:Class rdf:ID="Pasta"> + <rdfs:subClassOf rdf:resource="#EdibleThing" /> + <owl:disjointWith rdf:resource="#Meat" /> + <owl:disjointWith rdf:resource="#Fowl" /> + <owl:disjointWith rdf:resource="#Seafood" /> + <owl:disjointWith rdf:resource="#Dessert" /> + <owl:disjointWith rdf:resource="#Fruit" /> + </owl:Class> + + <owl:Class rdf:ID="PastaWithWhiteSauce"> + <rdfs:subClassOf rdf:resource="#Pasta" /> + <owl:disjointWith rdf:resource="#PastaWithRedSauce" /> + </owl:Class> + + <owl:Class rdf:ID="PastaWithSpicyRedSauceCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#PastaWithSpicyRedSauce" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Full" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Strong" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="PastaWithSpicyRedSauce"> + <rdfs:subClassOf rdf:resource="#PastaWithRedSauce" /> + </owl:Class> + + <owl:Class rdf:ID="PastaWithRedSauce"> + <rdfs:subClassOf rdf:resource="#Pasta" /> + </owl:Class> + + <owl:Class rdf:ID="PastaWithNonSpicyRedSauceCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#PastaWithNonSpicyRedSauce" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="PastaWithNonSpicyRedSauce"> + <rdfs:subClassOf rdf:resource="#PastaWithRedSauce" /> + <owl:disjointWith rdf:resource="#PastaWithSpicyRedSauce" /> + </owl:Class> + + <owl:Class rdf:ID="PastaWithLightCreamSauce"> + <rdfs:subClassOf rdf:resource="#PastaWithWhiteSauce" /> + <owl:disjointWith rdf:resource="#PastaWithHeavyCreamSauce" /> + </owl:Class> + + <owl:Class rdf:ID="PastaWithLightCreamCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#PastaWithLightCreamSauce" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Light" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Delicate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="PastaWithHeavyCreamSauce"> + <rdfs:subClassOf rdf:resource="#PastaWithWhiteSauce" /> + </owl:Class> + + <owl:Class rdf:ID="PastaWithHeavyCreamCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#PastaWithHeavyCreamSauce" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="OysterShellfishCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#OysterShellfish" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Sweet" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="OysterShellfish"> + <rdfs:subClassOf rdf:resource="#Shellfish" /> + </owl:Class> + + <owl:Class rdf:ID="OtherTomatoBasedFoodCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#OtherTomatoBasedFood" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="OtherTomatoBasedFood"> + <rdfs:subClassOf rdf:resource="#EdibleThing" /> + <owl:disjointWith rdf:resource="#Pasta" /> + <owl:disjointWith rdf:resource="#Meat" /> + <owl:disjointWith rdf:resource="#Fowl" /> + <owl:disjointWith rdf:resource="#Seafood" /> + <owl:disjointWith rdf:resource="#Dessert" /> + <owl:disjointWith rdf:resource="#Fruit" /> + </owl:Class> + + <owl:Class rdf:ID="NonSweetFruitCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#NonSweetFruit" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Delicate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#OffDry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="SweetFruitCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#SweetFruit" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Sweet" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + + <owl:Class rdf:ID="NonSweetFruit"> + <rdfs:subClassOf rdf:resource="#EdibleThing" /> + <owl:disjointWith rdf:resource="#SweetFruit" /> + </owl:Class> + + <owl:Class rdf:ID="NonSpicyRedMeatCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#NonSpicyRedMeat" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Strong" /> + <owl:Thing rdf:about="#Moderate" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="NonSpicyRedMeat"> + <rdfs:subClassOf rdf:resource="#RedMeat" /> + <owl:disjointWith rdf:resource="#SpicyRedMeat" /> + </owl:Class> + + <owl:Class rdf:ID="NonRedMeatCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#NonRedMeat" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Strong" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="NonRedMeat"> + <rdfs:subClassOf rdf:resource="#Meat" /> + <owl:disjointWith rdf:resource="#RedMeat" /> + </owl:Class> + + <owl:Class rdf:ID="NonOysterShellfishCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#NonOysterShellfish" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="NonOysterShellfish"> + <rdfs:subClassOf rdf:resource="#Shellfish" /> + <owl:disjointWith rdf:resource="#OysterShellfish" /> + </owl:Class> + + <owl:Class rdf:ID="NonBlandFishCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#NonBlandFish" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="NonBlandFish"> + <rdfs:subClassOf rdf:resource="#Fish" /> + </owl:Class> + + <owl:Class rdf:ID="Meat"> + <rdfs:subClassOf rdf:resource="#EdibleThing" /> + <owl:disjointWith rdf:resource="#Fowl" /> + <owl:disjointWith rdf:resource="#Seafood" /> + <owl:disjointWith rdf:resource="#Dessert" /> + <owl:disjointWith rdf:resource="#Fruit" /> + </owl:Class> + + <owl:Class rdf:ID="MealCourse"> + <rdfs:subClassOf rdf:resource="#ConsumableThing" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:minCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:minCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom rdf:resource="#Wine" /> + </owl:Restriction> + </rdfs:subClassOf> + <owl:disjointWith rdf:resource="#PotableLiquid" /> + <owl:disjointWith rdf:resource="#EdibleThing" /> + </owl:Class> + + <owl:Class rdf:ID="Meal"> + <rdfs:subClassOf rdf:resource="#ConsumableThing" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#course" /> + <owl:minCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#course" /> + <owl:allValuesFrom rdf:resource="#MealCourse" /> + </owl:Restriction> + </rdfs:subClassOf> + <owl:disjointWith rdf:resource="#MealCourse" /> + <owl:disjointWith rdf:resource="#PotableLiquid" /> + <owl:disjointWith rdf:resource="#EdibleThing" /> + </owl:Class> + + <owl:Class rdf:ID="LightMeatFowlCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#LightMeatFowl" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="LightMeatFowl"> + <rdfs:subClassOf rdf:resource="#Fowl" /> + </owl:Class> + + <owl:Class rdf:ID="FruitCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#Fruit" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + + + <owl:Class rdf:ID="Fruit"> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#SweetFruit" /> + <owl:Class rdf:about="#NonSweetFruit" /> + </owl:unionOf> + </owl:Class> + + <owl:Class rdf:ID="Fowl"> + <rdfs:subClassOf rdf:resource="#EdibleThing" /> + <owl:disjointWith rdf:resource="#Seafood" /> + <owl:disjointWith rdf:resource="#Dessert" /> + <owl:disjointWith rdf:resource="#Fruit" /> + </owl:Class> + + <owl:Class rdf:ID="FishCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#Fish" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="DessertCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#Dessert" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Full" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Strong" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Sweet" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="Dessert"> + <rdfs:subClassOf rdf:resource="#EdibleThing" /> + <owl:disjointWith rdf:resource="#Fruit" /> + </owl:Class> + + <owl:Class rdf:ID="SweetFruit"> + <rdfs:subClassOf rdf:resource="#EdibleThing" /> + </owl:Class> + + <owl:Class rdf:ID="SweetDessertCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#SweetDessert" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="SweetDessert"> + <rdfs:subClassOf rdf:resource="#Dessert" /> + </owl:Class> + + <owl:Class rdf:ID="DarkMeatFowlCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#DarkMeatFowl" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Light" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Delicate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="DarkMeatFowl"> + <rdfs:subClassOf rdf:resource="#Fowl" /> + <owl:disjointWith rdf:resource="#LightMeatFowl" /> + </owl:Class> + + <owl:Class rdf:ID="CheeseNutsDessertCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#CheeseNutsDessert" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="CheeseNutsDessert"> + <rdfs:subClassOf rdf:resource="#Dessert" /> + <owl:disjointWith rdf:resource="#SweetDessert" /> + </owl:Class> + + <owl:Class rdf:ID="BlandFishCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#BlandFish" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Delicate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="BlandFish"> + <rdfs:subClassOf rdf:resource="#Fish" /> + <owl:disjointWith rdf:resource="#NonBlandFish" /> + </owl:Class> + + <owl:ObjectProperty rdf:ID="hasFood"> + <rdfs:domain rdf:resource="#MealCourse" /> + <rdfs:range rdf:resource="#EdibleThing" /> + </owl:ObjectProperty> + + <owl:Class rdf:ID="Fish"> + <rdfs:subClassOf rdf:resource="#Seafood" /> + <owl:disjointWith rdf:resource="#Shellfish" /> + </owl:Class> + + <owl:Class rdf:ID="SpicyRedMeat"> + <rdfs:subClassOf rdf:resource="#RedMeat" /> + </owl:Class> + + <owl:Class rdf:ID="ShellfishCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#Shellfish" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Moderate" /> + <owl:Thing rdf:about="#Strong" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Full" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="Shellfish"> + <rdfs:subClassOf rdf:resource="#Seafood" /> + </owl:Class> + + <owl:Class rdf:ID="SeafoodCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#Seafood" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="Seafood"> + <rdfs:subClassOf rdf:resource="#EdibleThing" /> + <owl:disjointWith rdf:resource="#Dessert" /> + <owl:disjointWith rdf:resource="#Fruit" /> + </owl:Class> + + <owl:Class rdf:ID="RedMeatCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#RedMeat" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="RedMeat"> + <rdfs:subClassOf rdf:resource="#Meat" /> + </owl:Class> + + <SweetDessert rdf:ID="Cake" /> + + <SweetFruit rdf:ID="Bananas" /> + + <SweetFruit rdf:ID="MixedFruit" /> + + <NonOysterShellfish rdf:ID="Mussels" /> + + <CheeseNutsDessert rdf:ID="Nuts" /> + + <OysterShellfish rdf:ID="Oysters" /> + + <PastaWithLightCreamSauce rdf:ID="PastaWithWhiteClamSauce" /> + + <SweetFruit rdf:ID="Peaches" /> + + <SweetDessert rdf:ID="Pie" /> + + <OtherTomatoBasedFood rdf:ID="Pizza" /> + + <NonRedMeat rdf:ID="Pork" /> + + <NonSpicyRedMeat rdf:ID="RoastBeef" /> + + <BlandFish rdf:ID="Scrod" /> + + <PastaWithNonSpicyRedSauce rdf:ID="SpaghettiWithTomatoSauce" /> + + <NonSpicyRedMeat rdf:ID="Steak" /> + + <NonBlandFish rdf:ID="Swordfish" /> + + <EatingGrape rdf:ID="ThompsonSeedless" /> + + <owl:Class rdf:ID="EatingGrape"> + <rdfs:subClassOf rdf:resource="#Grape" /> + </owl:Class> + + <NonBlandFish rdf:ID="Tuna" /> + + <LightMeatFowl rdf:ID="Turkey" /> + + <NonSpicyRedMeat rdf:ID="Veal" /> + + <owl:Class rdf:ID="SpicyRedMeatCourse"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#MealCourse" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFood" /> + <owl:allValuesFrom rdf:resource="#SpicyRedMeat" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasBody" /> + <owl:hasValue rdf:resource="#Full" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasDrink" /> + <owl:allValuesFrom> + <owl:Restriction> + <owl:onProperty rdf:resource="&vin;hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <SpicyRedMeat rdf:ID="BeefCurry" /> + + <LightMeatFowl rdf:ID="Chicken" /> + + <NonOysterShellfish rdf:ID="Clams" /> + + <DarkMeatFowl rdf:ID="Duck" /> + + <SpicyRedMeat rdf:ID="GarlickyRoast" /> + + <DarkMeatFowl rdf:ID="Goose" /> + + <BlandFish rdf:ID="Halibut" /> + + <NonOysterShellfish rdf:ID="Crab" /> + + <BlandFish rdf:ID="Flounder" /> + + <NonOysterShellfish rdf:ID="Lobster" /> + + <PastaWithHeavyCreamSauce rdf:ID="FettucineAlfRedo" /> + + <PastaWithSpicyRedSauce rdf:ID="FraDiavolo" /> + + <CheeseNutsDessert rdf:ID="Cheese" /> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + <!DOCTYPE owl [ + <!ENTITY vin "http://www.w3.org/2002/03owlt/miscellaneous/consistent001#" > + <!ENTITY food "http://www.w3.org/2002/03owlt/miscellaneous/consistent002#" > + <!ENTITY owl "http://www.w3.org/2002/07/owl#" > + <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" > + ]> + +<rdf:RDF + xmlns = "&vin;" + xmlns:vin = "&vin;" + xml:base = "&vin;" + xmlns:food= "&food;" + xmlns:owl = "&owl;" + xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs= "http://www.w3.org/2000/01/rdf-schema#" + > + + <owl:Ontology rdf:about=""> + + <rdfs:comment>An example OWL ontology</rdfs:comment> + <owl:priorVersion> + <owl:Ontology rdf:about="http://www.example.org/wine-020303"/> + </owl:priorVersion> + <owl:imports rdf:resource="http://www.w3.org/2002/03owlt/miscellaneous/consistent002"/> + <rdfs:comment>Derived from the DAML Wine ontology at + http://ontolingua.stanford.edu/doc/chimaera/ontologies/wines.daml + Substantially changed, in particular the Region based relations. + </rdfs:comment> + <rdfs:label>Wine Ontology</rdfs:label> + + </owl:Ontology> + + <owl:Class rdf:ID="Wine"> + <rdfs:subClassOf rdf:resource="&food;PotableLiquid" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasMaker" /> + <owl:cardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:cardinality> + </owl:Restriction> + + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasMaker" /> + <owl:allValuesFrom rdf:resource="#Winery" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:minCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:minCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:cardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:cardinality> + + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:cardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:cardinality> + </owl:Restriction> + </rdfs:subClassOf> + + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:cardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:cardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + + <owl:onProperty rdf:resource="#hasColor" /> + <owl:cardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:cardinality> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn"/> + <owl:someValuesFrom rdf:resource="&vin;Region"/> + </owl:Restriction> + + </rdfs:subClassOf> + <rdfs:label xml:lang="en">wine</rdfs:label> + <rdfs:label xml:lang="fr">vin</rdfs:label> + </owl:Class> + + <owl:Class rdf:ID="Vintage"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasVintageYear"/> + <owl:cardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:cardinality> + + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="WineGrape"> + <rdfs:subClassOf rdf:resource="&food;Grape" /> + </owl:Class> + + <owl:Class rdf:ID="WhiteWine"> + <owl:intersectionOf rdf:parseType="Collection"> + + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="WhiteTableWine"> + <owl:intersectionOf rdf:parseType="Collection"> + + <owl:Class rdf:about="#TableWine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="WhiteNonSweetWine"> + <owl:intersectionOf rdf:parseType="Collection"> + + <owl:Class rdf:about="#WhiteWine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Dry" /> + <owl:Thing rdf:about="#OffDry" /> + </owl:oneOf> + + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="WhiteLoire"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Loire" /> + <owl:Class rdf:about="#WhiteWine" /> + + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:about="#WhiteLoire"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:allValuesFrom> + <owl:Class> + + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#CheninBlancGrape" /> + <owl:Thing rdf:about="#PinotBlancGrape" /> + <owl:Thing rdf:about="#SauvignonBlancGrape" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + + </owl:Class> + + <owl:Class rdf:ID="WhiteBurgundy"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Burgundy" /> + <owl:Class rdf:about="#WhiteWine" /> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:about="#WhiteBurgundy"> + + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#ChardonnayGrape" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="WhiteBordeaux"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Bordeaux" /> + <owl:Class rdf:about="#WhiteWine" /> + + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:about="#WhiteBordeaux"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:allValuesFrom> + <owl:Class> + + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#SemillonGrape" /> + <owl:Thing rdf:about="#SauvignonBlancGrape" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + + <owl:Class rdf:ID="Region" /> + + <owl:ObjectProperty rdf:ID="locatedIn"> + <rdf:type rdf:resource="&owl;TransitiveProperty" /> + <rdfs:domain rdf:resource="http://www.w3.org/2002/07/owl#Thing" /> + <rdfs:range rdf:resource="#Region" /> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="adjacentRegion"> + <rdf:type rdf:resource="&owl;SymmetricProperty" /> + + <rdfs:domain rdf:resource="#Region" /> + <rdfs:range rdf:resource="#Region" /> + </owl:ObjectProperty> + + <owl:Class rdf:ID="VintageYear" /> + + <owl:DatatypeProperty rdf:ID="yearValue"> + <rdfs:domain rdf:resource="#VintageYear" /> + <rdfs:range rdf:resource="&xsd;positiveInteger" /> + </owl:DatatypeProperty> + + <VintageYear rdf:ID="Year1998"> + + <yearValue rdf:datatype="&xsd;positiveInteger">1998</yearValue> + </VintageYear> + + <owl:ObjectProperty rdf:ID="hasVintageYear"> + <rdf:type rdf:resource="&owl;FunctionalProperty" /> + <rdfs:domain rdf:resource="#Vintage" /> + <rdfs:range rdf:resource="#VintageYear" /> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="madeFromGrape"> + + <rdfs:subPropertyOf rdf:resource="&food;madeFromFruit" /> + <rdfs:domain rdf:resource="#Wine" /> + <rdfs:range rdf:resource="#WineGrape" /> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="madeIntoWine"> + <owl:inverseOf rdf:resource="#madeFromGrape" /> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="hasWineDescriptor"> + + <rdfs:domain rdf:resource="#Wine" /> + <rdfs:range rdf:resource="#WineDescriptor" /> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="hasSugar"> + <rdf:type rdf:resource="&owl;FunctionalProperty" /> + <rdfs:subPropertyOf rdf:resource="#hasWineDescriptor" /> + <rdfs:range rdf:resource="#WineSugar" /> + </owl:ObjectProperty> + + + <owl:ObjectProperty rdf:ID="hasBody"> + <rdf:type rdf:resource="&owl;FunctionalProperty" /> + <rdfs:subPropertyOf rdf:resource="#hasWineDescriptor" /> + <rdfs:range rdf:resource="#WineBody" /> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="hasFlavor"> + <rdf:type rdf:resource="&owl;FunctionalProperty" /> + <rdfs:subPropertyOf rdf:resource="#hasWineDescriptor" /> + <rdfs:range rdf:resource="#WineFlavor" /> + + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="hasColor"> + <rdf:type rdf:resource="&owl;FunctionalProperty" /> + <rdfs:subPropertyOf rdf:resource="#hasWineDescriptor" /> + <rdfs:domain rdf:resource="#Wine" /> + <rdfs:range rdf:resource="#WineColor" /> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="hasMaker"> + + <rdf:type rdf:resource="&owl;FunctionalProperty" /> + </owl:ObjectProperty> + + <owl:ObjectProperty rdf:ID="producesWine"> + <owl:inverseOf rdf:resource="#hasMaker" /> + </owl:ObjectProperty> + + <owl:Class rdf:ID="Zinfandel"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#ZinfandelGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:about="#Zinfandel"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </rdfs:subClassOf> + + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Full" /> + <owl:Thing rdf:about="#Medium" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Moderate" /> + <owl:Thing rdf:about="#Strong" /> + + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="Winery" /> + + <owl:Class rdf:ID="WineDescriptor"> + <rdfs:comment>Made WineDescriptor unionType of tastes and color</rdfs:comment> + + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#WineTaste" /> + <owl:Class rdf:about="#WineColor" /> + </owl:unionOf> + </owl:Class> + + <owl:Class rdf:ID="WineTaste"> + <rdfs:subClassOf rdf:resource="#WineDescriptor" /> + </owl:Class> + + <owl:Class rdf:ID="WineColor"> + <rdfs:subClassOf rdf:resource="#WineDescriptor" /> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#White" /> + <owl:Thing rdf:about="#Rose" /> + <owl:Thing rdf:about="#Red" /> + </owl:oneOf> + </owl:Class> + + + <owl:Class rdf:ID="WineSugar"> + <rdfs:subClassOf rdf:resource="#WineTaste" /> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Sweet" /> + <owl:Thing rdf:about="#OffDry" /> + <owl:Thing rdf:about="#Dry" /> + </owl:oneOf> + </owl:Class> + + <owl:Class rdf:ID="WineFlavor"> + + <rdfs:subClassOf rdf:resource="#WineTaste" /> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Delicate" /> + <owl:Thing rdf:about="#Moderate" /> + <owl:Thing rdf:about="#Strong" /> + </owl:oneOf> + </owl:Class> + + <owl:Class rdf:ID="WineBody"> + <rdfs:subClassOf rdf:resource="#WineTaste" /> + + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Light" /> + <owl:Thing rdf:about="#Medium" /> + <owl:Thing rdf:about="#Full" /> + </owl:oneOf> + </owl:Class> + + <Region rdf:ID="USRegion" /> + + <owl:Class rdf:ID="Tours"> + <owl:intersectionOf rdf:parseType="Collection"> + + <owl:Class rdf:about="#Loire" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#ToursRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:about="#Tours"> + + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#CheninBlancGrape" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="TableWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="SweetWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Sweet" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="SweetRiesling"> + <rdfs:subClassOf rdf:resource="#DessertWine" /> + <rdfs:subClassOf> + <owl:Restriction> + + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Full" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Moderate" /> + <owl:Thing rdf:about="#Strong" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + + <owl:Class rdf:about="#Riesling" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Sweet" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="StEmilion"> + <rdfs:subClassOf> + + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Strong" /> + + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#CabernetSauvignonGrape" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Bordeaux" /> + <owl:Restriction> + + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#StEmilionRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="SemillonOrSauvignonBlanc"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + + <owl:Thing rdf:about="#Medium" /> + <owl:Thing rdf:about="#Full" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#SemillonGrape" /> + <owl:Thing rdf:about="#SauvignonBlancGrape" /> + </owl:oneOf> + </owl:Class> + + </owl:allValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Semillon"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#SemillonOrSauvignonBlanc" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + + <owl:hasValue rdf:resource="#SemillonGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + + <owl:Class rdf:ID="SauvignonBlanc"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#SemillonOrSauvignonBlanc" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#SauvignonBlancGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Sauterne"> + <rdfs:subClassOf rdf:resource="#LateHarvest" /> + <rdfs:subClassOf rdf:resource="#Bordeaux" /> + <rdfs:subClassOf> + + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#SauterneRegion" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + + <owl:Class rdf:ID="Sancerre"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#OffDry" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Delicate" /> + </owl:Restriction> + + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#SauvignonBlancGrape" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Loire" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + + <owl:hasValue rdf:resource="#SancerreRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="RoseWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + + <owl:hasValue rdf:resource="#Rose" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Riesling"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#White" /> + + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#RieslingGrape" /> + </owl:Restriction> + <owl:Restriction> + + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="RedWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="RedTableWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#TableWine" /> + + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="RedBurgundy"> + <rdfs:subClassOf> + <owl:Restriction> + + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#PinotNoirGrape" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Burgundy" /> + <owl:Class rdf:about="#RedWine" /> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="RedBordeaux"> + <rdfs:subClassOf> + + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#CabernetSauvignonGrape" /> + <owl:Thing rdf:about="#MerlotGrape" /> + </owl:oneOf> + </owl:Class> + + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Bordeaux" /> + <owl:Class rdf:about="#RedWine" /> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Port"> + + <rdfs:subClassOf rdf:resource="#RedWine" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#PortugalRegion" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Full" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Strong" /> + </owl:Restriction> + + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Sweet" /> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="PinotNoir"> + + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#PinotNoirGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + + </owl:Class> + + <owl:Class rdf:ID="PinotBlanc"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#PinotBlancGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="PetiteSyrah"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Moderate" /> + <owl:Thing rdf:about="#Strong" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Medium" /> + + <owl:Thing rdf:about="#Full" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#PetiteSyrahGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + + </owl:Class> + + <owl:Class rdf:ID="Pauillac"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Full" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Strong" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#CabernetSauvignonGrape" /> + + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Medoc" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#PauillacRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Muscadet"> + + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Light" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + + <owl:hasValue rdf:resource="#Delicate" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </rdfs:subClassOf> + + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#PinotBlancGrape" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Loire" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#MuscadetRegion" /> + + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Meursault"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Full" /> + </owl:Restriction> + + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#WhiteBurgundy" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#MeursaultRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + + <owl:Class rdf:ID="Merlot"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Moderate" /> + <owl:Thing rdf:about="#Delicate" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Light" /> + <owl:Thing rdf:about="#Medium" /> + </owl:oneOf> + </owl:Class> + + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#MerlotGrape" /> + </owl:Restriction> + + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Meritage"> + <rdfs:subClassOf> + + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#CabernetSauvignonGrape" /> + <owl:Thing rdf:about="#CabernetFrancGrape" /> + <owl:Thing rdf:about="#MalbecGrape" /> + <owl:Thing rdf:about="#PetiteVerdotGrape" /> + <owl:Thing rdf:about="#MerlotGrape" /> + </owl:oneOf> + + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:minCardinality rdf:datatype="&xsd;nonNegativeInteger">2</owl:minCardinality> + </owl:Restriction> + </owl:intersectionOf> + + </owl:Class> + + <Region rdf:ID="MedocRegion"> + <locatedIn rdf:resource="#BordeauxRegion" /> + </Region> + + <owl:Class rdf:ID="Medoc"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + + <owl:Class rdf:about="#Bordeaux" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#MedocRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Margaux"> + <rdfs:subClassOf> + + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Delicate" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#MerlotGrape" /> + + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </rdfs:subClassOf> + + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Medoc" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#MargauxRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <Region rdf:ID="LoireRegion"> + + <locatedIn rdf:resource="#FrenchRegion" /> + </Region> + + <owl:Class rdf:ID="Loire"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#LoireRegion" /> + </owl:Restriction> + + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="LateHarvest"> + <rdfs:subClassOf rdf:resource="#Wine" /> + <owl:disjointWith rdf:resource="#EarlyHarvest" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Sweet" /> + + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Moderate" /> + + <owl:Thing rdf:about="#Strong" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="ItalianWine"> + <owl:intersectionOf rdf:parseType="Collection"> + + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#ItalianRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <Region rdf:ID="ItalianRegion" /> + + <owl:Class rdf:ID="IceWine"> + + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Medium" /> + <owl:Thing rdf:about="#Full" /> + </owl:oneOf> + + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Moderate" /> + <owl:Thing rdf:about="#Strong" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + + <owl:Class rdf:about="#LateHarvest" /> + <owl:Class rdf:about="#DessertWine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="GermanWine"> + + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#GermanyRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Gamay"> + + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#GamayGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="FullBodiedWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Full" /> + + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <Region rdf:ID="FrenchRegion" /> + + <owl:Class rdf:ID="FrenchWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + + <owl:hasValue rdf:resource="#FrenchRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="EarlyHarvest"> + <rdfs:subClassOf rdf:resource="#Wine" /> + <rdfs:subClassOf> + <owl:Restriction> + + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Dry" /> + <owl:Thing rdf:about="#OffDry" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="DryWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="DryWhiteWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#DryWine" /> + <owl:Class rdf:about="#WhiteWine" /> + </owl:intersectionOf> + </owl:Class> + + + <owl:Class rdf:ID="DryRiesling"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Delicate" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:allValuesFrom> + <owl:Class> + + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Light" /> + <owl:Thing rdf:about="#Medium" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + + <owl:Class rdf:about="#Riesling" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="DryRedWine"> + <owl:intersectionOf rdf:parseType="Collection"> + + <owl:Class rdf:about="#DryWine" /> + <owl:Class rdf:about="#RedWine" /> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="DessertWine"> + <rdfs:subClassOf rdf:resource="#Wine" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#OffDry" /> + <owl:Thing rdf:about="#Sweet" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + + </rdfs:subClassOf> + </owl:Class> + + <owl:Class rdf:ID="CotesDOr"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </rdfs:subClassOf> + + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#RedBurgundy" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#CotesDOrRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Chianti"> + + <rdfs:subClassOf rdf:resource="#ItalianWine" /> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#ChiantiRegion" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#SangioveseGrape" /> + </owl:Restriction> + + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:allValuesFrom> + <owl:Class> + + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Light" /> + <owl:Thing rdf:about="#Medium" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + </owl:Class> + + + <owl:Class rdf:ID="CheninBlanc"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:allValuesFrom> + <owl:Class> + + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Full" /> + <owl:Thing rdf:about="#Medium" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Dry" /> + <owl:Thing rdf:about="#OffDry" /> + </owl:oneOf> + </owl:Class> + + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#CheninBlancGrape" /> + </owl:Restriction> + + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Chardonnay"> + <rdfs:subClassOf> + + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#White" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:allValuesFrom> + + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Full" /> + <owl:Thing rdf:about="#Medium" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Strong" /> + <owl:Thing rdf:about="#Moderate" /> + </owl:oneOf> + + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#ChardonnayGrape" /> + + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <Region rdf:ID="CaliforniaRegion"> + + <locatedIn rdf:resource="#USRegion" /> + </Region> + + <Region rdf:ID="TexasRegion"> + <locatedIn rdf:resource="#USRegion" /> + </Region> + + <owl:Class rdf:ID="CaliforniaWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#CaliforniaRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="TexasWine"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#TexasRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="CabernetSauvignon"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </rdfs:subClassOf> + + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:allValuesFrom> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Moderate" /> + <owl:Thing rdf:about="#Strong" /> + </owl:oneOf> + + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:allValuesFrom> + <owl:Class> + + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#Medium" /> + <owl:Thing rdf:about="#Full" /> + </owl:oneOf> + </owl:Class> + </owl:allValuesFrom> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#CabernetSauvignonGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="CabernetFranc"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Moderate" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Medium" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:hasValue rdf:resource="#CabernetFrancGrape" /> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Burgundy"> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#BourgogneRegion" /> + </owl:Restriction> + </owl:intersectionOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + + </rdfs:subClassOf> + </owl:Class> + + <Region rdf:ID="BourgogneRegion"> + <locatedIn rdf:resource="#FrenchRegion" /> + </Region> + + <Region rdf:ID="BordeauxRegion"> + <locatedIn rdf:resource="#FrenchRegion" /> + </Region> + + <owl:Class rdf:ID="Bordeaux"> + + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#BordeauxRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="Beaujolais"> + + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Red" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + + <owl:hasValue rdf:resource="#Light" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#Dry" /> + </owl:Restriction> + </rdfs:subClassOf> + + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Delicate" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + + <owl:hasValue rdf:resource="#GamayGrape" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#madeFromGrape" /> + <owl:maxCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxCardinality> + </owl:Restriction> + + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#BeaujolaisRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + + <Region rdf:ID="AustralianRegion" /> + + <owl:Class rdf:ID="Anjou"> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasColor" /> + <owl:hasValue rdf:resource="#Rose" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + + <owl:Restriction> + <owl:onProperty rdf:resource="#hasBody" /> + <owl:hasValue rdf:resource="#Light" /> + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasFlavor" /> + <owl:hasValue rdf:resource="#Delicate" /> + + </owl:Restriction> + </rdfs:subClassOf> + <rdfs:subClassOf> + <owl:Restriction> + <owl:onProperty rdf:resource="#hasSugar" /> + <owl:hasValue rdf:resource="#OffDry" /> + </owl:Restriction> + </rdfs:subClassOf> + <owl:intersectionOf rdf:parseType="Collection"> + + <owl:Class rdf:about="#Loire" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#AnjouRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="AmericanWine"> + <owl:intersectionOf rdf:parseType="Collection"> + + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#USRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <owl:Class rdf:ID="AlsatianWine"> + <owl:intersectionOf rdf:parseType="Collection"> + + <owl:Class rdf:about="#Wine" /> + <owl:Restriction> + <owl:onProperty rdf:resource="#locatedIn" /> + <owl:hasValue rdf:resource="#AlsaceRegion" /> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + + <WineBody rdf:ID="Full" /> + + <WineBody rdf:ID="Medium" /> + + + <WineBody rdf:ID="Light" /> + + <WineColor rdf:ID="Red" /> + + <WineColor rdf:ID="Rose" /> + + <WineColor rdf:ID="White" /> + + <WineFlavor rdf:ID="Strong" /> + + <WineFlavor rdf:ID="Moderate" /> + + <WineFlavor rdf:ID="Delicate" /> + + <WineSugar rdf:ID="Dry" /> + + <WineSugar rdf:ID="OffDry"> + + <owl:differentFrom rdf:resource="#Dry"/> + <owl:differentFrom rdf:resource="#Sweet"/> + </WineSugar> + + <WineSugar rdf:ID="Sweet"> + <owl:differentFrom rdf:resource="#Dry"/> + </WineSugar> + + <owl:AllDifferent> + <owl:distinctMembers rdf:parseType="Collection"> + <vin:WineColor rdf:about="#Red" /> + + <vin:WineColor rdf:about="#White" /> + <vin:WineColor rdf:about="#Rose" /> + </owl:distinctMembers> + </owl:AllDifferent> + + <owl:AllDifferent> + <owl:distinctMembers rdf:parseType="Collection"> + <vin:WineBody rdf:about="#Light" /> + <vin:WineBody rdf:about="#Medium" /> + + <vin:WineBody rdf:about="#Full" /> + </owl:distinctMembers> + </owl:AllDifferent> + + <owl:AllDifferent> + <owl:distinctMembers rdf:parseType="Collection"> + <vin:WineFlavor rdf:about="#Delicate" /> + <vin:WineFlavor rdf:about="#Moderate" /> + <vin:WineFlavor rdf:about="#Strong" /> + + </owl:distinctMembers> + </owl:AllDifferent> + + <owl:AllDifferent> + <owl:distinctMembers rdf:parseType="Collection"> + <vin:WineSugar rdf:about="#Sweet" /> + <vin:WineSugar rdf:about="#OffDry" /> + <vin:WineSugar rdf:about="#Dry" /> + </owl:distinctMembers> + </owl:AllDifferent> + + <Region rdf:ID="AlsaceRegion"> + <locatedIn rdf:resource="#FrenchRegion" /> + </Region> + + <Region rdf:ID="AnjouRegion"> + <locatedIn rdf:resource="#LoireRegion" /> + </Region> + + <Region rdf:ID="ArroyoGrandeRegion"> + <locatedIn rdf:resource="#CaliforniaRegion" /> + + </Region> + + <Winery rdf:ID="Beringer" /> + + <Winery rdf:ID="Bancroft" /> + + <Chardonnay rdf:ID="BancroftChardonnay"> + <locatedIn rdf:resource="#NapaRegion" /> + <hasMaker rdf:resource="#Bancroft" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + + <hasBody rdf:resource="#Medium" /> + </Chardonnay> + + <Region rdf:ID="BeaujolaisRegion"> + <locatedIn rdf:resource="#FrenchRegion" /> + </Region> + + <WineGrape rdf:ID="CabernetFrancGrape" /> + + <WineGrape rdf:ID="CabernetSauvignonGrape" /> + + <Region rdf:ID="CentralCoastRegion"> + <locatedIn rdf:resource="#CaliforniaRegion" /> + + </Region> + + <WineGrape rdf:ID="ChardonnayGrape" /> + + <Winery rdf:ID="ChateauChevalBlanc" /> + + <StEmilion rdf:ID="ChateauChevalBlancStEmilion"> + <hasMaker rdf:resource="#ChateauChevalBlanc" /> + </StEmilion> + + <Winery rdf:ID="ChateauDYchem" /> + + <Sauterne rdf:ID="ChateauDYchemSauterne"> + <madeFromGrape rdf:resource="#SauvignonBlancGrape" /> + + <madeFromGrape rdf:resource="#SemillonGrape" /> + <hasFlavor rdf:resource="#Strong" /> + <hasMaker rdf:resource="#ChateauDYchem" /> + </Sauterne> + + <Winery rdf:ID="ChateauDeMeursault" /> + + <Meursault rdf:ID="ChateauDeMeursaultMeursault"> + <hasFlavor rdf:resource="#Moderate" /> + <hasMaker rdf:resource="#ChateauDeMeursault" /> + </Meursault> + + + <Winery rdf:ID="ChateauLafiteRothschild" /> + + <Pauillac rdf:ID="ChateauLafiteRothschildPauillac"> + <hasMaker rdf:resource="#ChateauLafiteRothschild" /> + </Pauillac> + + <Margaux rdf:ID="ChateauMargaux"> + <hasMaker rdf:resource="#ChateauMargauxWinery" /> + </Margaux> + + <Winery rdf:ID="ChateauMargauxWinery" /> + + <Winery rdf:ID="ChateauMorgon" /> + + + <Beaujolais rdf:ID="ChateauMorgonBeaujolais"> + <hasMaker rdf:resource="#ChateauMorgon" /> + </Beaujolais> + + <WineGrape rdf:ID="CheninBlancGrape" /> + + <WineGrape rdf:ID="ZinfandelGrape" /> + + <Chianti rdf:ID="ChiantiClassico"> + <hasBody rdf:resource="#Medium" /> + <hasMaker rdf:resource="#McGuinnesso" /> + + </Chianti> + + <Region rdf:ID="ChiantiRegion"> + <locatedIn rdf:resource="#ItalianRegion" /> + </Region> + + <Winery rdf:ID="ClosDeLaPoussie" /> + + <Sancerre rdf:ID="ClosDeLaPoussieSancerre"> + <hasMaker rdf:resource="#ClosDeLaPoussie" /> + </Sancerre> + + <Winery rdf:ID="ClosDeVougeot" /> + + + <CotesDOr rdf:ID="ClosDeVougeotCotesDOr"> + <hasMaker rdf:resource="#ClosDeVougeot" /> + </CotesDOr> + + <Winery rdf:ID="CongressSprings" /> + + <Semillon rdf:ID="CongressSpringsSemillon"> + <hasMaker rdf:resource="#CongressSprings" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + + </Semillon> + + <Winery rdf:ID="Corbans" /> + + <Riesling rdf:ID="CorbansDryWhiteRiesling"> + <locatedIn rdf:resource="#NewZealandRegion" /> + <hasMaker rdf:resource="#Corbans" /> + <hasSugar rdf:resource="#OffDry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + + </Riesling> + + <SauvignonBlanc rdf:ID="CorbansPrivateBinSauvignonBlanc"> + <locatedIn rdf:resource="#NewZealandRegion" /> + <hasMaker rdf:resource="#Corbans" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Full" /> + </SauvignonBlanc> + + <SauvignonBlanc rdf:ID="CorbansSauvignonBlanc"> + + <locatedIn rdf:resource="#NewZealandRegion" /> + <hasMaker rdf:resource="#Corbans" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Medium" /> + </SauvignonBlanc> + + <Winery rdf:ID="CortonMontrachet" /> + + <WhiteBurgundy rdf:ID="CortonMontrachetWhiteBurgundy"> + <hasMaker rdf:resource="#CortonMontrachet" /> + + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Full" /> + </WhiteBurgundy> + + <Region rdf:ID="CotesDOrRegion"> + <locatedIn rdf:resource="#BourgogneRegion" /> + </Region> + + <Winery rdf:ID="Cotturi" /> + + <Zinfandel rdf:ID="CotturiZinfandel"> + + <locatedIn rdf:resource="#SonomaRegion" /> + <hasMaker rdf:resource="#Cotturi" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Full" /> + </Zinfandel> + + <Winery rdf:ID="DAnjou" /> + + <Region rdf:ID="EdnaValleyRegion"> + <locatedIn rdf:resource="#CaliforniaRegion" /> + + </Region> + + <Winery rdf:ID="Elyse" /> + + <Zinfandel rdf:ID="ElyseZinfandel"> + <locatedIn rdf:resource="#NapaRegion" /> + <hasMaker rdf:resource="#Elyse" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Full" /> + </Zinfandel> + + + <Winery rdf:ID="Forman" /> + + <CabernetSauvignon rdf:ID="FormanCabernetSauvignon"> + <locatedIn rdf:resource="#NapaRegion" /> + <hasMaker rdf:resource="#Forman" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Medium" /> + </CabernetSauvignon> + + <Chardonnay rdf:ID="FormanChardonnay"> + + <locatedIn rdf:resource="#NapaRegion" /> + <hasMaker rdf:resource="#Forman" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Full" /> + </Chardonnay> + + <Winery rdf:ID="Foxen" /> + + <CheninBlanc rdf:ID="FoxenCheninBlanc"> + <locatedIn rdf:resource="#SantaBarbaraRegion" /> + + <hasMaker rdf:resource="#Foxen" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Full" /> + </CheninBlanc> + + <WineGrape rdf:ID="GamayGrape" /> + + <Winery rdf:ID="GaryFarrell" /> + + <Merlot rdf:ID="GaryFarrellMerlot"> + <locatedIn rdf:resource="#SonomaRegion" /> + + <hasMaker rdf:resource="#GaryFarrell" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </Merlot> + + <Region rdf:ID="GermanyRegion" /> + + <Winery rdf:ID="Handley" /> + + <Winery rdf:ID="KalinCellars" /> + + <Semillon rdf:ID="KalinCellarsSemillon"> + + <hasMaker rdf:resource="#KalinCellars" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Full" /> + </Semillon> + + <Winery rdf:ID="KathrynKennedy" /> + + <Meritage rdf:ID="KathrynKennedyLateral"> + <hasMaker rdf:resource="#KathrynKennedy" /> + <hasSugar rdf:resource="#Dry" /> + + <hasFlavor rdf:resource="#Delicate" /> + <hasBody rdf:resource="#Medium" /> + </Meritage> + + <Winery rdf:ID="LaneTanner" /> + + <PinotNoir rdf:ID="LaneTannerPinotNoir"> + <locatedIn rdf:resource="#SantaBarbaraRegion" /> + <hasMaker rdf:resource="#LaneTanner" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Delicate" /> + + <hasBody rdf:resource="#Light" /> + </PinotNoir> + + <Winery rdf:ID="Longridge" /> + + <Merlot rdf:ID="LongridgeMerlot"> + <locatedIn rdf:resource="#NewZealandRegion" /> + <hasMaker rdf:resource="#Longridge" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Light" /> + + </Merlot> + + <WineGrape rdf:ID="MalbecGrape" /> + + <Region rdf:ID="MargauxRegion"> + <locatedIn rdf:resource="#MedocRegion" /> + </Region> + + <Winery rdf:ID="Marietta" /> + + <CabernetSauvignon rdf:ID="MariettaCabernetSauvignon"> + <locatedIn rdf:resource="#SonomaRegion" /> + <hasMaker rdf:resource="#Marietta" /> + + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </CabernetSauvignon> + + <RedTableWine rdf:ID="MariettaOldVinesRed"> + <locatedIn rdf:resource="#SonomaRegion" /> + <hasMaker rdf:resource="#Marietta" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + + <hasBody rdf:resource="#Medium" /> + </RedTableWine> + + <PetiteSyrah rdf:ID="MariettaPetiteSyrah"> + <locatedIn rdf:resource="#SonomaRegion" /> + <hasMaker rdf:resource="#Marietta" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </PetiteSyrah> + + + <Zinfandel rdf:ID="MariettaZinfandel"> + <locatedIn rdf:resource="#SonomaRegion" /> + <hasMaker rdf:resource="#Marietta" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </Zinfandel> + + <Winery rdf:ID="McGuinnesso" /> + + <Region rdf:ID="MendocinoRegion"> + + <locatedIn rdf:resource="#CaliforniaRegion" /> + <adjacentRegion rdf:resource="#SonomaRegion" /> + </Region> + + <WineGrape rdf:ID="MerlotGrape" /> + + <Region rdf:ID="MeursaultRegion"> + <locatedIn rdf:resource="#BourgogneRegion" /> + </Region> + + <Winery rdf:ID="MountEdenVineyard" /> + + <Chardonnay rdf:ID="MountEdenVineyardEdnaValleyChardonnay"> + + <locatedIn rdf:resource="#EdnaValleyRegion" /> + <hasMaker rdf:resource="#MountEdenVineyard" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </Chardonnay> + + <PinotNoir rdf:ID="MountEdenVineyardEstatePinotNoir"> + <locatedIn rdf:resource="#EdnaValleyRegion" /> + <hasMaker rdf:resource="#MountEdenVineyard" /> + + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Full" /> + </PinotNoir> + + <Winery rdf:ID="Mountadam" /> + + <Chardonnay rdf:ID="MountadamChardonnay"> + <locatedIn rdf:resource="#SouthAustraliaRegion" /> + <hasMaker rdf:resource="#Mountadam" /> + <hasSugar rdf:resource="#Dry" /> + + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Full" /> + </Chardonnay> + + <PinotNoir rdf:ID="MountadamPinotNoir"> + <locatedIn rdf:resource="#SouthAustraliaRegion" /> + <hasMaker rdf:resource="#Mountadam" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + + </PinotNoir> + + <DryRiesling rdf:ID="MountadamRiesling"> + <locatedIn rdf:resource="#SouthAustraliaRegion" /> + <hasMaker rdf:resource="#Mountadam" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Delicate" /> + <hasBody rdf:resource="#Medium" /> + </DryRiesling> + + <Region rdf:ID="MuscadetRegion"> + + <locatedIn rdf:resource="#LoireRegion" /> + </Region> + + <Region rdf:ID="NapaRegion"> + <locatedIn rdf:resource="#CaliforniaRegion" /> + </Region> + + <Region rdf:ID="NewZealandRegion" /> + + <Winery rdf:ID="PageMillWinery" /> + + <CabernetSauvignon rdf:ID="PageMillWineryCabernetSauvignon"> + <locatedIn rdf:resource="#NapaRegion" /> + + <hasMaker rdf:resource="#PageMillWinery" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </CabernetSauvignon> + + <Region rdf:ID="PauillacRegion"> + <locatedIn rdf:resource="#MedocRegion" /> + </Region> + + <Winery rdf:ID="PeterMccoy" /> + + + <Chardonnay rdf:ID="PeterMccoyChardonnay"> + <locatedIn rdf:resource="#SonomaRegion" /> + <hasMaker rdf:resource="#PeterMccoy" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </Chardonnay> + + <WineGrape rdf:ID="PetiteSyrahGrape" /> + + <WineGrape rdf:ID="PetiteVerdotGrape" /> + + + <WineGrape rdf:ID="PinotBlancGrape" /> + + <WineGrape rdf:ID="PinotNoirGrape" /> + + <Region rdf:ID="PortugalRegion" /> + + <Winery rdf:ID="PulignyMontrachet" /> + + <WhiteBurgundy rdf:ID="PulignyMontrachetWhiteBurgundy"> + <hasMaker rdf:resource="#PulignyMontrachet" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + + </WhiteBurgundy> + + <WineGrape rdf:ID="RieslingGrape" /> + + <Anjou rdf:ID="RoseDAnjou"> + <hasMaker rdf:resource="#DAnjou" /> + </Anjou> + + <Region rdf:ID="SancerreRegion"> + <locatedIn rdf:resource="#LoireRegion" /> + </Region> + + <WineGrape rdf:ID="SangioveseGrape" /> + + + <Region rdf:ID="SantaBarbaraRegion"> + <locatedIn rdf:resource="#CaliforniaRegion" /> + </Region> + + <Winery rdf:ID="SantaCruzMountainVineyard" /> + + <CabernetSauvignon rdf:ID="SantaCruzMountainVineyardCabernetSauvignon"> + <locatedIn rdf:resource="#SantaCruzMountainsRegion" /> + <hasMaker rdf:resource="#SantaCruzMountainVineyard" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Strong" /> + + <hasBody rdf:resource="#Full" /> + </CabernetSauvignon> + + <Region rdf:ID="CentralTexasRegion"> + <locatedIn rdf:resource="#TexasRegion" /> + </Region> + + <Winery rdf:ID="StGenevieve" /> + + <WhiteWine rdf:ID="StGenevieveTexasWhite"> + <locatedIn rdf:resource="#CentralTexasRegion" /> + + <hasMaker rdf:resource="#StGenevieve" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + </WhiteWine> + + <Region rdf:ID="SantaCruzMountainsRegion"> + <locatedIn rdf:resource="#CaliforniaRegion" /> + </Region> + + <Winery rdf:ID="SaucelitoCanyon" /> + + + <Zinfandel rdf:ID="SaucelitoCanyonZinfandel"> + <locatedIn rdf:resource="#ArroyoGrandeRegion" /> + <hasMaker rdf:resource="#SaucelitoCanyon" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </Zinfandel> + + <Zinfandel rdf:ID="SaucelitoCanyonZinfandel1998"> + <locatedIn rdf:resource="#ArroyoGrandeRegion" /> + + <hasVintageYear rdf:resource="#Year1998" /> + <hasMaker rdf:resource="#SaucelitoCanyon" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </Zinfandel> + + <Region rdf:ID="SauterneRegion"> + <locatedIn rdf:resource="#BordeauxRegion" /> + + </Region> + + <WineGrape rdf:ID="SauvignonBlancGrape" /> + + <Winery rdf:ID="SchlossRothermel" /> + + <SweetRiesling rdf:ID="SchlossRothermelTrochenbierenausleseRiesling"> + <locatedIn rdf:resource="#GermanyRegion" /> + <hasMaker rdf:resource="#SchlossRothermel" /> + <hasSugar rdf:resource="#Sweet" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Full" /> + + </SweetRiesling> + + <Winery rdf:ID="SchlossVolrad" /> + + <SweetRiesling rdf:ID="SchlossVolradTrochenbierenausleseRiesling"> + <locatedIn rdf:resource ="#GermanyRegion" /> + <hasMaker rdf:resource="#SchlossVolrad" /> + <hasSugar rdf:resource="#Sweet" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Full" /> + </SweetRiesling> + + + <Winery rdf:ID="SeanThackrey" /> + + <PetiteSyrah rdf:ID="SeanThackreySiriusPetiteSyrah"> + <locatedIn rdf:resource="#NapaRegion" /> + <hasMaker rdf:resource="#SeanThackrey" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Strong" /> + <hasBody rdf:resource="#Full" /> + </PetiteSyrah> + + <Winery rdf:ID="Selaks" /> + + + <IceWine rdf:ID="SelaksIceWine"> + <locatedIn rdf:resource="#NewZealandRegion" /> + <hasMaker rdf:resource="#Selaks" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + <hasColor rdf:resource="#White" /> + </IceWine> + + <SauvignonBlanc rdf:ID="SelaksSauvignonBlanc"> + <locatedIn rdf:resource="#NewZealandRegion" /> + + <hasMaker rdf:resource="#Selaks" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </SauvignonBlanc> + + <WineGrape rdf:ID="SemillonGrape" /> + + <Winery rdf:ID="SevreEtMaine" /> + + <Muscadet rdf:ID="SevreEtMaineMuscadet"> + <hasMaker rdf:resource="#SevreEtMaine" /> + + </Muscadet> + + <Region rdf:ID="SonomaRegion"> + <locatedIn rdf:resource="#CaliforniaRegion" /> + </Region> + + <Region rdf:ID="SouthAustraliaRegion"> + <locatedIn rdf:resource="#AustralianRegion" /> + </Region> + + <Region rdf:ID="StEmilionRegion"> + <locatedIn rdf:resource="#BordeauxRegion" /> + + </Region> + + <Winery rdf:ID="Stonleigh" /> + + <SauvignonBlanc rdf:ID="StonleighSauvignonBlanc"> + <locatedIn rdf:resource="#NewZealandRegion" /> + <hasMaker rdf:resource="#Stonleigh" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Delicate" /> + <hasBody rdf:resource="#Medium" /> + </SauvignonBlanc> + + + <Winery rdf:ID="Taylor" /> + + <Port rdf:ID="TaylorPort"> + <hasMaker rdf:resource="#Taylor" /> + </Port> + + <Region rdf:ID="ToursRegion"> + <locatedIn rdf:resource="#LoireRegion" /> + </Region> + + <Winery rdf:ID="Ventana" /> + + <CheninBlanc rdf:ID="VentanaCheninBlanc"> + + <locatedIn rdf:resource="#CentralCoastRegion" /> + <hasMaker rdf:resource="#Ventana" /> + <hasSugar rdf:resource="#OffDry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </CheninBlanc> + + <Winery rdf:ID="WhitehallLane" /> + + <CabernetFranc rdf:ID="WhitehallLaneCabernetFranc"> + <locatedIn rdf:resource="#NapaRegion" /> + + <hasMaker rdf:resource="#WhitehallLane" /> + <hasSugar rdf:resource="#Dry" /> + <hasFlavor rdf:resource="#Moderate" /> + <hasBody rdf:resource="#Medium" /> + </CabernetFranc> + + <DessertWine rdf:ID="WhitehallLanePrimavera"> + <locatedIn rdf:resource="#NapaRegion" /> + <hasSugar rdf:resource="#Sweet" /> + <hasFlavor rdf:resource="#Delicate" /> + + <hasBody rdf:resource="#Light" /> + </DessertWine> + + <owl:AllDifferent> + <owl:distinctMembers rdf:parseType="Collection"> + <vin:Winery rdf:about="#Bancroft" /> + <vin:Winery rdf:about="#ChateauChevalBlanc" /> + <vin:Winery rdf:about="#ChateauDYchem" /> + <vin:Winery rdf:about="#ChateauDeMeursault" /> + <vin:Winery rdf:about="#ChateauLafiteRothschild" /> + + <vin:Winery rdf:about="#ChateauMargauxWinery" /> + <vin:Winery rdf:about="#ChateauMorgon" /> + <vin:Winery rdf:about="#ClosDeLaPoussie" /> + <vin:Winery rdf:about="#ClosDeVougeot" /> + <vin:Winery rdf:about="#CongressSprings" /> + <vin:Winery rdf:about="#Corbans" /> + <vin:Winery rdf:about="#CortonMontrachet" /> + <vin:Winery rdf:about="#Cotturi" /> + <vin:Winery rdf:about="#DAnjou" /> + + <vin:Winery rdf:about="#Elyse" /> + <vin:Winery rdf:about="#Forman" /> + <vin:Winery rdf:about="#Foxen" /> + <vin:Winery rdf:about="#GaryFarrell" /> + <vin:Winery rdf:about="#KalinCellars" /> + <vin:Winery rdf:about="#KathrynKennedy" /> + <vin:Winery rdf:about="#LaneTanner" /> + <vin:Winery rdf:about="#Longridge" /> + <vin:Winery rdf:about="#Marietta" /> + + <vin:Winery rdf:about="#McGuinnesso" /> + <vin:Winery rdf:about="#MountEdenVineyard" /> + <vin:Winery rdf:about="#Mountadam" /> + <vin:Winery rdf:about="#PageMillWinery" /> + <vin:Winery rdf:about="#PeterMccoy" /> + <vin:Winery rdf:about="#PulignyMontrachet" /> + <vin:Winery rdf:about="#SantaCruzMountainVineyard" /> + <vin:Winery rdf:about="#SaucelitoCanyon" /> + <vin:Winery rdf:about="#SchlossRothermel" /> + + <vin:Winery rdf:about="#SchlossVolrad" /> + <vin:Winery rdf:about="#SeanThackrey" /> + <vin:Winery rdf:about="#Selaks" /> + <vin:Winery rdf:about="#SevreEtMaine" /> + <vin:Winery rdf:about="#StGenevieve" /> + <vin:Winery rdf:about="#Stonleigh" /> + <vin:Winery rdf:about="#Taylor" /> + <vin:Winery rdf:about="#Ventana" /> + <vin:Winery rdf:about="#WhitehallLane" /> + + </owl:distinctMembers> + </owl:AllDifferent> + +</rdf:RDF> + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-miscellaneous-102 + Jeremy J. Carroll + Abstract syntax restrictions with multiple components +are in OWL DL. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/miscellaneous/consistent102#" + xml:base="http://www.w3.org/2002/03owlt/miscellaneous/consistent102" > + <owl:Ontology/> + <owl:Thing rdf:ID="i"> + <rdf:type> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="p"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:ID="a"/> + </owl:allValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#p"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:ID="s"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </rdf:type> + </owl:Thing> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-miscellaneous-103 + Jeremy J. Carroll + This description cannot be expressed as a multicomponent restriction +in the OWL 1 abstract syntax. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/miscellaneous/consistent103#" + xml:base="http://www.w3.org/2002/03owlt/miscellaneous/consistent103" > + <owl:Ontology/> + <owl:Thing rdf:ID="i"> + <rdf:type> + <owl:Class> + <owl:intersectionOf rdf:parseType="Collection"> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:ID="p"/> + </owl:onProperty> + <owl:allValuesFrom> + <owl:Class rdf:ID="a"/> + </owl:allValuesFrom> + </owl:Restriction> + <owl:Restriction> + <owl:onProperty> + <owl:ObjectProperty rdf:about="#q"/> + </owl:onProperty> + <owl:someValuesFrom> + <owl:Class rdf:ID="s"/> + </owl:someValuesFrom> + </owl:Restriction> + </owl:intersectionOf> + </owl:Class> + </rdf:type> + </owl:Thing> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-miscellaneous-202 + Jeremy J. Carroll + This shows that insignificant whitespace in an rdf:XMLLiteral is not significant within OWL. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns="http://www.w3.org/1999/xhtml" + xmlns:first="http://www.w3.org/2002/03owlt/miscellaneous/consistent202#" + xml:base="http://www.w3.org/2002/03owlt/miscellaneous/consistent202" > + + <owl:Ontology/> + + <owl:DatatypeProperty rdf:ID="fp" /> + <owl:FunctionalProperty + rdf:about="#fp" /> + <owl:Thing> + <first:fp rdf:parseType="Literal"><br /> +<img src="vn.png" alt="Venn diagram" longdesc="vn.html" title="Venn"></img></first:fp> + <first:fp rdf:parseType="Literal"><br +></br> +<img +src="vn.png" title= +"Venn" alt +="Venn diagram" longdesc= +"vn.html" /></first:fp> + </owl:Thing> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-miscellaneous-203 + Jeremy J. Carroll + This shows that initial whitespace in an rdf:XMLLiteral (http://www.w3.org/TR/rdf-concepts/#section-XMLLiteral) is significant within OWL. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns="http://www.w3.org/1999/xhtml" + xmlns:first="http://www.w3.org/2002/03owlt/miscellaneous/inconsistent203#" + xml:base="http://www.w3.org/2002/03owlt/miscellaneous/inconsistent203" > + + <owl:Ontology/> + + <owl:DatatypeProperty + rdf:ID="fp" /> + <owl:FunctionalProperty + rdf:about="#fp" /> + <owl:Thing> + <first:fp rdf:parseType="Literal"> +<br /> +<img src="vn.png" alt="Venn diagram" longdesc="vn.html" title="Venn"></img> + +</first:fp> + <first:fp rdf:parseType="Literal"><br +></br> +<img +src="vn.png" title= +"Venn" alt +="Venn diagram" longdesc= +"vn.html" /> +</first:fp> + </owl:Thing> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-miscellaneous-204 + Jeremy J. Carroll + This shows a simple inconsistency depending on the datatype +rdf:XMLLiteral. +This file is inconsistent with a datatype map which supports rdf:XMLLiteral, +and consistent otherwise. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns="http://www.w3.org/1999/xhtml" + xmlns:first="http://www.w3.org/2002/03owlt/miscellaneous/inconsistent204#" + xml:base="http://www.w3.org/2002/03owlt/miscellaneous/inconsistent204" > + <owl:Ontology/> + <owl:FunctionalProperty rdf:ID="fp"/> + <owl:DatatypeProperty rdf:about="#fp"/> + <owl:Thing> + <first:fp rdf:parseType="Literal" + ><span xml:lang='en'> + <b>Good!</b></span + ></first:fp> + <first:fp rdf:parseType="Literal" + ><span xml:lang='en'> + <b>Bad!</b></span + ></first:fp> + </owl:Thing> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + + + + WebOnt-miscellaneous-302-Direct + Jeremy J. Carroll + Mike Smith + A version of WebOnt-miscellaneous-302 applicable under the Direct Semantics, in which the annotation in the entailed ontology is not considered. + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/miscellaneous/premises302#" + xml:base="http://www.w3.org/2002/03owlt/miscellaneous/nonconclusions302" > + +<owl:Ontology/> + +<owl:AnnotationProperty rdf:about="premises302#prop" /> + +<owl:Thing rdf:about="premises302#a"> + <first:prop>bar</first:prop> +</owl:Thing> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/miscellaneous/premises302#" + xml:base="http://www.w3.org/2002/03owlt/miscellaneous/premises302" > + +<owl:Ontology/> +<owl:AnnotationProperty rdf:ID="prop" /> +<owl:Thing rdf:about="#a"> + <first:prop>foo</first:prop> +</owl:Thing> + +</rdf:RDF> + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The input ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + WebOnt-miscellaneous-303 + Jeremy J. Carroll + <code>dc:creator</code> may be declared as an annotation property. + + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/miscellaneous/consistent303" > + + <owl:Ontology/> + <owl:AnnotationProperty rdf:about='http://purl.org/dc/elements/1.0/creator'/> + +</rdf:RDF> + + + + + + + WebOnt-oneOf-001 + Jeremy J. Carroll + <code>oneOf</code> <em>does not</em> indicate that the named +individuals are distinct. Thus a consistent interpretation +of this file is when all the individual names denote the +same individual. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/oneOf/consistent001#" + xml:base="http://www.w3.org/2002/03owlt/oneOf/consistent001" > + <owl:Ontology/> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <rdf:Description rdf:ID="amy"/> + <rdf:Description rdf:ID="bob"/> + <rdf:Description rdf:ID="caroline"/> + </owl:oneOf> + <owl:equivalentClass> + <owl:Class> + <owl:oneOf rdf:parseType="Collection"> + <rdf:Description rdf:ID="yolanda"/> + <rdf:Description rdf:ID="zebedee"/> + </owl:oneOf> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-oneOf-004 + Jeremy J. Carroll + This test illustrates the use of dataRange in OWL DL. +This test combines some of the ugliest features of XML, RDF and OWL. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/oneOf/premises004#" + xml:base="http://www.w3.org/2002/03owlt/oneOf/conclusions004" > + <owl:Ontology/> + <owl:DatatypeProperty rdf:about="premises004#p"/> + <owl:Thing rdf:about="premises004#i"> + <first:p rdf:datatype= +"http://www.w3.org/2001/XMLSchema#integer">4</first:p> + </owl:Thing> +</rdf:RDF> + <!DOCTYPE rdf:RDF [ + <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#"> + <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> +]> +<rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/oneOf/premises004#" + xml:base="http://www.w3.org/2002/03owlt/oneOf/premises004" > + <owl:Ontology/> + <owl:DatatypeProperty rdf:ID="p"> + <rdfs:range> + <owl:DataRange> + <owl:oneOf> + <rdf:List> + <rdf:first rdf:datatype="&xsd;integer">1</rdf:first> + <rdf:rest> + <rdf:List> + <rdf:first rdf:datatype="&xsd;integer">2</rdf:first> + <rdf:rest> + <rdf:List> + <rdf:first rdf:datatype="&xsd;integer">3</rdf:first> + <rdf:rest> + <rdf:List> + <rdf:first rdf:datatype="&xsd;integer">4</rdf:first> + <rdf:rest rdf:resource="&rdf;nil"/> + </rdf:List> + </rdf:rest> + </rdf:List> + </rdf:rest> + </rdf:List> + </rdf:rest> + </rdf:List> + </owl:oneOf> + </owl:DataRange> + </rdfs:range> + <rdfs:range> + <owl:DataRange> + <owl:oneOf> + <rdf:List> + <rdf:first rdf:datatype="&xsd;integer">4</rdf:first> + <rdf:rest> + <rdf:List> + <rdf:first rdf:datatype="&xsd;integer">5</rdf:first> + <rdf:rest> + <rdf:List> + <rdf:first rdf:datatype="&xsd;integer">6</rdf:first> + <rdf:rest rdf:resource="&rdf;nil"/> + </rdf:List> + </rdf:rest> + </rdf:List> + </rdf:rest> + </rdf:List> + </owl:oneOf> + </owl:DataRange> + </rdfs:range> + </owl:DatatypeProperty> + <owl:Thing rdf:ID="i"> + <rdf:type> + <owl:Restriction> + <owl:onProperty rdf:resource="#p"/> + <owl:minCardinality rdf:datatype="&xsd;int">1</owl:minCardinality> + </owl:Restriction> + </rdf:type> + </owl:Thing> +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL Lite document, but was not OWL Lite because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-sameAs-001 + Jeremy J. Carroll + Annotation properties refer to a class instance. sameAs, in OWL Full, also refers to the class instance. + + + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/sameAs/premises001#" + xml:base="http://www.w3.org/2002/03owlt/sameAs/conclusions001" + > + + <owl:Ontology/> + <owl:Class rdf:about="premises001#c2"> + <first:annotate>description of c1</first:annotate> + </owl:Class> + <owl:AnnotationProperty rdf:about="premises001#annotate" /> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" +xmlns:first="http://www.w3.org/2002/03owlt/sameAs/premises001#" + xml:base="http://www.w3.org/2002/03owlt/sameAs/premises001" + > + + <owl:Ontology/> + <owl:Class rdf:ID="c1"> + <owl:sameAs> + <owl:Class rdf:ID="c2"/> + </owl:sameAs> + <first:annotate>description of c1</first:annotate> + </owl:Class> + + <owl:AnnotationProperty rdf:ID="annotate" /> + +</rdf:RDF> + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-unionOf-003 + Jeremy J. Carroll + Sets with appropriate extensions are related by unionOf. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/unionOf/conclusions003" > + + + <owl:Ontology/> + <owl:Class rdf:about="premises003#A-and-B"> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="premises003#A"/> + <owl:Class rdf:about="premises003#B"/> + </owl:unionOf> + </owl:Class> + + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://www.w3.org/2002/03owlt/unionOf/premises003" > + <owl:Ontology/> + <owl:Class rdf:ID="A"> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:ID="a"/> + </owl:oneOf> + </owl:Class> + <owl:Class rdf:ID="B"> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:ID="b"/> + </owl:oneOf> + </owl:Class> + <owl:Class rdf:ID="A-and-B"> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="#a"/> + <owl:Thing rdf:about="#b"/> + </owl:oneOf> + </owl:Class> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + The version of this test approved by the WebOnt WG was incorrect. The premise ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + The version of this test approved by the WebOnt WG was incorrect. The conclusion ontology present in that version of the test was marked as an OWL DL document, but was not OWL DL because it did not contain a triple of the form O rdf:type owl:Ontology. The ontology has been revised to contain the necessary triple. + + + + WebOnt-unionOf-004 + Jeremy J. Carroll + An inverse to test <a xmlns="http://www.w3.org/1999/xhtml" href="#unionOf-003">003</a>. + + + + + + + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/unionOf/premises004#" + xmlns:second="http://www.w3.org/2002/03owlt/unionOf/conclusions004#" + xml:base="http://www.w3.org/2002/03owlt/unionOf/conclusions004" > + + <owl:Ontology/> + + <owl:Class rdf:about="premises004#A-and-B"> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:about="premises004#a"/> + <owl:Thing rdf:about="premises004#b"/> + </owl:oneOf> + </owl:Class> + +</rdf:RDF> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:first="http://www.w3.org/2002/03owlt/unionOf/premises004#" + xmlns:second="http://www.w3.org/2002/03owlt/unionOf/conclusions004#" + xml:base="http://www.w3.org/2002/03owlt/unionOf/premises004" > + + <owl:Ontology/> + + <owl:Class rdf:about="#A-and-B"> + <owl:unionOf rdf:parseType="Collection"> + <owl:Class rdf:about="#A"/> + <owl:Class rdf:about="#B"/> + </owl:unionOf> + </owl:Class> + + <owl:Class rdf:ID="A"> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:ID="a"/> + </owl:oneOf> + </owl:Class> + <owl:Class rdf:ID="B"> + <owl:oneOf rdf:parseType="Collection"> + <owl:Thing rdf:ID="b"/> + </owl:oneOf> + </owl:Class> + +</rdf:RDF> + + + + + + + + + + + + + + + + + + + + diff --git a/contract/src/test/resources/annotatedpropertychain.ttl.rdf b/contract/src/test/resources/annotatedpropertychain.ttl.rdf new file mode 100644 index 0000000000..772b78a505 --- /dev/null +++ b/contract/src/test/resources/annotatedpropertychain.ttl.rdf @@ -0,0 +1,24 @@ +_:ont a . +_:x + . +_:x + . +_:x + . +_:x _:y1 . +_:x "An aunt is a mother's sister." . + + _:y1 . +_:y1 + . +_:y1 _:y2 . +_:y2 + . +_:y2 + . + a + . + a + . + a + . \ No newline at end of file diff --git a/contract/src/test/resources/cardinalitywithwhitespace.owl b/contract/src/test/resources/cardinalitywithwhitespace.owl new file mode 100644 index 0000000000..dc29a2ec25 --- /dev/null +++ b/contract/src/test/resources/cardinalitywithwhitespace.owl @@ -0,0 +1,23 @@ + +]> + + + + + + + +1 + + + + + \ No newline at end of file diff --git a/contract/src/test/resources/cidoc_crm_v5.0.4_official_release.rdfs.xml b/contract/src/test/resources/cidoc_crm_v5.0.4_official_release.rdfs.xml new file mode 100644 index 0000000000..3908ad4340 --- /dev/null +++ b/contract/src/test/resources/cidoc_crm_v5.0.4_official_release.rdfs.xml @@ -0,0 +1,4722 @@ + + + + + + + Οντότητα CIDOC CRM + CRM Entity + CRM Entität + CRM Сущность + Entité CRM + Entidade CRM + This class comprises all things in the universe of discourse of the CIDOC Conceptual Reference Model. +It is an abstract concept providing for three general properties: +1. Identification by name or appellation, and in particular by a preferred identifier +2. Classification by type, allowing further refinement of the specific subclass an instance belongs to +3. Attachment of free text for the expression of anything not captured by formal properties +With the exception of E59 Primitive Value, all other classes within the CRM are directly or indirectly specialisations of E1 CRM Entity. + + + + + Entité temporelle + Temporal Entity + Временная Сущность + Έγχρονη Οντότητα + Geschehendes + Entidade Temporal + This class comprises all phenomena, such as the instances of E4 Periods, E5 Events and states, which happen over a limited extent in time. + In some contexts, these are also called perdurants. This class is disjoint from E77 Persistent Item. This is an abstract class and has no direct instances. E2 Temporal Entity is specialized into E4 Period, which applies to a particular geographic area (defined with a greater or lesser degree of precision), and E3 Condition State, which applies to instances of E18 Physical Thing. + + + + + + Состояние + Condition State + Zustandsphase + État matériel + Κατάσταση + Estado Material + This class comprises the states of objects characterised by a certain condition over a time-span. +An instance of this class describes the prevailing physical condition of any material object or feature during a specific E52 Time Span. In general, the time-span for which a certain condition can be asserted may be shorter than the real time-span, for which this condition held. + The nature of that condition can be described using P2 has type. For example, the E3 Condition State “condition of the SS Great Britain between 22 September 1846 and 27 August 1847” can be characterized as E55 Type “wrecked”. + + + + + + Phase + Period + Période + Период + Περίοδος + Período + This class comprises sets of coherent phenomena or cultural manifestations bounded in time and space. +It is the social or physical coherence of these phenomena that identify an E4 Period and not the associated spatio-temporal bounds. These bounds are a mere approximation of the actual process of growth, spread and retreat. Consequently, different periods can overlap and coexist in time and space, such as when a nomadic culture exists in the same area as a sedentary culture. +Typically this class is used to describe prehistoric or historic periods such as the “Neolithic Period”, the “Ming Dynasty” or the “McCarthy Era”. There are however no assumptions about the scale of the associated phenomena. In particular all events are seen as synthetic processes consisting of coherent phenomena. Therefore E4 Period is a superclass of E5 Event. For example, a modern clinical E67 Birth can be seen as both an atomic E5 Event and as an E4 Period that consists of multiple activities performed by multiple instances of E39 Actor. +There are two different conceptualisations of ‘artistic style’, defined either by physical features or by historical context. For example, “Impressionism” can be viewed as a period lasting from approximately 1870 to 1905 during which paintings with particular characteristics were produced by a group of artists that included (among others) Monet, Renoir, Pissarro, Sisley and Degas. Alternatively, it can be regarded as a style applicable to all paintings sharing the characteristics of the works produced by the Impressionist painters, regardless of historical context. The first interpretation is an E4 Period, and the second defines morphological object types that fall under E55 Type. +Another specific case of an E4 Period is the set of activities and phenomena associated with a settlement, such as the populated period of Nineveh. + + + + + + Συμβάν + Événement + Событие + Event + Ereignis + Evento + This class comprises changes of states in cultural, social or physical systems, regardless of scale, brought about by a series or group of coherent physical, cultural, technological or legal phenomena. Such changes of state will affect instances of E77 Persistent Item or its subclasses. +The distinction between an E5 Event and an E4 Period is partly a question of the scale of observation. Viewed at a coarse level of detail, an E5 Event is an ‘instantaneous’ change of state. At a fine level, the E5 Event can be analysed into its component phenomena within a space and time frame, and as such can be seen as an E4 Period. The reverse is not necessarily the case: not all instances of E4 Period give rise to a noteworthy change of state. + + + + + + Разрушение + Destruction + Destruction + Zerstörung + Καταστροφή + Destruição + This class comprises events that destroy one or more instances of E18 Physical Thing such that they lose their identity as the subjects of documentation. +Some destruction events are intentional, while others are independent of human activity. Intentional destruction may be documented by classifying the event as both an E6 Destruction and E7 Activity. +The decision to document an object as destroyed, transformed or modified is context sensitive: +1. If the matter remaining from the destruction is not documented, the event is modelled solely as E6 Destruction. +2. An event should also be documented using E81 Transformation if it results in the destruction of one or more objects and the simultaneous production of others using parts or material from the original. In this case, the new items have separate identities. Matter is preserved, but identity is not. +3. When the initial identity of the changed instance of E18 Physical Thing is preserved, the event should be documented as E11 Modification. + + + + + + Activity + Activité + Handlung + Деятельность + Δράση + Atividade + This class comprises actions intentionally carried out by instances of E39 Actor that result in changes of state in the cultural, social, or physical systems documented. +This notion includes complex, composite and long-lasting actions such as the building of a settlement or a war, as well as simple, short-lived actions such as the opening of a door. + + + + + + Acquisition + Απόκτηση + Событие Приобретения + Acquisition + Erwerb + Aquisição + This class comprises transfers of legal ownership from one or more instances of E39 Actor to one or more other instances of E39 Actor. +The class also applies to the establishment or loss of ownership of instances of E18 Physical Thing. It does not, however, imply changes of any other kinds of right. The recording of the donor and/or recipient is optional. It is possible that in an instance of E8 Acquisition there is either no donor or no recipient. Depending on the circumstances, it may describe: +1. the beginning of ownership +2. the end of ownership +3. the transfer of ownership +4. the acquisition from an unknown source +5. the loss of title due to destruction of the item +It may also describe events where a collector appropriates legal title, for example by annexation or field collection. The interpretation of the museum notion of "accession" differs between institutions. The CRM therefore models legal ownership (E8 Acquisition) and physical custody (E10 Transfer of Custody) separately. Institutions will then model their specific notions of accession and deaccession as combinations of these. + + + + + + Move + Μετακίνηση + Objektbewegung + Перемещение + Déplacement + Locomoção + This class comprises changes of the physical location of the instances of E19 Physical Object. +Note, that the class E9 Move inherits the property P7 took place at (witnessed): E53 Place. This property should be used to describe the trajectory or a larger area within which a move takes place, whereas the properties P26 moved to (was destination of), P27 moved from (was origin of) describe the start and end points only. Moves may also be documented to consist of other moves (via P9 consists of (forms part of)), in order to describe intermediate stages on a trajectory. In that case, start and end points of the partial moves should match appropriately between each other and with the overall event. + + + + + + Changement de détenteur + Transfer of Custody + Übertragung des Gewahrsams + Μεταβίβαση Κατοχής + Передача Опеки + Transferência de Custódia + This class comprises transfers of physical custody of objects between instances of E39 Actor. +The recording of the donor and/or recipient is optional. It is possible that in an instance of E10 Transfer of Custody there is either no donor or no recipient. Depending on the circumstances it may describe: +1. the beginning of custody +2. the end of custody +3. the transfer of custody +4. the receipt of custody from an unknown source +5. the declared loss of an object +The distinction between the legal responsibility for custody and the actual physical possession of the object should be expressed using the property P2 has type (is type of). A specific case of transfer of custody is theft. +The interpretation of the museum notion of "accession" differs between institutions. The CRM therefore models legal ownership and physical custody separately. Institutions will then model their specific notions of accession and deaccession as combinations of these. + + + + + + Событие Изменения + Modification + Τροποποίηση + Modification + Bearbeitung + Modificação + This class comprises all instances of E7 Activity that create, alter or change E24 Physical Man-Made Thing. +This class includes the production of an item from raw materials, and other so far undocumented objects, and the preventive treatment or restoration of an object for conservation. +Since the distinction between modification and production is not always clear, modification is regarded as the more generally applicable concept. This implies that some items may be consumed or destroyed in a Modification, and that others may be produced as a result of it. An event should also be documented using E81 Transformation if it results in the destruction of one or more objects and the simultaneous production of others using parts or material from the originals. In this case, the new items have separate identities. +If the instance of the E29 Design or Procedure utilized for the modification prescribes the use of specific materials, they should be documented using property P68 foresees use of (use foreseen by): E57 Material of E29 Design or Procedure, rather than via P126 employed (was employed in): E57 Material. + + + + + + Production + Παραγωγή + Herstellung + Событие Производства + Production + Produção + This class comprises activities that are designed to, and succeed in, creating one or more new items. +It specializes the notion of modification into production. The decision as to whether or not an object is regarded as new is context sensitive. Normally, items are considered “new” if there is no obvious overall similarity between them and the consumed items and material used in their production. In other cases, an item is considered “new” because it becomes relevant to documentation by a modification. For example, the scribbling of a name on a potsherd may make it a voting token. The original potsherd may not be worth documenting, in contrast to the inscribed one. +This entity can be collective: the printing of a thousand books, for example, would normally be considered a single event. +An event should also be documented using E81 Transformation if it results in the destruction of one or more objects and the simultaneous production of others using parts or material from the originals. In this case, the new items have separate identities and matter is preserved, but identity is not. + + + + + + + Присвоение Атрибута + Affectation d'attribut + Merkmalszuweisung + Attribute Assignment + Απόδοση Ιδιοτήτων + Atribuição de Característica + This class comprises the actions of making assertions about properties of an object or any relation between two items or concepts. +This class allows the documentation of how the respective assignment came about, and whose opinion it was. All the attributes or properties assigned in such an action can also be seen as directly attached to the respective item or concept, possibly as a collection of contradictory values. All cases of properties in this model that are also described indirectly through an action are characterised as "short cuts" of this action. This redundant modelling of two alternative views is preferred because many implementations may have good reasons to model either the action or the short cut, and the relation between both alternatives can be captured by simple rules. +In particular, the class describes the actions of people making propositions and statements during certain museum procedures, e.g. the person and date when a condition statement was made, an identifier was assigned, the museum object was measured, etc. Which kinds of such assignments and statements need to be documented explicitly in structures of a schema rather than free text, depends on if this information should be accessible by structured queries. + + + + + + Εκτίμηση Κατάστασης + Оценка Состояния + Expertise de l'état matériel + Zustandsfeststellung + Condition Assessment + Avaliação do Estado Material + This class describes the act of assessing the state of preservation of an object during a particular period. +The condition assessment may be carried out by inspection, measurement or through historical research. This class is used to document circumstances of the respective assessment that may be relevant to interpret its quality at a later stage, or to continue research on related documents. + + + + + +Απόδοση Αναγνωριστικού + Назначение Идентификатора + Identifier Assignment + Kennzeichenzuweisung + Attribution d’identificateur + Atribuição de Identificador + This class comprises activities that result in the allocation of an identifier to an instance of E1 CRM Entity. An E15 Identifier Assignment may include the creation of the identifier from multiple constituents, which themselves may be instances of E41 Appellation. The syntax and kinds of constituents to be used may be declared in a rule constituting an instance of E29 Design or Procedure. +Examples of such identifiers include Find Numbers, Inventory Numbers, uniform titles in the sense of librarianship and Digital Object Identifiers (DOI). Documenting the act of identifier assignment and deassignment is especially useful when objects change custody or the identification system of an organization is changed. In order to keep track of the identity of things in such cases, it is important to document by whom, when and for what purpose an identifier is assigned to an item. +The fact that an identifier is a preferred one for an organisation can be expressed by using the property E1 CRM Entity. P48 has preferred identifier (is preferred identifier of): E42 Identifier. It can better be expressed in a context independent form by assigning a suitable E55 Type, such as “preferred identifier assignment”, to the respective instance of E15 Identifier Assignment via the P2 has type property. + + + + + + Событие Измерения + Μέτρηση + Messung + Mesurage + Measurement + Medição + This class comprises actions measuring physical properties and other values that can be determined by a systematic procedure. +Examples include measuring the monetary value of a collection of coins or the running time of a specific video cassette. +The E16 Measurement may use simple counting or tools, such as yardsticks or radiation detection devices. The interest is in the method and care applied, so that the reliability of the result may be judged at a later stage, or research continued on the associated documents. The date of the event is important for dimensions, which may change value over time, such as the length of an object subject to shrinkage. Details of methods and devices are best handled as free text, whereas basic techniques such as "carbon 14 dating" should be encoded using P2 has type (is type of:) E55 Type. + + + + + + Typuszuweisung + Присвоение Типа + Attribution de type + Type Assignment + Απόδοση Τύπου + Atribuição de Tipo + This class comprises the actions of classifying items of whatever kind. Such items include objects, specimens, people, actions and concepts. +This class allows for the documentation of the context of classification acts in cases where the value of the classification depends on the personal opinion of the classifier, and the date that the classification was made. This class also encompasses the notion of "determination," i.e. the systematic and molecular identification of a specimen in biology. + + + + + + Materielles + Υλικό Πράγμα + Physical Thing + Chose matérielle + Физическая Вещь + Coisa Material + This class comprises all persistent physical items with a relatively stable form, man-made or natural. +Depending on the existence of natural boundaries of such things, the CRM distinguishes the instances of E19 Physical Object from instances of E26 Physical Feature, such as holes, rivers, pieces of land etc. Most instances of E19 Physical Object can be moved (if not too heavy), whereas features are integral to the surrounding matter. +The CRM is generally not concerned with amounts of matter in fluid or gaseous states. + + + + + + Физический Объект + Objet matériel + Physical Object + Υλικό Αντικείμενο + Materieller Gegenstand + Objeto Material + This class comprises items of a material nature that are units for documentation and have physical boundaries that separate them completely in an objective way from other objects. +The class also includes all aggregates of objects made for functional purposes of whatever kind, independent of physical coherence, such as a set of chessmen. Typically, instances of E19 Physical Object can be moved (if not too heavy). +In some contexts, such objects, except for aggregates, are also called “bona fide objects” (Smith & Varzi, 2000, pp.401-420), i.e. naturally defined objects. +The decision as to what is documented as a complete item, rather than by its parts or components, may be a purely administrative decision or may be a result of the order in which the item was acquired. + + + + + + Биологический Объект + Biological Object + Βιολογικό Ακτικείμενο + Objet biologique + Biologischer Gegenstand + Objeto Biológico + This class comprises individual items of a material nature, which live, have lived or are natural products of or from living organisms. +Artificial objects that incorporate biological elements, such as Victorian butterfly frames, can be documented as both instances of E20 Biological Object and E22 Man-Made Object. + + + + + + Person + Personne + Person + Личность + Πρόσωπο + Pessoa + This class comprises real persons who live or are assumed to have lived. +Legendary figures that may have existed, such as Ulysses and King Arthur, fall into this class if the documentation refers to them as historical figures. In cases where doubt exists as to whether several persons are in fact identical, multiple instances can be created and linked to indicate their relationship. The CRM does not propose a specific form to support reasoning about possible identity. + + + + + + + Objet fabriqué + Ανθρωπογενές Αντικείμενο + Künstlicher Gegenstand + Рукотворный Объект + Man-Made Object + Objeto Fabricado + This class comprises physical objects purposely created by human activity. +No assumptions are made as to the extent of modification required to justify regarding an object as man-made. For example, an inscribed piece of rock or a preserved butterfly are both regarded as instances of E22 Man-Made Object. + + + + + + + Физическая Рукотворная Вещь + Physical Man-Made Thing + Ανθρωπογενές Υλικό Πράγμα + Hergestelltes + Chose matérielle fabriquée + Coisa Material Fabricada + This class comprises all persistent physical items that are purposely created by human activity. +This class comprises man-made objects, such as a swords, and man-made features, such as rock art. No assumptions are made as to the extent of modification required to justify regarding an object as man-made. For example, a “cup and ring” carving on bedrock is regarded as instance of E24 Physical Man-Made Thing. + + + + + + + Caractéristique fabriquée + Man-Made Feature + Искусственный Признак + Ανθρωπογενές Μόρφωμα + Hergestelltes Merkmal + Característica Fabricada + This class comprises physical features that are purposely created by human activity, such as scratches, artificial caves, artificial water channels, etc. +No assumptions are made as to the extent of modification required to justify regarding a feature as man-made. For example, rock art or even “cup and ring” carvings on bedrock a regarded as types of E25 Man-Made Feature. + + + + + + + Υλικό Μόρφωμα + Physical Feature + Физический Признак + Materielles Merkmal + Caractéristique matérielle + Característica Material + This class comprises identifiable features that are physically attached in an integral way to particular physical objects. +Instances of E26 Physical Feature share many of the attributes of instances of E19 Physical Object. They may have a one-, two- or three-dimensional geometric extent, but there are no natural borders that separate them completely in an objective way from the carrier objects. For example, a doorway is a feature but the door itself, being attached by hinges, is not. +Instances of E26 Physical Feature can be features in a narrower sense, such as scratches, holes, reliefs, surface colours, reflection zones in an opal crystal or a density change in a piece of wood. In the wider sense, they are portions of particular objects with partially imaginary borders, such as the core of the Earth, an area of property on the surface of the Earth, a landscape or the head of a contiguous marble statue. They can be measured and dated, and it is sometimes possible to state who or what is or was responsible for them. They cannot be separated from the carrier object, but a segment of the carrier object may be identified (or sometimes removed) carrying the complete feature. +This definition coincides with the definition of "fiat objects" (Smith & Varzi, 2000, pp.401-420), with the exception of aggregates of “bona fide objects”. + + + + + + Φυσικός Χώρος + Site + Site + Участок + Gelände + Lugar + This class comprises pieces of land or sea floor. +In contrast to the purely geometric notion of E53 Place, this class describes constellations of matter on the surface of the Earth or other celestial body, which can be represented by photographs, paintings and maps. + Instances of E27 Site are composed of relatively immobile material items and features in a particular configuration at a particular location + + + + + Objet conceptuel + Begrifflicher Gegenstand + Концептуальный Объект + Conceptual Object + Νοητικό Αντικείμενο + Objeto Conceitual + This class comprises non-material products of our minds and other human produced data that have become objects of a discourse about their identity, circumstances of creation or historical implication. The production of such information may have been supported by the use of technical devices such as cameras or computers. +Characteristically, instances of this class are created, invented or thought by someone, and then may be documented or communicated between persons. Instances of E28 Conceptual Object have the ability to exist on more than one particular carrier at the same time, such as paper, electronic signals, marks, audio media, paintings, photos, human memories, etc. +They cannot be destroyed. They exist as long as they can be found on at least one carrier or in at least one human memory. Their existence ends when the last carrier and the last memory are lost. + + + + + + Σχέδιο + Entwurf oder Verfahren + Conception ou procédure + Проект или Процедура + Design or Procedure + Projeto ou Procedimento + This class comprises documented plans for the execution of actions in order to achieve a result of a specific quality, form or contents. In particular it comprises plans for deliberate human activities that may result in the modification or production of instances of E24 Physical Thing. +Instances of E29 Design or Procedure can be structured in parts and sequences or depend on others. This is modelled using P69 is associated with. +Designs or procedures can be seen as one of the following: +1. A schema for the activities it describes +2. A schema of the products that result from their application. +3. An independent intellectual product that may have never been applied, such as Leonardo da Vinci’s famous plans for flying machines. +Because designs or procedures may never be applied or only partially executed, the CRM models a loose relationship between the plan and the respective product. + + + + + + Право + Δικαίωμα + Droit + Right + Recht + Direitos + This class comprises legal privileges concerning material and immaterial things or their derivatives. +These include reproduction and property rights + + + + + Document + Document + Dokument + Документ + Τεκμήριο + Documento + This class comprises identifiable immaterial items that make propositions about reality. +These propositions may be expressed in text, graphics, images, audiograms, videograms or by other similar means. Documentation databases are regarded as a special case of E31 Document. This class should not be confused with the term “document” in Information Technology, which is compatible with E73 Information Object. + + + + + + Referenzdokument + Официальный Документ + Document de référence + Πηγή Καθιερωμένων Όρων + Authority Document + Documento de Referência + This class comprises encyclopaedia, thesauri, authority lists and other documents that define terminology or conceptual systems for consistent use. + + + + + + Линвистический Объект + Linguistic Object + Γλωσσικό Αντικείμενο + Objet linguistique + Sprachlicher Gegenstand + Objeto Lingüístico + This class comprises identifiable expressions in natural language or languages. +Instances of E33 Linguistic Object can be expressed in many ways: e.g. as written texts, recorded speech or sign language. However, the CRM treats instances of E33 Linguistic Object independently from the medium or method by which they are expressed. Expressions in formal languages, such as computer code or mathematical formulae, are not treated as instances of E33 Linguistic Object by the CRM. These should be modelled as instances of E73 Information Object. +The text of an instance of E33 Linguistic Object can be documented in a note by P3 has note: E62 String + + + + + + Επιγραφή + Inscription + Inscription + Надпись + Inschrift + Inscrição + This class comprises recognisable, short texts attached to instances of E24 Physical Man-Made Thing. +The transcription of the text can be documented in a note by P3 has note: E62 String. The alphabet used can be documented by P2 has type: E55 Type. This class does not intend to describe the idiosyncratic characteristics of an individual physical embodiment of an inscription, but the underlying prototype. The physical embodiment is modelled in the CRM as E24 Physical Man-Made Thing. +The relationship of a physical copy of a book to the text it contains is modelled using E84 Information Carrier. P128 carries (is carried by): E33 Linguistic Object. + + + + + + + Заголовок + Titre + Titel + Title + Τίτλος + Título + This class comprises the names assigned to works, such as texts, artworks or pieces of music. +Titles are proper noun phrases or verbal phrases, and should not be confused with generic object names such as “chair”, “painting” or “book” (the latter are common nouns that stand for instances of E55 Type). Titles may be assigned by the creator of the work itself, or by a social group. +This class also comprises the translations of titles that are used as surrogates for the original titles in different social contexts. + + + + + + + Визуальный Предмет + Item visuel + Οπτικό Στοιχείο + Visual Item + Bildliches + Item Visual + This class comprises the intellectual or conceptual aspects of recognisable marks and images. +This class does not intend to describe the idiosyncratic characteristics of an individual physical embodiment of a visual item, but the underlying prototype. For example, a mark such as the ICOM logo is generally considered to be the same logo when used on any number of publications. The size, orientation and colour may change, but the logo remains uniquely identifiable. The same is true of images that are reproduced many times. This means that visual items are independent of their physical support. +The class E36 Visual Item provides a means of identifying and linking together instances of E24 Physical Man-Made Thing that carry the same visual symbols, marks or images etc. The property P62 depicts (is depicted by) between E24 Physical Man-Made Thing and depicted subjects (E1 CRM Entity) can be regarded as a short-cut of the more fully developed path from E24 Physical Man-Made Thing through P65 shows visual item (is shown by), E36 Visual Item, P138 represents (has representation) to E1CRM Entity, which in addition captures the optical features of the depiction. + + + + + + Пометка + Marque + Σήμανση + Mark + Marke + Marca + This class comprises symbols, signs, signatures or short texts applied to instances of E24 Physical Man-Made Thing by arbitrary techniques in order to indicate the creator, owner, dedications, purpose, etc. +This class specifically excludes features that have no semantic significance, such as scratches or tool marks. These should be documented as instances of E25 Man-Made Feature. + + + + + +Изображение + Εικόνα + Bild + Image + Image + Imagem + This class comprises distributions of form, tone and colour that may be found on surfaces such as photos, paintings, prints and sculptures or directly on electronic media. +The degree to which variations in the distribution of form and colour affect the identity of an instance of E38 Image depends on a given purpose. The original painting of the Mona Lisa in the Louvre may be said to bear the same instance of E38 Image as reproductions in the form of transparencies, postcards, posters or T-shirts, even though they may differ in size and carrier and may vary in tone and colour. The images in a “spot the difference” competition are not the same with respect to their context, however similar they may at first appear. + + + + + +Akteur +Агент + Agent + Δράστης + Actor + Agente + This class comprises people, either individually or in groups, who have the potential to perform intentional actions for which they can be held responsible. +The CRM does not attempt to model the inadvertent actions of such actors. Individual people should be documented as instances of E21 Person, whereas groups should be documented as instances of either E74 Group or its subclass E40 Legal Body. + + + + + + Collectivité + Juristische Person + Νομικό Πρόσωπο + Юридическое Лицо + Legal Body + Pessoa Jurídica + This class comprises institutions or groups of people that have obtained a legal recognition as a group and can act collectively as agents. +This means that they can perform actions, own property, create or destroy things and can be held collectively responsible for their actions like individual people. The term 'personne morale' is often used for this in French. + + + + + +Benennung + Обозначение + Appellation + Appellation + Ονομασία + Designação + This class comprises all sequences of signs of any nature, either meaningful or not, that are used or can be used to refer to and identify a specific instance of some class within a certain context. +Instances of E41 Appellation do not identify things by their meaning, even if they happen to have one, but by convention, tradition, or agreement. Instances of E41 Appellation are cultural constructs; as such, they have a context, a history, and a use in time and space by some group of users. A given instance of E41 Appellation can have alternative forms, i.e., other instances of E41 Appellation that are always regarded as equivalent independent from the thing it denotes. +Specific subclasses of E41 Appellation should be used when instances of E41 Appellation of a characteristic form are used for particular objects. Instances of E49 Time Appellation, for example, which take the form of instances of E50 Date, can be easily recognised. +E41 Appellation should not be confused with the act of naming something. Cf. E15 Identifier Assignment + + + + +Identificateur d'objet + Κωδικός Αναγνώρισης + Идентификатор Объекта + Kennung + Identifier + Identificador de Objeto + This class comprises strings or codes assigned to instances of E1 CRM Entity in order to identify them uniquely and permanently within the context of one or more organisations. Such codes are often known as inventory numbers, registration codes, etc. and are typically composed of alphanumeric sequences. The class E42 Identifier is not normally used for machine-generated identifiers used for automated processing unless these are also used by human agents. + + + +Обозначение Места + Place Appellation + Appellation de lieu + Ortsbenennung + Ονομασία Τόπου + Designação de Local + This class comprises any sort of identifier characteristically used to refer to an E53 Place. +Instances of E44 Place Appellation may vary in their degree of precision and their meaning may vary over time - the same instance of E44 Place Appellation may be used to refer to several places, either because of cultural shifts, or because objects used as reference points have moved around. Instances of E44 Place Appellation can be extremely varied in form: postal addresses, instances of E47 Spatial Coordinate, and parts of buildings can all be considered as instances of E44 Place Appellation. + + + + +Adresse + Adresse + Διεύθυνση + Адрес + Address + Endereço + This class comprises identifiers expressed in coding systems for places, such as postal addresses used for mailing. +An E45 Address can be considered both as the name of an E53 Place and as an E51 Contact Point for an E39 Actor. This dual aspect is reflected in the multiple inheritance. However, some forms of mailing addresses, such as a postal box, are only instances of E51 Contact Point, since they do not identify any particular Place. These should not be documented as instances of E45 Address. + + + + + +Désignation de section + Определение Района + Section Definition + Abschnittsdefinition + Ονομασία Τμήματος + Designação de Seção + This class comprises areas of objects referred to in terms specific to the general geometry or structure of its kind. +The 'prow' of the boat, the 'frame' of the picture, the 'front' of the building are all instances of E46 Section Definition. The class highlights the fact that parts of objects can be treated as locations. This holds in particular for features without natural boundaries, such as the “head” of a marble statue made out of one block (cf. E53 Place). In answer to the question 'where is the signature?' one might reply 'on the lower left corner'. (Section Definition is closely related to the term “segment” in Gerstl, P.& Pribbenow, S, 1996 “ A conceptual theory of part – whole relations and its applications”, Data & Knowledge Engineering 20 305-322, North Holland- Elsevier ). + + + + +Coordonnées spatiales + Пространственные Координаты + Χωρικές Συντεταγμένες + Raumkoordinaten + Spatial Coordinates + Coordenadas Espaciais + This class comprises the textual or numeric information required to locate specific instances of E53 Place within schemes of spatial identification. + +Coordinates are a specific form of E44 Place Appellation, that is, a means of referring to a particular E53 Place. Coordinates are not restricted to longitude, latitude and altitude. Any regular system of reference that maps onto an E19 Physical Object can be used to generate coordinates. + + + + +Название Места + Toponyme + Τοπωνύμιο + Place Name + Orts- oder Flurname + Nome de Local + This class comprises particular and common forms of E44 Place Appellation. +Place Names may change their application over time: the name of an E53 Place may change, and a name may be reused for a different E53 Place. Instances of E48 Place Name are typically subject to place name gazetteers. + + + +Обозначение Времени + Ονομασία Χρόνου + Zeitbenennung + Time Appellation + Appellation temporelle + Designação de Tempo + This class comprises all forms of names or codes, such as historical periods, and dates, which are characteristically used to refer to a specific E52 Time-Span. +The instances of E49 Time Appellation may vary in their degree of precision, and they may be relative to other time frames, “Before Christ” for example. Instances of E52 Time-Span are often defined by reference to a cultural period or an event e.g. ‘the duration of the Ming Dynasty’. + + + + Datum + Ημερομηνία + Дата + Date + Date + Data + This class comprises specific forms of E49 Time Appellation. + + + + Kontaktpunkt + Στοιχείο Επικοινωνίας + Coordonnées individuelles + Contact Point + Контакт + Ponto de Contato + This class comprises identifiers employed, or understood, by communication services to direct communications to an instance of E39 Actor. These include E-mail addresses, telephone numbers, post office boxes, Fax numbers, URLs etc. Most postal addresses can be considered both as instances of E44 Place Appellation and E51 Contact Point. In such cases the subclass E45 Address should be used. +URLs are addresses used by machines to access another machine through an http request. Since the accessed machine acts on behalf of the E39 Actor providing the machine, URLs are considered as instances of E51 Contact Point to that E39 Actor. + + + + + Durée + Zeitspanne + Интервал Времени + Χρονικό Διάστημα + Time-Span + Período de Tempo + This class comprises abstract temporal extents, in the sense of Galilean physics, having a beginning, an end and a duration. +Time Span has no other semantic connotations. Time-Spans are used to define the temporal extent of instances of E4 Period, E5 Event and any other phenomena valid for a certain time. An E52 Time-Span may be identified by one or more instances of E49 Time Appellation. +Since our knowledge of history is imperfect, instances of E52 Time-Span can best be considered as approximations of the actual Time-Spans of temporal entities. The properties of E52 Time-Span are intended to allow these approximations to be expressed precisely. An extreme case of approximation, might, for example, define an E52 Time-Span having unknown beginning, end and duration. Used as a common E52 Time-Span for two events, it would nevertheless define them as being simultaneous, even if nothing else was known. + Automatic processing and querying of instances of E52 Time-Span is facilitated if data can be parsed into an E61 Time Primitive. + + + + +Lieu + Place + Τόπος + Место + Ort + Local + This class comprises extents in space, in particular on the surface of the earth, in the pure sense of physics: independent from temporal phenomena and matter. +The instances of E53 Place are usually determined by reference to the position of “immobile” objects such as buildings, cities, mountains, rivers, or dedicated geodetic marks. A Place can be determined by combining a frame of reference and a location with respect to this frame. It may be identified by one or more instances of E44 Place Appellation. + It is sometimes argued that instances of E53 Place are best identified by global coordinates or absolute reference systems. However, relative references are often more relevant in the context of cultural documentation and tend to be more precise. In particular, we are often interested in position in relation to large, mobile objects, such as ships. For example, the Place at which Nelson died is known with reference to a large mobile object – H.M.S Victory. A resolution of this Place in terms of absolute coordinates would require knowledge of the movements of the vessel and the precise time of death, either of which may be revised, and the result would lack historical and cultural relevance. +Any object can serve as a frame of reference for E53 Place determination. The model foresees the notion of a "section" of an E19 Physical Object as a valid E53 Place determination. + + + +Dimension + Dimensions + Μέγεθος + Величина + Maß + Dimensão + This class comprises quantifiable properties that can be measured by some calibrated means and can be approximated by values, i.e. points or regions in a mathematical or conceptual space, such as natural or real numbers, RGB values etc. +An instance of E54 Dimension represents the true quantity, independent from its numerical approximation, e.g. in inches or in cm. The properties of the class E54 Dimension allow for expressing the numerical approximation of the values of an instance of E54 Dimension. If the true values belong to a non-discrete space, such as spatial distances, it is recommended to record them as approximations by intervals or regions of indeterminacy enclosing the assumed true values. For instance, a length of 5 cm may be recorded as 4.5-5.5 cm, according to the precision of the respective observation. Note, that interoperability of values described in different units depends critically on the representation as value regions. +Numerical approximations in archaic instances of E58 Measurement Unit used in historical records should be preserved. Equivalents corresponding to current knowledge should be recorded as additional instances of E54 Dimension as appropriate. + + + + +Τύπος + Type + Type + Тип + Typus + Tipo + This class comprises concepts denoted by terms from thesauri and controlled vocabularies used to characterize and classify instances of CRM classes. Instances of E55 Type represent concepts in contrast to instances of E41 Appellation which are used to name instances of CRM classes. +E55 Type is the CRM’s interface to domain specific ontologies and thesauri. These can be represented in the CRM as subclasses of E55 Type, forming hierarchies of terms, i.e. instances of E55 Type linked via P127 has broader term (has narrower term). Such hierarchies may be extended with additional properties. + + + + +Langue + Язык + Language + Γλώσσα + Sprache + Língua + This class is a specialization of E55 Type and comprises the natural languages in the sense of concepts. +This type is used categorically in the model without reference to instances of it, i.e. the Model does not foresee the description of instances of instances of E56 Language, e.g.: “instances of Mandarin Chinese”. +It is recommended that internationally or nationally agreed codes and terminology are used to denote instances of E56 Language, such as those defined in ISO 639:1988. + + + + + Matériau + Υλικό + Материал + Material + Material + Material + This class is a specialization of E55 Type and comprises the concepts of materials. +Instances of E57 Material may denote properties of matter before its use, during its use, and as incorporated in an object, such as ultramarine powder, tempera paste, reinforced concrete. Discrete pieces of raw-materials kept in museums, such as bricks, sheets of fabric, pieces of metal, should be modelled individually in the same way as other objects. Discrete used or processed pieces, such as the stones from Nefer Titi's temple, should be modelled as parts (cf. P46 is composed of). +This type is used categorically in the model without reference to instances of it, i.e. the Model does not foresee the description of instances of instances of E57 Material, e.g.: “instances of gold”. +It is recommended that internationally or nationally agreed codes and terminology are used. + + + + Unité de mesure + Measurement Unit + Μονάδα Μέτρησης + Maßeinheit + Единица Измерения + Unidade de Medida + This class is a specialization of E55 Type and comprises the types of measurement units: feet, inches, centimetres, litres, lumens, etc. +This type is used categorically in the model without reference to instances of it, i.e. the Model does not foresee the description of instances of instances of E58 Measurement Unit, e.g.: “instances of cm”. +Syst?me International (SI) units or internationally recognized non-SI terms should be used whenever possible. (ISO 1000:1992). Archaic Measurement Units used in historical records should be preserved. + + + + + Début d'existence + Beginning of Existence + Daseinsbeginn + Αρχή Ύπαρξης + Начало Существования + Início da Existência + This class comprises events that bring into existence any E77 Persistent Item. +It may be used for temporal reasoning about things (intellectual products, physical items, groups of people, living beings) beginning to exist; it serves as a hook for determination of a terminus post quem and ante quem. + + + + Daseinsende + Конец Существования + Τέλος Ύπαρξης + Fin d'existence + End of Existence + Fim da Existência + This class comprises events that end the existence of any E77 Persistent Item. +It may be used for temporal reasoning about things (physical items, groups of people, living beings) ceasing to exist; it serves as a hook for determination of a terminus postquem and antequem. In cases where substance from a Persistent Item continues to exist in a new form, the process would be documented by E81 Transformation. + + + + + Δημιουργία + Событие Творения + Création + Begriffliche Schöpfung + Creation + Criação + This class comprises events that result in the creation of conceptual items or immaterial products, such as legends, poems, texts, music, images, movies, laws, types etc. + + + + + + Formation + Событие Формирования + Formation + Gruppenbildung + Συγκρότηση Ομάδας + Formação + This class comprises events that result in the formation of a formal or informal E74 Group of people, such as a club, society, association, corporation or nation. +E66 Formation does not include the arbitrary aggregation of people who do not act as a collective. +The formation of an instance of E74 Group does not mean that the group is populated with members at the time of formation. In order to express the joining of members at the time of formation, the respective activity should be simultaneously an instance of both E66 Formation and E85 Joining. + + + + + + Birth + Рождение + Naissance + Geburt + Γέννηση + Nascimento + This class comprises the births of human beings. E67 Birth is a biological event focussing on the context of people coming into life. (E63 Beginning of Existence comprises the coming into life of any living beings). +Twins, triplets etc. are brought into life by the same E67 Birth event. The introduction of the E67 Birth event as a documentation element allows the description of a range of family relationships in a simple model. Suitable extensions may describe more details and the complexity of motherhood with the intervention of modern medicine. In this model, the biological father is not seen as a necessary participant in the E67 Birth event. + + + + + Роспуск + Gruppenauflösung + Διάλυση Ομάδας + Dissolution + Dissolution + Dissolução + This class comprises the events that result in the formal or informal termination of an E74 Group of people. +If the dissolution was deliberate, the Dissolution event should also be instantiated as an E7 Activity. + + + + + Смерть + Death + Tod + Mort + Θάνατος + Morte + This class comprises the deaths of human beings. +If a person is killed, their death should be instantiated as E69 Death and as E7 Activity. The death or perishing of other living beings should be documented using E64 End of Existence. + + + + + + Chose + Thing + Πράγμα + Sache + Coisa + This general class comprises usable discrete, identifiable, instances of E77 Persistent Item that are documented as single units. + +They can be either intellectual products or physical things, and are characterized by relative stability. They may for instance either have a solid physical form, an electronic encoding, or they may be logical concept or structure. + + + + +Künstliches + Chose fabriquée + Рукотворная Вещь + Man-Made Thing + Ανθρώπινο Δημιούργημα + Coisa Fabricada + This class comprises discrete, identifiable man-made items that are documented as single units. +These items are either intellectual products or man-made physical things, and are characterized by relative stability. They may for instance have a solid physical form, an electronic encoding, or they may be logical concepts or structures. + + + + +Objet juridique + Объект Права + Νομικό Αντικείμενο + Legal Object + Rechtsobjekt + Objeto Jurídico + This class comprises those material or immaterial items to which instances of E30 Right, such as the right of ownership or use, can be applied. +This is true for all E18 Physical Thing. In the case of instances of E28 Conceptual Object, however, the identity of the E28 Conceptual Object or the method of its use may be too ambiguous to reliably establish instances of E30 Right, as in the case of taxa and inspirations. Ownership of corporations is currently regarded as out of scope of the CRM. + + + + + Informationsgegenstand + Information Object + Πληροφοριακό Αντικείμενο + Objet d'information + Информационный Объект + Objeto de Informação + This class comprises identifiable immaterial items, such as a poems, jokes, data sets, images, texts, multimedia objects, procedural prescriptions, computer program code, algorithm or mathematical formulae, that have an objectively recognizable structure and are documented as single units. +An E73 Information Object does not depend on a specific physical carrier, which can include human memory, and it can exist on one or more carriers simultaneously. +Instances of E73 Information Object of a linguistic nature should be declared as instances of the E33 Linguistic Object subclass. Instances of E73 Information Object of a documentary nature should be declared as instances of the E31 Document subclass. Conceptual items such as types and classes are not instances of E73 Information Object, nor are ideas without a reproducible expression. + + + + + +Группа + Group + Ομάδα + Menschliche Gruppe + Groupe + Grupo + This class comprises any gatherings or organizations of two or more people that act collectively or in a similar way due to any form of unifying relationship. In the wider sense this class also comprises official positions which used to be regarded in certain contexts as one actor, independent of the current holder of the office, such as the president of a country. +A gathering of people becomes an E74 Group when it exhibits organizational characteristics usually typified by a set of ideas or beliefs held in common, or actions performed together. These might be communication, creating some common artifact, a common purpose such as study, worship, business, sports, etc. Nationality can be modeled as membership in an E74 Group (cf. HumanML markup). Married couples and other concepts of family are regarded as particular examples of E74 Group. + + + + + Appellation d'objet conceptuel + Обозначение Концептуального Объекта + Begriff- oder Konzeptbenennung + Conceptual Object Appellation + Ονομασία Νοητικού Αντικειμένου + Designação de Objeto Conceitual + This class comprises all appellations specific to intellectual products or standardized patterns. + + + + Persistent Item + Постоянная Сущность + Seiendes + Ον + Entité persistante + Entidade Persistente + This class comprises items that have a persistent identity, sometimes known as “endurants” in philosophy. +They can be repeatedly recognized within the duration of their existence by identity criteria rather than by continuity or observation. Persistent Items can be either physical entities, such as people, animals or things, or conceptual entities such as ideas, concepts, products of the imagination or common names. +The criteria that determine the identity of an item are often difficult to establish -; the decision depends largely on the judgement of the observer. For example, a building is regarded as no longer existing if it is dismantled and the materials reused in a different configuration. On the other hand, human beings go through radical and profound changes during their life-span, affecting both material composition and form, yet preserve their identity by other criteria. Similarly, inanimate objects may be subject to exchange of parts and matter. The class E77 Persistent Item does not take any position about the nature of the applicable identity criteria and if actual knowledge about identity of an instance of this class exists. There may be cases, where the identity of an E77 Persistent Item is not decidable by a certain state of knowledge. +The main classes of objects that fall outside the scope the E77 Persistent Item class are temporal objects such as periods, events and acts, and descriptive properties. + + + + Коллекция + Συλλογή + Collection + Collection + Sammlung + Coleção + This class comprises aggregations of instances of E18 Physical Thing that are assembled and maintained (“curated” and “preserved,” in museological terminology) by one or more instances of E39 Actor over time for a specific purpose and audience, and according to a particular collection development plan. +Items may be added or removed from an E78 Collection in pursuit of this plan. This class should not be confused with the E39 Actor maintaining the E78 Collection often referred to with the name of the E78 Collection (e.g. “The Wallace Collection decided…”). +Collective objects in the general sense, like a tomb full of gifts, a folder with stamps or a set of chessmen, should be documented as instances of E19 Physical Object, and not as instances of E78 Collection. This is because they form wholes either because they are physically bound together or because they are kept together for their functionality. + + + + + Addition d'élément + Part Addition + Teilhinzufügung + Добавление Части + Προσθήκη Μερών + Adição de Parte + This class comprises activities that result in an instance of E24 Physical Man-Made Thing being increased, enlarged or augmented by the addition of a part. +Typical scenarios include the attachment of an accessory, the integration of a component, the addition of an element to an aggregate object, or the accessioning of an object into a curated E78 Collection. Objects to which parts are added are, by definition, man-made, since the addition of a part implies a human activity. Following the addition of parts, the resulting man-made assemblages are treated objectively as single identifiable wholes, made up of constituent or component parts bound together either physically (for example the engine becoming a part of the car), or by sharing a common purpose (such as the 32 chess pieces that make up a chess set). This class of activities forms a basis for reasoning about the history and continuity of identity of objects that are integrated into other objects over time, such as precious gemstones being repeatedly incorporated into different items of jewellery, or cultural artifacts being added to different museum instances of E78 Collection over their lifespan. + + + + + Teilentfernung + Soustraction d'élément + Part Removal + Удаление Части + Αφαίρεση Μερών + Remoção de Parte + This class comprises the activities that result in an instance of E18 Physical Thing being decreased by the removal of a part. +Typical scenarios include the detachment of an accessory, the removal of a component or part of a composite object, or the deaccessioning of an object from a curated E78 Collection. If the E80 Part Removal results in the total decomposition of the original object into pieces, such that the whole ceases to exist, the activity should instead be modelled as an E81 Transformation, i.e. a simultaneous destruction and production. In cases where the part removed has no discernible identity prior to its removal but does have an identity subsequent to its removal, the activity should be regarded as both E80 Part Removal and E12 Production. This class of activities forms a basis for reasoning about the history, and continuity of identity over time, of objects that are removed from other objects, such as precious gemstones being extracted from different items of jewelry, or cultural artifacts being deaccessioned from different museum collections over their lifespan. + + + + +Трансформация + Transformation + Transformation + Umwandlung + Μετατροπή + Transformação + This class comprises the events that result in the simultaneous destruction of one or more than one E77 Persistent Item and the creation of one or more than one E77 Persistent Item that preserves recognizable substance from the first one(s) but has fundamentally different nature and identity. +Although the old and the new instances of E77 Persistent Item are treated as discrete entities having separate, unique identities, they are causally connected through the E81 Transformation; the destruction of the old E77 Persistent Item(s) directly causes the creation of the new one(s) using or preserving some relevant substance. Instances of E81 Transformation are therefore distinct from re-classifications (documented using E17 Type Assignment) or modifications (documented using E11 Modification) of objects that do not fundamentally change their nature or identity. Characteristic cases are reconstructions and repurposing of historical buildings or ruins, fires leaving buildings in ruins, taxidermy of specimen in natural history and the reorganization of a corporate body into a new one. + + + + + + Actor Appellation + Обозначение Агента + Ονομασία Δράστη + Appellation d'agent + Akteurbenennung + Designação de Agente + This class comprises any sort of name, number, code or symbol characteristically used to identify an E39 Actor. +An E39 Actor will typically have more than one E82 Actor Appellation, and instances of E82 Actor Appellation in turn may have alternative representations. The distinction between corporate and personal names, which is particularly important in library applications, should be made by explicitly linking the E82 Actor Appellation to an instance of either E21 Person or E74 Group/E40 Legal Body. If this is not possible, the distinction can be made through the use of the P2 has type mechanism. + + + + +Typuserfindung + Создание Типа + Type Creation + Création de type + Δημιουργία Τύπου + Criação de Tipo + This class comprises activities formally defining new types of items. +It is typically a rigorous scholarly or scientific process that ensures a type is exhaustively described and appropriately named. In some cases, particularly in archaeology and the life sciences, E83 Type Creation requires the identification of an exemplary specimen and the publication of the type definition in an appropriate scholarly forum. The activity of E83 Type Creation is central to research in the life sciences, where a type would be referred to as a “taxon,” the type description as a “protologue,” and the exemplary specimens as “orgininal element” or “holotype”. + + + + +Φορέας Πληροφορίας + Information Carrier + Носитель Информации + Support d'information + Informationsträger + Suporte de Informação + This class comprises all instances of E22 Man-Made Object that are explicitly designed to act as persistent physical carriers for instances of E73 Information Object. +This allows a relationship to be asserted between an E19 Physical Object and its immaterial information contents. An E84 Information Carrier may or may not contain information, e.g., a diskette. Note that any E18 Physical Thing may carry information, such as an E34 Inscription. However, unless it was specifically designed for this purpose, it is not an Information Carrier. Therefore the property P128 carries (is carried by) applies to E18 Physical Thing in general. + + + + Beitritt + Joining + This class comprises the activities that result in an instance of E39 Actor becoming a member of an instance of E74 Group. This class does not imply initiative by either party. +Typical scenarios include becoming a member of a social organisation, becoming employee of a company, marriage, the adoption of a child by a family and the inauguration of somebody into an official position. + + + + + + Austritt + Leaving + This class comprises the activities that result in an instance of E39 Actor to be disassociated from an instance of E74 Group. This class does not imply initiative by either party. +Typical scenarios include the termination of membership in a social organisation, ending the employment at a company, divorce, and the end of tenure of somebody in an official position. + + + + Kuratorische Tätigkeit + Curation Activity + This class comprises the activities that result in the continuity of management and the preservation and evolution of instances of E78 Collection, following an implicit or explicit curation plan. +It specializes the notion of activity into the curation of a collection and allows the history of curation to be recorded. +Items are accumulated and organized following criteria like subject, chronological period, material type, style of art etc. and can be added or removed from an E78 Collection for a specific purpose and/or audience. The initial aggregation of items of a collection is regarded as an instance of E12 Production Event while the activity of evolving, preserving and promoting a collection is regarded as an instance of E87 Curation Activity. + + + + + + Aussagenobjekt + Propositional Object + This class comprises immaterial items, including but not limited to stories, plots, procedural prescriptions, algorithms, laws of physics or images that are, or represent in some sense, sets of propositions about real or imaginary things and that are documented as single units or serve as topics of discourse. + +This class also comprises items that are “about” something in the sense of a subject. In the wider sense, this class includes expressions of psychological value such as non-figural art and musical themes. However, conceptual items such as types and classes are not instances of E89 Propositional Object. This should not be confused with the definition of a type, which is indeed an instance of E89 Propositional Object. + + + + + Symbolisches Objekt + Symbolic Object + This class comprises identifiable symbols and any aggregation of symbols, such as characters, identifiers, traffic signs, emblems, texts, data sets, images, musical scores, multimedia objects, computer program code or mathematical formulae that have an objectively recognizable structure and that are documented as single units. +It includes sets of signs of any nature, which may serve to designate something, or to communicate some propositional content. +An instance of E90 Symbolic Object does not depend on a specific physical carrier, which can include human memory, and it can exist on one or more carriers simultaneously. An instance of E90 Symbolic Object may or may not have a specific meaning, for example an arbitrary character string. + + + + + + + αναγνωρίζεται ως + wird bezeichnet als + is identified by + идентифицируется посредством + est identifiée par + é identificado por +This property describes the naming or identification of any real world item by a name or any other identifier. +This property is intended for identifiers in general use, which form part of the world the model intends to describe, and not merely for internal database identifiers which are specific to a technical system, unless these latter also have a more general use outside the technical context. This property includes in particular identification by mathematical expressions such as coordinate systems used for the identification of instances of E53 Place. The property does not reveal anything about when, where and by whom this identifier was used. A more detailed representation can be made using the fully developed (i.e. indirect) path through E15 Identifier Assignment. + + + + + + + bezeichnet + идентифицирует + identifie + είναι αναγνωριστικό + identifies + identifica + + + + + + hat den Typus + has type + έχει τύπο + est de type + имеет тип + é do tipo +This property allows sub typing of CRM entities - a form of specialisation – through the use of a terminological hierarchy, or thesaurus. +The CRM is intended to focus on the high-level entities and relationships needed to describe data structures. Consequently, it does not specialise entities any further than is required for this immediate purpose. However, entities in the isA hierarchy of the CRM may by specialised into any number of sub entities, which can be defined in the E55 Type hierarchy. E51 Contact Point, for example, may be specialised into “e-mail address”, “telephone number”, “post office box”, “URL” etc. none of which figures explicitly in the CRM hierarchy. Sub typing obviously requires consistency between the meaning of the terms assigned and the more general intent of the CRM entity in question. + + + + + + +является типом для + est le type de + είναι ο τύπος του/της + ist Typus von + is type of + é o tipo de + + + + + + hat Anmerkung + имеет примечание + has note + a pour note + έχει επεξήγηση + tem nota +This property is a container for all informal descriptions about an object that have not been expressed in terms of CRM constructs. +In particular it captures the characterisation of the item itself, its internal structures, appearance etc. +Like property P2 has type (is type of), this property is a consequence of the restricted focus of the CRM. The aim is not to capture, in a structured form, everything that can be said about an item; indeed, the CRM formalism is not regarded as sufficient to express everything that can be said. Good practice requires use of distinct note fields for different aspects of a characterisation. The P3.1 has type property of P3 has note allows differentiation of specific notes, e.g. “construction”, “decoration” etc. +An item may have many notes, but a note is attached to a specific item. + + + + + + +a pour durée + has time-span + hat Zeitspanne + βρισκόταν σε εξέλιξη + имеет временной отрезок + tem período de tempo +This property describes the temporal confinement of an instance of an E2 Temporal Entity. +The related E52 Time-Span is understood as the real Time-Span during which the phenomena were active, which make up the temporal entity instance. It does not convey any other meaning than a positioning on the “time-line” of chronology. The Time-Span in turn is approximated by a set of dates (E61 Time Primitive). A temporal entity can have in reality only one Time-Span, but there may exist alternative opinions about it, which we would express by assigning multiple Time-Spans. Related temporal entities may share a Time-Span. Time-Spans may have completely unknown dates but other descriptions by which we can infer knowledge. + + + + + + + is time-span of + είναι χρονικό διάστημα του/της + est la durée de + является временным отрезком для + ist Zeitspanne von + é o período de tempo de + + + + + + + consists of + consiste en + αποτελείται από + besteht aus + состоит из + consiste de +This property describes the decomposition of an E3 Condition State into discrete, subsidiary states. +It is assumed that the sub-states into which the condition state is analysed form a logical whole - although the entire story may not be completely known – and that the sub-states are in fact constitutive of the general condition state. For example, a general condition state of “in ruins” may be decomposed into the individual stages of decay + + + + + + bildet Teil von + fait partie de + формирует часть + forms part of + αποτελεί μέρος του/της + faz parte de + + + + + + + a eu lieu dans + совершался на + έλαβε χώρα σε + fand statt in + took place at + ocorreu em +This property describes the spatial location of an instance of E4 Period. +The related E53 Place should be seen as an approximation of the geographical area within which the phenomena that characterise the period in question occurred. P7took place at (witnessed) does not convey any meaning other than spatial positioning (generally on the surface of the earth). For example, the period “R?volution fran?aise” can be said to have taken place in “France”, the “Victorian” period, may be said to have taken place in “Britain” and its colonies, as well as other parts of Europe and north America. +A period can take place at multiple locations. + + + + + + + a été témoin de + witnessed + bezeugte + был местом совершения + υπήρξε τόπος του + testemunhou + + + + + + + имел место на или в + έλαβε χώρα σε ή εντός + fand statt auf oder innerhalb von + took place on or within + a eu lieu sur ou dans + ocorreu em ou dentro +This property describes the location of an instance of E4 Period with respect to an E19 Physical Object. +P8 took place on or within (witnessed) is a short-cut of a path defining a E53 Place with respect to the geometry of an object. cf. E46 Section Definition. +This property is in effect a special case of P7 took place at. It describes a period that can be located with respect to the space defined by an E19 Physical Object such as a ship or a building. The precise geographical location of the object during the period in question may be unknown or unimportant. +For example, the French and German armistice of 22 June 1940 was signed in the same railway carriage as the armistice of 11 November 1918. + + + + + + + являлся местом для + bezeugte + witnessed + a été témoin de + υπήρξε τόπος του + testemunhou + + + + + + + αποτελείται από + consists of + setzt sich zusammen aus + состоит из + consiste en + consiste de +This property describes the decomposition of an instance of E4 Period into discrete, subsidiary periods. +The sub-periods into which the period is decomposed form a logical whole - although the entire picture may not be completely known - and the sub-periods are constitutive of the general period. + + + + + + + αποτελεί μέρος του/της + формирует часть + bildet Teil von + fait partie de + forms part of + faz parte de + + + + + + + находится в пределах + εμπίπτει + s’insère dans le cours de + falls within + fällt in + está contido em +This property describes an instance of E4 Period, which falls within the E53 Place and E52 Time-Span of another. +The difference with P9 consists of (forms part of) is subtle. Unlike P9 consists of (forms part of), P10 falls within (contains) does not imply any logical connection between the two periods and it may refer to a period of a completely different type. + + + + + + + περιλαμβάνει + содержит + contains + contient + enthält + contém + + + + + + + a eu pour participant + имел участника + hatte Teilnehmer + had participant + είχε συμμέτοχο + tem participante +This property describes the active or passive participation of instances of E39 Actors in an E5 Event. +It connects the life-line of the related E39 Actor with the E53 Place and E50 Date of the event. The property implies that the Actor was involved in the event but does not imply any causal relationship. The subject of a portrait can be said to have participated in the creation of the portrait. + + + + + + + + συμμετείχε σε + nahm Teil an + участвовал в + participated in + a participé à + participa em + + + + + + + + occurred in the presence of + появился в присутствии + fand statt im Beisein von + συνέβη παρουσία του/της + est arrivé en présence de + ocorreu na presença de +This property describes the active or passive presence of an E77 Persistent Item in an E5 Event without implying any specific role. +It connects the history of a thing with the E53 Place and E50 Date of an event. For example, an object may be the desk, now in a museum on which a treaty was signed. The presence of an immaterial thing implies the presence of at least one of its carriers. + + + + + + +was present at + ήταν παρών/παρούσα/παρόν σε + war anwesend bei + était présent à + присутствовал при + estava presente no + + + + + + + zerstörte + a détruit + уничтожил + κατέστρεψε + destroyed + destruiu +This property allows specific instances of E18 Physical Thing that have been destroyed to be related to a destruction event. +Destruction implies the end of an item’s life as a subject of cultural documentation – the physical matter of which the item was composed may in fact continue to exist. A destruction event may be contiguous with a Production that brings into existence a derived object composed partly of matter from the destroyed object. + + + + + + + + wurde zerstört durch + was destroyed by + καταστράφηκε από + a été détruite par + был уничтожен посредством + foi destruído por + + + + + + + + wurde ausgeführt von + réalisée par + carried out by + πραγματοποιήθηκε από + выполнялся + realizada por +This property describes the active participation of an E39 Actor in an E7 Activity. +It implies causal or legal responsibility. The P14.1 in the role of property of the property allows the nature of an Actor’s participation to be specified. + + + + + + + + выполнял + πραγματοποίησε + führte aus + performed + a exécuté + executou + + + + + + + + wurde beeinflußt durch + a été influencée par + επηρεάστηκε από + находился под влиянием + was influenced by + foi influenciado por +This is a high level property, which captures the relationship between an E7 Activity and anything that may have had some bearing upon it. +The property has more specific sub properties. + + + + + + + оказал влияние на + επηρέασε + a influencé + beeinflußte + influenced + influenciou + + + + + + + a utilisé l'objet spécifique + χρησιμοποίησε αντικείμενο + used specific object + benutzte das bestimmte Objekt + использовал особый объект + usou objeto específico +This property describes the use of material or immaterial things in a way essential to the performance or the outcome of an E7 Activity. +This property typically applies to tools, instruments, moulds, raw materials and items embedded in a product. It implies that the presence of the object in question was a necessary condition for the action. For example, the activity of writing this text required the use of a computer. An immaterial thing can be used if at least one of its carriers is present. For example, the software tools on a computer. +Another example is the use of a particular name by a particular group of people over some span to identify a thing, such as a settlement. In this case, the physical carriers of this name are at least the people understanding its use. + + + + + + + + + a été utilisé pour + wurde benutzt für + был использован для + was used for + χρησιμοποιήθηκε για + foi usado por + + + + + + + + + был обусловлен посредством + wurde angeregt durch + είχε ως αφορμή + was motivated by + a été motivée par + foi motivado por + +This property describes an item or items that are regarded as a reason for carrying out the E7 Activity. +For example, the discovery of a large hoard of treasure may call for a celebration, an order from head quarters can start a military manoeuvre. + + + + + + + + ήταν αφορμή + motivated + regte an + обусловил + a motivé + motivou + + + + + + + + был предполагаемым использованием для + était l'utilisation prévue de + war beabsichtigteter Gebrauch von + ήταν προορισμένη χρήση του + was intended use of + era prevista a utilização de + +This property relates an E7 Activity with objects created specifically for use in the activity. +This is distinct from the intended use of an item in some general type of activity such as the book of common prayer which was intended for use in Church of England services (see P101 had as general use (was use of)). + + + + + + a été fabriquée pour + έγινε για + был создан для + wurde hergestellt für + was made for + foi feito para + + + + + + + hatte den bestimmten Zweck + avait pour but spécifique + είχε συγκεκριμένο σκοπό + had specific purpose + имел конкретную цель + tinha propósito específico + +This property identifies the relationship between a preparatory activity and the event it is intended to be preparation for. +This includes activities, orders and other organisational actions, taken in preparation for other activities or events. +P20 had specific purpose (was purpose of) implies that an activity succeeded in achieving its aim. If it does not succeed, such as the setting of a trap that did not catch anything, one may document the unrealized intention using P21 had general purpose (was purpose of):E55 Type and/or P33 used specific technique (was used by): E29 Design or Procedure. + + + + + + war Zweck von + был целью для + ήταν σκοπός του/της + était le but de + was purpose of + era o propósito de + + + + + + + είχε γενικό σκοπό + hatte den allgemeinen Zweck + avait pour but général + имел общую цель + had general purpose + tinha propósito geral + +This property describes an intentional relationship between an E7 Activity and some general goal or purpose. +This may involve activities intended as preparation for some type of activity or event. P21had general purpose (was purpose of) differs from P20 had specific purpose (was purpose of) in that no occurrence of an event is implied as the purpose. + + + + + + + был целью для + était le but de + ήταν σκοπός του/της + war Zweck von + was purpose of + era o propósito de + + + + + + + μετεβίβασε τον τίτλο σε + a fait passer le droit de propriété à + übertrug Besitztitel auf + transferred title to + передал право собственности + transferiu os direitos de propriedade para + +This property identifies the E39 Actor that acquires the legal ownership of an object as a result of an E8 Acquisition. +The property will typically describe an Actor purchasing or otherwise acquiring an object from another Actor. However, title may also be acquired, without any corresponding loss of title by another Actor, through legal fieldwork such as hunting, shooting or fishing. +In reality the title is either transferred to or from someone, or both. + + + + + + + + + απέκτησε τον τίτλο μέσω + acquired title through + erwarb Besitztitel durch + a acquis le droit de propriété du fait de + получил право собственности через + adquiriu os direitos de propriedade por meio da + + + + + + + + + μετεβίβασε τον τίτλο από + a fait passer le droit de propriété de + передал право собственности от + übertrug Besitztitel von + transferred title from + transferiu os direitos de propriedade de + +This property identifies the E39 Actor or Actors who relinquish legal ownership as the result of an E8 Acquisition. +The property will typically be used to describe a person donating or selling an object to a museum. In reality title is either transferred to or from someone, or both. + + + + + + + + + a perdu le droit de propriété du fait de + trat Besitztitel ab in + право собственности отдано через + surrendered title through + παρέδωσε τον τίτλο μέσω + perdeu os direitos de propriedade por meio da + + + + + + + + übertrug Besitz über + передал право собственности на + μετεβίβασε τον τίτλο του/της + a fait passer le droit de propriété sur + transferred title of + transferiu os direitos de propriedade sobre o + +This property identifies the E18 Physical Thing or things involved in an E8 Acquisition. +In reality, an acquisition must refer to at least one transferred item. + + + + + + + + сменил владельца через + changed ownership through + ging über in Besitz durch + άλλαξε ιδιοκτησία μέσω + a changé de mains du fait de + mudou de proprietário por meio de + + + + + + + moved + μετεκίνησε + переместил + a déplacé + bewegte + locomoveu + +This property identifies the E19 Physical Object that is moved during a move event. +The property implies the object’s passive participation. For example, Monet’s painting “Impression sunrise” was moved for the first Impressionist exhibition in 1874. +In reality, a move must concern at least one object. + + + + + + + + перемещен посредством + moved by + μετακινήθηκε από + a été déplacé par + wurde bewegt durch + foi locomovido por + + + + + + + + + μετακινήθηκε προς + moved to + a déplacé vers + перемещен в + bewegte bis zu + locomoveu para + +This property identifies the destination of a E9 Move. +A move will be linked to a destination, such as the move of an artefact from storage to display. A move may be linked to many terminal instances of E53 Places. In this case the move describes a distribution of a set of objects. The area of the move includes the origin, route and destination. + + + + + + + + + was destination of + war Zielort von + ήταν προορισμός του/της + был пунктом назначения для + a été la destination de + era destinação de + + + + + + + + μετακινήθηκε από + moved from + a retiré de + bewegte weg von + перемещен из + locomoveu de + This property identifies the starting E53 Place of an E9 Move. +A move will be linked to an origin, such as the move of an artefact from storage to display. A move may be linked to many origins. In this case the move describes the picking up of a set of objects. The area of the move includes the origin, route and destination. + + + + + + + + was origin of + war Ausgangsort von + был исходной точкой для + a été l'origine de + ήταν αφετηρία του/της + era origem de + + + + + + + + + changement de détenteur au détriment de + übergab Gewahrsam an + custody surrendered by + μετεβίβασε κατοχή από + опека отдана + custódia concedida por + +This property identifies the E39 Actor or Actors who surrender custody of an instance of E18 Physical Thing in an E10 Transfer of Custody activity. +The property will typically describe an Actor surrendering custody of an object when it is handed over to someone else’s care. On occasion, physical custody may be surrendered involuntarily – through accident, loss or theft. +In reality, custody is either transferred to someone or from someone, or both. + + + + + + + + surrendered custody through + опека отдана через + a cessé d’être détenteur à cause de + παρέδωσε κατοχή μέσω + wurde Gewahrsam übergeben durch + final da custódia por meio de + + + + + + + +μετεβίβασε κατοχή σε + опека получена + custody received by + changement de détenteur au profit de + übertrug Gewahrsam auf + custódia recebida por +This property identifies the E39 Actor or Actors who receive custody of an instance of E18 Physical Thing in an E10 Transfer of Custody activity. +The property will typically describe Actors receiving custody of an object when it is handed over from another Actor’s care. On occasion, physical custody may be received involuntarily or illegally – through accident, unsolicited donation, or theft. +In reality, custody is either transferred to someone or from someone, or both. + + + + + + + + παρέλαβε κατοχή μέσω + received custody through + получил опеку через + est devenu détenteur grâce à + erhielt Gewahrsam durch + início da custódia por meio de + + + + + + + + + передало опеку на + transferred custody of + changement de détenteur concernant + übertrug Gewahrsam über + μετεβίβασε κατοχή του/της/των + transferida custódia de + +This property identifies an item or items of E18 Physical Thing concerned in an E10 Transfer of Custody activity. +The property will typically describe the object that is handed over by an E39 Actor to another Actor’s custody. On occasion, physical custody may be transferred involuntarily or illegally – through accident, unsolicited donation, or theft. + + + + + + + custody transferred through + άλλαξε κατοχή μέσω + a changé de détenteur du fait de + wechselte Gewahrsam durch + опека передана через + custódia transferida por meio de + + + + + + + veränderte + a modifié + has modified + изменил + τροποποίησε + modificou + +This property identifies the E24 Physical Man-Made Thing modified in an E11 Modification. +If a modification is applied to a non-man-made object, it is regarded as an E22 Man-Made Object from that time onwards. + + + + + + + + + a été modifié par + wurde verändert durch + τροποποιήθηκε από + был изменен посредством + was modified by + foi modificada por + + + + + + + + + χρησιμοποίησε γενική τεχνική + benutzte das allgemeine Verfahren + a employé comme technique générique + использовал общую технику + used general technique + usou técnica geral + +This property identifies the technique that was employed in an act of modification. +These techniques should be drawn from an external E55 Type hierarchy of consistent terminology of general techniques such as embroidery, oil-painting, etc. Specific techniques may be further described as instances of E29 Design or Procedure. + + + + + + + + + был техникой для + ήταν τεχνική του/της + war Verfahren von + was technique of + a été la technique mise en œuvre dans + foi técnica da + + + + + + + + + χρησιμοποίησε συγκεκριμένη τεχνική + used specific technique + a employé comme technique spécifique + использовал особую технику + benutzte das bestimmte Verfahren + usou técnica específica + +This property identifies a specific instance of E29 Design or Procedure in order to carry out an instance of E7 Activity or parts of it. +The property differs from P32 used general technique (was technique of) in that P33 refers to an instance of E29 Design or Procedure, which is a concrete information object in its own right rather than simply being a term or a method known by tradition. +Typical examples would include intervention plans for conservation or the construction plans of a building. + + + + + + + + + was used by + a été employée par + был использован посредством + wurde benutzt von + χρησιμοποιήθηκε για + foi usada por + + + + + + + + + αφορούσε σε + имел дело с + betraf + concerned + a concerné + interessada + This property identifies the E18 Physical Thing that was assessed during an E14 Condition Assessment activity. +Conditions may be assessed either by direct observation or using recorded evidence. In the latter case the E18 Physical Thing does not need to be present or extant. + + + + + + + + + wurde beurteilt durch + εκτιμήθηκε από + expertisé par le biais de + was assessed by + был оценен посредством + foi avaliada por + + + + + + + + + идентифицировал + hat identifiziert + a identifié + έχει διαπιστώσει + has identified + identificou + This property identifies the E3 Condition State that was observed in an E14 Condition Assessment activity. + + + + + + + + идентифицирован посредством + wurde identifiziert durch + est identifié par + έχει διαπιστωθεί από + was identified by + foi identificado por + + + + + + + + + a attribué + απέδωσε + assigned + wies zu + назначил + atribuiu + + This property records the identifier that was assigned to an item in an Identifier Assignment activity. +The same identifier may be assigned on more than one occasion. +An Identifier might be created prior to an assignment. + + + + + + + + + wurde zugewiesen durch + αποδόθηκε ως ιδιότητα από + was assigned by + был присвоен посредством + a été attribuée par + foi atribuído por + + + + + + + + + ακύρωσε + отменил назначение + deassigned + hob Zuweisung auf von + a désattribué + retirou a atribuição do + This property records the identifier that was deassigned from an instance of E1 CRM Entity. +Deassignment of an identifier may be necessary when an item is taken out of an inventory, a new numbering system is introduced or items are merged or split up. +The same identifier may be deassigned on more than one occasion. + + + + + + + + + был отменен посредством + a été désattribué par + wurde aufgehoben durch + ακυρώθηκε από + was deassigned by + foi retirada a atribuição por + + + + + + + + + a mesuré + vermaß + μέτρησε + measured + измерил + mediu + + This property associates an instance of E16 Measurement with the instance of E1 CRM Entity to which it applied. An instance of E1 CRM Entity may be measured more than once. Material and immaterial things and processes may be measured, e.g. the number of words in a text, or the duration of an event. + + + + + + + + + wurde vermessen durch + был измерен посредством + was measured by + μετρήθηκε από + a été mesuré par + foi medida por + + + + + + + + + observed dimension + παρατήρησε + определил величину + beobachtete Dimension + a relevé comme dimension + verificou a dimensão + This property records the dimension that was observed in an E16 Measurement Event. +E54 Dimension can be any quantifiable aspect of E70 Thing. Weight, image colour depth and monetary value are dimensions in this sense. One measurement activity may determine more than one dimension of one object. +Dimensions may be determined either by direct observation or using recorded evidence. In the latter case the measured Thing does not need to be present or extant. +Even though knowledge of the value of a dimension requires measurement, the dimension may be an object of discourse prior to, or even without, any measurement being made. + + + + + + + + + наблюдался в + παρατηρήθηκε από + was observed in + wurde beobachtet in + a été relevée au cours de + foi verificada durante + + + + + + + + + классифицировал + classified + a classifié + χαρακτήρισε + klassifizierte + classificou + + This property records the item to which a type was assigned in an E17 Type Assignment activity. +Any instance of a CRM entity may be assigned a type through type assignment. Type assignment events allow a more detailed path from E1 CRM Entity through P41 classified (was classified), E17 Type Assignment, P42 assigned (was assigned by) to E55 Type for assigning types to objects compared to the shortcut offered by P2 has type (is type of). + + + + + + + + + a été classifiée par le biais de + was classified by + был классифицирован посредством + χαρακτηρίσθηκε από + wurde klassifiziert durch + foi classificada por + + + + + + + + + απέδωσε ως ιδιότητα + assigned + a attribué + назначил + wies zu + atribuiu + + This property records the type that was assigned to an entity by an E17 Type Assignment activity. +Type assignment events allow a more detailed path from E1 CRM Entity through P41 classified (was classified by), E17 Type Assignment, P42 assigned (was assigned by) to E55 Type for assigning types to objects compared to the shortcut offered by P2 has type (is type of). +For example, a fragment of an antique vessel could be assigned the type “attic red figured belly handled amphora” by expert A. The same fragment could be assigned the type “shoulder handled amphora” by expert B. +A Type may be intellectually constructed independent from assigning an instance of it. + + + + + + + + + был присвоен посредством + αποδόθηκε από + was assigned by + wurde zugewiesen durch + a été attribué par + foi atribuído por + + + + + + + + + hat Dimension + a pour dimension + имеет величину + has dimension + έχει μέγεθος + tem dimensão + This property records a E54 Dimension of some E70 Thing. +It is a shortcut of the more fully developed path from E70 Thing through P39 measured (was measured by), E16 Measurement P40 observed dimension (was observed in) to E54 Dimension. It offers no information about how and when an E54 Dimension was established, nor by whom. +An instance of E54 Dimension is specific to an instance of E70 Thing. + + + + + + + + ist Dimension von + is dimension of + является величиной для + est dimension de + είναι μέγεθος του + é dimensão de + + + + + + + + имеет условие + hat Zustand + a pour état matériel + has condition + έχει κατάσταση + tem estado material + + This property records an E3 Condition State for some E18 Physical Thing. +It is a shortcut of the more fully developed path from E18 Physical Thing through P34 concerned (was assessed by), E14 Condition Assessment P35 has identified (was identified by) to E3 Condition State. It offers no information about how and when the E3 Condition State was established, nor by whom. +An instance of Condition State is specific to an instance of Physical Thing. + + + + + + + + ist Zustand von + état matériel de + είναι κατάσταση του + является условием для + is condition of + estado material de + + + + + + + + consiste en + αποτελείται από + besteht aus + consists of + составлен из + consiste de + + This property identifies the instances of E57 Materials of which an instance of E18 Physical Thing is composed. +All physical things consist of physical materials. P45 consists of (is incorporated in) allows the different Materials to be recorded. P45 consists of (is incorporated in) refers here to observed Material as opposed to the consumed raw material. +A Material, such as a theoretical alloy, may not have any physical instances + + + + + + + ist enthalten in + είναι ενσωματωμένος/η/ο σε + is incorporated in + входит в состав + est présent dans + está presente em + + + + + + + + is composed of + est composée de + αποτελείται από + ist zusammengesetzt aus + составлен из + é composto de + + This property allows instances of E18 Physical Thing to be analysed into component elements. +Component elements, since they are themselves instances of E18 Physical Thing, may be further analysed into sub-components, thereby creating a hierarchy of part decomposition. An instance of E18 Physical Thing may be shared between multiple wholes, for example two buildings may share a common wall. +This property is intended to describe specific components that are individually documented, rather than general aspects. Overall descriptions of the structure of an instance of E18 Physical Thing are captured by the P3 has note property. +The instances of E57 Materials of which an item of E18 Physical Thing is composed should be documented using P45 consists of (is incorporated in). + + + + + + + + формирует часть + fait partie de + αποτελεί μέρος του/της + bildet Teil von + forms part of + faz parte de + + + + + + + + has preferred identifier + a pour identificateur retenu + hat bevorzugtes Kennzeichen + имеет предпочтительный идентификатор + έχει προτιμώμενο αναγνωριστικό + tem identificador preferido + + This property records the preferred E42 Identifier that was used to identify an instance of E1 CRM Entity at the time this property was recorded. +More than one preferred identifier may have been assigned to an item over time. +Use of this property requires an external mechanism for assigning temporal validity to the respective CRM instance. +P48 has preferred identifier (is preferred identifier of), is a shortcut for the path from E1 CRM Entity through P140 assigned attribute to (was attributed by), E15 Identifier Assignment, P37 assigned (was assigned by) to E42 Identifier. The fact that an identifier is a preferred one for an organisation can be better expressed in a context independent form by assigning a suitable E55 Type to the respective instance of E15 Identifier Assignment using the P2 has type property. + + + + + + + + + is preferred identifier of + является предпочтительным идентификатором для + ist bevorzugtes Kennzeichen für + είναι προτιμώμενο αναγνωριστικό + est l’identificateur retenu de + é o identificador preferido de + + + + + + + + + имеет бывшего или текущего смотрителя + είναι ή ήταν στην κατοχή του + est ou a été détenu par + hat früheren oder derzeitigen Betreuer + has former or current keeper + é ou foi guardada por + + This property identifies the E39 Actor or Actors who have or have had custody of an instance of E18 Physical Thing at some time. +The distinction with P50 has current keeper (is current keeper of) is that P49 has former or current keeper (is former or current keeper of) leaves open the question as to whether the specified keepers are current. +P49 has former or current keeper (is former or current keeper of) is a shortcut for the more detailed path from E18 Physical Thing through P30 transferred custody of (custody transferred through), E10 Transfer of Custody, P28 custody surrendered by (surrendered custody through) or P29 custody received by (received custody through) to E39 Actor. + + + + + + + + is former or current keeper of + κατέχει ή κατείχε + est ou a été détenteur de + ist früherer oder derzeitiger Betreuer von + является бывшим или текущим смотрителем для + é ou foi guardador de + + + + + + + + hat derzeitigen Betreuer + has current keeper + είναι στην κατοχή του + est actuellement détenu par + имеет текущего смотрителя + é guardada por + + This property identifies the E39 Actor or Actors who had custody of an instance of E18 Physical Thing at the time this property was recorded. +P50 has current keeper (is current keeper of) is a shortcut for the more detailed path from E18 Physical Thing through P30 transferred custody of (custody transferred through), E10 Transfer of Custody, P29 custody received by (received custody through) to E39 Actor. + + + + + + + + + является текущим смотрителем для + is current keeper of + ist derzeitiger Betreuer von + est actuel détenteur de + κατέχει + é guardador de + + + + + + + + + hat früheren oder derzeitigen Besitzer + имеет бывшего или текущего владельца + έχει ή είχε ιδιοκτήτη + est ou a été possédée par + has former or current owner + é ou foi propriedade de + + This property identifies the E39 Actor that is or has been the legal owner (i.e. title holder) of an instance of E18 Physical Thing at some time. +The distinction with P52 has current owner (is current owner of) is that P51 has former or current owner (is former or current owner of) does not indicate whether the specified owners are current. P51 has former or current owner (is former or current owner of) is a shortcut for the more detailed path from E18 Physical Thing through P24 transferred title of (changed ownership through), E8 Acquisition, P23 transferred title from (surrendered title through), or P22 transferred title to (acquired title through) to E39 Actor. + + + + + + + + является бывшим или текущим владельцем для + είναι ή ήταν ιδιοκτήτης του/της + est ou a été propriétaire de + is former or current owner of + ist früherer oder derzeitiger Besitzer von + é ou foi proprietário de + + + + + + + + has current owner + hat derzeitigen Besitzer + имеет текущего владельца + est actuellement possédée par + έχει ιδιοκτήτη + é propriedade de + + This property identifies the E21 Person, E74 Group or E40 Legal Body that was the owner of an instance of E18 Physical Thing at the time this property was recorded. +P52 has current owner (is current owner of) is a shortcut for the more detailed path from E18 Physical Thing through P24 transferred title of (changed ownership through), E8 Acquisition, P22 transferred title to (acquired title through) to E39 Actor, if and only if this acquisition event is the most recent. + + + + + + + + + + ist derzeitiger Besitzer von + est le propriétaire actuel de + is current owner of + является текущим владельцем для + είναι ιδιοκτήτης του + é proprietário de + + + + + + + + + + a ou a eu pour localisation + βρίσκεται ή βρισκόταν σε + имеет текущее или бывшее местоположение + has former or current location + hat früheren oder derzeitigen Standort + é ou foi localizada em + This property allows an instance of E53 Place to be associated as the former or current location of an instance of E18 Physical Thing. +In the case of E19 Physical Objects, the property does not allow any indication of the Time-Span during which the Physical Object was located at this Place, nor if this is the current location. +In the case of immobile objects, the Place would normally correspond to the Place of creation. +P53 has former or current location (is former or current location of) is a shortcut. A more detailed representation can make use of the fully developed (i.e. indirect) path from E19 Physical Object through P25 moved (moved by), E9 Move, P26 moved to (was destination of) or P27 moved from (was origin of) to E53 Place. + + + + + + + + является текущим или бывшим местоположением для + is former or current location of + είναι ή ήταν θέση του + ist früherer oder derzeitiger Standort von + est ou a été localisation de + é ou foi localização de + + + + + + + + a actuellement pour localisation à demeure + hat derzeitigen permanenten Standort + has current permanent location + έχει μόνιμη θέση + имеет текущее постоянное местоположение + é localizado permanentemente em + + This property records the foreseen permanent location of an instance of E19 Physical Object at the time this property was recorded. +P54 has current permanent location (is current permanent location of) is similar to P55 has current location (currently holds). However, it indicates the E53 Place currently reserved for an object, such as the permanent storage location or a permanent exhibit location. The object may be temporarily removed from the permanent location, for example when used in temporary exhibitions or loaned to another institution. The object may never actually be located at its permanent location. + + + + + + + + είναι μόνιμη θέση του/της + ist derzeitiger permanenter Standort von + est actuellement localisation à demeure de + is current permanent location of + является текущим постоянным местоположением для + é localização permanente de + + + + + + + + βρίσκεται σε + has current location + a pour localisation actuelle + в данный момент находится в + hat derzeitigen Standort + é localizado em + + This property records the location of an E19 Physical Object at the time the property was recorded. +This property is a specialisation of P53 has former or current location (is former or current location of). It indicates that the E53 Place associated with the E19 Physical Object is the current location of the object. The property does not allow any indication of how long the Object has been at the current location. +P55 has current location (currently holds) is a shortcut. A more detailed representation can make use of the fully developed (i.e. indirect) path from E19 Physical Object through P25 moved (moved by), E9 Move P26 moved to (was destination of) to E53 Place if and only if this Move is the most recent. + + + + + + + + + hält derzeitig + είναι θέση του + в данный момент содержит + est localisation actuelle de + currently holds + é localização atual de + + + + + + + + + несет признак + trägt Merkmal + présente pour caractéristique + φέρει μόρφωμα + bears feature + possui característica + This property describes a E26 Physical Feature found on a E19 Physical Object It does not specify the location of the feature on the object. +P56 bears feature (is found on) is a shortcut. A more detailed representation can make use of the fully developed (i.e. indirect) path from E19 Physical Object through P59 has section (is located on or within), E53 Place, P53 has former or current location (is former or current location of) to E26 Physical Feature. +A Physical Feature can only exist on one object. One object may bear more than one Physical Feature. An E27 Site should be considered as an E26 Physical Feature on the surface of the Earth. + + + + + + + + + βρίσκεται σε + se trouve sur + wird gefunden auf + is found on + найден на + é encontrada em + + + + + + + + + has number of parts + имеет число частей + έχει αριθμό μερών + a pour nombre de parties + hat Anzahl Teile + tem número de partes + + This property documents the E60 Number of parts of which an instance of E19 Physical Object is composed. +This may be used as a method of checking inventory counts with regard to aggregate or collective objects. What constitutes a part or component depends on the context and requirements of the documentation. Normally, the parts documented in this way would not be considered as worthy of individual attention. +For a more complete description, objects may be decomposed into their components and constituents using P46 is composed of (forms parts of) and P45 consists of (is incorporated in). This allows each element to be described individually. + + + + + + + + has section definition + hat Abschittsdefinition + имеет определение района + έχει ορισμό τμήματος + a pour désignation de section + tem designação de seção + + This property links an area (section) named by a E46 Section Definition to the instance of E18 Physical Thing upon which it is found. +The CRM handles sections as locations (instances of E53 Place) within or on E18 Physical Thing that are identified by E46 Section Definitions. Sections need not be discrete and separable components or parts of an object. +This is part of a more developed path from E18 Physical Thing through P58, E46 Section Definition, P87 is identified by (identifies) that allows a more precise definition of a location found on an object than the shortcut P59 has section (is located on or within). +A particular instance of a Section Definition only applies to one instance of Physical Thing. + + + + + + + определяет район + defines section + definiert Abschitt auf oder von + définit une section de + ορίζει τμήμα σε + define uma seção de + + + + + + + + has section + έχει τομέα + hat Bereich + имеет район + a pour section + tem seção + This property links an area to the instance of E18 Physical Thing upon which it is found. +It is typically used when a named E46 Section Definition is not appropriate. +E18 Physical Thing may be subdivided into arbitrary regions. +P59 has section (is located on or within) is a shortcut. If the E53 Place is identified by a Section Definition, a more detailed representation can make use of the fully developed (i.e. indirect) path from E18 Physical Thing through P58 has section definition (defines section), E46 Section Definition, P87 is identified by (identifies) to E53 Place. A Place can only be located on or within one Physical Object. + + + + + + + + находится на или внутри + befindet sich auf oder in + βρίσκεται σε ή εντός + se situe sur ou dans + is located on or within + está localizada sobre ou dentro de + + + + + + + + bildet ab + описывает + depicts + απεικονίζει + figure + retrata + + This property identifies something that is depicted by an instance of E24 Physical Man-Made Thing. +This property is a shortcut of the more fully developed path from E24 Physical Man-Made Thing through P65 shows visual item (is shown by), E36 Visual Item, P138 represents (has representation) to E1CRM Entity. P62.1 mode of depiction allows the nature of the depiction to be refined. + + + + + + + + απεικονίζεται σε + wird abgebildet durch + is depicted by + описан посредством + est figurée sur + é retratada por + + + + + + + + présente l'item visuel + shows visual item + zeigt Bildliches + показывает визуальный предмет + εμφανίζει οπτικό στοιχείο + apresenta item visual + + This property documents an E36 Visual Item shown by an instance of E24 Physical Man-Made Thing. +This property is similar to P62 depicts (is depicted by) in that it associates an item of E24 Physical Man-Made Thing with a visual representation. However, P65 shows visual item (is shown by) differs from the P62 depicts (is depicted by) property in that it makes no claims about what the E36 Visual Item is deemed to represent. E36 Visual Item identifies a recognisable image or visual symbol, regardless of what this image may or may not represent. +For example, all recent British coins bear a portrait of Queen Elizabeth II, a fact that is correctly documented using P62 depicts (is depicted by). Different portraits have been used at different periods, however. P65 shows visual item (is shown by) can be used to refer to a particular portrait. +P65 shows visual item (is shown by) may also be used for Visual Items such as signs, marks and symbols, for example the 'Maltese Cross' or the 'copyright symbol’ that have no particular representational content. +This property is part of the fully developed path from E24 Physical Man-Made Thing through P65 shows visual item (is shown by), E36 Visual Item, P138 represents (has representation) to E1 CRM Entity which is shortcut by, P62 depicts (is depicted by). + + + + + + + + + wird gezeigt durch + est présenté par + is shown by + εμφανίζεται σε + показан посредством + é apresentado por + + + + + + + + + αναφέρεται σε + refers to + ссылается на + fait référence à + verweist auf + referencia + + This property documents that an E89 Propositional Object makes a statement about an instance of E1 CRM Entity. P67 refers to (is referred to by) has the P67.1 has type link to an instance of E55 Type. This is intended to allow a more detailed description of the type of reference. This differs from P129 is about (is subject of), which describes the primary subject or subjects of the E89 Propositional Object. + + + + + + + + est référencé par + αναφέρεται από + wird angeführt von + is referred to by + имеет ссылку на себя от + é referenciado por + + + + + + + + foresees use of + sieht den Gebrauch vor von + обычно применяет + utilise habituellement + συνήθως χρησιμοποιεί + normalmente emprega + + This property identifies an E57 Material foreseeen to be used by an E29 Design or Procedure. +E29 Designs and procedures commonly foresee the use of particular E57 Materials. The fabrication of adobe bricks, for example, requires straw, clay and water. This property enables this to be documented. +This property is not intended for the documentation of E57 Materials that were used on a particular occasion when an instance of E29 Design or Procedure was executed. + + + + + + + + + συνήθως χρησιμοποιείται από + vorgesehen für Gebrauch durch defined + est habituellement utilisé par + обычно используется посредством + use foreseen by + é empregado por + + + + + + + + + est associée à + σχετίζεται με + ассоциирован с + ist verbunden mit + is associated with + é associado com + + This symmetric property describes the association of an E29 Design or Procedure with other Designs or Procedures. +Any instance of E29 Design or Procedure may be associated with other designs or procedures. The P69.1 has type property of P69 is associated with allows the nature of the association to be specified; examples of types of association between instances of E29 Design or Procedure include: whole-part, sequence, prerequisite, etc. + + + + + + + + mentionne + документирует + τεκμηριώνει + documents + belegt + documenta + + This property describes the CRM Entities documented by instances of E31 Document. +Documents may describe any conceivable entity, hence the link to the highest-level entity in the CRM hierarchy. This property is intended for cases where a reference is regarded as being of a documentary character, in the scholarly or scientific sense. + + + + + + + + + is documented in + τεκμηριώνεται σε + wird belegt in + est mentionnée dans + документирован в + é documentado em + + + + + + + + + listet + перечисляет + lists + περιλαμβάνει + définit + define + + This property documents a source E32 Authority Document for an instance of an E1 CRM Entity. + + + + + + + + + περιλαμβάνεται σε + wird aufgelistet in + is listed in + перечислен в + est défini par + é definido por + + + + + + + + + est en langue + имеет язык + has language + hat Sprache + έχει γλώσσα + é da língua + + This property describes the E56 Language of an E33 Linguistic Object. +Linguistic Objects are composed in one or more human Languages. This property allows these languages to be documented. + + + + + + + + ist Sprache von + είναι γλώσσα του/της + est la langue de + является языком для + is language of + é a língua de + + + + + + + + έχει μετάφραση + hat Übersetzung + имеет перевод + has translation + a pour traduction + tem tradução + + This property describes the source and target of instances of E33Linguistic Object involved in a translation. +When a Linguistic Object is translated into a new language it becomes a new Linguistic Object, despite being conceptually similar to the source object. + + + + + + + + est la traduction de + является переводом + είναι μετάφραση του/της + ist Übersetzung von + is translation of + é tradução de + + + + + + + + имеет текущее или бывшее местожительства + has current or former residence + hat derzeitigen oder früheren Sitz + έχει ή είχε κατοικία + réside ou a résidé à + reside ou residiu em + + This property describes the current or former E53 Place of residence of an E39 Actor. +The residence may be either the Place where the Actor resides, or a legally registered address of any kind. + + + + + + + είναι ή ήταν κατοικία του/της + ist derzeitiger oder früherer Sitz von + est ou a été la résidence de + является текущим или бывшим местом жительства для + is current or former residence of + é ou foi residência de + + + + + + + владеет + κατέχει + besitzt + est détenteur de + possesses + é detentor de + +This property identifies former or current instances of E30 Rights held by an E39 Actor. + + + + + + κατέχεται από + принадлежит + sind im Besitz von + est détenu par + is possessed by + são detidos por + + + + + + + has contact point + имеет контакт + a pour coordonnées individuelles + έχει σημείο επικοινωνίας + hat Kontaktpunkt + possui ponto de contato + +This property identifies an E51 Contact Point of any type that provides access to an E39 Actor by any communication method, such as e-mail or fax. + + + + + + + permettent de contacter + bietet Zugang zu + provides access to + παρέχει πρόσβαση σε + предоставляет доступ к + é ponto de contado de + + + + + + + αναγνωρίζεται ως + est identifiée par + is identified by + идентифицируется посредством + wird bezeichnet als + é identificado por + + This property identifies an E52 Time-Span using an E49Time Appellation. + + + + + + + identifies + bezeichnet + identifie + είναι αναγνωριστικό + идентифицирует + identifica + + + + + + + + αρχή προσδιορίζεται από + начало ограничено + hat Anfangsbegründung + beginning is qualified by + début est qualifié par + início é qualificado por + + This property qualifies the beginning of an E52 Time-Span in some way. +The nature of the qualification may be certainty, precision, source etc. + + + + + + + + τέλος προσδιορίζεται από + fin est qualifiée par + hat Begründung des Endes + конец ограничен + end is qualified by + final é qualificado por + + This property qualifies the end of an E52 Time-Span in some way. +The nature of the qualification may be certainty, precision, source etc. + + + + + + + + ongoing throughout + καθόλη τη διάρκεια του/της + andauernd während + couvre au moins + длится в течение + abrange no mínimo + + This property describes the minimum period of time covered by an E52 Time-Span. +Since Time-Spans may not have precisely known temporal extents, the CRM supports statements about the minimum and maximum temporal extents of Time-Spans. This property allows a Time-Span’s minimum temporal extent (i.e. its inner boundary) to be assigned an E61 Time Primitive value. Time Primitives are treated by the CRM as application or system specific date intervals, and are not further analysed. + + + + + + + κάποτε εντός + некоторое время в течение + irgendwann innerhalb von + couvre au plus + at some time within + abrange no máximo + This property describes the maximum period of time within which an E52 Time-Span falls. +Since Time-Spans may not have precisely known temporal extents, the CRM supports statements about the minimum and maximum temporal extents of Time-Spans. This property allows a Time-Span’s maximum temporal extent (i.e. its outer boundary) to be assigned an E61 Time Primitive value. Time Primitives are treated by the CRM as application or system specific date intervals, and are not further analysed. + + + + + + + a duré au moins + είχε ελάχιστη διάρκεια + hatte Mindestdauer + had at least duration + имеет длительность по крайней мере больше чем + durou no mínimo + +This property describes the minimum length of time covered by an E52 Time-Span. +It allows an E52 Time-Span to be associated with an E54 Dimension representing it’s minimum duration (i.e. it’s inner boundary) independent from the actual beginning and end. + + + + + + + είναι ελάχιστη διάρκεια του/της + a été la durée minimum de + был минимальной длительностью для + was minimum duration of + war Mindestdauer von + foi a duração mínima de + + + + + + + είχε μέγιστη διάρκεια + had at most duration + hatte Höchstdauer + имеет длительность меньше чем + a duré au plus + durou no máximo + +This property describes the maximum length of time covered by an E52 Time-Span. +It allows an E52 Time-Span to be associated with an E54 Dimension representing it’s maximum duration (i.e. it’s outer boundary) independent from the actual beginning and end. + + + + + + + был максимальной длительностью для + war längste Dauer von + was maximum duration of + είναι μέγιστη διάρκεια του/της + a été la durée maximum de + foi a duração máxima de + + + + + + +falls within + содержится в + περιέχεται σε + s’insère dans + fällt in + está contido em + +This property describes the inclusion relationship between two instances of E52 Time-Span. +This property supports the notion that a Time-Span’s temporal extent falls within the temporal extent of another Time-Span. It addresses temporal containment only, and no contextual link between the two instances of Time-Span is implied. + + + + + + + inclut + enthält + contains + περιέχει + содержит + contém + + + + + + + αναγνωρίζεται ως + is identified by + идентифицируется посредством + est identifié par + wird bezeichnet als + é identificado por + + This property identifies an E53 Place using an E44 Place Appellation. +Examples of Place Appellations used to identify Places include instances of E48 Place Name, addresses, E47 Spatial Coordinates etc. + + + + + + + + bezeichnet + είναι αναγνωριστικό + идентифицирует + identifie + identifies + identifica + + + + + + + + сделан из + est en + αποτελείται από + consists of + besteht aus + consiste de + This property identifies an E53 Place that forms part of another Place. +It supports the notion that a Place can be subdivided into one or more constituent parts. It implies both spatial and contextual containment relationships between the two Places. + + + + + + + fait partie de + формирует часть + forms part of + bildet Teil von + είναι τμήμα του + faz parte de + + + + + + + s’insère dans + falls within + содержится в + fällt in + περιέχεται σε + está contido em + +This property identifies the instances of E53 Places that fall within the area covered by another Place. +It addresses spatial containment only, and no ‘whole-part’ relationship between the two places is implied. + + + + + + + inclut + содержит + περιέχει + enthält + contains + contém + + + + + + + hat Wert + έχει τιμή + a la valeur + имеет значение + has value + tem valor + +This property allows an E54 Dimension to be approximated by an E60 Number primitive. + + + + + + + имеет единицу + έχει μονάδα μέτρησης + a pour unité + hat Einheit + has unit + tem unidade + + This property shows the type of unit an E54 Dimension was expressed in. + + + + + + является единицей для + est l'unité de + ist Einheit von + αποτελεί μονάδα μέτρησης του/της + is unit of + é unidade de + + + + + + + a fait exister + brought into existence + создал + brachte in Existenz + γέννησε + trouxe à existência + + This property allows an E63 Beginning of Existence event to be linked to the E77 Persistent Item brought into existence by it. +It allows a “start” to be attached to any Persistent Item being documented i.e. E70 Thing, E72 Legal Object, E39 Actor, E41 Appellation, E51 Contact Point and E55 Type + + + + + + + was brought into existence by + γεννήθηκε από + wurde in Existenz gebracht durch + a commencé à exister du fait de + был создан посредством + passou a existir por + + + + + + + + a fait cesser d’exister + положил конец существованию + beendete die Existenz von + took out of existence + αναίρεσε + cessou a existência de + + This property allows an E64 End of Existence event to be linked to the E77 Persistent Item taken out of existence by it. +In the case of immaterial things, the E64 End of Existence is considered to take place with the destruction of the last physical carrier. +This allows an “end” to be attached to any Persistent Item being documented i.e. E70 Thing, E72 Legal Object, E39 Actor, E41 Appellation, E51 Contact Point and E55 Type. For many Persistent Items we know the maximum life-span and can infer, that they must have ended to exist. We assume in that case an End of Existence, which may be as unnoticeable as forgetting the secret knowledge by the last representative of some indigenous nation. + + + + + + + + прекратил существование посредством + a cessé d’exister du fait de + was taken out of existence by + αναιρέθηκε από + wurde seiner Existenz beraubt durch + deixou de existir + + + + + + + + δημιούργησε + создал + has created + hat erschaffen + a créé + criou + + This property allows a conceptual E65 Creation to be linked to the E28 Conceptual Object created by it. +It represents the act of conceiving the intellectual content of the E28 Conceptual Object. It does not represent the act of creating the first physical carrier of the E28 Conceptual Object. As an example, this is the composition of a poem, not its commitment to paper. + + + + + + + + δημιουργήθηκε από + a été créé par + был создан посредством + was created by + wurde erschaffen durch + foi criado por + + + + + + + + a fondé + сформировал + hat gebildet + has formed + σχημάτισε + formou +This property links the founding or E66 Formation for an E74 Group with the Group itself. + + + + + + + + a été fondé par + wurde gebildet von + σχηματίστηκε από + was formed by + была сформирована посредством + foi formado por + + + + + + + + посредством матери + durch Mutter + de mère + by mother + είχε μητέρα + pela mãe + +This property links an E67 Birth event to an E21 Person as a participant in the role of birth-giving mother. + +Note that biological fathers are not necessarily participants in the Birth (see P97 from father (was father for)). The Person being born is linked to the Birth with the property P98 brought into life (was born). This is not intended for use with general natural history material, only people. There is no explicit method for modelling conception and gestation except by using extensions. This is a sub-property of P11 had participant (participated in). + + + + + + + + ήταν μητέρα του/της + a donné naissance à + gave birth + дал рождение + gebar + deu nascimento + + + + + + + +gab Vaterschaft + от отца + from father + είχε πατέρα + de père + pelo pai + +This property links an E67 Birth event to an E21 Person in the role of biological father. +Note that biological fathers are not seen as necessary participants in the Birth, whereas birth-giving mothers are (see P96 by mother (gave birth)). The Person being born is linked to the Birth with the property P98 brought into life (was born). +This is not intended for use with general natural history material, only people. There is no explicit method for modelling conception and gestation except by using extensions. +A Birth event is normally (but not always) associated with one biological father. + + + + + + + was father for + ήταν πατέρας του/της + a été père dans + war Vater für + был отцом для + foi pai para + + + + + + + a donné vie à + brachte zur Welt + brought into life + породил + έφερε στη ζωή + trouxe à vida +This property links an E67Birth event to an E21 Person in the role of offspring. +Twins, triplets etc. are brought into life by the same Birth event. This is not intended for use with general Natural History material, only people. There is no explicit method for modelling conception and gestation except by using extensions. + + + + + + + + est né + γεννήθηκε + wurde geboren durch + was born + был рожден + veio à vida pelo + + + + + + + + διέλυσε + распустил + a dissous + dissolved + löste auf + dissolveu + This property links the disbanding or E68 Dissolution of an E74 Group to the Group itself. + + + + + + + + wurde aufgelöst durch + был распущен посредством + a été dissous par + διαλύθηκε από + was dissolved by + foi dissolvido por + + + + + + + + was death of + a été la mort de + ήταν θάνατος του/της + Tod von + был смертью для + foi a morte para + +This property property links an E69 Death event to the E21 Person that died. + + + + + + + + + + + + + had as general use + avait comme utilisation générale + είχε ως γενική χρήση + hatte die allgemeine Verwendung + имел основное применение + tem como uso geral + +This property links an instance of E70 Thing to an E55 Type of usage. +It allows the relationship between particular things, both physical and immaterial, and general methods and techniques of use to be documented. Thus it can be asserted that a baseball bat had a general use for sport and a specific use for threatening people during the Great Train Robbery. + + + + + + + war die Verwendung von + was use of + était l’utilisation de + был применением для + ήταν χρήση του/της + foi uso de + + + + + + has title + имеет заголовок + trägt den Titel + a pour titre + έχει τίτλο + tem título +This property describes the E35 Title applied to an instance of E71 Man-Made Thing. The E55 Type of Title is assigned in a sub property. +The P102.1 has type property of the P102 has title (is title of) property enables the relationship between the Title and the thing to be further clarified, for example, if the Title was a given Title, a supplied Title etc. +It allows any man-made material or immaterial thing to be given a Title. It is possible to imagine a Title being created without a specific object in mind. + + + + + + + + is title of + ist der Titel von + είναι τίτλος του/της + est le titre de + является заголовком для + é título de + + + + + + + + + était destiné à + was intended for + bestimmt für + был задуман для + προοριζόταν για + era destinado à + +This property links an instance of E71 Man-Made Thing to an E55 Type of usage. +It creates a property between specific man-made things, both physical and immaterial, to Types of intended methods and techniques of use. Note: A link between specific man-made things and a specific use activity should be expressed using P19 was intended use of (was made for). + + + + + + war Bestimmung von + was intention of + был интенцией для + ήταν προορισμός του + était la raison d'être de + era a destinação de + + + + + + + est sujet à + is subject to + является объектом для + υπόκειται σε + Gegenstand von + está sujeito à + +This property links a particular E72 Legal Object to the instances of E30 Right to which it is subject. +The Right is held by an E39 Actor as described by P75 possesses (is possessed by). + + + + + + + ισχύει για + s’applique à + findet Anwendung auf + применяется к + applies to + se aplicam à + + + + + + право принадлежит + droit détenu par + Rechte stehen zu + δικαίωμα κατέχεται από + right held by + são direitos de + +This property identifies the E39 Actor who holds the instances of E30 Right to an E72 Legal Object. + It is a superproperty of P52 has current owner (is current owner of) because ownership is a right that is held on the owned object. +P105 right held by (has right on) is a shortcut of the fully developed path from E72 Legal Object through P104 is subject to (applies to), E30 Right, P75 possesses (is possessed by) to E39 Actor. + + + + + + + hat Rechte an + владеет правом на + has right on + détient un droit sur + έχει δικαίωμα σε + possui direitos sobre + + + + + + ist zusammengesetzt aus + составлен из + is composed of + est composé de + αποτελείται από + é composto de + +This property associates an instance of E90 Symbolic Object with a part of it that is by itself an instance of E90 Symbolic Object, such as fragments of texts or clippings from an image. + + + + + + + формирует часть + αποτελεί μέρος του/της + bildet Teil von + fait partie de + forms part of + faz parte de + + + + + + a pour membre actuel ou ancien + has current or former member + έχει ή είχε μέλος + имеет действующего или бывшего члена + hat derzeitiges oder früheres Mitglied + tem ou teve membro + +This property relates an E39 Actor to the E74 Group of which that E39 Actor is a member. +Groups, Legal Bodies and Persons, may all be members of Groups. A Group necessarily consists of more than one member. +This property is a shortcut of the more fully developed path from E74 Group through P144 joined with (gained member by), E85 Joining, P143 joined (was joined by) to E39 Actor +The property P107.1 kind of member can be used to specify the type of membership or the role the member has in the group. + + + + + + + είναι ή ήταν μέλος του/της + is current or former member of + ist derzeitiges oder früheres Mitglied von + является действующим или бывшим членом + est actuel ou ancien membre de + é ou foi membro de + + + + + + παρήγαγε + a produit + произвел + hat hergestellt + has produced + produziu + +This property identifies the E24 Physical Man-Made Thing that came into existence as a result of an E12 Production. +The identity of an instance of E24 Physical Man-Made Thing is not defined by its matter, but by its existence as a subject of documentation. An E12 Production can result in the creation of multiple instances of E24 Physical Man-Made Thing. + + + + + + + + + παρήχθη από + a été produit par + wurde hergestellt durch + был произведен посредством + was produced by + foi produzido por + + + + + + + + + a pour conservateur actuel ou ancien + hat derzeitigen oder früheren Kurator + has current or former curator + έχει ή είχε επιμελητή + имеет действующего или бывшего хранителя + tem ou teve curador + + This property identifies the E39 Actor or Actors who assume or have assumed overall curatorial responsibility for an E78 Collection. +This property is effectively a short-cut. It does not allow a history of curation to be recorded. This would require use of an Event assigning responsibility for a Collection to a curator. + + + + + + + + является действующим или бывшим хранителем + είναι ή ήταν επιμελητής του/της + est ou a été le conservateur de + ist derzeitiger oder früherer Kurator von + is current or former curator of + é ou foi curador de + + + + + + + + + увеличил + a augmenté + erweiterte + επαύξησε + augmented + aumentou + + This property identifies the E24 Physical Man-Made Thing that is added to (augmented) in an E79 Part Addition. +Although a Part Addition event normally concerns only one item of Physical Man-Made Thing, it is possible to imagine circumstances under which more than one item might be added to (augmented). For example, the artist Jackson Pollock trailing paint onto multiple canvasses. + + + + + + + + + a été augmenté par + was augmented by + был увеличен посредством + επαυξήθηκε από + wurde erweitert durch + foi aumentada por + + + + + + + fügte hinzu + προσέθεσε + a ajouté + added + добавил + adicionou + + This property identifies the E18 Physical Thing that is added during an E79 Part Addition activity + + + + + + + + + a été ajouté par + wurde hinzugefügt durch + was added by + προστέθηκε από + был добавлен посредством + foi adicionado por + + + + + + + +This property identifies the E24 Physical Man-Made Thing that was diminished by E80 Part Removal. +Although a Part removal activity normally concerns only one item of Physical Man-Made Thing, it is possible to imagine circumstances under which more than one item might be diminished by a single Part Removal activity. + + уменьшил + diminished + verminderte + a diminué + εξάλειψε + diminuiu + + + + + + + was diminished by + εξαλείφθηκε από + a été diminué par + был уменьшен посредством + wurde vermindert durch + foi diminuído por + + + + + + + удален + entfernte + removed + αφαίρεσε + a enlevé + removeu + This property identifies the E18 Physical Thing that is removed during an E80 Part Removal activity. + + + + + + + αφαιρέθηκε από + wurde entfernt durch + was removed by + a été enlevée par + был удален посредством + foi removido por + + + + + + + est temporellement égale à + zeitgleich zu + συμπίπτει χρονικά με + равен по времени + is equal in time to + é temporalmente igual a + This symmetric property allows the instances of E2 Temporal Entity with the same E52 Time-Span to be equated. +This property is only necessary if the time span is unknown (otherwise the equivalence can be calculated). +This property is the same as the "equal" relationship of Allen’s temporal logic (Allen, 1983, pp. 832-843). + + + + + + + finishes + заканчивает + beendet + termine + περατώνει + finaliza + This property allows the ending point for a E2 Temporal Entity to be situated by reference to the ending point of another temporal entity of longer duration. +This property is only necessary if the time span is unknown (otherwise the relationship can be calculated). This property is the same as the "finishes / finished-by" relationships of Allen’s temporal logic (Allen, 1983, pp. 832-843). + + + + + + + est terminée par + заканчивается + περατώνεται με + wurde beendet mit + is finished by + é finalizada por + + + + + + commence + starts + начинает + beginnt + αρχίζει + inicia + This property allows the starting point for a E2 Temporal Entity to be situated by reference to the starting point of another temporal entity of longer duration. +This property is only necessary if the time span is unknown (otherwise the relationship can be calculated). This property is the same as the "starts / started-by" relationships of Allen’s temporal logic (Allen, 1983, pp. 832-843). + + + + + + + est commencée par + wurde begonnen mit + αρχίζει με + начинается + is started by + é iniciada por + + + + + + fällt in + εμφανίζεται κατά τη διάρκεια + появляется во течение + occurs during + a lieu pendant + ocorre durante + This property allows the entire E52 Time-Span of an E2 Temporal Entity to be situated within the Time-Span of another temporal entity that starts before and ends after the included temporal entity. +This property is only necessary if the time span is unknown (otherwise the relationship can be calculated). This property is the same as the "during / includes" relationships of Allen’s temporal logic (Allen, 1983, pp. 832-843). + + + + + + + περιλαμβάνει + включает + comporte + includes + beinhaltet + inclui + + + + + + overlaps in time with + перекрывает во времени + προηγείται μερικώς επικαλύπτοντας + überlappt zeitlich mit + est partiellement recouverte dans le temps par + sobrepõe temporalmente + This property identifies an overlap between the instances of E52 Time-Span of two instances of E2 Temporal Entity. +It implies a temporal order between the two entities: if A overlaps in time B, then A must start before B, and B must end after A. This property is only necessary if the relevant time spans are unknown (otherwise the relationship can be calculated). +This property is the same as the "overlaps / overlapped-by" relationships of Allen’s temporal logic (Allen, 1983, pp. 832-843). + + + + + + + wird zeitlich überlappt von + перекрывается во времени + recouvre partiellement dans le temps + is overlapped in time by + έπεται μερικώς επικαλυπτόμενο + é sobreposto temporalmente por + + + + + + meets in time with + προηγείται + trifft zeitlich auf + следует во времени за + est temporellement contiguë avec + é temporalmente contíguo com + This property indicates that one E2 Temporal Entity immediately follows another. +It implies a particular order between the two entities: if A meets in time with B, then A must precede B. This property is only necessary if the relevant time spans are unknown (otherwise the relationship can be calculated). +This property is the same as the "meets / met-by" relationships of Allen’s temporal logic (Allen, 1983, pp. 832-843). + + + + + + + est immédiatement précédé par + έπεται + is met in time by + wird zeitlich getroffen von + предшествует во времени + é imediatamente precedido por + + + + + + появляется до + a lieu avant + εμφανίζεται πριν + occurs before + kommt vor + ocorre antes + This property identifies the relative chronological sequence of two temporal entities. +It implies that a temporal gap exists between the end of A and the start of B. This property is only necessary if the relevant time spans are unknown (otherwise the relationship can be calculated). +This property is the same as the "before / after" relationships of Allen’s temporal logic (Allen, 1983, pp. 832-843). + + + + + + + a lieu après + εμφανίζεται μετά + появляется после + kommt nach + occurs after + ocorre depois + + + + + + επικαλύπτεται με + überlappt mit + chevauche + пересекается с + overlaps with + sobrepõe com + This symmetric property allows the instances of E53 Place with overlapping geometric extents to be associated with each other. +It does not specify anything about the shared area. This property is purely spatial, in contrast to Allen operators, which are purely temporal. + + + + + + + граничит с + borders with + jouxte + grenzt an + συνορεύει με + fronteira com + This symmetric property allows the instances of E53 Place which share common borders to be related as such. +This property is purely spatial, in contrast to Allen operators, which are purely temporal. + + + + + + + a eu pour résultat + ergab + είχε ως αποτέλεσμα + повлек появление + resulted in + resultou em + This property identifies the E77 Persistent Item or items that are the result of an E81 Transformation. +New items replace the transformed item or items, which cease to exist as units of documentation. The physical continuity between the old and the new is expressed by the link to the common Transformation. + + + + + + + + est le résultat de + προέκυψε από + был результатом + ergab sich aus + resulted from + resultado de + + + + + + + transformed + wandelte um + μετέτρεψε + трансформировал + a transformé + transformou + This property identifies the E77 Persistent Item or items that cease to exist due to a E81 Transformation. +It is replaced by the result of the Transformation, which becomes a new unit of documentation. The continuity between both items, the new and the old, is expressed by the link to the common Transformation. + + + + + + + + a été transformé par + был трансформирован посредством + μετατράπηκε από + was transformed by + wurde umgewandelt durch + foi transformado por + + + + + + +used object of type + a employé un objet du type + использовал объект типа + benutzte Objekt des Typus + χρησιμοποίησε αντικείμενο τύπου + usou objeto do tipo + This property defines the kind of objects used in an E7 Activity, when the specific instance is either unknown or not of interest, such as use of "a hammer". + + + + + + + был типом объекта использованного в + was type of object used in + Objekt des Typus ... wurde benutzt in + était le type d’objet employé par + ήταν o τύπος αντικείμενου που χρησιμοποιήθηκε σε + foi tipo do objeto usado em + + + + + + a employé + verwendete + employed + использовал + χρησιμοποίησε + empregou + This property identifies E57 Material employed in an E11 Modification. +The E57 Material used during the E11 Modification does not necessarily become incorporated into the E24 Physical Man-Made Thing that forms the subject of the E11 Modification. + + + + + + + was employed in + wurde verwendet bei + использовался в + χρησιμοποιήθηκε σε + a été employé dans + foi empregado em + + + + + + έχει ευρύτερο όρο + a pour terme générique + hat den Oberbegriff + has broader term + имеет вышестоящий термин + tem termo genérico + This property identifies a super-Type to which an E55 Type is related. + It allows Types to be organised into hierarchies. This is the sense of "broader term generic (BTG)" as defined in ISO 2788 + + + + + + + a pour terme spécifique + hat den Unterbegriff + has narrower term + έχει στενότερο όρο + tem termo específico + + + + + + carries + est le support de + несет + φέρει + trägt + é o suporte de + This property identifies an E73 Information Object carried by an instance of E24 Physical Man-Made Thing. +In general this would be an E84 Information Carrier P65 shows visual item (is shown by) is a specialisation of P128 carries (is carried by) which should be used for carrying visual items. + + + + + + + + φέρεται από + is carried by + переносится посредством + a pour support + wird getragen von + é suportado por + + + + + + + est au sujet de + is about + касается + έχει ως θέμα + handelt über + é sobre + This property documents that an E89 Propositional Object has as subject an instance of E1 CRM Entity. + + + + + + + + est le sujet de + wird behandelt in + является предметом для + είναι θέμα του/της + is subject of + é assunto de + + + + + + + παρουσιάζει χαρακτηριστικά του/της + shows features of + демонстрирует признаки + présente des caractéristiques de + zeigt Merkmale von + apresenta características de +This property generalises the notions of "copy of" and "similar to" into a dynamic, asymmetric relationship, where the domain expresses the derivative, if such a direction can be established. +Otherwise, the relationship is symmetric. It is a short-cut of P15 was influenced by (influenced) in a creation or production, if such a reason for the similarity can be verified. Moreover it expresses similarity in cases that can be stated between two objects only, without historical knowledge about its reasons. + + + + + + + χαρακτηριστικά του βρίσκονται επίσης σε + a des caractéristiques se trouvant aussi sur + Merkmale auch auf + признаки также найдены на + features are also found on + características são também encontradas em + + + + + + αναγνωρίζεται ως + wird identifziert durch + is identified by + est identifié par + идентифицируется посредством + é identificado por + This property identifies a name used specifically to identify an E39 Actor. +This property is a specialisation of P1 is identified by (identifies) is identified by. + + + + + + + + identifie + identifies + είναι αναγνωριστικό + идентифицирует + identifiziert + identifica + + + + + + + επικαλύπτεται με + überlappt mit + chevauche + пересекается с + overlaps with + sobrepõe + This symmetric property allows instances of E4 Period that overlap both temporally and spatially to be related, i,e. they share some spatio-temporal extent. +This property does not imply any ordering or sequence between the two periods, either spatial or temporal. + + + + + + + getrennt von + is separated from + διαχωρίζεται από + est séparée de + отделен от + é separado de + This symmetric property allows instances of E4 Period that do not overlap both temporally and spatially, to be related i,e. they do not share any spatio-temporal extent. +This property does not imply any ordering or sequence between the two periods either spatial or temporal. + + + + + + + setzte sich fort in + συνέχισε + продолжил + est la suite de + continued + continuou + This property allows two activities to be related where the domain is considered as an intentional continuation of the range. +Used multiple times, this allows a chain of related activities to be created which follow each other in sequence. + + + + + + + + wurde fortgesetzt durch + был продолжен + a été continuée par + was continued by + συνεχίστηκε από + foi continuada por + + + + + + + created type + erschuf Typus + δημιούργησε τύπο + a créé le type + создал тип + criou tipo + This property identifies the E55 Type, which is created in an E83Type Creation activity. + + + + + + + was created by + wurde geschaffen durch + a été créé par + δημιουργήθηκε από + был создан посредством + foi criado por + + + + + + + s’est fondée sur + был основан на + stützte sich auf + βασίστηκε σε + was based on + foi baseado em + This property identifies one or more items that were used as evidence to declare a new E55 Type. +The examination of these items is often the only objective way to understand the precise characteristics of a new Type. Such items should be deposited in a museum or similar institution for that reason. The taxonomic role renders the specific relationship of each item to the Type, such as "holotype" or "original element". + + + + + + + + supported type creation + υποστήριξε τη δημιουργία τύπου + a justifié la création de type + belegte + поддержал создание типа + suportou a criação de tipo + + + + + + + exemplifies + exemplifie + δειγματίζει + поясняет + erläutert + é exemplificado por + This property allows an item to be declared as a particular example of an E55 Type or taxon + The P137.1 in the taxonomic role property of P137 exemplifies (is exemplified by) allows differentiation of taxonomic roles. The taxonomic role renders the specific relationship of this example to the Type, such as "prototypical", "archetypical", "lectotype", etc. The taxonomic role "lectotype" is not associated with the Type Creation (E83) itself, but selected in a later phase. + + + + + + + + поясняется посредством + erläutert durch Beispiel + is exemplified by + δειγματίζεται από + est exemplifié par + exemplifica + + + + + + + παριστάνει + represents + представляет + stellt dar + représente + representa + This property establishes the relationship between an E36 Visual Item and the entity that it visually represents. +Any entity may be represented visually. This property is part of the fully developed path from E24 Physical Man-Made Thing through P65 shows visual item (is shown by), E36 Visual Item, P138 represents (has representation) to E1 CRM Entity, which is shortcut by P62depicts (is depicted by). P138.1 mode of representation allows the nature of the representation to be refined. + + + + + + + + has representation + имеет представление + est représentée par + παριστάνεται από + wird dargestellt durch + tem representação + + + + + + + a pour autre forme + имеет альтернативную форму + has alternative form + hat alternative Form + έχει εναλλακτική μορφή + tem forma alternativa + This property establishes a relationship of equivalence between two instances of E41 Appellation independent from any item identified by them. It is a dynamic asymmetric relationship, where the range expresses the derivative, if such a direction can be established. Otherwise, the relationship is symmetric. The relationship is not transitive. +The equivalence applies to all cases of use of an instance of E41 Appellation. Multiple names assigned to an object, which are not equivalent for all things identified with a specific instance of E41 Appellation, should be modelled as repeated values of P1 is identified by (identifies). +P139.1 has type allows the type of derivation, such as “transliteration from Latin 1 to ASCII” be refined.. + + + + + + + wies Merkmal zu + απέδωσε ιδιότητα σε + assigned attribute to + a affecté un attribut à + присвоил атрибут для + atribuiu atributo para + This property indicates the item to which an attribute or relation is assigned. + + + + + + was attributed by + a reçu un attribut par + получил атрибут посредством + bekam Merkmal zugewiesen durch + χαρακτηρίστηκε από + foi atribuído por + + + + + + assigned + присвоил + wies zu + απέδωσε + a attribué + atribuiu + This property indicates the attribute that was assigned or the item that was related to the item denoted by a property P140 assigned attribute to in an Attribute assignment action. + + + + + + + был присвоен посредством + wurde zugewiesen durch + a été attribué par + was assigned by + αποδόθηκε από + foi atribuído por + + + + + + used constituent + benutzte Bestandteil + This property associates the event of assigning an instance of E42 Identifier to an entity, with the instances of E41 Appellation that were used as elements of the identifier. + + + + + + + + wurde benutzt in + was used in + + + + + + + joined + verband + This property identifies the instance of E39 Actor that becomes member of a E74 Group in an E85 Joining. + Joining events allow for describing people becoming members of a group with a more detailed path from E74 Group through P144 joined with (gained member by), E85 Joining, P143 joined (was joined by) to E39 Actor, compared to the shortcut offered by P107 has current or former member (is current or former member of). + + + + + + + + was joined by + wurde verbunden durch + + + + + + + joined with + verband mit + This property identifies the instance of E74 Group of which an instance of E39 Actor becomes a member through an instance of E85 Joining. +Although a Joining activity normally concerns only one instance of E74 Group, it is possible to imagine circumstances under which becoming member of one Group implies becoming member of another Group as well. +Joining events allow for describing people becoming members of a group with a more detailed path from E74 Group through P144 joined with (gained member by), E85 Joining, P143 joined (was joined by) to E39 Actor, compared to the shortcut offered by P107 has current or former member (is current or former member of). +The property P144.1 kind of member can be used to specify the type of membership or the role the member has in the group. + + + + + + + + gained member by + erwarb Mitglied durch + + + + + + + separated + entließ +This property identifies the instance of E39 Actor that leaves an instance of E74 Group through an instance of E86 Leaving. + + + + + + + left by + wurde entlassen durch + + + + + + + separated from + entließ von + This property identifies the instance of E74 Group an instance of E39 Actor leaves through an instance of E86 Leaving. +Although a Leaving activity normally concerns only one instance of E74 Group, it is possible to imagine circumstances under which leaving one E74 Group implies leaving another E74 Group as well. + + + + + + + + lost member by + verlor Mitglied durch + + + + + + + curated + betreute kuratorisch + This property associates an instance of E78 Collection or collections with subject of a curation activity following some implicit or explicit curation plan. + + + + + + + was curated by + wurde kuratorisch betreut durch + + + + + + has component + hat Bestandteil + This property associates an instance of E89 Propositional Object with a structural part of it that is by itself an instance of E89 Propositional Object. + + + + + + is component of + ist Bestandteil von + + + + + + is identified by + This property identifies an instance of E28 Conceptual Object using an instance of E75 Conceptual Object Appellation. + + + + + + + identifies + + + + + \ No newline at end of file diff --git a/contract/src/test/resources/dublincore.rdf b/contract/src/test/resources/dublincore.rdf new file mode 100644 index 0000000000..7f7f4b1e59 --- /dev/null +++ b/contract/src/test/resources/dublincore.rdf @@ -0,0 +1,1278 @@ + + + + + + + + + ]> + + + DCMI Metadata Terms in the /terms/ namespace + + 2010-10-11 + + + Title + A name given to the resource. + + 2008-01-14 + 2010-10-11 + + + + + + + Creator + An entity primarily responsible for making the resource. + Examples of a Creator include a person, an organization, or a service. + + + 2008-01-14 + 2010-10-11 + + + + + + + + + Subject + The topic of the resource. + Typically, the subject will be represented using keywords, key phrases, or + classification codes. Recommended best practice is to use a controlled vocabulary. To describe the spatial + or temporal topic of the resource, use the Coverage element. + + + 2008-01-14 + 2008-01-14 + + + This term is intended to be used with non-literal values as defined in the DCMI + Abstract Model (http://dublincore.org/documents/abstract-model/). As of December 2007, the DCMI Usage Board + is seeking a way to express this intention with a formal range declaration. + + + + + Description + An account of the resource. + Description may include but is not limited to: an abstract, a table of + contents, a graphical representation, or a free-text account of the resource. + + + 2008-01-14 + 2008-01-14 + + + + + + Publisher + An entity responsible for making the resource available. + Examples of a Publisher include a person, an organization, or a service. + + + 2008-01-14 + 2010-10-11 + + + + + + + Contributor + An entity responsible for making contributions to the resource. + Examples of a Contributor include a person, an organization, or a service. + + + 2008-01-14 + 2010-10-11 + + + + + + + Date + A point or period of time associated with an event in the lifecycle of the + resource. + + Date may be used to express temporal information at any level of + granularity. Recommended best practice is to use an encoding scheme, such as the W3CDTF profile of ISO 8601 + [W3CDTF]. + + + 2008-01-14 + 2008-01-14 + + + + + + + Type + The nature or genre of the resource. + Recommended best practice is to use a controlled vocabulary such as the + DCMI Type Vocabulary [DCMITYPE]. To describe the file format, physical medium, or dimensions of the + resource, use the Format element. + + + 2008-01-14 + 2008-01-14 + + + + + + + Format + The file format, physical medium, or dimensions of the resource. + Examples of dimensions include size and duration. Recommended best + practice is to use a controlled vocabulary such as the list of Internet Media Types [MIME]. + + + 2008-01-14 + 2008-01-14 + + + + + + + Identifier + An unambiguous reference to the resource within a given context. + Recommended best practice is to identify the resource by means of a string + conforming to a formal identification system. + + + 2008-01-14 + 2008-01-14 + + + + + + + Source + A related resource from which the described resource is derived. + The described resource may be derived from the related resource in whole + or in part. Recommended best practice is to identify the related resource by means of a string conforming to + a formal identification system. + + + 2008-01-14 + 2008-01-14 + + + This term is intended to be used with non-literal values as defined in the DCMI + Abstract Model (http://dublincore.org/documents/abstract-model/). As of December 2007, the DCMI Usage Board + is seeking a way to express this intention with a formal range declaration. + + + + + + Language + A language of the resource. + Recommended best practice is to use a controlled vocabulary such as RFC + 4646 [RFC4646]. + + + 2008-01-14 + 2008-01-14 + + + + + + + Relation + A related resource. + Recommended best practice is to identify the related resource by means of + a string conforming to a formal identification system. + + + 2008-01-14 + 2008-01-14 + + + This term is intended to be used with non-literal values as defined in the DCMI + Abstract Model (http://dublincore.org/documents/abstract-model/). As of December 2007, the DCMI Usage Board + is seeking a way to express this intention with a formal range declaration. + + + + + Coverage + The spatial or temporal topic of the resource, the spatial applicability of the + resource, or the jurisdiction under which the resource is relevant. + + Spatial topic and spatial applicability may be a named place or a location + specified by its geographic coordinates. Temporal topic may be a named period, date, or date range. A + jurisdiction may be a named administrative entity or a geographic place to which the resource applies. + Recommended best practice is to use a controlled vocabulary such as the Thesaurus of Geographic Names [TGN]. + Where appropriate, named places or time periods can be used in preference to numeric identifiers such as + sets of coordinates or date ranges. + + + 2008-01-14 + 2008-01-14 + + + + + + + Rights + Information about rights held in and over the resource. + Typically, rights information includes a statement about various property + rights associated with the resource, including intellectual property rights. + + + 2008-01-14 + 2008-01-14 + + + + + + + Audience + A class of entity for whom the resource is intended or useful. + + 2001-05-21 + 2008-01-14 + + + + + + Alternative Title + An alternative name for the resource. + The distinction between titles and alternative titles is + application-specific. + + + 2000-07-11 + 2010-10-11 + + + + + + + + Table Of Contents + A list of subunits of the resource. + + 2000-07-11 + 2008-01-14 + + + + + + + Abstract + A summary of the resource. + + 2000-07-11 + 2008-01-14 + + + + + + + Date Created + Date of creation of the resource. + + 2000-07-11 + 2008-01-14 + + + + + + + + Date Valid + Date (often a range) of validity of a resource. + + 2000-07-11 + 2008-01-14 + + + + + + + + Date Available + Date (often a range) that the resource became or will become available. + + + 2000-07-11 + 2008-01-14 + + + + + + + + Date Issued + Date of formal issuance (e.g., publication) of the resource. + + 2000-07-11 + 2008-01-14 + + + + + + + + Date Modified + Date on which the resource was changed. + + 2000-07-11 + 2008-01-14 + + + + + + + + Extent + The size or duration of the resource. + + 2000-07-11 + 2008-01-14 + + + + + + + + Medium + The material or physical carrier of the resource. + + 2000-07-11 + 2008-01-14 + + + + + + + + + Is Version Of + A related resource of which the described resource is a version, edition, or + adaptation. + + Changes in version imply substantive changes in content rather than + differences in format. + + + 2000-07-11 + 2008-01-14 + + + This term is intended to be used with non-literal values as defined in the DCMI + Abstract Model (http://dublincore.org/documents/abstract-model/). As of December 2007, the DCMI Usage Board + is seeking a way to express this intention with a formal range declaration. + + + + + + Has Version + A related resource that is a version, edition, or adaptation of the described + resource. + + + 2000-07-11 + 2008-01-14 + + + This term is intended to be used with non-literal values as defined in the DCMI + Abstract Model (http://dublincore.org/documents/abstract-model/). As of December 2007, the DCMI Usage Board + is seeking a way to express this intention with a formal range declaration. + + + + + + Is Replaced By + A related resource that supplants, displaces, or supersedes the described + resource. + + + 2000-07-11 + 2008-01-14 + + + This term is intended to be used with non-literal values as defined in the DCMI + Abstract Model (http://dublincore.org/documents/abstract-model/). As of December 2007, the DCMI Usage Board + is seeking a way to express this intention with a formal range declaration. + + + + + + Replaces + A related resource that is supplanted, displaced, or superseded by the described + resource. + + + 2000-07-11 + 2008-01-14 + + + This term is intended to be used with non-literal values as defined in the DCMI + Abstract Model (http://dublincore.org/documents/abstract-model/). As of December 2007, the DCMI Usage Board + is seeking a way to express this intention with a formal range declaration. + + + + + + Is Required By + A related resource that requires the described resource to support its function, + delivery, or coherence. + + + 2000-07-11 + 2008-01-14 + + + This term is intended to be used with non-literal values as defined in the DCMI + Abstract Model (http://dublincore.org/documents/abstract-model/). As of December 2007, the DCMI Usage Board + is seeking a way to express this intention with a formal range declaration. + + + + + + Requires + A related resource that is required by the described resource to support its + function, delivery, or coherence. + + + 2000-07-11 + 2008-01-14 + + + This term is intended to be used with non-literal values as defined in the DCMI + Abstract Model (http://dublincore.org/documents/abstract-model/). As of December 2007, the DCMI Usage Board + is seeking a way to express this intention with a formal range declaration. + + + + + + Is Part Of + A related resource in which the described resource is physically or logically + included. + + + 2000-07-11 + 2008-01-14 + + + This term is intended to be used with non-literal values as defined in the DCMI + Abstract Model (http://dublincore.org/documents/abstract-model/). As of December 2007, the DCMI Usage Board + is seeking a way to express this intention with a formal range declaration. + + + + + + Has Part + A related resource that is included either physically or logically in the + described resource. + + + 2000-07-11 + 2008-01-14 + + + This term is intended to be used with non-literal values as defined in the DCMI + Abstract Model (http://dublincore.org/documents/abstract-model/). As of December 2007, the DCMI Usage Board + is seeking a way to express this intention with a formal range declaration. + + + + + + Is Referenced By + A related resource that references, cites, or otherwise points to the described + resource. + + + 2000-07-11 + 2008-01-14 + + + This term is intended to be used with non-literal values as defined in the DCMI + Abstract Model (http://dublincore.org/documents/abstract-model/). As of December 2007, the DCMI Usage Board + is seeking a way to express this intention with a formal range declaration. + + + + + + References + A related resource that is referenced, cited, or otherwise pointed to by the + described resource. + + + 2000-07-11 + 2008-01-14 + + + This term is intended to be used with non-literal values as defined in the DCMI + Abstract Model (http://dublincore.org/documents/abstract-model/). As of December 2007, the DCMI Usage Board + is seeking a way to express this intention with a formal range declaration. + + + + + + Is Format Of + A related resource that is substantially the same as the described resource, but + in another format. + + + 2000-07-11 + 2008-01-14 + + + This term is intended to be used with non-literal values as defined in the DCMI + Abstract Model (http://dublincore.org/documents/abstract-model/). As of December 2007, the DCMI Usage Board + is seeking a way to express this intention with a formal range declaration. + + + + + + Has Format + A related resource that is substantially the same as the pre-existing described + resource, but in another format. + + + 2000-07-11 + 2008-01-14 + + + This term is intended to be used with non-literal values as defined in the DCMI + Abstract Model (http://dublincore.org/documents/abstract-model/). As of December 2007, the DCMI Usage Board + is seeking a way to express this intention with a formal range declaration. + + + + + + Conforms To + An established standard to which the described resource conforms. + + 2001-05-21 + 2008-01-14 + + + + + + + + Spatial Coverage + Spatial characteristics of the resource. + + 2000-07-11 + 2008-01-14 + + + + + + + + Temporal Coverage + Temporal characteristics of the resource. + + 2000-07-11 + 2008-01-14 + + + + + + + + Mediator + An entity that mediates access to the resource and for whom the resource is + intended or useful. + + In an educational context, a mediator might be a parent, teacher, teaching + assistant, or care-giver. + + + 2001-05-21 + 2008-01-14 + + + + + + + Date Accepted + Date of acceptance of the resource. + Examples of resources to which a Date Accepted may be relevant are a + thesis (accepted by a university department) or an article (accepted by a journal). + + + 2002-07-13 + 2008-01-14 + + + + + + + + Date Copyrighted + Date of copyright. + + 2002-07-13 + 2008-01-14 + + + + + + + + Date Submitted + Date of submission of the resource. + Examples of resources to which a Date Submitted may be relevant are a + thesis (submitted to a university department) or an article (submitted to a journal). + + + 2002-07-13 + 2008-01-14 + + + + + + + + Audience Education Level + A class of entity, defined in terms of progression through an educational or + training context, for which the described resource is intended. + + + 2002-07-13 + 2008-01-14 + + + + + + + Access Rights + Information about who can access the resource or an indication of its security + status. + + Access Rights may include information regarding access or restrictions + based on privacy, security, or other policies. + + + 2003-02-15 + 2008-01-14 + + + + + + + + Bibliographic Citation + A bibliographic reference for the resource. + Recommended practice is to include sufficient bibliographic detail to + identify the resource as unambiguously as possible. + + + 2003-02-15 + 2008-01-14 + + + + + + + + + License + A legal document giving official permission to do something with the resource. + + + 2004-06-14 + 2008-01-14 + + + + + + + + Rights Holder + A person or organization owning or managing rights over the resource. + + + 2004-06-14 + 2008-01-14 + + + + + + Provenance + A statement of any changes in ownership and custody of the resource since its + creation that are significant for its authenticity, integrity, and interpretation. + + The statement may include a description of any changes successive + custodians made to the resource. + + + 2004-09-20 + 2008-01-14 + + + + + + Instructional Method + A process, used to engender knowledge, attitudes and skills, that the described + resource is designed to support. + + Instructional Method will typically include ways of presenting + instructional materials or conducting instructional activities, patterns of learner-to-learner and + learner-to-instructor interactions, and mechanisms by which group and individual levels of learning are + measured. Instructional methods include all aspects of the instruction and learning processes from planning + and implementation through evaluation and feedback. + + + 2005-06-13 + 2008-01-14 + + + + + + Accrual Method + The method by which items are added to a collection. + + 2005-06-13 + 2010-10-11 + + + + + + + Accrual Periodicity + The frequency with which items are added to a collection. + + 2005-06-13 + 2010-10-11 + + + + + + + Accrual Policy + The policy governing the addition of items to a collection. + + 2005-06-13 + 2010-10-11 + + + + + + + Agent + A resource that acts or has the power to act. + Examples of Agent include person, organization, and software agent. + + + 2008-01-14 + + + + + + Agent Class + A group of agents. + Examples of Agent Class include groups seen as classes, such as students, + women, charities, lecturers. + + + 2008-01-14 + + + + + + Bibliographic Resource + A book, article, or other documentary resource. + + 2008-01-14 + + + + + File Format + A digital resource format. + Examples include the formats defined by the list of Internet Media Types. + + + 2008-01-14 + + + + + + Frequency + A rate at which something recurs. + + 2008-01-14 + + + + + Jurisdiction + The extent or range of judicial, law enforcement, or other authority. + + + 2008-01-14 + + + + + + License Document + A legal document giving official permission to do something with a Resource. + + + 2008-01-14 + + + + + + Linguistic System + A system of signs, symbols, sounds, gestures, or rules used in communication. + + Examples include written, spoken, sign, and computer languages. + + + 2008-01-14 + + + + + Location + A spatial region or named place. + + 2008-01-14 + + + + + + Location, Period, or Jurisdiction + A location, period of time, or jurisdiction. + + 2008-01-14 + + + + + Media Type + A file format or physical medium. + + 2008-01-14 + + + + + + Media Type or Extent + A media type or extent. + + 2008-01-14 + + + + + Method of Instruction + A process that is used to engender knowledge, attitudes, and skills. + + + 2008-01-14 + + + + + Method of Accrual + A method by which resources are added to a collection. + + 2008-01-14 + + + + + Period of Time + An interval of time that is named or defined by its start and end dates. + + + 2008-01-14 + + + + + + Physical Medium + A physical material or carrier. + Examples include paper, canvas, or DVD. + + 2008-01-14 + + + + + + Physical Resource + A material thing. + + 2008-01-14 + + + + + Policy + A plan or course of action by an authority, intended to influence and determine + decisions, actions, and other matters. + + + 2008-01-14 + + + + + Provenance Statement + A statement of any changes in ownership and custody of a resource since its + creation that are significant for its authenticity, integrity, and interpretation. + + + 2008-01-14 + + + + + Rights Statement + A statement about the intellectual property rights (IPR) held in or over a + Resource, a legal document giving official permission to do something with a resource, or a statement about + access rights. + + + 2008-01-14 + + + + + Size or Duration + A dimension or extent, or a time taken to play or execute. + Examples include a number of pages, a specification of length, width, and + breadth, or a period in hours, minutes, and seconds. + + + 2008-01-14 + + + + + + Standard + A basis for comparison; a reference point against which other things can be + evaluated. + + + 2008-01-14 + + + + + ISO 639-2 + The three-letter alphabetic codes listed in ISO639-2 for the representation of + names of languages. + + + 2000-07-11 + 2008-01-14 + + + + + + RFC 1766 + The set of tags, constructed according to RFC 1766, for the identification of + languages. + + + 2000-07-11 + 2008-01-14 + + + + + + URI + The set of identifiers constructed according to the generic syntax for Uniform + Resource Identifiers as specified by the Internet Engineering Task Force. + + + 2000-07-11 + 2008-01-14 + + + + + + DCMI Point + The set of points in space defined by their geographic coordinates according to + the DCMI Point Encoding Scheme. + + + 2000-07-11 + 2008-01-14 + + + + + + ISO 3166 + The set of codes listed in ISO 3166-1 for the representation of names of + countries. + + + 2000-07-11 + 2008-01-14 + + + + + + DCMI Box + The set of regions in space defined by their geographic coordinates according to + the DCMI Box Encoding Scheme. + + + 2000-07-11 + 2008-01-14 + + + + + + DCMI Period + The set of time intervals defined by their limits according to the DCMI Period + Encoding Scheme. + + + 2000-07-11 + 2008-01-14 + + + + + + W3C-DTF + The set of dates and times constructed according to the W3C Date and Time Formats + Specification. + + + 2000-07-11 + 2008-01-14 + + + + + + RFC 3066 + The set of tags constructed according to RFC 3066 for the identification of + languages. + + RFC 3066 has been obsoleted by RFC 4646. + + 2002-07-13 + 2008-01-14 + + + + + + RFC 5646 + The set of tags constructed according to RFC 5646 for the identification of + languages. + + RFC 5646 obsoletes RFC 4646. + + 2010-10-11 + + + + + + RFC 4646 + The set of tags constructed according to RFC 4646 for the identification of + languages. + + RFC 4646 obsoletes RFC 3066. + + 2008-01-14 + + + + + + ISO 639-3 + The set of three-letter codes listed in ISO 639-3 for the representation of names + of languages. + + + 2008-01-14 + + + + + + LCSH + The set of labeled concepts specified by the Library of Congress Subject + Headings. + + + 2000-07-11 + 2008-01-14 + + + + + MeSH + The set of labeled concepts specified by the Medical Subject Headings. + + + 2000-07-11 + 2008-01-14 + + + + + + DDC + The set of conceptual resources specified by the Dewey Decimal Classification. + + + 2000-07-11 + 2008-01-14 + + + + + + LCC + The set of conceptual resources specified by the Library of Congress + Classification. + + + 2000-07-11 + 2008-01-14 + + + + + + UDC + The set of conceptual resources specified by the Universal Decimal + Classification. + + + 2000-07-11 + 2008-01-14 + + + + + + DCMI Type Vocabulary + The set of classes specified by the DCMI Type Vocabulary, used to categorize the + nature or genre of the resource. + + + 2000-07-11 + 2010-10-11 + + + + + + + IMT + The set of media types specified by the Internet Assigned Numbers Authority. + + + 2000-07-11 + 2008-01-14 + + + + + + TGN + The set of places specified by the Getty Thesaurus of Geographic Names. + + + 2000-07-11 + 2008-01-14 + + + + + + NLM + The set of conceptual resources specified by the National Library of Medicine + Classification. + + + 2005-06-13 + 2008-01-14 + + + + + \ No newline at end of file diff --git a/contract/src/test/resources/extraBlankNodes.owl b/contract/src/test/resources/extraBlankNodes.owl new file mode 100644 index 0000000000..6c29659b9b --- /dev/null +++ b/contract/src/test/resources/extraBlankNodes.owl @@ -0,0 +1,12 @@ +Prefix(xsd:=) +Prefix(owl:=) +Prefix(xml:=) +Prefix(rdf:=) +Prefix(rdfs:=) +Prefix(ex:=) + +Ontology( +ObjectPropertyAssertion(ex:hasName ex:john _:x) +DataPropertyAssertion(ex:givenName _:x "John"^^xsd:string) +DataPropertyAssertion(ex:familyName _:x "Doe"^^xsd:string) +) \ No newline at end of file diff --git a/contract/src/test/resources/importNoOntology/core.ttl b/contract/src/test/resources/importNoOntology/core.ttl new file mode 100644 index 0000000000..09dab1ff88 --- /dev/null +++ b/contract/src/test/resources/importNoOntology/core.ttl @@ -0,0 +1,29 @@ +# $Id: core.ttl,v 1.3 2014-02-19 16:36:06 eric Exp $ +# +# ericP at the keyboard + +@prefix rdfs: . +@prefix owl: . +@prefix xsd: . + +@prefix : . + +:hasDosagePlan a owl:ObjectProperty ; + rdfs:domain :MedicationAdministration ; + rdfs:range :DosagePlan . + +:DosagePlan rdfs:subClassOf [ owl:onProperty :hasMedicationSchedule ; owl:cardinality 1 ] . +:hasMedicationSchedule a owl:ObjectProperty ; + rdfs:domain :DosagePlan ; + rdfs:range :MedicationSchedule . + +:hasMedicationFrequency a owl:DatatypeProperty ; + rdfs:domain :Dosage ; + rdfs:range xsd:integer . +:hasMedicationDuration a owl:DatatypeProperty ; + rdfs:domain :Dosage ; + rdfs:range xsd:float . +:MedicationSchedule + rdfs:subClassOf + [ owl:onProperty :hasMedicationFrequency ; owl:cardinality 1 ] , + [ owl:onProperty :hasMedicationDuration ; owl:cardinality 1 ] . diff --git a/contract/src/test/resources/importNoOntology/subject-amy.ttl b/contract/src/test/resources/importNoOntology/subject-amy.ttl new file mode 100644 index 0000000000..8ecb04cf42 --- /dev/null +++ b/contract/src/test/resources/importNoOntology/subject-amy.ttl @@ -0,0 +1,15 @@ +# $Id: subject-amy.ttl,v 1.11 2014-02-19 16:39:26 eric Exp $ +# +# ericP at the keyboard + +@prefix : . +@prefix core: . +@prefix bridg: . + + a owl:Ontology ; + owl:imports . + +:subjectOnImmunosuppressantB + core:hasDosagePlan [ + core:hasMedicationSchedule [ core:hasMedicationFrequency 6 ; core:hasMedicationDuration 1.0 ] + ] . diff --git a/contract/src/test/resources/importNoOntology/subject-bob.ttl b/contract/src/test/resources/importNoOntology/subject-bob.ttl new file mode 100644 index 0000000000..f09cabdc9b --- /dev/null +++ b/contract/src/test/resources/importNoOntology/subject-bob.ttl @@ -0,0 +1,25 @@ +# $Id: subject-bob.ttl,v 1.12 2014-02-19 16:39:26 eric Exp $ +# +# ericP at the keyboard + +@prefix : . +@prefix core: . + + a owl:Ontology ; + owl:imports . + +:subjectOnImmunosuppressantA + core:hasDosagePlan [ + core:hasMedicationSchedule [ core:hasMedicationFrequency 1 ; core:hasMedicationDuration 1.0 ] + ] . + +:subjectOnImmunosuppressantA2 + core:hasDosagePlan [ + core:hasMedicationSchedule [ core:hasMedicationFrequency 1 ; core:hasMedicationDuration 1.0 ] + ] . + +:subjectOnImmunosuppressantA3 + core:hasDosagePlan [ + core:hasMedicationSchedule [ core:hasMedicationFrequency 1 ; core:hasMedicationDuration 1.0 ] + ] . + diff --git a/contract/src/test/resources/importNoOntology/subject-sue.ttl b/contract/src/test/resources/importNoOntology/subject-sue.ttl new file mode 100644 index 0000000000..f10911b8ab --- /dev/null +++ b/contract/src/test/resources/importNoOntology/subject-sue.ttl @@ -0,0 +1,21 @@ +# $Id: subject-sue.ttl,v 1.12 2014-02-19 16:39:26 eric Exp $ +# +# ericP at the keyboard + +@prefix : . +@prefix core: . +@prefix bridg: . + + a owl:Ontology ; + owl:imports . + +:subjectOnImmunosuppressantB + core:hasDosagePlan [ + core:hasMedicationSchedule [ core:hasMedicationFrequency 6 ; core:hasMedicationDuration 1.0 ] + ] . + +:subjectOnImmunosuppressantB2 + core:hasDosagePlan [ + core:hasMedicationSchedule [ core:hasMedicationFrequency 8 ; core:hasMedicationDuration 1.0 ] + ] . + diff --git a/contract/src/test/resources/importNoOntology/subjects.ttl b/contract/src/test/resources/importNoOntology/subjects.ttl new file mode 100644 index 0000000000..b9eb878542 --- /dev/null +++ b/contract/src/test/resources/importNoOntology/subjects.ttl @@ -0,0 +1,22 @@ +# $Id: subjects.ttl,v 1.2 2014-02-19 16:40:50 eric Exp $ +# +# ericP at the keyboard + +@prefix rdfs: . +@prefix owl: . +@prefix xsd: . + +@prefix amy: . +@prefix bob: . +@prefix sue: . + +@prefix : . + + a owl:Ontology ; + owl:imports , + , + . + +:doc :imported true . + +amy:doc :imported true . bob:doc :imported true . sue:doc :imported true . diff --git a/contract/src/test/resources/imports/A.owl b/contract/src/test/resources/imports/A.owl new file mode 100644 index 0000000000..6ef1b0de45 --- /dev/null +++ b/contract/src/test/resources/imports/A.owl @@ -0,0 +1,22 @@ + + + + + + + + +]> + + + + + + + diff --git a/contract/src/test/resources/imports/B.owl b/contract/src/test/resources/imports/B.owl new file mode 100644 index 0000000000..695c641fd6 --- /dev/null +++ b/contract/src/test/resources/imports/B.owl @@ -0,0 +1,24 @@ + + + + + + + +]> + + + + + + + + + + diff --git a/contract/src/test/resources/imports/C.owl b/contract/src/test/resources/imports/C.owl new file mode 100644 index 0000000000..d7203156c6 --- /dev/null +++ b/contract/src/test/resources/imports/C.owl @@ -0,0 +1,24 @@ + + + + + + + +]> + + + + + + + + + + \ No newline at end of file diff --git a/contract/src/test/resources/imports/D.owl b/contract/src/test/resources/imports/D.owl new file mode 100644 index 0000000000..02f028ca13 --- /dev/null +++ b/contract/src/test/resources/imports/D.owl @@ -0,0 +1,24 @@ + + + + + + + +]> + + + + + + + + + + diff --git a/contract/src/test/resources/imports/thesubont.omn b/contract/src/test/resources/imports/thesubont.omn new file mode 100644 index 0000000000..f8d7ad0359 --- /dev/null +++ b/contract/src/test/resources/imports/thesubont.omn @@ -0,0 +1,7 @@ +Prefix: : +Prefix: su: +Ontology: +Import: + +Class: Thesubclass + SubClassOf: su:Thesuperclass \ No newline at end of file diff --git a/contract/src/test/resources/imports/thesuperont.omn b/contract/src/test/resources/imports/thesuperont.omn new file mode 100644 index 0000000000..60f878a5e3 --- /dev/null +++ b/contract/src/test/resources/imports/thesuperont.omn @@ -0,0 +1,3 @@ +Ontology: + +Class: \ No newline at end of file diff --git a/contract/src/test/resources/importscyclic/A.owl b/contract/src/test/resources/importscyclic/A.owl new file mode 100644 index 0000000000..117db2330b --- /dev/null +++ b/contract/src/test/resources/importscyclic/A.owl @@ -0,0 +1,25 @@ + + + + + + + + +]> + + + + + + + + + diff --git a/contract/src/test/resources/importscyclic/B.owl b/contract/src/test/resources/importscyclic/B.owl new file mode 100644 index 0000000000..695c641fd6 --- /dev/null +++ b/contract/src/test/resources/importscyclic/B.owl @@ -0,0 +1,24 @@ + + + + + + + +]> + + + + + + + + + + diff --git a/contract/src/test/resources/importscyclic/C.owl b/contract/src/test/resources/importscyclic/C.owl new file mode 100644 index 0000000000..d7203156c6 --- /dev/null +++ b/contract/src/test/resources/importscyclic/C.owl @@ -0,0 +1,24 @@ + + + + + + + +]> + + + + + + + + + + \ No newline at end of file diff --git a/contract/src/test/resources/importscyclic/D.owl b/contract/src/test/resources/importscyclic/D.owl new file mode 100644 index 0000000000..0fbe2d1441 --- /dev/null +++ b/contract/src/test/resources/importscyclic/D.owl @@ -0,0 +1,24 @@ + + + + + + + +]> + + + + + + + + + + diff --git a/contract/src/test/resources/importscyclic/relaMath.owl b/contract/src/test/resources/importscyclic/relaMath.owl new file mode 100644 index 0000000000..d2a2ca9a6a --- /dev/null +++ b/contract/src/test/resources/importscyclic/relaMath.owl @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/contract/src/test/resources/importscyclic/reprMath.owl b/contract/src/test/resources/importscyclic/reprMath.owl new file mode 100644 index 0000000000..2b032020a4 --- /dev/null +++ b/contract/src/test/resources/importscyclic/reprMath.owl @@ -0,0 +1,132 @@ + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + 200 + 500 + + + + + + + + + + + + + 500 + + + + + + + + + + + + + + + 18 + + + + + + + + + + + + 6 + + + + + + + + + + 6 + + + + + + + + + 18 + + + + + + + + + 18 + + + + + + + + 22 + + + + + + + + 4 + + + + + + + + 1 + 3 + + + + + + \ No newline at end of file diff --git a/contract/src/test/resources/koala.jar b/contract/src/test/resources/koala.jar new file mode 100644 index 0000000000..7c8f48a4b5 Binary files /dev/null and b/contract/src/test/resources/koala.jar differ diff --git a/contract/src/test/resources/koala.owl b/contract/src/test/resources/koala.owl new file mode 100644 index 0000000000..923ea93c78 --- /dev/null +++ b/contract/src/test/resources/koala.owl @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + 1.2 + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + Male + + + + + + 1 + + + + + 1 + + + + + + 1.1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/contract/src/test/resources/noBaseEscapedSlashes.ttl b/contract/src/test/resources/noBaseEscapedSlashes.ttl new file mode 100644 index 0000000000..c2d18623b3 --- /dev/null +++ b/contract/src/test/resources/noBaseEscapedSlashes.ttl @@ -0,0 +1,28 @@ +@prefix obo: . +@prefix owl: . + +## Rio does not like this as base is not declared +obo:foo a