sovity / edc-ui

Connector UI for the sovity EDC Community Edition.
https://sovity.de/en/connect-to-data-space-en/
Apache License 2.0
32 stars 13 forks source link

Create New Asset - Additional Properties Attribute #545

Closed mpr13129 closed 9 months ago

mpr13129 commented 10 months ago

Description

To be honest, i can't understand how additional properties really work and what they are for. From the AssetMapperTest.java in connector backend, there is a test: test_buildAssetDto() that builds the asset from a json file (example-asset.jsonld) . There the additional properies are along with the rest properties.

richardtreier commented 10 months ago

There are fields additionalProperties and additionalJsonProperties in the UiAsset / UiAssetCreateRequest of our API: https://github.com/sovity/edc-extensions/blob/main/launchers/connectors/sovity-dev/src/test/java/de/sovity/edc/e2e/UiApiWrapperTest.java#L213

The key is that the JSON of assets properties was replaced by JSON-LD in the Eclipse EDC. All new custom properties will have to be URLs.

Starting points are JSON-LD and the V2 management API that is now in use.

richardtreier commented 9 months ago

I am closing the issue for now.

The trouble of dealing with JSON-LD is not small at all, as it is a format that needs to be semantically interpreted.

Unfortunately, we did not get to decide on this. Our own UI API handles all the semantic JSON-LD Mapping in the backend. We left the additionalProperties and additionalJsonProperties fields so if people want to both use our API Wrapper that tries to follow the DCAT standard, but also read or write other parts of the Asset JSON-LD.

To get closest to "just let me use JSON" would be something along the lines of

const customProperties = {
  "this-property": "should not be affected by JSON-LD compaction / expansion"
  "some-array": ["do not compact this"]
}

const asset: UiAsset = {
  assetId: 'my-asset',
  // [...]
  additionalProperties: {
    // Stored as string, because otherwise JSON-LD compaction and expansion 
    // or the requirement of URL properties would ruin the JSON
    'http://unknown/customPropertiesJson': JSON.stringify(customProperties)
  }
}

Which is wild, I admit.