Skip to content

Commit

Permalink
refactor: move common transformers to transformer-core (eclipse-edc#3982
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ndr-brt authored Mar 8, 2024
1 parent 95d71be commit 50f4b31
Show file tree
Hide file tree
Showing 83 changed files with 173 additions and 209 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.protocol.dsp.catalog.transform.from;
package org.eclipse.edc.core.transform.transformer.dcat.from;

import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.json.JsonBuilderFactory;
Expand All @@ -30,7 +30,7 @@
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_CATALOG_TYPE;
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_DATASET_ATTRIBUTE;
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_DATA_SERVICE_ATTRIBUTE;
import static org.eclipse.edc.protocol.dsp.type.DspCatalogPropertyAndTypeNames.DSPACE_PROPERTY_PARTICIPANT_ID;
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DSPACE_PROPERTY_PARTICIPANT_ID;

/**
* Converts from a {@link Catalog} to a DCAT catalog as a {@link JsonObject} in JSON-LD expanded form.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.protocol.dsp.catalog.transform.from;
package org.eclipse.edc.core.transform.transformer.dcat.from;

import jakarta.json.JsonBuilderFactory;
import jakarta.json.JsonObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.protocol.dsp.catalog.transform.from;
package org.eclipse.edc.core.transform.transformer.dcat.from;

import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.json.Json;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.protocol.dsp.catalog.transform.from;
package org.eclipse.edc.core.transform.transformer.dcat.from;

import jakarta.json.JsonBuilderFactory;
import jakarta.json.JsonObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
*
*/

package org.eclipse.edc.core.transform.dspace;
package org.eclipse.edc.core.transform.transformer.dspace;

import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA;

/**
* Contains constants specifically intended for serializing a {@link org.eclipse.edc.spi.types.domain.DataAddress}
* to JSON-LD using the `dspace:` prefix format.
*/
public interface DspaceDataAddressSerialization {
public interface DataAddressDspaceSerialization {
String DSPACE_DATAADDRESS_TYPE = DSPACE_SCHEMA + "DataAddress";
String ENDPOINT_TYPE_PROPERTY = DSPACE_SCHEMA + "endpointType";
String ENDPOINT_PROPERTY = DSPACE_SCHEMA + "endpoint";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.dspace.from;
package org.eclipse.edc.core.transform.transformer.dspace.from;

import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.json.JsonBuilderFactory;
Expand All @@ -26,22 +26,22 @@

import java.util.Set;

import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.DSPACE_DATAADDRESS_TYPE;
import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTIES_PROPERTY;
import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_NAME_PROPERTY;
import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_PROPERTY_TYPE;
import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_VALUE_PROPERTY;
import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_TYPE_PROPERTY;
import static org.eclipse.edc.core.transform.transformer.dspace.DataAddressDspaceSerialization.DSPACE_DATAADDRESS_TYPE;
import static org.eclipse.edc.core.transform.transformer.dspace.DataAddressDspaceSerialization.ENDPOINT_PROPERTIES_PROPERTY;
import static org.eclipse.edc.core.transform.transformer.dspace.DataAddressDspaceSerialization.ENDPOINT_PROPERTY_NAME_PROPERTY;
import static org.eclipse.edc.core.transform.transformer.dspace.DataAddressDspaceSerialization.ENDPOINT_PROPERTY_PROPERTY_TYPE;
import static org.eclipse.edc.core.transform.transformer.dspace.DataAddressDspaceSerialization.ENDPOINT_PROPERTY_VALUE_PROPERTY;
import static org.eclipse.edc.core.transform.transformer.dspace.DataAddressDspaceSerialization.ENDPOINT_TYPE_PROPERTY;
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE;
import static org.eclipse.edc.spi.types.domain.DataAddress.EDC_DATA_ADDRESS_TYPE_PROPERTY;

public class JsonObjectFromDataAddressTransformer extends AbstractJsonLdTransformer<DataAddress, JsonObject> {
public class JsonObjectFromDataAddressDspaceTransformer extends AbstractJsonLdTransformer<DataAddress, JsonObject> {

private static final Set<String> EXCLUDED_PROPERTIES = Set.of(EDC_DATA_ADDRESS_TYPE_PROPERTY);
private final JsonBuilderFactory jsonFactory;
private final ObjectMapper mapper;

public JsonObjectFromDataAddressTransformer(JsonBuilderFactory jsonFactory, ObjectMapper mapper) {
public JsonObjectFromDataAddressDspaceTransformer(JsonBuilderFactory jsonFactory, ObjectMapper mapper) {
super(DataAddress.class, JsonObject.class);
this.jsonFactory = jsonFactory;
this.mapper = mapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.dspace.to;
package org.eclipse.edc.core.transform.transformer.dspace.to;

import jakarta.json.JsonArray;
import jakarta.json.JsonObject;
Expand All @@ -26,17 +26,17 @@
import java.util.function.Consumer;
import java.util.function.Function;

import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTIES_PROPERTY;
import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY;
import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_NAME_PROPERTY;
import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_VALUE_PROPERTY;
import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_TYPE_PROPERTY;
import static org.eclipse.edc.core.transform.transformer.dspace.DataAddressDspaceSerialization.ENDPOINT_PROPERTIES_PROPERTY;
import static org.eclipse.edc.core.transform.transformer.dspace.DataAddressDspaceSerialization.ENDPOINT_PROPERTY;
import static org.eclipse.edc.core.transform.transformer.dspace.DataAddressDspaceSerialization.ENDPOINT_PROPERTY_NAME_PROPERTY;
import static org.eclipse.edc.core.transform.transformer.dspace.DataAddressDspaceSerialization.ENDPOINT_PROPERTY_VALUE_PROPERTY;
import static org.eclipse.edc.core.transform.transformer.dspace.DataAddressDspaceSerialization.ENDPOINT_TYPE_PROPERTY;

/**
* Transforms a {@link JsonObject} into a DataAddress using the DSPACE-serialization format.
*/
public class JsonObjectToDataAddressTransformer extends AbstractJsonLdTransformer<JsonObject, DataAddress> {
public JsonObjectToDataAddressTransformer() {
public class JsonObjectToDataAddressDspaceTransformer extends AbstractJsonLdTransformer<JsonObject, DataAddress> {
public JsonObjectToDataAddressDspaceTransformer() {
super(JsonObject.class, DataAddress.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.transformer.from;
package org.eclipse.edc.core.transform.transformer.edc.from;

import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.json.JsonBuilderFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.transformer.from;
package org.eclipse.edc.core.transform.transformer.edc.from;

import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.json.JsonBuilderFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.transformer.from;
package org.eclipse.edc.core.transform.transformer.edc.from;

import jakarta.json.JsonBuilderFactory;
import jakarta.json.JsonObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.transformer.from;
package org.eclipse.edc.core.transform.transformer.edc.from;

import jakarta.json.JsonArrayBuilder;
import jakarta.json.JsonBuilderFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.transformer.to;
package org.eclipse.edc.core.transform.transformer.edc.to;

import jakarta.json.JsonObject;
import jakarta.json.JsonValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.transformer.to;
package org.eclipse.edc.core.transform.transformer.edc.to;

import jakarta.json.JsonArray;
import jakarta.json.JsonObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.transformer.to;
package org.eclipse.edc.core.transform.transformer.edc.to;

import jakarta.json.JsonObject;
import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.transformer.to;
package org.eclipse.edc.core.transform.transformer.edc.to;

import jakarta.json.JsonArray;
import jakarta.json.JsonObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.transformer.to;
package org.eclipse.edc.core.transform.transformer.edc.to;

import jakarta.json.JsonObject;
import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.transformer.to;
package org.eclipse.edc.core.transform.transformer.edc.to;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
*
*/

package org.eclipse.edc.core.transform.transformer;
package org.eclipse.edc.core.transform.transformer.odrl;

import org.eclipse.edc.core.transform.transformer.to.JsonObjectToActionTransformer;
import org.eclipse.edc.core.transform.transformer.to.JsonObjectToConstraintTransformer;
import org.eclipse.edc.core.transform.transformer.to.JsonObjectToDutyTransformer;
import org.eclipse.edc.core.transform.transformer.to.JsonObjectToOperatorTransformer;
import org.eclipse.edc.core.transform.transformer.to.JsonObjectToPermissionTransformer;
import org.eclipse.edc.core.transform.transformer.to.JsonObjectToPolicyTransformer;
import org.eclipse.edc.core.transform.transformer.to.JsonObjectToProhibitionTransformer;
import org.eclipse.edc.core.transform.transformer.edc.to.JsonObjectToActionTransformer;
import org.eclipse.edc.core.transform.transformer.odrl.to.JsonObjectToConstraintTransformer;
import org.eclipse.edc.core.transform.transformer.odrl.to.JsonObjectToDutyTransformer;
import org.eclipse.edc.core.transform.transformer.odrl.to.JsonObjectToOperatorTransformer;
import org.eclipse.edc.core.transform.transformer.odrl.to.JsonObjectToPermissionTransformer;
import org.eclipse.edc.core.transform.transformer.odrl.to.JsonObjectToPolicyTransformer;
import org.eclipse.edc.core.transform.transformer.odrl.to.JsonObjectToProhibitionTransformer;
import org.eclipse.edc.spi.agent.ParticipantIdMapper;
import org.eclipse.edc.transform.spi.TypeTransformer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.transformer.from;
package org.eclipse.edc.core.transform.transformer.odrl.from;

import jakarta.json.Json;
import jakarta.json.JsonArray;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.transformer.to;
package org.eclipse.edc.core.transform.transformer.odrl.to;

import jakarta.json.JsonNumber;
import jakarta.json.JsonObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.transformer.to;
package org.eclipse.edc.core.transform.transformer.odrl.to;

import jakarta.json.JsonObject;
import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.transformer.to;
package org.eclipse.edc.core.transform.transformer.odrl.to;

import jakarta.json.JsonObject;
import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.transformer.to;
package org.eclipse.edc.core.transform.transformer.odrl.to;

import jakarta.json.JsonObject;
import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.transformer.to;
package org.eclipse.edc.core.transform.transformer.odrl.to;

import jakarta.json.JsonObject;
import jakarta.json.JsonString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.transformer.to;
package org.eclipse.edc.core.transform.transformer.odrl.to;

import jakarta.json.JsonObject;
import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.protocol.dsp.catalog.transform.from;
package org.eclipse.edc.core.transform.transformer.dcat.from;

import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.json.Json;
Expand All @@ -39,7 +39,7 @@
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_CATALOG_TYPE;
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_DATASET_ATTRIBUTE;
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_DATA_SERVICE_ATTRIBUTE;
import static org.eclipse.edc.protocol.dsp.type.DspCatalogPropertyAndTypeNames.DSPACE_PROPERTY_PARTICIPANT_ID;
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DSPACE_PROPERTY_PARTICIPANT_ID;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.protocol.dsp.catalog.transform.from;
package org.eclipse.edc.core.transform.transformer.dcat.from;

import jakarta.json.Json;
import jakarta.json.JsonBuilderFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.protocol.dsp.catalog.transform.from;
package org.eclipse.edc.core.transform.transformer.dcat.from;

import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.json.Json;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.protocol.dsp.catalog.transform.from;
package org.eclipse.edc.core.transform.transformer.dcat.from;

import jakarta.json.Json;
import jakarta.json.JsonBuilderFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.core.transform.dspace.from;
package org.eclipse.edc.core.transform.transformer.dspace.from;

import jakarta.json.Json;
import org.eclipse.edc.jsonld.util.JacksonJsonLd;
Expand All @@ -23,16 +23,16 @@
import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTIES_PROPERTY;
import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY;
import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_NAME_PROPERTY;
import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_VALUE_PROPERTY;
import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_TYPE_PROPERTY;
import static org.eclipse.edc.core.transform.transformer.dspace.DataAddressDspaceSerialization.ENDPOINT_PROPERTIES_PROPERTY;
import static org.eclipse.edc.core.transform.transformer.dspace.DataAddressDspaceSerialization.ENDPOINT_PROPERTY;
import static org.eclipse.edc.core.transform.transformer.dspace.DataAddressDspaceSerialization.ENDPOINT_PROPERTY_NAME_PROPERTY;
import static org.eclipse.edc.core.transform.transformer.dspace.DataAddressDspaceSerialization.ENDPOINT_PROPERTY_VALUE_PROPERTY;
import static org.eclipse.edc.core.transform.transformer.dspace.DataAddressDspaceSerialization.ENDPOINT_TYPE_PROPERTY;
import static org.mockito.Mockito.mock;

class JsonObjectFromDataAddressTransformerTest {
class JsonObjectFromDataAddressDspaceTransformerTest {

private final JsonObjectFromDataAddressTransformer transformer = new JsonObjectFromDataAddressTransformer(
private final JsonObjectFromDataAddressDspaceTransformer transformer = new JsonObjectFromDataAddressDspaceTransformer(
Json.createBuilderFactory(Map.of()), JacksonJsonLd.createObjectMapper());
private final TransformerContext context = mock();

Expand Down
Loading

0 comments on commit 50f4b31

Please sign in to comment.