Skip to content

Commit

Permalink
Merge pull request #113 from catenax-ng/CX_PI12_S5_03
Browse files Browse the repository at this point in the history
[feat|sde-backend] : PCF exchange draft code changes
  • Loading branch information
almadigabor authored Apr 9, 2024
2 parents bc5706d + b789bb1 commit 69f7639
Show file tree
Hide file tree
Showing 22 changed files with 815 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Updated supported sub-model implementation classes.
- EDC asset update refactored in supported submodels.
- Support for pcf v6.0.0 submodel.
- Added module for pcf exchange service.

## [2.3.6] - 2024-03-06
### Fixed
Expand Down
1 change: 1 addition & 0 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,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-exchange/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/policy-hub/0.0.1, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx/portal/0.0.1, Apache-2.0, approved, automotive.tractusx
Expand Down
1 change: 1 addition & 0 deletions modules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ SDE backend splited into multiple services loosely-coupled Maven modules.
- modules/sde-submodules/single-level-bom-as-planned
- modules/sde-submodules/pcf
- modules/sde-usecases/traceability
- modules/pcf-exchange
15 changes: 15 additions & 0 deletions modules/pcf-exchange/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# PCF Exchange (SDE Maven module)
---
## Description

PCF**(Product Carbon Footprint)** exchange module use for exchange the PCF data/value as per consumer request and provide the pcf data to the consumer.

This module has provided code changes as per below pcf exchange kit specification. PCF exchanges has external services calls like dDTR, EDC services.

https://eclipse-tractusx.github.io/docs-kits/category/pcf-exchange-kit


##### External service dependency :
- dDTR service.
- EDC Service.
- BPN Discovery.
99 changes: 99 additions & 0 deletions modules/pcf-exchange/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<!--
/********************************************************************************
* Copyright (c) 2024 T-Systems International GmbH
* Copyright (c) 2024 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
********************************************************************************/
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.tractusx</groupId>
<artifactId>sde</artifactId>
<version>0.0.1</version>
<relativePath>../../</relativePath>
</parent>
<artifactId>pcf-exchange</artifactId>
<name>pcf-exchange</name>
<description>pcf-exchange description</description>
<dependencies>
<dependency>
<groupId>org.eclipse.tractusx</groupId>
<artifactId>sde-common</artifactId>
<version>0.0.1</version>
</dependency>

<dependency>
<groupId>org.eclipse.tractusx</groupId>
<artifactId>pcf</artifactId>
<version>0.0.1</version>
</dependency>

<dependency>
<groupId>org.eclipse.tractusx</groupId>
<artifactId>portal</artifactId>
<version>0.0.1</version>
</dependency>

<dependency>
<groupId>org.eclipse.tractusx</groupId>
<artifactId>edc</artifactId>
<version>0.0.1</version>
</dependency>

<dependency>
<groupId>org.eclipse.tractusx</groupId>
<artifactId>digital-twins</artifactId>
<version>0.0.1</version>
</dependency>

<dependency>
<groupId>org.eclipse.tractusx</groupId>
<artifactId>bpn-discovery</artifactId>
<version>0.0.1</version>
</dependency>


</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.processor.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<compilerArg>
-Amapstruct.unmappedTargetPolicy=IGNORE
</compilerArg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/********************************************************************************
* Copyright (c) 2024 T-Systems International GmbH
* Copyright (c) 2024 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.pcfexchange.entity;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import lombok.SneakyThrows;

@Converter
public class PcfJsonToStringConvertor implements AttributeConverter<JsonNode, String> {

ObjectMapper objectMapper = new ObjectMapper();

@Override
@SneakyThrows
public String convertToDatabaseColumn(JsonNode attribute) {
return attribute == null ? "{}" : attribute.toPrettyString();
}

@Override
@SneakyThrows
public JsonNode convertToEntityAttribute(String dbData) {
return dbData == null ? null : objectMapper.readTree(dbData);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/********************************************************************************
* Copyright (c) 2024 T-Systems International GmbH
* Copyright (c) 2024 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.pcfexchange.entity;

import org.eclipse.tractusx.sde.pcfexchange.enums.PCFRequestStatusEnum;
import org.eclipse.tractusx.sde.pcfexchange.enums.PCFTypeEnum;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;

@Table(name = "pcf_requests_tbl")
@Entity
@Data
public class PcfRequestEntity {

@Id
@Column(name = "request_id")
private String requestId;

@Column(name = "product_id")
private String productId;

@Column(name = "bpn_number")
private String bpnNumber;

@Column(name = "type")
@Enumerated(EnumType.STRING)
private PCFTypeEnum type;

@Column(name = "message" , columnDefinition = "TEXT")
private String message;

@Column(name = "status")
@Enumerated(EnumType.STRING)
private PCFRequestStatusEnum status;

@Column(name = "requested_time")
private Long requestedTime;

@Column(name = "last_updated_time")
private Long lastUpdatedTime;

@Column(name = "remark" , columnDefinition = "TEXT")
private String remark;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/********************************************************************************
* Copyright (c) 2024 T-Systems International GmbH
* Copyright (c) 2024 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.pcfexchange.entity;

import com.fasterxml.jackson.databind.JsonNode;

import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Table(name = "pcf_response_tbl")
@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PcfResponseEntity {

@Id
@Column(name = "response_id")
private String responseId;

@Column(name = "request_id")
private String requestId;

@Column(name = "pcf_data", columnDefinition = "TEXT")
@Convert(converter = PcfJsonToStringConvertor.class)
private JsonNode pcfData;

@Column(name = "last_updated_time")
private Long lastUpdatedTime;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/********************************************************************************
* Copyright (c) 2024 T-Systems International GmbH
* Copyright (c) 2024 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.pcfexchange.enums;

public enum PCFRequestStatusEnum {
REQUESTED,
APPROVED,

PUSHING_DATA,
PUSHING_UPDATED_DATA,

REJECTED,
SENDING_REJECT_NOTIFICATION,

PUSHED,
PUSHED_UPDATED_DATA,

RECEIVED,
FAILED_TO_PUSH_DATA,
FAILED_TO_SEND_REJECT_NOTIFICATION,
FAILED,

SENDING_REQUEST,
PENDING_DATA_FROM_PROVIDER
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/********************************************************************************
* Copyright (c) 2024 T-Systems International GmbH
* Copyright (c) 2024 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.pcfexchange.enums;

public enum PCFTypeEnum {
CONSUMER,
PROVIDER
}
Loading

0 comments on commit 69f7639

Please sign in to comment.