Skip to content

Commit

Permalink
Merge pull request #63 from catenax-ng/support-pcf-part_3
Browse files Browse the repository at this point in the history
[feat|sde-v2.2.0|major] support new pcf submodel.
  • Loading branch information
almadigabor authored Sep 20, 2023
2 parents af45255 + 35b9afe commit c6fa04a
Show file tree
Hide file tree
Showing 20 changed files with 644 additions and 6 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [2.2.0] - 2023-09-20
### Added
- Pcf model schema and model registration.
- Add entity mapping and model for pcf model execution.
- Support pcf submodel in sde.

## [2.1.1] - 2023-09-06
- bumped version

Expand Down Expand Up @@ -218,7 +224,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Compliance with Catena-X Guidelines
- Integration with Digital Twin registry service.

[unreleased]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/v2.1.1...main
[unreleased]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/v2.2.0...main
[2.2.0]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/v2.1.1...v2.2.0
[2.1.1]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/v2.1.0...v2.1.1
[2.1.0]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/v2.0.11...v2.1.0
[2.0.11]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/v2.0.10...v2.0.11
Expand Down
1 change: 1 addition & 0 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ maven/mavencentral/org.eclipse.tractusx/digital-twins/0.0.1, Apache-2.0, approve
maven/mavencentral/org.eclipse.tractusx/edc/0.0.1, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx/part-as-planned/0.0.1, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx/part-site-information-as-planned/0.0.1, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx/pcf/0.0.1, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx/portal/0.0.1, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx/sde-common/0.0.1, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx/serial-part-typization/0.0.1, Apache-2.0, approved, automotive.tractusx
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ To find information about supported submodules and there version in SDE please v
* SingleLevelBoMAsPlanned
* PartSiteInformationAsPlanned
* SingleLevelUsageAsBuilt
* Product Carbon Footprint(PCF)
2. ***Json Update***
* SerialPart
* SingleLevelBoMAsBuilt
Expand All @@ -197,6 +198,7 @@ To find information about supported submodules and there version in SDE please v
* SingleLevelBoMAsPlanned
* PartSiteInformationAsPlanned
* SingleLevelUsageAsBuilt
* Product Carbon Footprint(PCF)
3. ***Application UI***
* SerialPart
* SingleLevelBoMAsBuilt
Expand All @@ -205,6 +207,7 @@ To find information about supported submodules and there version in SDE please v
* SingleLevelBoMAsPlanned
* PartSiteInformationAsPlanned
* SingleLevelUsageAsBuilt
* Product Carbon Footprint(PCF)


