-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from catenax-ng/CX_PI12_S5_03
[feat|sde-backend] : PCF exchange draft code changes
- Loading branch information
Showing
22 changed files
with
815 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
46 changes: 46 additions & 0 deletions
46
...e/src/main/java/org/eclipse/tractusx/sde/pcfexchange/entity/PcfJsonToStringConvertor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
...-exchange/src/main/java/org/eclipse/tractusx/sde/pcfexchange/entity/PcfRequestEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
...exchange/src/main/java/org/eclipse/tractusx/sde/pcfexchange/entity/PcfResponseEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
...change/src/main/java/org/eclipse/tractusx/sde/pcfexchange/enums/PCFRequestStatusEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
26 changes: 26 additions & 0 deletions
26
...es/pcf-exchange/src/main/java/org/eclipse/tractusx/sde/pcfexchange/enums/PCFTypeEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.