Skip to content

Commit 0771361

Browse files
authored
feat: adopt conformsTo from dct (#5780)
1 parent b1b7e77 commit 0771361

6 files changed

Lines changed: 43 additions & 9 deletions

File tree

core/common/lib/json-ld-lib/src/main/resources/document/dspace-edc-context-v1.jsonld

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"@context": {
33
"@version": 1.1,
44
"edc": "https://w3id.org/edc/v0.0.1/ns/",
5+
"dct": "http://purl.org/dc/terms/",
56
"QuerySpec": {
67
"@id": "edc:QuerySpec",
78
"@context": {
@@ -26,6 +27,10 @@
2627
"inForceDate": "edc:inForceDate",
2728
"id": "edc:id",
2829
"description": "edc:description",
29-
"isCatalog": "edc:isCatalog"
30+
"isCatalog": "edc:isCatalog",
31+
"conformsTo": {
32+
"@id": "dct:conformsTo",
33+
"@type": "@id"
34+
}
3035
}
3136
}

core/common/lib/json-ld-lib/src/main/resources/document/management-context-v2.jsonld

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22
"@context": {
33
"@version": 1.1,
44
"edc": "https://w3id.org/edc/v0.0.1/ns/",
5+
"dct": "http://purl.org/dc/terms/",
56
"Asset": {
67
"@id": "edc:Asset",
78
"@context": {
89
"properties": {
910
"@id": "edc:properties",
1011
"@context": {
11-
"@vocab": "https://w3id.org/edc/v0.0.1/ns/"
12+
"@vocab": "https://w3id.org/edc/v0.0.1/ns/",
13+
"conformsTo": {
14+
"@id": "dct:conformsTo",
15+
"@type": "@id"
16+
}
1217
}
1318
},
1419
"privateProperties": {

extensions/common/api/management-api-schema-validator/src/main/resources/schema/management/v4/asset-schema.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,20 @@
2424
},
2525
"properties": {
2626
"type": "object",
27-
"example": { "key": "value" }
27+
"example": {
28+
"key": "value"
29+
},
30+
"properties": {
31+
"conformsTo": {
32+
"type": "string"
33+
}
34+
}
2835
},
2936
"privateProperties": {
3037
"type": "object",
31-
"example": { "privateKey": "privateValue" }
38+
"example": {
39+
"privateKey": "privateValue"
40+
}
3241
},
3342
"dataplaneMetadata": {
3443
"$ref": "https://w3id.org/edc/connector/management/schema/v4/dataplane-metadata-schema.json"

spi/common/json-ld-spi/src/main/java/org/eclipse/edc/jsonld/spi/PropertyAndTypeNames.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public interface PropertyAndTypeNames {
4141

4242
//DCT
4343
String DCT_FORMAT_ATTRIBUTE = DCT_SCHEMA + "format";
44+
String DCT_CONFORMS_TO_ATTRIBUTE = DCT_SCHEMA + "conformsTo";
4445

4546
String ODRL_POLICY_ATTRIBUTE = ODRL_SCHEMA + "hasPolicy";
4647
String ODRL_POLICY_TYPE_SET = ODRL_SCHEMA + "Set";

system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/v5/AssetApiV5EndToEndTest.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID;
5252
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE;
5353
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.VALUE;
54+
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCT_CONFORMS_TO_ATTRIBUTE;
5455
import static org.eclipse.edc.spi.constants.CoreConstants.EDC_CONNECTOR_MANAGEMENT_CONTEXT_V2;
5556
import static org.eclipse.edc.spi.constants.CoreConstants.EDC_NAMESPACE;
5657
import static org.eclipse.edc.spi.query.Criterion.criterion;
@@ -407,7 +408,10 @@ void createAsset_shouldBeStored(ManagementEndToEndV5TestContext context, AssetIn
407408
.add(CONTEXT, jsonLdContext())
408409
.add(TYPE, "Asset")
409410
.add(ID, id)
410-
.add("properties", createPropertiesBuilder().add("isCatalog", "true").build())
411+
.add("properties", createPropertiesBuilder()
412+
.add("isCatalog", "true")
413+
.add("conformsTo", "http://example.com/spec")
414+
.build())
411415
.add("privateProperties", createObjectBuilder()
412416
.add("anotherProp", "anotherVal")
413417
.build())
@@ -435,6 +439,8 @@ void createAsset_shouldBeStored(ManagementEndToEndV5TestContext context, AssetIn
435439
var asset = assetIndex.findById(id);
436440
assertThat(asset).isNotNull();
437441
assertThat(asset.isCatalog()).isTrue();
442+
assertThat(asset.getProperty(DCT_CONFORMS_TO_ATTRIBUTE)).isEqualTo(Map.of(ID, "http://example.com/spec"));
443+
438444
assertThat(asset.getPrivateProperty(EDC_NAMESPACE + "anotherProp")).isEqualTo("anotherVal");
439445
assertThat(asset.getDataAddress().getProperty("complex"))
440446
.asInstanceOf(MAP)
@@ -705,6 +711,7 @@ void findById(ManagementEndToEndV5TestContext context, AssetIndex assetIndex) {
705711

706712
var id = UUID.randomUUID().toString();
707713
var asset = createAsset().id(id)
714+
.property(DCT_CONFORMS_TO_ATTRIBUTE, Map.of(ID, "http://example.com/spec"))
708715
.dataAddress(createDataAddress().type("addressType").build())
709716
.build();
710717
assetIndex.create(asset);
@@ -719,8 +726,9 @@ void findById(ManagementEndToEndV5TestContext context, AssetIndex assetIndex) {
719726
assertThat(body).isNotNull();
720727
assertThat(body.getString(ID)).isEqualTo(id);
721728
assertThat(body.getMap("properties"))
722-
.hasSize(2)
723-
.containsEntry("description", "test description");
729+
.hasSize(3)
730+
.containsEntry("description", "test description")
731+
.containsEntry("conformsTo", "http://example.com/spec");
724732
assertThat(body.getMap("'dataAddress'"))
725733
.containsEntry("type", "addressType");
726734
assertThat(body.getMap("'dataAddress'.'complex'"))

system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/v5/CatalogApiV5EndToEndTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.CONTEXT;
6060
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID;
6161
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE;
62+
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCT_CONFORMS_TO_ATTRIBUTE;
6263
import static org.eclipse.edc.spi.constants.CoreConstants.EDC_CONNECTOR_MANAGEMENT_CONTEXT_V2;
6364
import static org.eclipse.edc.spi.constants.CoreConstants.EDC_NAMESPACE;
6465
import static org.hamcrest.CoreMatchers.containsString;
@@ -222,7 +223,11 @@ void requestCatalog_shouldReturnCatalog_withQuerySpec(ManagementEndToEndV5TestCo
222223
ContractDefinitionStore contractDefinitionStore) {
223224

224225
assetIndex.create(createAsset("id-1", "test-type").build());
225-
assetIndex.create(createAsset("id-2", "test-type").build());
226+
227+
var asset2 = createAsset("id-2", "test-type")
228+
.property(DCT_CONFORMS_TO_ATTRIBUTE, Map.of(ID, "https://example.org/schema")).build();
229+
230+
assetIndex.create(asset2);
226231
createContractOffer(policyDefinitionStore, contractDefinitionStore, List.of());
227232

228233
var criteria = createArrayBuilder()
@@ -258,7 +263,8 @@ void requestCatalog_shouldReturnCatalog_withQuerySpec(ManagementEndToEndV5TestCo
258263
.statusCode(200)
259264
.contentType(JSON)
260265
.body(TYPE, is("Catalog"))
261-
.body("dataset[0].id", is("id-2"));
266+
.body("dataset[0].id", is("id-2"))
267+
.body("dataset[0].conformsTo", is("https://example.org/schema"));
262268
}
263269

264270
@Test

0 commit comments

Comments
 (0)