---
Expand Down
1 change: 1 addition & 0 deletions modules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ SDE backend splited into multiple services loosely-coupled Maven modules.
- modules/sde-submodules/part-site-information-as-planned
- modules/sde-submodules/single-level-usage-as-built
- modules/sde-submodules/single-level-bom-as-planned
- modules/sde-submodules/pcf
- modules/sde-usecases/traceability
5 changes: 5 additions & 0 deletions modules/sde-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
<artifactId>single-level-usage-as-built</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>org.eclipse.tractusx</groupId>
<artifactId>pcf</artifactId>
<version>0.0.1</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public ResponseEntity<Resource> generateCSV(String fileName, List<List<String>>

@SneakyThrows
public static ByteArrayInputStream writeCsv(List<List<String>> data) {
final CSVFormat format = CSVFormat.EXCEL.withEscape(' ').withQuoteMode(QuoteMode.NONE).withDelimiter(';');
final CSVFormat format = CSVFormat.EXCEL.withEscape('/').withQuoteMode(QuoteMode.NONE).withDelimiter(';');

try (ByteArrayOutputStream out = new ByteArrayOutputStream();
CSVPrinter csvPrinter = new CSVPrinter(new PrintWriter(out), format);) {
Expand Down
3 changes: 2 additions & 1 deletion modules/sde-core/src/main/resources/use-case.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"serialpart",
"singlelevelbomasbuilt",
"batch",
"singlelevelusageasbuilt"
"singlelevelusageasbuilt",
"pcf"
]
},
{
Expand Down
81 changes: 79 additions & 2 deletions modules/sde-submodules/pcf/pcf.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
---
## Description

This module use for PCF submodel specification and descriptors. It's contain the codes related to PCF to validate, parse and transfer data for DigitalTwins and EDC to create aspect twins and data offer.

---
#### Version: 4.0.1
Expand All @@ -18,6 +19,71 @@ Please find below links for schema details:

### PCF CSV file headers

| Headers Name | Mandatory | Position |
|---------------------------------- |----------------------------- |-------- |
| id | No | 1 |
| specVersion | Yes | 2 |
| partialFullPcf | Yes | 3 |
| precedingPfId | Yes | 4 |
| version | No | 5 |
| created | Yes | 6 |
| extWBCSD_pfStatus | Yes | 7 |
| validityPeriodStart | Yes | 8 |
| validityPeriodEnd | No | 9 |
| comment | Yes | 10 |
| pcfLegalStatement | Yes | 11 |
| companyName | No | 12 |
| companyId | Yes | 13 |
| productDescription | Yes | 14 |
| productId | Yes | 15 |
| extWBCSD_productCodeCpc | No | 16 |
| productName | Yes | 17 |
| declaredUnit | Yes | 18 |
| unitaryProductAmount | No | 19 |
| productMassPerDeclaredUnit | Yes | 20 |
| exemptedEmissionsPercent | Yes | 21 |
| exemptedEmissionsDescription | Yes | 22 |
| extWBCSD_packagingEmissionsIncluded | No | 23 |
| boundaryProcessesDescription | Yes | 24 |
| geographyCountrySubdivision | Yes | 25 |
| geographyCountry | No | 26 |
| geographyRegionOrSubregion | Yes | 27 |
| referencePeriodStart | Yes | 28 |
| referencePeriodEnd | Yes | 30 |
| crossSectoralStandard | No | 31 |
| extWBCSD_operator | Yes | 32 |
| ruleName | Yes | 33 |
| extWBCSD_otherOperatorName | No | 34 |
| extWBCSD_characterizationFactors | Yes | 35 |
| extWBCSD_allocationRulesDescription | Yes | 36 |
| extTFS_allocationWasteIncineration | Yes | 37 |
| primaryDataShare | No | 38 |
| secondaryEmissionFactorSource | Yes | 39 |
| coveragePercent | Yes | 40 |
| technologicalDQRtemporalDQR | No | 41 |
| geographicalDQR | Yes | 42 |
| completenessDQR | Yes | 43 |
| reliabilityDQR | Yes | 44 |
| pcfExcludingBiogenic | No | 45 |
| pcfIncludingBiogenic | Yes | 46 |
| fossilGhgEmissions | Yes | 47 |
| biogenicCarbonEmissionsOtherThanCO2 | No | 48 |
| biogenicCarbonWithdrawal | Yes | 49 |
| dlucGhgEmissions | Yes | 50 |
| extTFS_luGhgEmissions | Yes | 51 |
| aircraftGhgEmissions | No | 52 |
| extWBCSD_packagingGhgEmissions | Yes | 53 |
| distributionStagePcfExcludingBiogenic | Yes | 54 |
| distributionStagePcfIncludingBiogenic | No | 55 |
| distributionStageFossilGhgEmissions | Yes | 56 |
| distributionStageBiogenicCarbonEmissionsOtherThanCO2 | Yes | 57 |
| distributionStageBiogenicCarbonWithdrawal | Yes | 58 |
| extTFS_distributionStageDlucGhgEmissions | No | 59 |
| extTFS_distributionStageLuGhgEmissions | Yes | 60 |
| carbonContentTotal | Yes | 61 |
| extWBCSD_fossilCarbonContent | No | 62 |
| carbonContentBiogenic | Yes | 63 |
| assetLifeCyclePhase | Yes | 64 |


#### [CSV Sample File Link]
Expand All @@ -28,8 +94,19 @@ Please find below links for schema details:

### Work Flow


- CSV to POJO
- CSV column validation and mandatory field validation
- POJO TO DTO
- UUID generate v4
- DigitalTwins API's calls
- EDC API's calls
- BPN Discovery API Call
- DB Store

### External Services Call


- DigitalTwins
- EDC Connectors
- BPN Discovery

[CSV Sample File Link]: src/main/resources/pcf.csv
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,20 @@
********************************************************************************/
package org.eclipse.tractusx.sde.submodels.pcf.mapper;

import java.util.List;

import org.eclipse.tractusx.sde.submodels.pcf.entity.PcfEntity;
import org.eclipse.tractusx.sde.submodels.pcf.model.CompanyIds;
import org.eclipse.tractusx.sde.submodels.pcf.model.CrossSectoralStandardsUsed;
import org.eclipse.tractusx.sde.submodels.pcf.model.DataQualityRating;
import org.eclipse.tractusx.sde.submodels.pcf.model.Pcf;
import org.eclipse.tractusx.sde.submodels.pcf.model.PcfAspect;
import org.eclipse.tractusx.sde.submodels.pcf.model.PcfSubmodelResponse;
import org.eclipse.tractusx.sde.submodels.pcf.model.PrecedingPfIds;
import org.eclipse.tractusx.sde.submodels.pcf.model.ProductIds;
import org.eclipse.tractusx.sde.submodels.pcf.model.ProductOrSectorSpecificRule;
import org.eclipse.tractusx.sde.submodels.pcf.model.ProductOrSectorSpecificRules;
import org.eclipse.tractusx.sde.submodels.pcf.model.SecondaryEmissionFactorSources;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -65,7 +77,95 @@ public JsonObject mapToResponse(PcfEntity entity) {
return null;
}

return null;
Pcf pcfResponse = Pcf.builder()
.biogenicCarbonEmissionsOtherThanCO2(entity.getBiogenicCarbonEmissionsOtherThanCO2())
.distributionStagePcfExcludingBiogenic(entity.getDistributionStagePcfExcludingBiogenic())
.distributionStagePcfIncludingBiogenic(entity.getDistributionStagePcfIncludingBiogenic())
.biogenicCarbonWithdrawal(entity.getBiogenicCarbonWithdrawal())
.distributionStageBiogenicCarbonEmissionsOtherThanCO2(entity.getDistributionStageBiogenicCarbonEmissionsOtherThanCO2())
.extWBCSDAllocationRulesDescription(entity.getExtWBCSDAllocationRulesDescription())
.exemptedEmissionsDescription(entity.getExemptedEmissionsDescription())
.distributionStageFossilGhgEmissions(entity.getDistributionStageFossilGhgEmissions())
.exemptedEmissionsPercent(entity.getExemptedEmissionsPercent())
.geographyCountrySubdivision(entity.getGeographyCountrySubdivision())
.extTFSLuGhgEmissions(entity.getExtTFSLuGhgEmissions())
.distributionStageBiogenicCarbonWithdrawal(entity.getDistributionStageBiogenicCarbonWithdrawal())
.pcfIncludingBiogenic(entity.getPcfIncludingBiogenic())
.aircraftGhgEmissions(entity.getAircraftGhgEmissions())
.productMassPerDeclaredUnit(entity.getProductMassPerDeclaredUnit())
.productOrSectorSpecificRules(List.of(ProductOrSectorSpecificRules.builder()
.extWBCSDOperator(entity.getExtWBCSDOperator())
.productOrSectorSpecificRulesObj(ProductOrSectorSpecificRule.builder()
.ruleName(entity.getRuleName())
.build())
.extWBCSDOtherOperatorName(entity.getExtWBCSDOtherOperatorName())
.build()))
.extTFSAllocationWasteIncineration(entity.getExtTFSAllocationWasteIncineration())
.pcfExcludingBiogenic(entity.getPcfExcludingBiogenic())
.referencePeriodEnd(entity.getReferencePeriodEnd())
.extWBCSDCharacterizationFactors(entity.getExtWBCSDCharacterizationFactors())
.secondaryEmissionFactorSources(List.of(SecondaryEmissionFactorSources.builder()
.secondaryEmissionFactorSource(entity.getSecondaryEmissionFactorSource())
.build()))
.unitaryProductAmount(entity.getUnitaryProductAmount())
.declaredUnit(entity.getDeclaredUnit())
.referencePeriodStart(entity.getReferencePeriodStart())
.geographyRegionOrSubregion(entity.getGeographyRegionOrSubregion())
.fossilGhgEmissions(entity.getFossilGhgEmissions())
.extWBCSDPackagingGhgEmissions(entity.getExtWBCSDPackagingGhgEmissions())
.boundaryProcessesDescription(entity.getBoundaryProcessesDescription())
.geographyCountry(entity.getGeographyCountry())
.extWBCSDPackagingEmissionsIncluded(Boolean.parseBoolean(entity.getExtWBCSDPackagingEmissionsIncluded()))
.dlucGhgEmissions(entity.getDlucGhgEmissions())
.carbonContentTotal(entity.getCarbonContentTotal())
.extTFSDistributionStageLuGhgEmissions(entity.getExtTFSDistributionStageLuGhgEmissions())
.extTFSDistributionStageDlucGhgEmissions(entity.getExtTFSDistributionStageDlucGhgEmissions())
.primaryDataShare(entity.getPrimaryDataShare())
.dataQualityRating(DataQualityRating.builder()
.completenessDQR(entity.getCompletenessDQR())
.technologicalDQR(entity.getTechnologicalDQR())
.geographicalDQR(entity.getGeographicalDQR())
.temporalDQR(entity.getTemporalDQR())
.reliabilityDQR(entity.getReliabilityDQR())
.coveragePercent(entity.getCoveragePercent())
.build())
.extWBCSDFossilCarbonContent(entity.getExtWBCSDFossilCarbonContent())
.crossSectoralStandardsUsed(List.of(CrossSectoralStandardsUsed.builder()
.crossSectoralStandard(entity.getCrossSectoralStandard())
.build()))
.extTFSAllocationWasteIncineration(entity.getExtTFSAllocationWasteIncineration())
.carbonContentBiogenic(entity.getCarbonContentBiogenic())
.build();


return new Gson().toJsonTree(PcfSubmodelResponse.builder()
.specVersion(entity.getSpecVersion())
.companyIds(CompanyIds.builder()
.companyId(entity.getCompanyId())
.build())
.extWBCSDProductCodeCpc(entity.getExtWBCSDProductCodeCpc())
.created(entity.getCreated())
.companyName(entity.getCompanyName())
.extWBCSDPfStatus(entity.getExtWBCSDPfStatus())
.version(entity.getVersion())
.productName(entity.getProductName())
.pcf(pcfResponse)
.partialFullPcf(entity.getPartialFullPcf())
.productIds(ProductIds.builder()
.productId(entity.getProductId())
.build())

.validityPeriodStart(entity.getValidityPeriodStart())
.comment(entity.getComment())
.id(entity.getId())
.validityPeriodEnd(entity.getValidityPeriodEnd())
.pcfLegalStatement(entity.getPcfLegalStatement())
.productDescription(entity.getProductDescription())

.precedingPfIds(PrecedingPfIds.builder()
.id(entity.getPrecedingPfId())
.build())
.build()).getAsJsonObject();

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/********************************************************************************
* Copyright (c) 2023 T-Systems International GmbH
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.sde.submodels.pcf.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

@Builder
@Data
@AllArgsConstructor
public class CompanyIds {

private String companyId;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/********************************************************************************
* Copyright (c) 2023 T-Systems International GmbH
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.sde.submodels.pcf.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

@Builder
@Data
@AllArgsConstructor
public class CrossSectoralStandardsUsed {

private String crossSectoralStandard;

}
Loading

0 comments on commit c6fa04a

Please sign in to comment.