Skip to content

Commit

Permalink
refactor: remove TransferProcess connectorId (#3625)
Browse files Browse the repository at this point in the history
* feat: add PrefixMonitor (#3510)

* refactor: remove connector id (#3396)

* fix: add missing "since"

* fix: add missing table name in drop column statement

* fix: remove connector id from tests

* refactor: add deprecated warning to swagger api

* fix: remove wrong change

* fix: remove connector_id from schema creation in schema.sql
  • Loading branch information
hamidonos authored Dec 6, 2023
1 parent bdd6a2a commit 924a977
Show file tree
Hide file tree
Showing 20 changed files with 14 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Microsoft Corporation - initial API and implementation
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - improvements
* SAP SE - refactoring
* Mercedes-Benz Tech Innovation GmbH - connector id removal
*
*/

Expand Down Expand Up @@ -130,7 +131,6 @@ public StatusResult<TransferProcess> initiateConsumerRequest(TransferRequest tra
var dataRequest = DataRequest.Builder.newInstance()
.id(id)
.assetId(transferRequest.getAssetId())
.connectorId(transferRequest.getConnectorId())
.dataDestination(transferRequest.getDataDestination())
.connectorAddress(transferRequest.getCounterPartyAddress())
.contractId(transferRequest.getContractId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ record TransferRequestSchema(
String connectorAddress,
@Schema(requiredMode = REQUIRED)
String counterPartyAddress,
@Schema(requiredMode = REQUIRED)
@Deprecated(since = "0.3.2")
@Schema(deprecated = true, description = "Provider connector id is stored in the contract agreement")
String connectorId,
@Schema(requiredMode = REQUIRED)
String contractId,
Expand All @@ -153,7 +154,6 @@ record TransferRequestSchema(
"@type": "https://w3id.org/edc/v0.0.1/ns/TransferRequest",
"protocol": "dataspace-protocol-http",
"counterPartyAddress": "http://provider-address",
"connectorId": "provider-id",
"contractId": "contract-id",
"assetId": "asset-id",
"dataDestination": {
Expand Down Expand Up @@ -203,7 +203,6 @@ record TransferProcessSchema(
"state": "STARTED",
"stateTimestamp": 1688465655,
"assetId": "asset-id",
"connectorId": "connectorId",
"contractId": "contractId",
"dataDestination": {
"type": "data-destination-type"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import static java.util.stream.Collectors.toList;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcess.TRANSFER_PROCESS_ASSET_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcess.TRANSFER_PROCESS_CALLBACK_ADDRESSES;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcess.TRANSFER_PROCESS_CONNECTOR_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcess.TRANSFER_PROCESS_CONTRACT_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcess.TRANSFER_PROCESS_CORRELATION_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcess.TRANSFER_PROCESS_DATA_DESTINATION;
Expand Down Expand Up @@ -70,7 +69,6 @@ public JsonObjectFromTransferProcessTransformer(JsonBuilderFactory builderFactor
.add(TRANSFER_PROCESS_CALLBACK_ADDRESSES, callbackAddresses)
.add(TRANSFER_PROCESS_DATA_DESTINATION, dataDestination);

Optional.ofNullable(input.getConnectorId()).ifPresent(it -> builder.add(TRANSFER_PROCESS_CONNECTOR_ID, it));
Optional.ofNullable(input.getErrorDetail()).ifPresent(it -> builder.add(TRANSFER_PROCESS_ERROR_DETAIL, it));

return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_ASSET_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_CALLBACK_ADDRESSES;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_CONNECTOR_ADDRESS;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_CONNECTOR_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_CONTRACT_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_COUNTER_PARTY_ADDRESS;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_DATA_DESTINATION;
Expand Down Expand Up @@ -68,7 +67,6 @@ public JsonObjectToTransferRequestTransformer() {
case TRANSFER_REQUEST_PRIVATE_PROPERTIES ->
(v) -> transformProperties(v, builder::privateProperties, context);
case TRANSFER_REQUEST_PROTOCOL -> (v) -> builder.protocol(transformString(v, context));
case TRANSFER_REQUEST_CONNECTOR_ID -> (v) -> builder.connectorId(transformString(v, context));
case TRANSFER_REQUEST_ASSET_ID -> (v) -> builder.assetId(transformString(v, context));
default -> doNothing();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import static java.lang.String.format;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_ASSET_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_CONNECTOR_ADDRESS;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_CONNECTOR_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_CONTRACT_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_COUNTER_PARTY_ADDRESS;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_DATA_DESTINATION;
Expand All @@ -43,7 +42,6 @@ public static Validator<JsonObject> instance(Monitor monitor) {
.verify(path -> new MandatoryCounterPartyAddressOrConnectorAddress(path, monitor))
.verify(TRANSFER_REQUEST_CONTRACT_ID, MandatoryValue::new)
.verify(TRANSFER_REQUEST_PROTOCOL, MandatoryValue::new)
.verify(TRANSFER_REQUEST_CONNECTOR_ID, MandatoryValue::new)
.verify(TRANSFER_REQUEST_ASSET_ID, MandatoryValue::new)
.verify(TRANSFER_REQUEST_DATA_DESTINATION, MandatoryObject::new)
.verifyObject(TRANSFER_REQUEST_DATA_DESTINATION, DataAddressValidator::instance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import static org.eclipse.edc.connector.api.management.transferprocess.model.TransferState.TRANSFER_STATE_TYPE;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcess.TRANSFER_PROCESS_ASSET_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcess.TRANSFER_PROCESS_CALLBACK_ADDRESSES;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcess.TRANSFER_PROCESS_CONNECTOR_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcess.TRANSFER_PROCESS_CONTRACT_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcess.TRANSFER_PROCESS_CORRELATION_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcess.TRANSFER_PROCESS_CREATED_AT;
Expand Down Expand Up @@ -94,7 +93,6 @@ void transferRequestExample() throws JsonProcessingException {
assertThat(transformed.getCounterPartyAddress()).isNotBlank();
assertThat(transformed.getContractId()).isNotBlank();
assertThat(transformed.getProtocol()).isNotBlank();
assertThat(transformed.getConnectorId()).isNotBlank();
assertThat(transformed.getAssetId()).isNotBlank();
assertThat(transformed.getDataDestination()).isNotNull();
assertThat(transformed.getPrivateProperties()).asInstanceOf(map(String.class, Object.class)).isNotEmpty();
Expand Down Expand Up @@ -130,7 +128,6 @@ void transferProcessExample() throws JsonProcessingException {
assertThat(content.getJsonArray(TRANSFER_PROCESS_STATE).getJsonObject(0).getString(VALUE)).isNotBlank();
assertThat(content.getJsonArray(TRANSFER_PROCESS_STATE_TIMESTAMP).getJsonObject(0).getJsonNumber(VALUE).longValue()).isGreaterThan(0);
assertThat(content.getJsonArray(TRANSFER_PROCESS_ASSET_ID).getJsonObject(0).getString(VALUE)).isNotBlank();
assertThat(content.getJsonArray(TRANSFER_PROCESS_CONNECTOR_ID).getJsonObject(0).getString(VALUE)).isNotBlank();
assertThat(content.getJsonArray(TRANSFER_PROCESS_CONTRACT_ID).getJsonObject(0).getString(VALUE)).isNotBlank();
assertThat(content.getJsonArray(TRANSFER_PROCESS_PRIVATE_PROPERTIES).getJsonObject(0)).asInstanceOf(map(String.class, Object.class)).isNotEmpty();
assertThat(content.getJsonArray(TRANSFER_PROCESS_TYPE_TYPE).getJsonObject(0).getString(VALUE)).isNotBlank();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcess.TRANSFER_PROCESS_ASSET_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcess.TRANSFER_PROCESS_CALLBACK_ADDRESSES;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcess.TRANSFER_PROCESS_CONNECTOR_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcess.TRANSFER_PROCESS_CONTRACT_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcess.TRANSFER_PROCESS_CORRELATION_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcess.TRANSFER_PROCESS_DATA_DESTINATION;
Expand Down Expand Up @@ -76,7 +75,6 @@ void transform() {
.id("correlationId")
.assetId("assetId")
.contractId("contractId")
.connectorId("connectorId")
.dataDestination(DataAddress.Builder.newInstance().type("any").properties(Map.of("bar", "foo")).build())
.build())
.callbackAddresses(List.of(CallbackAddress.Builder.newInstance().uri("http://any").events(emptySet()).build()))
Expand All @@ -93,7 +91,6 @@ void transform() {
assertThat(result.getJsonNumber(TRANSFER_PROCESS_STATE_TIMESTAMP).longValue()).isEqualTo(1234L);
assertThat(result.getString(TRANSFER_PROCESS_ASSET_ID)).isEqualTo("assetId");
assertThat(result.getString(TRANSFER_PROCESS_CONTRACT_ID)).isEqualTo("contractId");
assertThat(result.getString(TRANSFER_PROCESS_CONNECTOR_ID)).isEqualTo("connectorId");
assertThat(result.getString(TRANSFER_PROCESS_TYPE_TYPE)).isEqualTo(CONSUMER.toString());
assertThat(result.getJsonObject(TRANSFER_PROCESS_DATA_DESTINATION)).isSameAs(dataDestinationJson);
assertThat(result.getJsonArray(TRANSFER_PROCESS_CALLBACK_ADDRESSES).get(0)).isSameAs(callbackAddressJson);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_ASSET_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_CONNECTOR_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_CONTRACT_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_COUNTER_PARTY_ADDRESS;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_DATA_DESTINATION;
Expand Down Expand Up @@ -74,7 +73,6 @@ void transform() {
.add(TRANSFER_REQUEST_PROPERTIES, propertiesJson)
.add(TRANSFER_REQUEST_PRIVATE_PROPERTIES, privatePropertiesJson)
.add(TRANSFER_REQUEST_PROTOCOL, "protocol")
.add(TRANSFER_REQUEST_CONNECTOR_ID, "connectorId")
.add(TRANSFER_REQUEST_ASSET_ID, "assetId")
.build();

Expand All @@ -88,7 +86,6 @@ void transform() {
assertThat(result.getProperties()).containsAllEntriesOf(properties);
assertThat(result.getPrivateProperties()).containsAllEntriesOf(privateProperties);
assertThat(result.getProtocol()).isEqualTo("protocol");
assertThat(result.getConnectorId()).isEqualTo("connectorId");
assertThat(result.getAssetId()).isEqualTo("assetId");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import static org.assertj.core.api.InstanceOfAssertFactories.list;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_ASSET_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_CONNECTOR_ADDRESS;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_CONNECTOR_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_CONTRACT_ID;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_COUNTER_PARTY_ADDRESS;
import static org.eclipse.edc.connector.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_DATA_DESTINATION;
Expand All @@ -53,7 +52,6 @@ void shouldSucceed_whenObjectIsValid() {
.add(TRANSFER_REQUEST_COUNTER_PARTY_ADDRESS, value("http://connector-address"))
.add(TRANSFER_REQUEST_CONTRACT_ID, value("contract-id"))
.add(TRANSFER_REQUEST_PROTOCOL, value("protocol"))
.add(TRANSFER_REQUEST_CONNECTOR_ID, value("connectorId"))
.add(TRANSFER_REQUEST_ASSET_ID, value("assetId"))
.add(TRANSFER_REQUEST_DATA_DESTINATION, createArrayBuilder().add(createObjectBuilder()
.add(EDC_DATA_ADDRESS_TYPE_PROPERTY, value("type"))
Expand All @@ -71,7 +69,6 @@ void shouldSucceed_whenDeprecatedConnectorAddressIsUsed() {
.add(TRANSFER_REQUEST_CONNECTOR_ADDRESS, value("http://connector-address"))
.add(TRANSFER_REQUEST_CONTRACT_ID, value("contract-id"))
.add(TRANSFER_REQUEST_PROTOCOL, value("protocol"))
.add(TRANSFER_REQUEST_CONNECTOR_ID, value("connectorId"))
.add(TRANSFER_REQUEST_ASSET_ID, value("assetId"))
.add(TRANSFER_REQUEST_DATA_DESTINATION, createArrayBuilder().add(createObjectBuilder()
.add(EDC_DATA_ADDRESS_TYPE_PROPERTY, value("type"))
Expand Down Expand Up @@ -109,7 +106,6 @@ void shouldFail_whenMandatoryPropertiesAreMissing() {
.anySatisfy(violation -> assertThat(violation.path()).isEqualTo(TRANSFER_REQUEST_COUNTER_PARTY_ADDRESS))
.anySatisfy(violation -> assertThat(violation.path()).isEqualTo(TRANSFER_REQUEST_CONTRACT_ID))
.anySatisfy(violation -> assertThat(violation.path()).isEqualTo(TRANSFER_REQUEST_PROTOCOL))
.anySatisfy(violation -> assertThat(violation.path()).isEqualTo(TRANSFER_REQUEST_CONNECTOR_ID))
.anySatisfy(violation -> assertThat(violation.path()).isEqualTo(TRANSFER_REQUEST_ASSET_ID))
.anySatisfy(violation -> assertThat(violation.path()).isEqualTo(TRANSFER_REQUEST_DATA_DESTINATION));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ CREATE TABLE IF NOT EXISTS edc_data_request
process_id VARCHAR NOT NULL,
connector_address VARCHAR NOT NULL,
protocol VARCHAR NOT NULL,
connector_id VARCHAR,
asset_id VARCHAR NOT NULL,
contract_id VARCHAR NOT NULL,
data_destination JSON NOT NULL,
Expand All @@ -78,5 +77,4 @@ CREATE UNIQUE INDEX IF NOT EXISTS data_request_id_uindex
ON edc_data_request (datarequest_id);

CREATE UNIQUE INDEX IF NOT EXISTS lease_lease_id_uindex
ON edc_lease (lease_id);

ON edc_lease (lease_id);
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* Contributors:
* Microsoft Corporation - initial API and implementation
* Mercedes-Benz Tech Innovation GmbH - connector id removal
*
*/

Expand Down Expand Up @@ -215,7 +216,6 @@ private DataRequest mapDataRequest(ResultSet resultSet) throws SQLException {
.assetId(resultSet.getString(statements.getAssetIdColumn()))
.protocol(resultSet.getString(statements.getProtocolColumn()))
.dataDestination(fromJson(resultSet.getString(statements.getDataDestinationColumn()), DataAddress.class))
.connectorId(resultSet.getString(statements.getConnectorIdColumn()))
.connectorAddress(resultSet.getString(statements.getConnectorAddressColumn()))
.contractId(resultSet.getString(statements.getContractIdColumn()))
.processId(resultSet.getString(statements.getProcessIdColumn()))
Expand Down Expand Up @@ -268,7 +268,6 @@ private void updateDataRequest(Connection conn, DataRequest dataRequest, String
dataRequest.getProcessId(),
dataRequest.getConnectorAddress(),
dataRequest.getProtocol(),
dataRequest.getConnectorId(),
dataRequest.getAssetId(),
dataRequest.getContractId(),
toJson(dataRequest.getDataDestination()),
Expand Down Expand Up @@ -324,7 +323,6 @@ private void insertDataRequest(String processId, DataRequest dr, Connection conn
dr.getId(),
dr.getProcessId(),
dr.getConnectorAddress(),
dr.getConnectorId(),
dr.getAssetId(),
dr.getContractId(),
toJson(dr.getDataDestination()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* Contributors:
* Microsoft Corporation - initial API and implementation
* Mercedes-Benz Tech Innovation GmbH - connector id removal
*
*/

Expand Down Expand Up @@ -104,7 +105,6 @@ public String getInsertDataRequestTemplate() {
.column(getDataRequestIdColumn())
.column(getProcessIdColumn())
.column(getConnectorAddressColumn())
.column(getConnectorIdColumn())
.column(getAssetIdColumn())
.column(getContractIdColumn())
.jsonColumn(getDataDestinationColumn())
Expand All @@ -126,7 +126,6 @@ public String getUpdateDataRequestTemplate() {
.column(getProcessIdColumn())
.column(getConnectorAddressColumn())
.column(getProtocolColumn())
.column(getConnectorIdColumn())
.column(getAssetIdColumn())
.column(getContractIdColumn())
.jsonColumn(getDataDestinationColumn())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* Contributors:
* Microsoft Corporation - initial API and implementation
* Mercedes-Benz Tech Innovation GmbH - connector id removal
*
*/

Expand Down Expand Up @@ -70,10 +71,6 @@ default String getProtocolColumn() {
return "protocol";
}

default String getConnectorIdColumn() {
return "connector_id";
}

default String getConnectorAddressColumn() {
return "connector_address";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* Contributors:
* Microsoft Corporation - initial API and implementation
* Mercedes-Benz Tech Innovation GmbH - connector id removal
*
*/

Expand All @@ -29,7 +30,6 @@ class DataRequestMapping extends TranslationMapping {
private static final String FIELD_PROCESS_ID = "processId";
private static final String FIELD_CONNECTOR_ADDRESS = "connectorAddress";
private static final String FIELD_PROTOCOL = "protocol";
private static final String FIELD_CONNECTOR_ID = "connectorId";
private static final String FIELD_ASSET_ID = "assetId";
private static final String FIELD_CONTRACT_ID = "contractId";
private static final String FIELD_DATA_DESTINATION = "dataDestination";
Expand All @@ -40,7 +40,6 @@ class DataRequestMapping extends TranslationMapping {
add(FIELD_PROCESS_ID, statements.getProcessIdColumn());
add(FIELD_CONNECTOR_ADDRESS, statements.getConnectorAddressColumn());
add(FIELD_PROTOCOL, statements.getProtocolColumn());
add(FIELD_CONNECTOR_ID, statements.getConnectorIdColumn());
add(FIELD_ASSET_ID, statements.getAssetIdColumn());
add(FIELD_CONTRACT_ID, statements.getContractIdColumn());
add(FIELD_DATA_DESTINATION, new JsonFieldMapping(statements.getDataDestinationColumn()));
Expand Down
Loading

0 comments on commit 924a977

Please sign in to comment.