diff --git a/src/sparnatural/generators/sparql/ClassBuilder.ts b/src/sparnatural/generators/sparql/ClassBuilder.ts index 043c3c3e..1c05a33f 100644 --- a/src/sparnatural/generators/sparql/ClassBuilder.ts +++ b/src/sparnatural/generators/sparql/ClassBuilder.ts @@ -5,6 +5,8 @@ import StartClassGroup from "../../components/builder-section/groupwrapper/crite import { getSettings } from "../../settings/defaultSettings"; import ISparnaturalSpecification from "../../spec-providers/ISparnaturalSpecification"; import SparqlFactory from "./SparqlFactory"; +import { RDFS } from '../../spec-providers/BaseRDFReader'; +import { OWL } from '../../spec-providers/owl/OWLSpecificationProvider'; const factory = new DataFactory(); @@ -64,7 +66,7 @@ export default class ClassBuilder { } #buildClsTriple(){ - // don't build the class triple if the entity does not hove type + // don't build the class triple if the entity does not have type if(this.specProvider.getEntity(this.classGroup.getTypeSelected()).hasTypeCriteria()) { var typePredicate; if(getSettings().typePredicate){ @@ -73,11 +75,19 @@ export default class ClassBuilder { typePredicate = factory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type") } - this.classTriple = SparqlFactory.buildTypeTriple( - factory.variable(this.classGroup.getVarName()?.replace('?','')) , - typePredicate, - factory.namedNode(this.classGroup.getTypeSelected()) - ) + // don't add the type if the range is rdfs:Resource or owl:Thing + if( + (this.classGroup.getTypeSelected() != RDFS.RESOURCE.value) + && + (this.classGroup.getTypeSelected() != OWL.THING.value) + ) { + this.classTriple = SparqlFactory.buildTypeTriple( + factory.variable(this.classGroup.getVarName()?.replace('?','')) , + typePredicate, + factory.namedNode(this.classGroup.getTypeSelected()) + ) + } + } } diff --git a/src/sparnatural/spec-providers/BaseRDFReader.ts b/src/sparnatural/spec-providers/BaseRDFReader.ts index 6f29d4b1..99efc449 100644 --- a/src/sparnatural/spec-providers/BaseRDFReader.ts +++ b/src/sparnatural/spec-providers/BaseRDFReader.ts @@ -24,9 +24,8 @@ export const RDFS = { COMMENT: factory.namedNode(RDFS_NAMESPACE + "comment") as NamedNode, DOMAIN: factory.namedNode(RDFS_NAMESPACE + "domain") as NamedNode, RANGE: factory.namedNode(RDFS_NAMESPACE + "range") as NamedNode, - SUBPROPERTY_OF: factory.namedNode( - RDFS_NAMESPACE + "subPropertyOf" - ) as NamedNode, + RESOURCE: factory.namedNode(RDFS_NAMESPACE + "Resource") as NamedNode, + SUBPROPERTY_OF: factory.namedNode(RDFS_NAMESPACE + "subPropertyOf") as NamedNode, SUBCLASS_OF: factory.namedNode(RDFS_NAMESPACE + "subClassOf") as NamedNode, }; diff --git a/src/sparnatural/spec-providers/owl/OWLSpecificationProvider.ts b/src/sparnatural/spec-providers/owl/OWLSpecificationProvider.ts index 3ed21190..40f247a1 100644 --- a/src/sparnatural/spec-providers/owl/OWLSpecificationProvider.ts +++ b/src/sparnatural/spec-providers/owl/OWLSpecificationProvider.ts @@ -20,12 +20,9 @@ const factory = new DataFactory(); const OWL_NAMESPACE = "http://www.w3.org/2002/07/owl#"; export const OWL = { - EQUIVALENT_PROPERTY: factory.namedNode( - OWL_NAMESPACE + "equivalentProperty" - ) as NamedNode, - EQUIVALENT_CLASS: factory.namedNode( - OWL_NAMESPACE + "equivalentClass" - ) as NamedNode, + THING: factory.namedNode(OWL_NAMESPACE + "Thing") as NamedNode, + EQUIVALENT_PROPERTY: factory.namedNode(OWL_NAMESPACE + "equivalentProperty") as NamedNode, + EQUIVALENT_CLASS: factory.namedNode(OWL_NAMESPACE + "equivalentClass") as NamedNode, UNION_OF: factory.namedNode(OWL_NAMESPACE + "unionOf") as NamedNode }; diff --git a/src/sparnatural/spec-providers/shacl/SHACLSpecificationProperty.ts b/src/sparnatural/spec-providers/shacl/SHACLSpecificationProperty.ts index e15b4ab6..cb96ced8 100644 --- a/src/sparnatural/spec-providers/shacl/SHACLSpecificationProperty.ts +++ b/src/sparnatural/spec-providers/shacl/SHACLSpecificationProperty.ts @@ -11,7 +11,6 @@ import ISHACLSpecificationEntity from "./ISHACLSpecificationEntity"; import { RdfStore } from "rdf-stores"; import { Quad, Quad_Subject, Term } from "@rdfjs/types/data-model"; import { StoreModel } from "../StoreModel"; -import { OWL } from "../owl/OWLSpecificationProvider"; import { StatisticsReader } from "../StatisticsReader"; const factory = new DataFactory();