Skip to content

Commit

Permalink
Merge pull request #125 from carlos-schmidt/chore/use-federated-catal…
Browse files Browse the repository at this point in the history
…og-transformers

Chore: use federated catalog transformers
  • Loading branch information
carlos-schmidt authored Jul 18, 2024
2 parents 07cfcd9 + 04ab9e4 commit 3c35a49
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 239 deletions.
1 change: 1 addition & 0 deletions client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies {
implementation(project(":data-plane-aas"))

implementation("$group:connector-core:$edcVersion") // PolicyService
implementation("$group:federated-catalog-core:$edcVersion") // Transformers
implementation("$group:control-plane-contract:$edcVersion") // Observe contract negotiations
implementation("$group:control-plane-transform:$edcVersion") // Type transformers
implementation("$group:data-plane-http-spi:$edcVersion") // EDC HttpDataAddress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@
import de.fraunhofer.iosb.client.datatransfer.DataTransferController;
import de.fraunhofer.iosb.client.negotiation.NegotiationController;
import de.fraunhofer.iosb.client.policy.PolicyController;
import org.eclipse.edc.catalog.transform.JsonObjectToCatalogTransformer;
import org.eclipse.edc.catalog.transform.JsonObjectToDataServiceTransformer;
import org.eclipse.edc.catalog.transform.JsonObjectToDatasetTransformer;
import org.eclipse.edc.catalog.transform.JsonObjectToDistributionTransformer;
import org.eclipse.edc.connector.controlplane.contract.spi.negotiation.ConsumerContractNegotiationManager;
import org.eclipse.edc.connector.controlplane.contract.spi.negotiation.observe.ContractNegotiationObservable;
import org.eclipse.edc.connector.controlplane.contract.spi.negotiation.store.ContractNegotiationStore;
import org.eclipse.edc.connector.controlplane.services.spi.catalog.CatalogService;
import org.eclipse.edc.connector.controlplane.transfer.spi.TransferProcessManager;
import org.eclipse.edc.connector.controlplane.transform.odrl.OdrlTransformersFactory;
import org.eclipse.edc.connector.core.agent.NoOpParticipantIdMapper;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.spi.system.Hostname;
import org.eclipse.edc.spi.system.ServiceExtension;
Expand Down Expand Up @@ -58,6 +64,7 @@ public class ClientExtension implements ServiceExtension {
public void initialize(ServiceExtensionContext context) {
var monitor = context.getMonitor();
var config = context.getConfig("edc.client");
registerTransformers();

var negotiationController = new NegotiationController(
consumerNegotiationManager,
Expand Down Expand Up @@ -88,4 +95,16 @@ public void initialize(ServiceExtensionContext context) {
.build());
}

/*
* Re-activate transformers that were deleted in EDC after version 0.6.0
* Also activate other transformers needed for PolicyService but not registered in the right place
*/
private void registerTransformers() {
transformer.register(new JsonObjectToCatalogTransformer());
transformer.register(new JsonObjectToDatasetTransformer());
transformer.register(new JsonObjectToDataServiceTransformer());
transformer.register(new JsonObjectToDistributionTransformer());
OdrlTransformersFactory.jsonObjectToOdrlTransformers(new NoOpParticipantIdMapper())
.forEach(transformer::register);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,12 @@
package de.fraunhofer.iosb.client.policy;

import de.fraunhofer.iosb.client.exception.AmbiguousOrNullException;
import de.fraunhofer.iosb.client.policy.transform.JsonObjectToCatalogTransformer;
import de.fraunhofer.iosb.client.policy.transform.JsonObjectToDataServiceTransformer;
import de.fraunhofer.iosb.client.policy.transform.JsonObjectToDatasetTransformer;
import de.fraunhofer.iosb.client.policy.transform.JsonObjectToDistributionTransformer;
import jakarta.json.Json;
import org.eclipse.edc.connector.controlplane.asset.spi.domain.Asset;
import org.eclipse.edc.connector.controlplane.catalog.spi.Catalog;
import org.eclipse.edc.connector.controlplane.catalog.spi.Dataset;
import org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractOffer;
import org.eclipse.edc.connector.controlplane.services.spi.catalog.CatalogService;
import org.eclipse.edc.connector.controlplane.transform.odrl.OdrlTransformersFactory;
import org.eclipse.edc.connector.core.agent.NoOpParticipantIdMapper;
import org.eclipse.edc.jsonld.TitaniumJsonLd;
import org.eclipse.edc.jsonld.spi.JsonLd;
import org.eclipse.edc.policy.model.Policy;
Expand Down Expand Up @@ -84,10 +78,7 @@ class PolicyService {
this.transformer = transformer;
this.config = config;
this.policyDefinitionStore = policyDefinitionStore;

this.jsonLdExpander = new TitaniumJsonLd(monitor);

registerTransformers();
}

Dataset getDatasetForAssetId(@NotNull String counterPartyId, @NotNull URL counterPartyUrl, @NotNull String assetId) throws InterruptedException {
Expand Down Expand Up @@ -190,16 +181,4 @@ private <T extends Rule> boolean ruleEquality(T first, T second) {
second.getConstraints());
}

/* Re-activate transformers that were deleted in EDC after version 0.6.0
* Also activate other transformers needed for PolicyService but not registered in the right place
*/
private void registerTransformers() {
transformer.register(new JsonObjectToCatalogTransformer());
transformer.register(new JsonObjectToDatasetTransformer());
transformer.register(new JsonObjectToDataServiceTransformer());
transformer.register(new JsonObjectToDistributionTransformer());
OdrlTransformersFactory.jsonObjectToOdrlTransformers(new NoOpParticipantIdMapper())
.forEach(transformer::register);
}

}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 3c35a49

Please sign in to comment.