@@ -654,10 +654,22 @@ public <T extends OWLAxiom> Stream<T> axioms(AxiomType<T> axiomType, Imports imp
654
654
*/
655
655
@ Override
656
656
public Stream <OWLClassAxiom > axioms (OWLClass clazz ) {
657
- Stream <? extends OWLClassAxiom > subClassOf = base .listOWLSubClassOfAxiomsBySubject (clazz );
658
- Stream <? extends OWLClassAxiom > disjointUnion = base .listOWLDisjointUnionAxioms (clazz );
659
- Stream <? extends OWLClassAxiom > disjoint = base .listOWLDisjointClassesAxioms (clazz );
660
- Stream <? extends OWLClassAxiom > equivalent = base .listOWLEquivalentClassesAxioms (clazz );
657
+ return listOWLAxioms (base , clazz );
658
+ }
659
+
660
+ @ Override
661
+ public Stream <OWLClassAxiom > axioms (OWLClass clazz , Imports imports ) {
662
+ if (imports == Imports .INCLUDED && !config .useContentCache ()) {
663
+ return listOWLAxioms (getFullGraphModel (), clazz );
664
+ }
665
+ return imports .stream (this ).flatMap (o -> o .axioms (clazz ));
666
+ }
667
+
668
+ private static Stream <OWLClassAxiom > listOWLAxioms (InternalGraphModel model , OWLClass clazz ) {
669
+ Stream <? extends OWLClassAxiom > subClassOf = model .listOWLSubClassOfAxiomsBySubject (clazz );
670
+ Stream <? extends OWLClassAxiom > disjointUnion = model .listOWLDisjointUnionAxioms (clazz );
671
+ Stream <? extends OWLClassAxiom > disjoint = model .listOWLDisjointClassesAxioms (clazz );
672
+ Stream <? extends OWLClassAxiom > equivalent = model .listOWLEquivalentClassesAxioms (clazz );
661
673
return Stream .of (subClassOf , disjointUnion , disjoint , equivalent ).flatMap (Function .identity ());
662
674
}
663
675
@@ -674,28 +686,39 @@ public Stream<OWLClassAxiom> axioms(OWLClass clazz) {
674
686
* <li>7) Any property characteristic axiom (i.e. Functional, Symmetric, Reflexive etc.) whose subject is the specified property</li>
675
687
* <li>8) Inverse properties axioms that contain the specified property</li>
676
688
* </ul>
677
- * <b>Note: either condition *3* or OWL-API-5.1.4 implementation (owlapi-impl) are wrong as shown by tests.</b>
678
689
*
679
690
* @param property The property whose defining axioms are to be retrieved
680
691
* @return A {@code Stream} of object property axioms that describe the specified property
681
692
*/
682
693
@ Override
683
694
public Stream <OWLObjectPropertyAxiom > axioms (OWLObjectPropertyExpression property ) {
684
- Stream <? extends OWLObjectPropertyAxiom > subPropertyOf = base .listOWLSubObjectPropertyOfAxiomsBySubject (property );
695
+ return listOWLAxioms (base , property );
696
+ }
697
+
698
+ @ Override
699
+ public Stream <OWLObjectPropertyAxiom > axioms (OWLObjectPropertyExpression property , Imports imports ) {
700
+ if (imports == Imports .INCLUDED && !config .useContentCache ()) {
701
+ return listOWLAxioms (getFullGraphModel (), property );
702
+ }
703
+ return imports .stream (this ).flatMap (o -> o .axioms (property ));
704
+ }
705
+
706
+ private static Stream <OWLObjectPropertyAxiom > listOWLAxioms (InternalGraphModel model , OWLObjectPropertyExpression property ) {
707
+ Stream <? extends OWLObjectPropertyAxiom > subPropertyOf = model .listOWLSubObjectPropertyOfAxiomsBySubject (property );
685
708
Stream <? extends OWLObjectPropertyAxiom > nary = Stream .of (
686
- base .listOWLEquivalentObjectPropertiesAxioms (property ),
687
- base .listOWLDisjointObjectPropertiesAxioms (property ),
688
- base .listOWLInverseObjectPropertiesAxioms (property )).flatMap (Function .identity ());
709
+ model .listOWLEquivalentObjectPropertiesAxioms (property ),
710
+ model .listOWLDisjointObjectPropertiesAxioms (property ),
711
+ model .listOWLInverseObjectPropertiesAxioms (property )).flatMap (Function .identity ());
689
712
Stream <? extends OWLObjectPropertyAxiom > unary = Stream .of (
690
- base .listOWLObjectPropertyDomainAxioms (property ),
691
- base .listOWLObjectPropertyRangeAxioms (property ),
692
- base .listOWLTransitiveObjectPropertyAxioms (property ),
693
- base .listOWLIrreflexiveObjectPropertyAxioms (property ),
694
- base .listOWLReflexiveObjectPropertyAxioms (property ),
695
- base .listOWLSymmetricObjectPropertyAxioms (property ),
696
- base .listOWLAsymmetricObjectPropertyAxioms (property ),
697
- base .listOWLFunctionalObjectPropertyAxioms (property ),
698
- base .listOWLInverseFunctionalObjectPropertyAxioms (property )).flatMap (Function .identity ());
713
+ model .listOWLObjectPropertyDomainAxioms (property ),
714
+ model .listOWLObjectPropertyRangeAxioms (property ),
715
+ model .listOWLTransitiveObjectPropertyAxioms (property ),
716
+ model .listOWLIrreflexiveObjectPropertyAxioms (property ),
717
+ model .listOWLReflexiveObjectPropertyAxioms (property ),
718
+ model .listOWLSymmetricObjectPropertyAxioms (property ),
719
+ model .listOWLAsymmetricObjectPropertyAxioms (property ),
720
+ model .listOWLFunctionalObjectPropertyAxioms (property ),
721
+ model .listOWLInverseFunctionalObjectPropertyAxioms (property )).flatMap (Function .identity ());
699
722
return Stream .of (subPropertyOf , nary , unary ).flatMap (Function .identity ());
700
723
}
701
724
@@ -716,14 +739,26 @@ public Stream<OWLObjectPropertyAxiom> axioms(OWLObjectPropertyExpression propert
716
739
*/
717
740
@ Override
718
741
public Stream <OWLDataPropertyAxiom > axioms (OWLDataProperty property ) {
719
- Stream <? extends OWLDataPropertyAxiom > subPropertyOf = base .listOWLSubDataPropertyOfAxiomsBySubject (property );
742
+ return listOWLAxioms (base , property );
743
+ }
744
+
745
+ @ Override
746
+ public Stream <OWLDataPropertyAxiom > axioms (OWLDataProperty property , Imports imports ) {
747
+ if (imports == Imports .INCLUDED && !config .useContentCache ()) {
748
+ return listOWLAxioms (getFullGraphModel (), property );
749
+ }
750
+ return imports .stream (this ).flatMap (o -> o .axioms (property ));
751
+ }
752
+
753
+ private static Stream <OWLDataPropertyAxiom > listOWLAxioms (InternalGraphModel model , OWLDataProperty property ) {
754
+ Stream <? extends OWLDataPropertyAxiom > subPropertyOf = model .listOWLSubDataPropertyOfAxiomsBySubject (property );
720
755
Stream <? extends OWLDataPropertyAxiom > nary = Stream .of (
721
- base .listOWLEquivalentDataPropertiesAxioms (property ),
722
- base .listOWLDisjointDataPropertiesAxioms (property )).flatMap (Function .identity ());
756
+ model .listOWLEquivalentDataPropertiesAxioms (property ),
757
+ model .listOWLDisjointDataPropertiesAxioms (property )).flatMap (Function .identity ());
723
758
Stream <? extends OWLDataPropertyAxiom > unary = Stream .of (
724
- base .listOWLDataPropertyDomainAxioms (property ),
725
- base .listOWLDataPropertyRangeAxioms (property ),
726
- base .listOWLFunctionalDataPropertyAxioms (property )).flatMap (Function .identity ());
759
+ model .listOWLDataPropertyDomainAxioms (property ),
760
+ model .listOWLDataPropertyRangeAxioms (property ),
761
+ model .listOWLFunctionalDataPropertyAxioms (property )).flatMap (Function .identity ());
727
762
return Stream .of (subPropertyOf , nary , unary ).flatMap (Function .identity ());
728
763
}
729
764
@@ -741,10 +776,22 @@ public Stream<OWLDataPropertyAxiom> axioms(OWLDataProperty property) {
741
776
*/
742
777
@ Override
743
778
public Stream <OWLAnnotationAxiom > axioms (OWLAnnotationProperty property ) {
779
+ return listOWLAxioms (base , property );
780
+ }
781
+
782
+ @ Override
783
+ public Stream <OWLAnnotationAxiom > axioms (OWLAnnotationProperty property , Imports imports ) {
784
+ if (imports == Imports .INCLUDED && !config .useContentCache ()) {
785
+ return listOWLAxioms (getFullGraphModel (), property );
786
+ }
787
+ return imports .stream (this ).flatMap (o -> o .axioms (property ));
788
+ }
789
+
790
+ private static Stream <OWLAnnotationAxiom > listOWLAxioms (InternalGraphModel model , OWLAnnotationProperty property ) {
744
791
return Stream .of (
745
- base .listOWLSubAnnotationPropertyOfAxiomsBySubject (property ),
746
- base .listOWLAnnotationPropertyDomainAxioms (property ),
747
- base .listOWLAnnotationPropertyRangeAxioms (property )).flatMap (Function .identity ());
792
+ model .listOWLSubAnnotationPropertyOfAxiomsBySubject (property ),
793
+ model .listOWLAnnotationPropertyDomainAxioms (property ),
794
+ model .listOWLAnnotationPropertyRangeAxioms (property )).flatMap (Function .identity ());
748
795
}
749
796
750
797
/**
@@ -765,14 +812,26 @@ public Stream<OWLAnnotationAxiom> axioms(OWLAnnotationProperty property) {
765
812
*/
766
813
@ Override
767
814
public Stream <OWLIndividualAxiom > axioms (OWLIndividual individual ) {
768
- Stream <? extends OWLIndividualAxiom > classAssertion = base .listOWLClassAssertionAxioms (individual );
769
- Stream <? extends OWLIndividualAxiom > nary = Stream .concat (base .listOWLSameIndividualAxioms (individual ),
770
- base .listOWLDifferentIndividualsAxioms (individual ));
815
+ return listOWLAxioms (base , individual );
816
+ }
817
+
818
+ @ Override
819
+ public Stream <OWLIndividualAxiom > axioms (OWLIndividual individual , Imports imports ) {
820
+ if (imports == Imports .INCLUDED && !config .useContentCache ()) {
821
+ return listOWLAxioms (getFullGraphModel (), individual );
822
+ }
823
+ return imports .stream (this ).flatMap (o -> o .axioms (individual ));
824
+ }
825
+
826
+ private static Stream <OWLIndividualAxiom > listOWLAxioms (InternalGraphModel model , OWLIndividual individual ) {
827
+ Stream <? extends OWLIndividualAxiom > classAssertion = model .listOWLClassAssertionAxioms (individual );
828
+ Stream <? extends OWLIndividualAxiom > nary = Stream .concat (model .listOWLSameIndividualAxioms (individual ),
829
+ model .listOWLDifferentIndividualsAxioms (individual ));
771
830
Stream <? extends OWLIndividualAxiom > propertyAssertion = Stream .of (
772
- base .listOWLObjectPropertyAssertionAxioms (individual ),
773
- base .listOWLDataPropertyAssertionAxioms (individual ),
774
- base .listOWLNegativeObjectPropertyAssertionAxioms (individual ),
775
- base .listOWLNegativeDataPropertyAssertionAxioms (individual )).flatMap (Function .identity ());
831
+ model .listOWLObjectPropertyAssertionAxioms (individual ),
832
+ model .listOWLDataPropertyAssertionAxioms (individual ),
833
+ model .listOWLNegativeObjectPropertyAssertionAxioms (individual ),
834
+ model .listOWLNegativeDataPropertyAssertionAxioms (individual )).flatMap (Function .identity ());
776
835
return Stream .of (classAssertion , nary , propertyAssertion ).flatMap (Function .identity ());
777
836
}
778
837
@@ -781,6 +840,14 @@ public Stream<OWLDatatypeDefinitionAxiom> axioms(OWLDatatype datatype) {
781
840
return base .listOWLDatatypeDefinitionAxioms (datatype );
782
841
}
783
842
843
+ @ Override
844
+ public Stream <OWLDatatypeDefinitionAxiom > axioms (OWLDatatype datatype , Imports imports ) {
845
+ if (imports == Imports .INCLUDED && !config .useContentCache ()) {
846
+ return getFullGraphModel ().listOWLDatatypeDefinitionAxioms (datatype );
847
+ }
848
+ return imports .stream (this ).flatMap (o -> o .axioms (datatype ));
849
+ }
850
+
784
851
@ SuppressWarnings ("unchecked" )
785
852
@ Override
786
853
public <A extends OWLAxiom > Stream <A > axioms (OWLAxiomSearchFilter filter , Object key ) {
@@ -791,7 +858,7 @@ public <A extends OWLAxiom> Stream<A> axioms(OWLAxiomSearchFilter filter, Object
791
858
* The generic search method: results all axioms which refer the given object.
792
859
* This method may walk over the whole axiom cache in the {@link #base internal model} or read graph directly,
793
860
* as it sees fit.
794
- * Functionally it differs from the original OWL-API method: it can handle a wider class of cases.
861
+ * Functionally, it differs from the original OWL-API method: it can handle a wider class of cases.
795
862
* For internal usage only.
796
863
*
797
864
* @param type {@link Class Class<OWLAxiom>}, not null, type of axiom
0 commit comments