Skip to content

Commit

Permalink
fix(dsp): add missing and change wrong annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
juliapampus committed Apr 24, 2023
1 parent 0d1784e commit 8324384
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.eclipse.edc.jsonld.spi.transformer.JsonLdTransformerRegistry;
import org.eclipse.edc.protocol.dsp.catalog.transform.from.JsonObjectFromCatalogRequestMessageTransformer;
import org.eclipse.edc.protocol.dsp.catalog.transform.to.JsonObjectToCatalogRequestMessageTransformer;
import org.eclipse.edc.runtime.metamodel.annotation.Extension;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;
Expand All @@ -30,25 +31,26 @@
/**
* Provides the transformers for catalog message types via the {@link JsonLdTransformerRegistry}.
*/
@Extension(value = DspCatalogTransformExtension.NAME)
public class DspCatalogTransformExtension implements ServiceExtension {

public static final String NAME = "Dataspace Protocol Catalog Transform Extension";

@Inject
private TypeManager typeManager;
@Inject
private JsonLdTransformerRegistry registry;

@Override
public String name() {
return NAME;
}

@Override
public void initialize(ServiceExtensionContext context) {
var jsonFactory = Json.createBuilderFactory(Map.of());
var mapper = typeManager.getMapper(TYPE_MANAGER_CONTEXT_JSON_LD);

registry.register(new JsonObjectFromCatalogRequestMessageTransformer(jsonFactory, mapper));
registry.register(new JsonObjectToCatalogRequestMessageTransformer(mapper));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package org.eclipse.edc.protocol.dsp.transferprocess.transformer;

import jakarta.json.Json;
import org.eclipse.edc.jsonld.JsonLdExtension;
import org.eclipse.edc.jsonld.spi.transformer.JsonLdTransformerRegistry;
import org.eclipse.edc.protocol.dsp.transferprocess.transformer.type.from.JsonObjectFromDataAddressTransformer;
import org.eclipse.edc.protocol.dsp.transferprocess.transformer.type.from.JsonObjectFromTransferCompletionMessageTransformer;
Expand All @@ -37,7 +36,7 @@
/**
* Provides the transformers for transferprocess message types via the {@link JsonLdTransformerRegistry}.
*/
@Extension(value = JsonLdExtension.NAME)
@Extension(value = DspTransferProcessTransformExtension.NAME)
public class DspTransferProcessTransformExtension implements ServiceExtension {

public static final String NAME = "Dataspace Protocol Transfer Process Transform Extension";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.eclipse.edc.jsonld.transformer.to.JsonValueToGenericTypeTransformer;
import org.eclipse.edc.policy.model.AtomicConstraint;
import org.eclipse.edc.policy.model.LiteralExpression;
import org.eclipse.edc.runtime.metamodel.annotation.Extension;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;
Expand All @@ -47,35 +48,36 @@
* Provides support for transforming DCAT catalog and ODRL policy types to and from JSON-LD. The
* respective transformers are registered with the {@link JsonLdTransformerRegistry}.
*/
@Extension(value = DspTransformExtension.NAME)
public class DspTransformExtension implements ServiceExtension {

public static final String NAME = "Dataspace Protocol Transform Extension";

@Inject
private TypeManager typeManager;

@Inject
private JsonLdTransformerRegistry registry;

@Override
public String name() {
return NAME;
}

@Override
public void initialize(ServiceExtensionContext context) {
var mapper = typeManager.getMapper(TYPE_MANAGER_CONTEXT_JSON_LD);
mapper.registerSubtypes(AtomicConstraint.class, LiteralExpression.class);

var jsonBuilderFactory = Json.createBuilderFactory(Map.of());

// EDC model to JSON-LD transformers
registry.register(new JsonObjectFromCatalogTransformer(jsonBuilderFactory, mapper));
registry.register(new JsonObjectFromDatasetTransformer(jsonBuilderFactory, mapper));
registry.register(new JsonObjectFromPolicyTransformer(jsonBuilderFactory));
registry.register(new JsonObjectFromDistributionTransformer(jsonBuilderFactory));
registry.register(new JsonObjectFromDataServiceTransformer(jsonBuilderFactory));

// JSON-LD to EDC model transformers
registry.register(new JsonObjectToCatalogTransformer());
registry.register(new JsonObjectToDataServiceTransformer());
Expand Down

0 comments on commit 8324384

Please sign in to comment.