From 94c146e112e69fd2a3fca4c582c443a4041b318d Mon Sep 17 00:00:00 2001 From: Andreas Meier Date: Mon, 30 Mar 2026 07:57:27 +0200 Subject: [PATCH] Fix name of property class --- .../ch/ethz/sis/rocrate/SchemaFacade.java | 59 +++++++++---------- 0.2.x/schema.shacl | 12 ++-- 0.2.x/spec.md | 2 +- 3 files changed, 35 insertions(+), 38 deletions(-) diff --git a/0.2.x/lib/java/src/java/ch/ethz/sis/rocrate/SchemaFacade.java b/0.2.x/lib/java/src/java/ch/ethz/sis/rocrate/SchemaFacade.java index 6a1637f..0554328 100644 --- a/0.2.x/lib/java/src/java/ch/ethz/sis/rocrate/SchemaFacade.java +++ b/0.2.x/lib/java/src/java/ch/ethz/sis/rocrate/SchemaFacade.java @@ -20,7 +20,7 @@ public class SchemaFacade implements ISchemaFacade private final static String RDFS_CLASS = "rdfs:Class"; - private final static String RDFS_PROPERTY = "rdfs:Property"; + private final static String RDF_PROPERTY = "rdf:Property"; public static final String EQUIVALENT_CLASS = "owl:equivalentClass"; @@ -153,7 +153,7 @@ public class SchemaFacade implements ISchemaFacade DataEntity.DataEntityBuilder builder = new DataEntity.DataEntityBuilder(); builder.setId(rdfsProperty.getId()); - builder.addProperty("@type", RDFS_PROPERTY); + builder.addProperty("@type", RDF_PROPERTY); builder.addProperty(RDFS_LABEL, rdfsProperty.getLabel()); builder.addProperty(RDFS_COMMENT, rdfsProperty.getComment()); @@ -321,44 +321,41 @@ public class SchemaFacade implements ISchemaFacade entity.getProperty("@id") .asText(); - switch (type) - { - case "rdfs:Property" -> - { - PropertyType rdfsProperty = new PropertyType(); - rdfsProperty.setId(resolvePrefixSingleValue(id)); + if (type.equals(RDF_PROPERTY) || type.equals("rdfs:Property")) + { + PropertyType rdfsProperty = new PropertyType(); + rdfsProperty.setId(resolvePrefixSingleValue(id)); - rdfsProperty.setOntologicalAnnotations( - parseMultiValued(entity, EQUIVALENT_CONCEPT)); + rdfsProperty.setOntologicalAnnotations( + parseMultiValued(entity, EQUIVALENT_CONCEPT)); - List rawRange = parseMultiValued(entity, rangeIdentifier); + List rawRange = parseMultiValued(entity, rangeIdentifier); - List dataTypes = rawRange.stream() - .filter(LiteralType::isLiteralType) - .map(LiteralType::getByTypeName) - .filter(Objects::nonNull) - .collect(Collectors.toList()); - List types = rawRange.stream() - .filter(x -> !LiteralType.isLiteralType(x)) - .map(this::resolvePrefixSingleValue) - .map(classes::get) - .collect(Collectors.toList()); + List dataTypes = rawRange.stream() + .filter(LiteralType::isLiteralType) + .map(LiteralType::getByTypeName) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + List types = rawRange.stream() + .filter(x -> !LiteralType.isLiteralType(x)) + .map(this::resolvePrefixSingleValue) + .map(classes::get) + .collect(Collectors.toList()); - dataTypes.stream().forEach(rdfsProperty::addDataType); - types.forEach(rdfsProperty::addType); + dataTypes.stream().forEach(rdfsProperty::addDataType); + types.forEach(rdfsProperty::addType); - rdfsProperty.setDomainIncludes( - parseMultiValued(entity, domainIdentifier).stream() - .map(x -> resolvePrefixSingleValue(x)) - .map(classes::get).collect( - Collectors.toList())); - properties.put(resolvePrefixSingleValue(id), rdfsProperty); + rdfsProperty.setDomainIncludes( + parseMultiValued(entity, domainIdentifier).stream() + .map(x -> resolvePrefixSingleValue(x)) + .map(classes::get).collect( + Collectors.toList())); + properties.put(resolvePrefixSingleValue(id), rdfsProperty); - } } - } + for (DataEntity entity : crate.getAllDataEntities()) { String type = entity.getProperty("@type").asText(); diff --git a/0.2.x/schema.shacl b/0.2.x/schema.shacl index 774159f..66b0f7b 100644 --- a/0.2.x/schema.shacl +++ b/0.2.x/schema.shacl @@ -17,12 +17,12 @@ ex:TypeMustBeClassShape sh:property [ sh:path rdf:type ; sh:or ( - [ sh:in (rdfs:Class owl:restriction rdfs:Property schema:Dataset schema:CreativeWork ) ] # Case 1: type is exactly rdfs:Class + [ sh:in (rdfs:Class owl:restriction rdf:Property schema:Dataset schema:CreativeWork ) ] # Case 1: type is exactly rdfs:Class [ sh:class rdfs:Class ] # Case 2: type is a node of type rdfs:Class ) ; #sh:nodeKind sh:IRI ; sh:minCount 1 ; - sh:message "type should be either rdfs:Class or owl:restriction or rdfs:Property or a valid reference to a rdfs:Class or " + sh:message "type should be either rdfs:Class or owl:restriction or rdf:Property or a valid reference to a rdfs:Class or " ] . @@ -59,13 +59,13 @@ ex:ClassDefinitionShape a sh:NodeShape ; #Check the shape of "owl:restriction" ex:OwlRestrictionDefinitionShape a sh:NodeShape; sh:targetClass owl:restriction ; - #owl:onProperty should reference a valid rdfs:Property + #owl:onProperty should reference a valid rdf:Property sh:property [ sh:path owl:onProperty; sh:maxCount 1; sh:minCount 1; sh:nodeKind sh:IRI; - sh:class rdfs:Property ; + sh:class rdf:Property ; ] ; sh:property [ sh:path owl:minCardinality ; @@ -81,7 +81,7 @@ ex:OwlRestrictionDefinitionShape a sh:NodeShape; ] . ex:PropertyDefinitionShape a sh:NodeShape ; - sh:targetClass rdfs:Property ; + sh:targetClass rdf:Property ; #sh:closed true; #sh:ignoredProperties (rdf:type) ; sh:property [ @@ -97,7 +97,7 @@ ex:PropertyDefinitionShape a sh:NodeShape ; sh:path owl:equivalentProperty ; sh:minCount 0 ; sh:nodeKind sh:IRI ; - #sh:class rdfs:Property ; + #sh:class rdf:Property ; ] ; sh:property [ sh:path schema:domainIncludes ; diff --git a/0.2.x/spec.md b/0.2.x/spec.md index f8572a4..8daf527 100644 --- a/0.2.x/spec.md +++ b/0.2.x/spec.md @@ -165,7 +165,7 @@ They also specify, which classes they can interact with. | Type/Property | Required? | Description | |------------------------|-----------|---------------------------------------------------------------------------------------------------------| | @id | MUST | ID of the entry | -| @type | MUST | Is `rdfs:Property` | +| @type | MUST | Is `rdf:Property` | | owl:equivalentProperty | MAY | Ontological annotation https://www.w3.org/TR/owl-ref/#equivalentClass-def | | schema:domainIncludes | MUST | Describes the possible types of the subject. This can be one or many. | | schema:rangeIncludes | MUST | Describes the possible types of the object. This can be one or many. |