From ec2dfb3a6b6796d787e7cdd8d32ae8cbbbba98ce Mon Sep 17 00:00:00 2001 From: ChetanT-System Date: Fri, 29 Mar 2024 14:07:00 +0530 Subject: [PATCH 1/4] - edc update asset changes and pcf schema updated --- CHANGELOG.md | 1 + .../EDCAspectRelationshipHandlerUseCase.java | 54 +++++++--------- .../batch/steps/EDCBatchHandlerUseCase.java | 26 ++++++-- .../steps/EDCPartAsPlannedHandlerStep.java | 47 ++++---------- ...rtSiteInformationAsPlannedHandlerStep.java | 47 ++++---------- .../sde/submodels/pcf/entity/PcfEntity.java | 1 + .../sde/submodels/pcf/mapper/PcfMapper.java | 9 +-- .../tractusx/sde/submodels/pcf/model/Pcf.java | 1 + .../sde/submodels/pcf/model/PcfAspect.java | 2 - .../pcf/model/PcfSubmodelResponse.java | 4 +- .../sde/submodels/pcf/service/PcfService.java | 9 +++ .../pcf/steps/EDCPcfHandlerUseCase.java | 62 ++++++++----------- .../pcf/src/main/resources/pcf.json | 32 +++++++--- .../spt/steps/EDCAspectHandlerUseCase.java | 45 ++++---------- ...EDCSingleLevelBoMAsPlannedHandlerStep.java | 47 ++++---------- ...gleLevelUsageAsBuiltCsvHandlerUseCase.java | 3 +- ...SingleLevelUsageAsBuiltHandlerUseCase.java | 26 ++++++-- 17 files changed, 177 insertions(+), 239 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddcbce7e5..424cfd808 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Added controller interface api's for Policy management. - External EDC service interface api updated. - Updated supported sub-model implementation classes. +- EDC asset update refactored in supported submodels. ## [2.3.6] - 2024-03-06 diff --git a/modules/sde-submodules/assembly-part-relationship/src/main/java/org/eclipse/tractusx/sde/submodels/apr/steps/EDCAspectRelationshipHandlerUseCase.java b/modules/sde-submodules/assembly-part-relationship/src/main/java/org/eclipse/tractusx/sde/submodels/apr/steps/EDCAspectRelationshipHandlerUseCase.java index 508676ca7..a04ce0f66 100644 --- a/modules/sde-submodules/assembly-part-relationship/src/main/java/org/eclipse/tractusx/sde/submodels/apr/steps/EDCAspectRelationshipHandlerUseCase.java +++ b/modules/sde-submodules/assembly-part-relationship/src/main/java/org/eclipse/tractusx/sde/submodels/apr/steps/EDCAspectRelationshipHandlerUseCase.java @@ -27,11 +27,12 @@ import org.eclipse.tractusx.sde.common.constants.CommonConstants; import org.eclipse.tractusx.sde.common.entities.PolicyModel; import org.eclipse.tractusx.sde.common.exception.CsvHandlerUseCaseException; -import org.eclipse.tractusx.sde.common.exception.ServiceException; +import org.eclipse.tractusx.sde.common.exception.NoDataFoundException; import org.eclipse.tractusx.sde.common.submodel.executor.Step; import org.eclipse.tractusx.sde.edc.entities.request.asset.AssetEntryRequest; import org.eclipse.tractusx.sde.edc.entities.request.asset.AssetEntryRequestFactory; import org.eclipse.tractusx.sde.edc.facilitator.CreateEDCAssetFacilator; +import org.eclipse.tractusx.sde.edc.facilitator.DeleteEDCFacilitator; import org.eclipse.tractusx.sde.edc.gateways.external.EDCGateway; import org.eclipse.tractusx.sde.submodels.apr.entity.AspectRelationshipEntity; import org.eclipse.tractusx.sde.submodels.apr.model.AspectRelationship; @@ -51,6 +52,7 @@ public class EDCAspectRelationshipHandlerUseCase extends Step { private final EDCGateway edcGateway; private final CreateEDCAssetFacilator createEDCAssetFacilator; private final AspectRelationshipService aspectRelationshipService; + private final DeleteEDCFacilitator deleteEDCFacilitator; @SneakyThrows public AspectRelationship run(String submodel, AspectRelationship input, String processId, PolicyModel policy) { @@ -61,29 +63,35 @@ public AspectRelationship run(String submodel, AspectRelationship input, String AssetEntryRequest assetEntryRequest = assetFactory.getAssetRequest(submodel, getSubmodelShortDescriptionOfModel(), shellId, subModelId, input.getParentUuid()); + + Map eDCAsset = null; + if (!edcGateway.assetExistsLookup(assetEntryRequest.getId())) { if (CommonConstants.UPDATED_Y.equals(input.getUpdated()) && input.getOldSubmodelIdforUpdateCase() != null) { - deleteIfAnyReferenceExist(input.getOldSubmodelIdforUpdateCase()); + deleteIfAnyReferenceExist(input, input.getOldSubmodelIdforUpdateCase()); } - edcProcessingforAspectRelationship(assetEntryRequest, input, policy); - + eDCAsset = createEDCAssetFacilator.createEDCAsset(assetEntryRequest, policy); } else { - - deleteEDCFirstForUpdate(submodel, input, processId); - edcProcessingforAspectRelationship(assetEntryRequest, input, policy); + eDCAsset = createEDCAssetFacilator.updateEDCAsset(assetEntryRequest, policy); input.setUpdated(CommonConstants.UPDATED_Y); } + // EDC transaction information for DB + input.setAssetId(eDCAsset.get("assetId")); + input.setAccessPolicyId(eDCAsset.get("accessPolicyId")); + input.setUsagePolicyId(eDCAsset.get("usagePolicyId")); + input.setContractDefinationId(eDCAsset.get("contractDefinitionId")); + return input; } catch (Exception e) { throw new CsvHandlerUseCaseException(input.getRowNumber(), "EDC: " + e.getMessage()); } } - private void deleteIfAnyReferenceExist(String oldSubModelId) { + private void deleteIfAnyReferenceExist(AspectRelationship input, String oldSubModelId) { try { AspectRelationshipEntity aspectRelationshipEntity = aspectRelationshipService .readEntityBySubModelId(oldSubModelId); @@ -91,6 +99,10 @@ private void deleteIfAnyReferenceExist(String oldSubModelId) { log.info( "Deleted existing EDC asset in update case reference,so EDC end will be single asset for each submodel: " + oldSubModelId); + } catch (NoDataFoundException e) { + log.warn( + "In deleteIfAnyReferenceExist The EDC assetInfo not found in local database for delete, looking EDC connector and going to delete asset"); + deleteEDCFacilitator.findEDCOfferInformation(input.getShellId(), input.getSubModelId()); } catch (Exception e) { log.warn( "Trying to delete existing EDC asset in update case reference,so EDC end will be single asset for each submodel: " @@ -99,28 +111,4 @@ private void deleteIfAnyReferenceExist(String oldSubModelId) { } - @SneakyThrows - private void deleteEDCFirstForUpdate(String submodel, AspectRelationship input, String processId) { - try { - AspectRelationshipEntity aspectRelationshipEntity = aspectRelationshipService - .readEntity(input.getChildUuid()); - aspectRelationshipService.deleteEDCAsset(aspectRelationshipEntity); - } catch (Exception e) { - if (!e.getMessage().contains("404 Not Found")) { - throw new ServiceException("Exception in EDC delete request process: " + e.getMessage()); - } - } - } - - @SneakyThrows - private void edcProcessingforAspectRelationship(AssetEntryRequest assetEntryRequest, AspectRelationship input, PolicyModel policy) { - - Map createEDCAsset = createEDCAssetFacilator.createEDCAsset(assetEntryRequest, policy); - - // EDC transaction information for DB - input.setAssetId(assetEntryRequest.getId()); - input.setAccessPolicyId(createEDCAsset.get("accessPolicyId")); - input.setUsagePolicyId(createEDCAsset.get("usagePolicyId")); - input.setContractDefinationId(createEDCAsset.get("contractDefinitionId")); - } -} \ No newline at end of file +} diff --git a/modules/sde-submodules/batch/src/main/java/org/eclipse/tractusx/sde/submodels/batch/steps/EDCBatchHandlerUseCase.java b/modules/sde-submodules/batch/src/main/java/org/eclipse/tractusx/sde/submodels/batch/steps/EDCBatchHandlerUseCase.java index 40070ba62..48fb75ee9 100644 --- a/modules/sde-submodules/batch/src/main/java/org/eclipse/tractusx/sde/submodels/batch/steps/EDCBatchHandlerUseCase.java +++ b/modules/sde-submodules/batch/src/main/java/org/eclipse/tractusx/sde/submodels/batch/steps/EDCBatchHandlerUseCase.java @@ -25,11 +25,13 @@ import org.eclipse.tractusx.sde.common.constants.CommonConstants; import org.eclipse.tractusx.sde.common.entities.PolicyModel; import org.eclipse.tractusx.sde.common.exception.CsvHandlerUseCaseException; +import org.eclipse.tractusx.sde.common.exception.NoDataFoundException; import org.eclipse.tractusx.sde.common.exception.ServiceException; import org.eclipse.tractusx.sde.common.submodel.executor.Step; import org.eclipse.tractusx.sde.edc.entities.request.asset.AssetEntryRequest; import org.eclipse.tractusx.sde.edc.entities.request.asset.AssetEntryRequestFactory; import org.eclipse.tractusx.sde.edc.facilitator.CreateEDCAssetFacilator; +import org.eclipse.tractusx.sde.edc.facilitator.DeleteEDCFacilitator; import org.eclipse.tractusx.sde.edc.gateways.external.EDCGateway; import org.eclipse.tractusx.sde.submodels.batch.entity.BatchEntity; import org.eclipse.tractusx.sde.submodels.batch.model.Batch; @@ -38,7 +40,9 @@ import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +@Slf4j @Service @RequiredArgsConstructor public class EDCBatchHandlerUseCase extends Step { @@ -47,6 +51,7 @@ public class EDCBatchHandlerUseCase extends Step { private final EDCGateway edcGateway; private final CreateEDCAssetFacilator createEDCAssetFacilator; private final BatchService batchDeleteService; + private final DeleteEDCFacilitator deleteEDCFacilitator; @SneakyThrows public Batch run(String submodel, Batch input, String processId, PolicyModel policy) { @@ -57,15 +62,22 @@ public Batch run(String submodel, Batch input, String processId, PolicyModel pol AssetEntryRequest assetEntryRequest = assetFactory.getAssetRequest(submodel, getSubmodelShortDescriptionOfModel(), shellId, subModelId, input.getUuid()); - if (!edcGateway.assetExistsLookup(assetEntryRequest.getId())) { - edcProcessingforBatch(assetEntryRequest, input, policy); + Map eDCAsset = null; + + if (!edcGateway.assetExistsLookup(assetEntryRequest.getId())) { + eDCAsset = createEDCAssetFacilator.createEDCAsset(assetEntryRequest, policy); } else { - deleteEDCFirstForUpdate(submodel, input, processId); - edcProcessingforBatch(assetEntryRequest, input, policy); + eDCAsset = createEDCAssetFacilator.updateEDCAsset(assetEntryRequest, policy); input.setUpdated(CommonConstants.UPDATED_Y); } + // EDC transaction information for DB + input.setAssetId(eDCAsset.get("assetId")); + input.setAccessPolicyId(eDCAsset.get("accessPolicyId")); + input.setUsagePolicyId(eDCAsset.get("usagePolicyId")); + input.setContractDefinationId(eDCAsset.get("contractDefinitionId")); + return input; } catch (Exception e) { throw new CsvHandlerUseCaseException(input.getRowNumber(), "EDC: " + e.getMessage()); @@ -77,6 +89,10 @@ private void deleteEDCFirstForUpdate(String submodel, Batch input, String proces try { BatchEntity batchEntity = batchDeleteService.readEntity(input.getUuid()); batchDeleteService.deleteEDCAsset(batchEntity); + } catch (NoDataFoundException e) { + log.warn( + "The EDC assetInfo not found in local database for delete, looking EDC connector and going to delete asset"); + deleteEDCFacilitator.findEDCOfferInformation(input.getShellId(), input.getSubModelId()); } catch (Exception e) { if (!e.getMessage().contains("404 Not Found")) { throw new ServiceException("Unable to delete EDC offer for update: " + e.getMessage()); @@ -95,4 +111,4 @@ private void edcProcessingforBatch(AssetEntryRequest assetEntryRequest, Batch in input.setUsagePolicyId(createEDCAsset.get("usagePolicyId")); input.setContractDefinationId(createEDCAsset.get("contractDefinitionId")); } -} \ No newline at end of file +} diff --git a/modules/sde-submodules/part-as-planned/src/main/java/org/eclipse/tractusx/sde/submodels/pap/steps/EDCPartAsPlannedHandlerStep.java b/modules/sde-submodules/part-as-planned/src/main/java/org/eclipse/tractusx/sde/submodels/pap/steps/EDCPartAsPlannedHandlerStep.java index c8efc62ed..19db44106 100644 --- a/modules/sde-submodules/part-as-planned/src/main/java/org/eclipse/tractusx/sde/submodels/pap/steps/EDCPartAsPlannedHandlerStep.java +++ b/modules/sde-submodules/part-as-planned/src/main/java/org/eclipse/tractusx/sde/submodels/pap/steps/EDCPartAsPlannedHandlerStep.java @@ -24,15 +24,12 @@ import org.eclipse.tractusx.sde.common.constants.CommonConstants; import org.eclipse.tractusx.sde.common.entities.PolicyModel; import org.eclipse.tractusx.sde.common.exception.CsvHandlerUseCaseException; -import org.eclipse.tractusx.sde.common.exception.ServiceException; import org.eclipse.tractusx.sde.common.submodel.executor.Step; import org.eclipse.tractusx.sde.edc.entities.request.asset.AssetEntryRequest; import org.eclipse.tractusx.sde.edc.entities.request.asset.AssetEntryRequestFactory; import org.eclipse.tractusx.sde.edc.facilitator.CreateEDCAssetFacilator; import org.eclipse.tractusx.sde.edc.gateways.external.EDCGateway; -import org.eclipse.tractusx.sde.submodels.pap.entity.PartAsPlannedEntity; import org.eclipse.tractusx.sde.submodels.pap.model.PartAsPlanned; -import org.eclipse.tractusx.sde.submodels.pap.services.PartAsPlannedService; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; @@ -45,7 +42,6 @@ public class EDCPartAsPlannedHandlerStep extends Step { private final AssetEntryRequestFactory assetFactory; private final EDCGateway edcGateway; private final CreateEDCAssetFacilator createEDCAssetFacilator; - private final PartAsPlannedService partAsPlannedService; @SneakyThrows public PartAsPlanned run(String submodel, PartAsPlanned input, String processId, PolicyModel policy) { @@ -56,45 +52,26 @@ public PartAsPlanned run(String submodel, PartAsPlanned input, String processId, AssetEntryRequest assetEntryRequest = assetFactory.getAssetRequest(submodel, getSubmodelShortDescriptionOfModel(), shellId, subModelId, input.getUuid()); + + Map eDCAsset = null; + if (!edcGateway.assetExistsLookup(assetEntryRequest.getId())) { - edcProcessingforPartAsPlanned(assetEntryRequest, input, policy); + eDCAsset = createEDCAssetFacilator.createEDCAsset(assetEntryRequest, policy); } else { - - deleteEDCFirstForUpdate(submodel, input, processId); - edcProcessingforPartAsPlanned(assetEntryRequest, input, policy); + eDCAsset = createEDCAssetFacilator.updateEDCAsset(assetEntryRequest, policy); input.setUpdated(CommonConstants.UPDATED_Y); } - return input; - } catch (Exception e) { - throw new CsvHandlerUseCaseException(input.getRowNumber(), "EDC: " + e.getMessage()); - } - } + // EDC transaction information for DB + input.setAssetId(eDCAsset.get("assetId")); + input.setAccessPolicyId(eDCAsset.get("accessPolicyId")); + input.setUsagePolicyId(eDCAsset.get("usagePolicyId")); + input.setContractDefinationId(eDCAsset.get("contractDefinitionId")); - @SneakyThrows - private void deleteEDCFirstForUpdate(String submodel, PartAsPlanned input, String processId) { - try { - PartAsPlannedEntity partAsPlannedEntity = partAsPlannedService.readEntity(input.getUuid()); - partAsPlannedService.deleteEDCAsset(partAsPlannedEntity); + return input; } catch (Exception e) { - if (!e.getMessage().contains("404 Not Found")) { - throw new ServiceException("Unable to delete EDC offer for update: " + e.getMessage()); - } + throw new CsvHandlerUseCaseException(input.getRowNumber(), "EDC: " + e.getMessage()); } } - - @SneakyThrows - private void edcProcessingforPartAsPlanned(AssetEntryRequest assetEntryRequest, PartAsPlanned input, - PolicyModel policy) { - - Map createEDCAsset = createEDCAssetFacilator.createEDCAsset(assetEntryRequest, policy); - - // EDC transaction information for DB - input.setAssetId(assetEntryRequest.getId()); - input.setAccessPolicyId(createEDCAsset.get("accessPolicyId")); - input.setUsagePolicyId(createEDCAsset.get("usagePolicyId")); - input.setContractDefinationId(createEDCAsset.get("contractDefinitionId")); - } - } \ No newline at end of file diff --git a/modules/sde-submodules/part-site-information-as-planned/src/main/java/org/eclipse/tractusx/sde/submodels/psiap/steps/EDCPartSiteInformationAsPlannedHandlerStep.java b/modules/sde-submodules/part-site-information-as-planned/src/main/java/org/eclipse/tractusx/sde/submodels/psiap/steps/EDCPartSiteInformationAsPlannedHandlerStep.java index 09a914710..511c191ad 100644 --- a/modules/sde-submodules/part-site-information-as-planned/src/main/java/org/eclipse/tractusx/sde/submodels/psiap/steps/EDCPartSiteInformationAsPlannedHandlerStep.java +++ b/modules/sde-submodules/part-site-information-as-planned/src/main/java/org/eclipse/tractusx/sde/submodels/psiap/steps/EDCPartSiteInformationAsPlannedHandlerStep.java @@ -24,15 +24,12 @@ import org.eclipse.tractusx.sde.common.constants.CommonConstants; import org.eclipse.tractusx.sde.common.entities.PolicyModel; import org.eclipse.tractusx.sde.common.exception.CsvHandlerUseCaseException; -import org.eclipse.tractusx.sde.common.exception.ServiceException; import org.eclipse.tractusx.sde.common.submodel.executor.Step; import org.eclipse.tractusx.sde.edc.entities.request.asset.AssetEntryRequest; import org.eclipse.tractusx.sde.edc.entities.request.asset.AssetEntryRequestFactory; import org.eclipse.tractusx.sde.edc.facilitator.CreateEDCAssetFacilator; import org.eclipse.tractusx.sde.edc.gateways.external.EDCGateway; -import org.eclipse.tractusx.sde.submodels.psiap.entity.PartSiteInformationAsPlannedEntity; import org.eclipse.tractusx.sde.submodels.psiap.model.PartSiteInformationAsPlanned; -import org.eclipse.tractusx.sde.submodels.psiap.services.PartSiteInformationAsPlannedService; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; @@ -45,7 +42,6 @@ public class EDCPartSiteInformationAsPlannedHandlerStep extends Step { private final AssetEntryRequestFactory assetFactory; private final EDCGateway edcGateway; private final CreateEDCAssetFacilator createEDCAssetFacilator; - private final PartSiteInformationAsPlannedService partSiteInformationAsPlannedService; @SneakyThrows public PartSiteInformationAsPlanned run(String submodel, PartSiteInformationAsPlanned input, String processId, @@ -57,46 +53,25 @@ public PartSiteInformationAsPlanned run(String submodel, PartSiteInformationAsPl AssetEntryRequest assetEntryRequest = assetFactory.getAssetRequest(submodel, getSubmodelShortDescriptionOfModel(), shellId, subModelId, input.getUuid()); + + Map eDCAsset = null; + if (!edcGateway.assetExistsLookup(assetEntryRequest.getId())) { - edcProcessingforPartAsPlanned(assetEntryRequest, input, policy); + eDCAsset = createEDCAssetFacilator.createEDCAsset(assetEntryRequest, policy); } else { - - deleteEDCFirstForUpdate(submodel, input, processId); - edcProcessingforPartAsPlanned(assetEntryRequest, input, policy); + eDCAsset = createEDCAssetFacilator.updateEDCAsset(assetEntryRequest, policy); input.setUpdated(CommonConstants.UPDATED_Y); } + // EDC transaction information for DB + input.setAssetId(eDCAsset.get("assetId")); + input.setAccessPolicyId(eDCAsset.get("accessPolicyId")); + input.setUsagePolicyId(eDCAsset.get("usagePolicyId")); + input.setContractDefinationId(eDCAsset.get("contractDefinitionId")); + return input; } catch (Exception e) { throw new CsvHandlerUseCaseException(input.getRowNumber(), "EDC: " + e.getMessage()); } } - - @SneakyThrows - private void deleteEDCFirstForUpdate(String submodel, PartSiteInformationAsPlanned input, String processId) { - try { - PartSiteInformationAsPlannedEntity partSiteInformationAsPlannedEntity = partSiteInformationAsPlannedService - .readEntity(input.getUuid()); - partSiteInformationAsPlannedService.deleteEDCAsset(partSiteInformationAsPlannedEntity); - - } catch (Exception e) { - if (!e.getMessage().contains("404 Not Found")) { - throw new ServiceException("Unable to delete EDC offer for update: " + e.getMessage()); - } - } - } - - @SneakyThrows - private void edcProcessingforPartAsPlanned(AssetEntryRequest assetEntryRequest, PartSiteInformationAsPlanned input, - PolicyModel policy) { - - Map createEDCAsset = createEDCAssetFacilator.createEDCAsset(assetEntryRequest, policy); - - // EDC transaction information for DB - input.setAssetId(assetEntryRequest.getId()); - input.setAccessPolicyId(createEDCAsset.get("accessPolicyId")); - input.setUsagePolicyId(createEDCAsset.get("usagePolicyId")); - input.setContractDefinationId(createEDCAsset.get("contractDefinitionId")); - } - } \ No newline at end of file diff --git a/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/entity/PcfEntity.java b/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/entity/PcfEntity.java index 226056eaf..150fd2220 100644 --- a/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/entity/PcfEntity.java +++ b/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/entity/PcfEntity.java @@ -126,6 +126,7 @@ public class PcfEntity extends CommonPropEntity { @Column(name = "extTFS_distributionStageDlucGhgEmissions") private Double extTFSDistributionStageDlucGhgEmissions; // 1.0, private Double distributionStagePcfIncludingBiogenic; // 0.0, + private Double distributionStageAircraftGhgEmissions; // 0, private Double carbonContentBiogenic; // 0.0, private String partialFullPcf;// Cradle-to-gate private String productId;// urn:gtin:4712345060507 diff --git a/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/mapper/PcfMapper.java b/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/mapper/PcfMapper.java index 149627a19..6b8ba341f 100644 --- a/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/mapper/PcfMapper.java +++ b/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/mapper/PcfMapper.java @@ -145,9 +145,7 @@ public JsonObject mapToResponse(PcfEntity entity) { PcfSubmodelResponse build=PcfSubmodelResponse.builder() .specVersion(entity.getSpecVersion()) - .companyIds(List.of(CompanyIds.builder() - .companyId(entity.getCompanyId()) - .build())) + .companyIds(List.of(entity.getCompanyId())) .extWBCSDProductCodeCpc(entity.getExtWBCSDProductCodeCpc()) .created(entity.getCreated()) .companyName(entity.getCompanyName()) @@ -156,10 +154,7 @@ public JsonObject mapToResponse(PcfEntity entity) { .productName(entity.getProductName()) .pcf(pcfResponse) .partialFullPcf(entity.getPartialFullPcf()) - .productIds(List.of(ProductIds.builder() - .productId(entity.getProductId()) - .build())) - + .productIds(List.of(entity.getProductId())) .validityPeriodStart(entity.getValidityPeriodStart()) .comment(entity.getComment()) .id(entity.getId()) diff --git a/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/model/Pcf.java b/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/model/Pcf.java index 6bc0f8c80..e560da5c4 100644 --- a/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/model/Pcf.java +++ b/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/model/Pcf.java @@ -103,6 +103,7 @@ public class Pcf { @SerializedName("extTFS_distributionStageDlucGhgEmissions") private Double extTFSDistributionStageDlucGhgEmissions; // 1.0, private Double distributionStagePcfIncludingBiogenic; // 0.0, + private Double distributionStageAircraftGhgEmissions; // 0.0, private Double carbonContentBiogenic; // 0.0, } \ No newline at end of file diff --git a/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/model/PcfAspect.java b/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/model/PcfAspect.java index 75242247d..eb015d754 100644 --- a/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/model/PcfAspect.java +++ b/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/model/PcfAspect.java @@ -20,7 +20,6 @@ package org.eclipse.tractusx.sde.submodels.pcf.model; - import org.eclipse.tractusx.sde.common.entities.CommonPropEntity; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -143,5 +142,4 @@ public class PcfAspect extends CommonPropEntity { private String pcfLegalStatement; private String productDescription; private String precedingPfId; - } \ No newline at end of file diff --git a/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/model/PcfSubmodelResponse.java b/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/model/PcfSubmodelResponse.java index 660aca95d..658690c4c 100644 --- a/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/model/PcfSubmodelResponse.java +++ b/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/model/PcfSubmodelResponse.java @@ -33,7 +33,7 @@ public class PcfSubmodelResponse { private String specVersion; - private List companyIds; + private List companyIds; @SerializedName(value = "extWBCSD_productCodeCpc") private String extWBCSDProductCodeCpc; @@ -46,7 +46,7 @@ public class PcfSubmodelResponse { private Double version; private Pcf pcf; private String partialFullPcf; - private List productIds; + private List productIds; private String validityPeriodStart; private String comment; private String id; diff --git a/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/service/PcfService.java b/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/service/PcfService.java index fad894330..0e40a02e2 100644 --- a/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/service/PcfService.java +++ b/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/service/PcfService.java @@ -63,6 +63,15 @@ public List readCreatedTwinsforDelete(String refProcessId) { } + public List readCreatedTwins(String processId) { + + return Optional.ofNullable(pcfRepository.findByProcessId(processId)).filter(a -> !a.isEmpty()) + .orElseThrow(() -> new NoDataFoundException( + String.format("No data found for processid %s ", processId))); + + } + + public void deleteAllDataBySequence(JsonObject jsonObject) { PcfEntity pcfEntity = pcfMapper.mapforEntity(jsonObject); diff --git a/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/steps/EDCPcfHandlerUseCase.java b/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/steps/EDCPcfHandlerUseCase.java index b3631af04..4fa9afe8f 100644 --- a/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/steps/EDCPcfHandlerUseCase.java +++ b/modules/sde-submodules/pcf/src/main/java/org/eclipse/tractusx/sde/submodels/pcf/steps/EDCPcfHandlerUseCase.java @@ -25,17 +25,15 @@ import org.eclipse.tractusx.sde.common.constants.CommonConstants; import org.eclipse.tractusx.sde.common.entities.PolicyModel; import org.eclipse.tractusx.sde.common.exception.CsvHandlerUseCaseException; -import org.eclipse.tractusx.sde.common.exception.ServiceException; import org.eclipse.tractusx.sde.common.submodel.executor.Step; import org.eclipse.tractusx.sde.edc.entities.request.asset.AssetEntryRequest; import org.eclipse.tractusx.sde.edc.entities.request.asset.AssetEntryRequestFactory; import org.eclipse.tractusx.sde.edc.facilitator.CreateEDCAssetFacilator; import org.eclipse.tractusx.sde.edc.gateways.external.EDCGateway; -import org.eclipse.tractusx.sde.submodels.pcf.entity.PcfEntity; import org.eclipse.tractusx.sde.submodels.pcf.model.PcfAspect; -import org.eclipse.tractusx.sde.submodels.pcf.service.PcfService; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.web.util.UriComponentsBuilder; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; @@ -47,7 +45,7 @@ public class EDCPcfHandlerUseCase extends Step { private final AssetEntryRequestFactory assetFactory; private final EDCGateway edcGateway; private final CreateEDCAssetFacilator createEDCAssetFacilator; - private final PcfService aspectService; + private static final String ASSET_PROP_VERSION = "1.0.0"; @Value(value = "${dft.hostname}") private String dftHostname; @@ -61,46 +59,40 @@ public PcfAspect run(String submodel, PcfAspect input, String processId, PolicyM AssetEntryRequest assetEntryRequest = assetFactory.getAssetRequest(submodel, getSubmodelShortDescriptionOfModel(), shellId, subModelId, input.getId()); - - if (!edcGateway.assetExistsLookup(assetEntryRequest.getId())) { - edcProcessingforAspect(assetEntryRequest, input, policy); + + assetEntryRequest.getProperties().put("rdfs:label", getSubmodelShortDescriptionOfModel()); + assetEntryRequest.getProperties().put("rdfs:comment", getSubmodelShortDescriptionOfModel()); + assetEntryRequest.getProperties().put("dcat:version", ASSET_PROP_VERSION); + assetEntryRequest.getProperties().put("cx-common:version", ASSET_PROP_VERSION); + assetEntryRequest.getProperties().put("aas-semantics:semanticId",Map.of("@id", getsemanticIdOfModel())); + assetEntryRequest.getProperties().put("dct:type", Map.of("@id", "cx-taxo:PcfExchange")); + + + String baseURL = UriComponentsBuilder.fromHttpUrl(dftHostname).path("/pcf/productIds/") + .path(input.getProductId()) + .toUriString(); - } else { + assetEntryRequest.getDataAddress().getProperties().put("baseUrl", baseURL); + + Map eDCAsset = null; - deleteEDCFirstForUpdate(submodel, input, processId); - edcProcessingforAspect(assetEntryRequest, input, policy); + if (!edcGateway.assetExistsLookup(assetEntryRequest.getId())) { + eDCAsset = createEDCAssetFacilator.createEDCAsset(assetEntryRequest, policy); + } else { + eDCAsset = createEDCAssetFacilator.updateEDCAsset(assetEntryRequest, policy); input.setUpdated(CommonConstants.UPDATED_Y); } + // EDC transaction information for DB + input.setAssetId(eDCAsset.get("assetId")); + input.setAccessPolicyId(eDCAsset.get("accessPolicyId")); + input.setUsagePolicyId(eDCAsset.get("usagePolicyId")); + input.setContractDefinationId(eDCAsset.get("contractDefinitionId")); + return input; } catch (Exception e) { throw new CsvHandlerUseCaseException(input.getRowNumber(), "EDC: " + e.getMessage()); } } - - @SneakyThrows - private void deleteEDCFirstForUpdate(String submodel, PcfAspect input, String processId) { - try { - PcfEntity entity = aspectService.readEntity(input.getId()); - aspectService.deleteEDCAsset(entity); - } catch (Exception e) { - if (!e.getMessage().contains("404 Not Found")) { - throw new ServiceException("Unable to delete EDC offer for update: " + e.getMessage()); - } - } - } - - @SneakyThrows - private void edcProcessingforAspect(AssetEntryRequest assetEntryRequest, PcfAspect input, PolicyModel policy) { - - Map createEDCAsset = createEDCAssetFacilator.createEDCAsset(assetEntryRequest, policy); - - // EDC transaction information for DB - input.setAssetId(assetEntryRequest.getId()); - input.setAccessPolicyId(createEDCAsset.get("accessPolicyId")); - input.setUsagePolicyId(createEDCAsset.get("usagePolicyId")); - input.setContractDefinationId(createEDCAsset.get("contractDefinitionId")); - } - } \ No newline at end of file diff --git a/modules/sde-submodules/pcf/src/main/resources/pcf.json b/modules/sde-submodules/pcf/src/main/resources/pcf.json index eb8f2db72..11c355da9 100644 --- a/modules/sde-submodules/pcf/src/main/resources/pcf.json +++ b/modules/sde-submodules/pcf/src/main/resources/pcf.json @@ -3,9 +3,9 @@ "$id": "http://example.com/example.json", "type": "array", "id": "pcf", - "idShort": "pcf", - "version": "4.0.1", - "semantic_id": "urn:bamm:io.catenax.pcf:4.0.1#Pcf", + "idShort": "PCFExchangeEndpoint", + "version": "6.0.0", + "semantic_id": "urn:bamm:io.catenax.pcf:6.0.0#Pcf", "title": "Product Carbon Footprint (pcf)", "shortDescription": "Product (Carbon) Footprint - Submodel pcf", "description": "A Product (Carbon) Footprint represents the carbon footprint of a product with values as specified in the Catena-X PCF Rulebook in accordance with the WBCSD (World Business Council for Sustainable Development) Pathfinder framework and the technical specifications for PCF Data Exchange (Version 2.0.0) from the WBCSD/ PACT initiative.", @@ -39,7 +39,8 @@ "extWBCSD_packagingGhgEmissions", "precedingPfId", "secondaryEmissionFactorSource", - "assetLifeCyclePhase" + "assetLifeCyclePhase", + "extWBCSD_otherOperatorName" ], "dependentRequired": {}, "properties": { @@ -221,7 +222,7 @@ ], "title": "ProductId", "format": "uri", - "description": "Identifier of a product in context of a product (carbon) footprint as specified in the Catena-X PCF Rulebook in accordance with the technical specifications for PCF Data Exchange (Version 2.0.0) from the WBCSD (World Business Council for Sustainable Development)/ PACT initiative.", + "description": "Non-empty set of product identifiers. Each value is supposed to uniquely identify the product as specified in the Catena-X PCF Rulebook in accordance with the technical specifications for PCF Data Exchange (Version 2.1.0) from the WBCSD (World Business Council for Sustainable Development)/ PACT initiative. In Catena-X productId corresponds with Industry Core manufacturerPartId.", "minLength": 1, "examples": [ "urn:gtin:4712345060507" @@ -359,7 +360,7 @@ "null" ], "title": "GeographyCountry", - "pattern": "([A-Z]{2})", + "pattern": "([A-Z]{2}|)", "description": "Two letter country code that must conform to data type ISO 3166CC as specified in the Catena-X PCF Rulebook in accordance with the technical specifications for PCF Data Exchange (Version 2.0.0) from the WBCSD (World Business Council for Sustainable Development)/ PACT initiative.", "examples": [ "DE" @@ -787,10 +788,10 @@ "null" ], "title": "DistributionStageBiogenicCarbonWithdrawal", - "minimum": 0, + "maximum": 0.0, "description": "GWP (Global Warming Potential) of biogenic CO2-withdrawal in distribution stage (biogenic CO2 contained in the product) as specified in the Catena-X PCF Rulebook.", "examples": [ - 0.5 + 0.0 ] }, "extTFS_distributionStageDlucGhgEmissions": { @@ -841,6 +842,18 @@ 0.1 ] }, + "distributionStageAircraftGhgEmissions": { + "type": [ + "number", + "null" + ], + "title": "distributionStageAircraftGhgEmissions", + "minimum": 0, + "description": "GHG (Greenhouse Gas) emissions for the distribution stage resulting from aircraft engine usage for the transport of the product as specified in the Catena-X PCF Rulebook in accordance with the technical specifications for PCF Data Exchange (Version 2.0.0) from the WBCSD (World Business Council for Sustainable Development)/ PACT initiative.", + "examples": [ + 0 + ] + }, "carbonContentBiogenic": { "type": [ "number", @@ -933,11 +946,12 @@ "distributionStagePcfIncludingBiogenic": 0.0, "distributionStageFossilGhgEmissions": 0.5, "distributionStageBiogenicCarbonEmissionsOtherThanCO2": 1.0, - "distributionStageBiogenicCarbonWithdrawal": 0.5, + "distributionStageBiogenicCarbonWithdrawal": 0.0, "extTFS_distributionStageDlucGhgEmissions": 1.0, "extTFS_distributionStageLuGhgEmissions": 1.1, "carbonContentTotal": 2.5, "extWBCSD_fossilCarbonContent": 0.1, + "distributionStageAircraftGhgEmissions":0, "carbonContentBiogenic": 0.0, "assetLifeCyclePhase": "AsPlanned" } diff --git a/modules/sde-submodules/serial-part-typization/src/main/java/org/eclipse/tractusx/sde/submodels/spt/steps/EDCAspectHandlerUseCase.java b/modules/sde-submodules/serial-part-typization/src/main/java/org/eclipse/tractusx/sde/submodels/spt/steps/EDCAspectHandlerUseCase.java index 0245a9368..5e1c507d6 100644 --- a/modules/sde-submodules/serial-part-typization/src/main/java/org/eclipse/tractusx/sde/submodels/spt/steps/EDCAspectHandlerUseCase.java +++ b/modules/sde-submodules/serial-part-typization/src/main/java/org/eclipse/tractusx/sde/submodels/spt/steps/EDCAspectHandlerUseCase.java @@ -27,15 +27,12 @@ import org.eclipse.tractusx.sde.common.constants.CommonConstants; import org.eclipse.tractusx.sde.common.entities.PolicyModel; import org.eclipse.tractusx.sde.common.exception.CsvHandlerUseCaseException; -import org.eclipse.tractusx.sde.common.exception.ServiceException; import org.eclipse.tractusx.sde.common.submodel.executor.Step; import org.eclipse.tractusx.sde.edc.entities.request.asset.AssetEntryRequest; import org.eclipse.tractusx.sde.edc.entities.request.asset.AssetEntryRequestFactory; import org.eclipse.tractusx.sde.edc.facilitator.CreateEDCAssetFacilator; import org.eclipse.tractusx.sde.edc.gateways.external.EDCGateway; -import org.eclipse.tractusx.sde.submodels.spt.entity.AspectEntity; import org.eclipse.tractusx.sde.submodels.spt.model.Aspect; -import org.eclipse.tractusx.sde.submodels.spt.service.AspectService; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; @@ -48,7 +45,6 @@ public class EDCAspectHandlerUseCase extends Step { private final AssetEntryRequestFactory assetFactory; private final EDCGateway edcGateway; private final CreateEDCAssetFacilator createEDCAssetFacilator; - private final AspectService aspectService; @SneakyThrows public Aspect run(String submodel, Aspect input, String processId, PolicyModel policy) { @@ -59,16 +55,21 @@ public Aspect run(String submodel, Aspect input, String processId, PolicyModel p AssetEntryRequest assetEntryRequest = assetFactory.getAssetRequest(submodel, getSubmodelShortDescriptionOfModel(), shellId, subModelId, input.getUuid()); + + Map eDCAsset =null; + if (!edcGateway.assetExistsLookup(assetEntryRequest.getId())) { - - edcProcessingforAspect(assetEntryRequest, input, policy); - + eDCAsset = createEDCAssetFacilator.createEDCAsset(assetEntryRequest, policy); } else { - - deleteEDCFirstForUpdate(submodel, input, processId); - edcProcessingforAspect(assetEntryRequest, input, policy); + eDCAsset = createEDCAssetFacilator.updateEDCAsset(assetEntryRequest, policy); input.setUpdated(CommonConstants.UPDATED_Y); } + + // EDC transaction information for DB + input.setAssetId(eDCAsset.get("assetId")); + input.setAccessPolicyId(eDCAsset.get("accessPolicyId")); + input.setUsagePolicyId(eDCAsset.get("usagePolicyId")); + input.setContractDefinationId(eDCAsset.get("contractDefinitionId")); return input; } catch (Exception e) { @@ -76,28 +77,4 @@ public Aspect run(String submodel, Aspect input, String processId, PolicyModel p } } - @SneakyThrows - private void deleteEDCFirstForUpdate(String submodel, Aspect input, String processId) { - try { - AspectEntity entity = aspectService.readEntity(input.getUuid()); - aspectService.deleteEDCAsset(entity); - } catch (Exception e) { - if (!e.getMessage().contains("404 Not Found")) { - throw new ServiceException("Unable to delete EDC offer for update: " + e.getMessage()); - } - } - } - - @SneakyThrows - private void edcProcessingforAspect(AssetEntryRequest assetEntryRequest, Aspect input, PolicyModel policy) { - - Map createEDCAsset = createEDCAssetFacilator.createEDCAsset(assetEntryRequest, policy); - - // EDC transaction information for DB - input.setAssetId(assetEntryRequest.getId()); - input.setAccessPolicyId(createEDCAsset.get("accessPolicyId")); - input.setUsagePolicyId(createEDCAsset.get("usagePolicyId")); - input.setContractDefinationId(createEDCAsset.get("contractDefinitionId")); - } - } \ No newline at end of file diff --git a/modules/sde-submodules/single-level-bom-as-planned/src/main/java/org/eclipse/tractusx/sde/submodels/slbap/steps/EDCSingleLevelBoMAsPlannedHandlerStep.java b/modules/sde-submodules/single-level-bom-as-planned/src/main/java/org/eclipse/tractusx/sde/submodels/slbap/steps/EDCSingleLevelBoMAsPlannedHandlerStep.java index 570038e67..da0c7299f 100644 --- a/modules/sde-submodules/single-level-bom-as-planned/src/main/java/org/eclipse/tractusx/sde/submodels/slbap/steps/EDCSingleLevelBoMAsPlannedHandlerStep.java +++ b/modules/sde-submodules/single-level-bom-as-planned/src/main/java/org/eclipse/tractusx/sde/submodels/slbap/steps/EDCSingleLevelBoMAsPlannedHandlerStep.java @@ -19,20 +19,18 @@ ********************************************************************************/ package org.eclipse.tractusx.sde.submodels.slbap.steps; + import java.util.Map; import org.eclipse.tractusx.sde.common.constants.CommonConstants; import org.eclipse.tractusx.sde.common.entities.PolicyModel; import org.eclipse.tractusx.sde.common.exception.CsvHandlerUseCaseException; -import org.eclipse.tractusx.sde.common.exception.ServiceException; import org.eclipse.tractusx.sde.common.submodel.executor.Step; import org.eclipse.tractusx.sde.edc.entities.request.asset.AssetEntryRequest; import org.eclipse.tractusx.sde.edc.entities.request.asset.AssetEntryRequestFactory; import org.eclipse.tractusx.sde.edc.facilitator.CreateEDCAssetFacilator; import org.eclipse.tractusx.sde.edc.gateways.external.EDCGateway; -import org.eclipse.tractusx.sde.submodels.slbap.entity.SingleLevelBoMAsPlannedEntity; import org.eclipse.tractusx.sde.submodels.slbap.model.SingleLevelBoMAsPlanned; -import org.eclipse.tractusx.sde.submodels.slbap.services.SingleLevelBoMAsPlannedService; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; @@ -45,7 +43,6 @@ public class EDCSingleLevelBoMAsPlannedHandlerStep extends Step { private final AssetEntryRequestFactory assetFactory; private final EDCGateway edcGateway; private final CreateEDCAssetFacilator createEDCAssetFacilator; - private final SingleLevelBoMAsPlannedService singleLevelBoMAsPlannedService; @SneakyThrows public SingleLevelBoMAsPlanned run(String submodel, SingleLevelBoMAsPlanned input, String processId, @@ -57,44 +54,26 @@ public SingleLevelBoMAsPlanned run(String submodel, SingleLevelBoMAsPlanned inpu try { AssetEntryRequest assetEntryRequest = assetFactory.getAssetRequest(submodel, getSubmodelShortDescriptionOfModel(), shellId, subModelId, input.getParentUuid()); + + Map eDCAsset =null; + if (!edcGateway.assetExistsLookup(assetEntryRequest.getId())) { - edcProcessingforSingleLevelBoMAsPlanned(assetEntryRequest, input, policy); + eDCAsset = createEDCAssetFacilator.createEDCAsset(assetEntryRequest, policy); } else { - deleteEDCFirstForUpdate(submodel, input, processId); - edcProcessingforSingleLevelBoMAsPlanned(assetEntryRequest, input, policy); + eDCAsset = createEDCAssetFacilator.updateEDCAsset(assetEntryRequest, policy); input.setUpdated(CommonConstants.UPDATED_Y); } - + + // EDC transaction information for DB + input.setAssetId(eDCAsset.get("assetId")); + input.setAccessPolicyId(eDCAsset.get("accessPolicyId")); + input.setUsagePolicyId(eDCAsset.get("usagePolicyId")); + input.setContractDefinationId(eDCAsset.get("contractDefinitionId")); + return input; } catch (Exception e) { throw new CsvHandlerUseCaseException(input.getRowNumber(), "EDC: " + e.getMessage()); } } - @SneakyThrows - private void deleteEDCFirstForUpdate(String submodel, SingleLevelBoMAsPlanned input, String processId) { - try { - SingleLevelBoMAsPlannedEntity singleLevelBoMAsPlannedEntity = singleLevelBoMAsPlannedService - .readEntity(input.getChildUuid()); - singleLevelBoMAsPlannedService.deleteEDCAsset(singleLevelBoMAsPlannedEntity); - - } catch (Exception e) { - if (!e.getMessage().contains("404 Not Found")) { - throw new ServiceException("Unable to delete EDC offer for update: " + e.getMessage()); - } - } - } - - @SneakyThrows - private void edcProcessingforSingleLevelBoMAsPlanned(AssetEntryRequest assetEntryRequest, - SingleLevelBoMAsPlanned input, PolicyModel policy) { - - Map createEDCAsset = createEDCAssetFacilator.createEDCAsset(assetEntryRequest, policy); - - // EDC transaction information for DB - input.setAssetId(assetEntryRequest.getId()); - input.setAccessPolicyId(createEDCAsset.get("accessPolicyId")); - input.setUsagePolicyId(createEDCAsset.get("usagePolicyId")); - input.setContractDefinationId(createEDCAsset.get("contractDefinitionId")); - } } \ No newline at end of file diff --git a/modules/sde-submodules/single-level-usage-as-built/src/main/java/org/eclipse/tractusx/sde/submodels/sluab/steps/DigitalTwinsSingleLevelUsageAsBuiltCsvHandlerUseCase.java b/modules/sde-submodules/single-level-usage-as-built/src/main/java/org/eclipse/tractusx/sde/submodels/sluab/steps/DigitalTwinsSingleLevelUsageAsBuiltCsvHandlerUseCase.java index e6b7e6172..734c17a59 100644 --- a/modules/sde-submodules/single-level-usage-as-built/src/main/java/org/eclipse/tractusx/sde/submodels/sluab/steps/DigitalTwinsSingleLevelUsageAsBuiltCsvHandlerUseCase.java +++ b/modules/sde-submodules/single-level-usage-as-built/src/main/java/org/eclipse/tractusx/sde/submodels/sluab/steps/DigitalTwinsSingleLevelUsageAsBuiltCsvHandlerUseCase.java @@ -143,7 +143,8 @@ private ShellDescriptorRequest lookUpParentEntityLocaly(SingleLevelUsageAsBuilt "No parent aspect found"); } - return digitalTwinsUtility.getShellDescriptorRequest(aspectEntity.getNameAtManufacturer(), + return digitalTwinsUtility.getShellDescriptorRequest(aspectEntity.getNameAtManufacturer() + "_" + aspectEntity + .getPartInstanceId(), aspectEntity.getManufacturerPartId(), aspectEntity.getUuid(), getSpecificAssetIds(aspectMapper.mapFrom(aspectEntity)), policy); } diff --git a/modules/sde-submodules/single-level-usage-as-built/src/main/java/org/eclipse/tractusx/sde/submodels/sluab/steps/EDCSingleLevelUsageAsBuiltHandlerUseCase.java b/modules/sde-submodules/single-level-usage-as-built/src/main/java/org/eclipse/tractusx/sde/submodels/sluab/steps/EDCSingleLevelUsageAsBuiltHandlerUseCase.java index 4e5f24469..150d3d823 100644 --- a/modules/sde-submodules/single-level-usage-as-built/src/main/java/org/eclipse/tractusx/sde/submodels/sluab/steps/EDCSingleLevelUsageAsBuiltHandlerUseCase.java +++ b/modules/sde-submodules/single-level-usage-as-built/src/main/java/org/eclipse/tractusx/sde/submodels/sluab/steps/EDCSingleLevelUsageAsBuiltHandlerUseCase.java @@ -24,11 +24,13 @@ import org.eclipse.tractusx.sde.common.constants.CommonConstants; import org.eclipse.tractusx.sde.common.entities.PolicyModel; import org.eclipse.tractusx.sde.common.exception.CsvHandlerUseCaseException; +import org.eclipse.tractusx.sde.common.exception.NoDataFoundException; import org.eclipse.tractusx.sde.common.exception.ServiceException; import org.eclipse.tractusx.sde.common.submodel.executor.Step; import org.eclipse.tractusx.sde.edc.entities.request.asset.AssetEntryRequest; import org.eclipse.tractusx.sde.edc.entities.request.asset.AssetEntryRequestFactory; import org.eclipse.tractusx.sde.edc.facilitator.CreateEDCAssetFacilator; +import org.eclipse.tractusx.sde.edc.facilitator.DeleteEDCFacilitator; import org.eclipse.tractusx.sde.edc.gateways.external.EDCGateway; import org.eclipse.tractusx.sde.submodels.sluab.entity.SingleLevelUsageAsBuiltEntity; import org.eclipse.tractusx.sde.submodels.sluab.model.SingleLevelUsageAsBuilt; @@ -37,7 +39,9 @@ import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +@Slf4j @Service @RequiredArgsConstructor public class EDCSingleLevelUsageAsBuiltHandlerUseCase extends Step { @@ -46,6 +50,7 @@ public class EDCSingleLevelUsageAsBuiltHandlerUseCase extends Step { private final EDCGateway edcGateway; private final CreateEDCAssetFacilator createEDCAssetFacilator; private final SingleLevelUsageAsBuiltService singleLevelUsageAsBuiltService; + private final DeleteEDCFacilitator deleteEDCFacilitator; @SneakyThrows public SingleLevelUsageAsBuilt run(String submodel, SingleLevelUsageAsBuilt input, String processId, @@ -57,16 +62,22 @@ public SingleLevelUsageAsBuilt run(String submodel, SingleLevelUsageAsBuilt inpu AssetEntryRequest assetEntryRequest = assetFactory.getAssetRequest(submodel, getSubmodelShortDescriptionOfModel(), shellId, subModelId, input.getParentUuid()); - if (!edcGateway.assetExistsLookup(assetEntryRequest.getId())) { - - edcProcessingforAspectRelationship(assetEntryRequest, input, policy); + Map eDCAsset =null; + + if (!edcGateway.assetExistsLookup(assetEntryRequest.getId())) { + eDCAsset = createEDCAssetFacilator.createEDCAsset(assetEntryRequest, policy); } else { - - deleteEDCFirstForUpdate(submodel, input, processId); - edcProcessingforAspectRelationship(assetEntryRequest, input, policy); + eDCAsset = createEDCAssetFacilator.updateEDCAsset(assetEntryRequest, policy); input.setUpdated(CommonConstants.UPDATED_Y); } + + // EDC transaction information for DB + input.setAssetId(eDCAsset.get("assetId")); + input.setAccessPolicyId(eDCAsset.get("accessPolicyId")); + input.setUsagePolicyId(eDCAsset.get("usagePolicyId")); + input.setContractDefinationId(eDCAsset.get("contractDefinitionId")); + return input; } catch (Exception e) { @@ -80,6 +91,9 @@ private void deleteEDCFirstForUpdate(String submodel, SingleLevelUsageAsBuilt in SingleLevelUsageAsBuiltEntity aspectRelationshipEntity = singleLevelUsageAsBuiltService .readEntity(input.getChildUuid()); singleLevelUsageAsBuiltService.deleteEDCAsset(aspectRelationshipEntity); + } catch (NoDataFoundException e) { + log.warn("The EDC assetInfo not found in local database for delete, looking EDC connector and going to delete asset"); + deleteEDCFacilitator.findEDCOfferInformation(input.getShellId(), input.getSubModelId()); } catch (Exception e) { if (!e.getMessage().contains("404 Not Found")) { throw new ServiceException("Unable to delete EDC offer for update: " + e.getMessage()); From 02673b249c5ed9837c484c3923ec9ac6f2a51c2f Mon Sep 17 00:00:00 2001 From: ChetanT-System Date: Fri, 29 Mar 2024 14:11:21 +0530 Subject: [PATCH 2/4] - updated changelog file. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 424cfd808..5c488b2cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - External EDC service interface api updated. - Updated supported sub-model implementation classes. - EDC asset update refactored in supported submodels. +- Support for pcf v6.0.0 submodel. ## [2.3.6] - 2024-03-06 From a9ddf7d2576cb20264488321cf90a62ecf335e15 Mon Sep 17 00:00:00 2001 From: adityagajbhiye9 <133367448+adityagajbhiye9@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:34:16 +0530 Subject: [PATCH 3/4] chore: moved dependabot.yml to root location --- .github/{workflows => }/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/{workflows => }/dependabot.yml (98%) diff --git a/.github/workflows/dependabot.yml b/.github/dependabot.yml similarity index 98% rename from .github/workflows/dependabot.yml rename to .github/dependabot.yml index 9593cce79..7af00f449 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/dependabot.yml @@ -36,7 +36,7 @@ updates: # Maintain dependencies for Docker - package-ecosystem: "docker" - directory: "./build/" + directory: "/" schedule: interval: "weekly" open-pull-requests-limit: 5 \ No newline at end of file From 99637803b3b25a3d57219cda3cb9e8e96fe94c12 Mon Sep 17 00:00:00 2001 From: adityagajbhiye9 <133367448+adityagajbhiye9@users.noreply.github.com> Date: Fri, 5 Apr 2024 13:06:39 +0530 Subject: [PATCH 4/4] Update dependabot.yml --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7af00f449..9593cce79 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -36,7 +36,7 @@ updates: # Maintain dependencies for Docker - package-ecosystem: "docker" - directory: "/" + directory: "./build/" schedule: interval: "weekly" open-pull-requests-limit: 5 \ No newline at end of file