Skip to content

Commit

Permalink
Merge pull request #140 from catenax-ng/release/v1.3.0-irs-backend-in…
Browse files Browse the repository at this point in the history
…tegration

[1°] - Release/v1.3.0-irs-backend-integration: Support the IRS in the backend component
  • Loading branch information
matbmoser authored Nov 3, 2023
2 parents c19d232 + 97581c9 commit 697d380
Show file tree
Hide file tree
Showing 34 changed files with 3,044 additions and 96 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@

The changelog format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [pre-released]
## [v1.3.0] - 03-11-2023


## Added
- New IRS Service which is able to communicate with the IRS component api.
- Added condition to deactivate the IRS
- Added tree manager to manage the tree of components used by each irs process
- Added structure to manage the information coming from the IRS and jobs initiated
- Enabled callback mechanism with the IRS component
- Created `/api/irs/{processId}/tree` and `/api/irs/{processId}/components` APIs


## [released]
## [1.2.1] - 31-10-2023

Expand Down
1 change: 0 additions & 1 deletion DEPENDENCIES_FRONTEND
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ npm/npmjs/-/cross-spawn/7.0.3, MIT, approved, clearlydefined
npm/npmjs/-/crypto-js/4.2.0, MIT AND BSD-2-Clause, approved, #11347
npm/npmjs/-/cssesc/3.0.0, MIT, approved, clearlydefined
npm/npmjs/-/csstype/2.6.21, MIT, approved, clearlydefined
npm/npmjs/-/cypress-keycloak/1.9.0, MIT, approved, #6952
npm/npmjs/-/de-indent/1.0.2, MIT, approved, clearlydefined
npm/npmjs/-/debug/4.3.4, MIT, approved, clearlydefined
npm/npmjs/-/deep-is/0.1.4, MIT, approved, #2130
Expand Down
10 changes: 10 additions & 0 deletions charts/digital-product-pass/values-beta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ backend:
enabled: true
bpn: true
edc: true
irs:
enabled: true
endpoint: "https://materialpass-irs.beta.demo.catena-x.net"
paths:
job: "/irs/jobs"
tree:
fileName: "treeDataModel"
indent: true
callbackUrl: "https://materialpass.beta.demo.catena-x.net/api/irs"
dtr:
central: false
Expand Down
10 changes: 10 additions & 0 deletions charts/digital-product-pass/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ backend:
bpn: false
edc: true
irs:
enabled: true
endpoint: "https://materialpass-irs.dev.demo.catena-x.net"
paths:
job: "/irs/jobs"
tree:
fileName: "treeDataModel"
indent: true
callbackUrl: "https://materialpass.dev.demo.catena-x.net/api/irs"
dtr:
central: false
centralUrl: 'https://semantics.dev.demo.catena-x.net/registry'
Expand Down
10 changes: 10 additions & 0 deletions charts/digital-product-pass/values-int.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ backend:
bpn: true
edc: true
irs:
enabled: true
endpoint: "https://materialpass-irs.int.demo.catena-x.net"
paths:
job: "/irs/jobs"
tree:
fileName: "treeDataModel"
indent: true
callbackUrl: "https://materialpass.int.demo.catena-x.net/api/irs"
dtr:
central: false
centralUrl: 'https://semantics.int.demo.catena-x.net/registry'
Expand Down
10 changes: 10 additions & 0 deletions charts/digital-product-pass/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ backend:
enabled: false
bpn: false
edc: false
# -- irs configuration
irs:
enabled: true # -- Enable search for children in the requests
endpoint: "https://<irs-server-url>" # -- IRS endpoint
paths:
job: "/irs/jobs" # -- API path for calling in the IRS endpoints and staring/getting jobs
tree:
fileName: "treeDataModel" # -- Tree dataModel filename created in the processId directory
indent: true # -- Indent tree file
callbackUrl: "https://<backend-url>/api/irs" # -- Backend call back base url for the irs controller
# -- digital twin registry configuration
dtr:
central: false
Expand Down
2 changes: 1 addition & 1 deletion consumer-backend/productpass/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</parent>
<groupId>org.eclipse.tractusx</groupId>
<artifactId>productpass</artifactId>
<version>1.2.1</version>
<version>1.3.0</version>
<packaging>jar</packaging>
<name>Catena-X Digital Product Passport Backend</name>
<description>Product Passport Consumer Backend System for Product Passport Consumer Frontend Application
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
/*********************************************************************************
*
* Catena-X - Product Passport Consumer Backend
*
* Copyright (c) 2022, 2023 BASF SE, BMW AG, Henkel AG & Co. KGaA
* Copyright (c) 2022, 2023 Contributors to the CatenaX (ng) GitHub Organisation.
*
*
* 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 govern in permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

package org.eclipse.tractusx.productpass.config;

import com.sun.source.tree.Tree;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
* This class consists exclusively to define the attributes and methods needed for the IRS configuration.
**/
@Configuration
@ConfigurationProperties(prefix="configuration.irs")
public class IrsConfig {

/** ATTRIBUTES **/
Boolean enabled;
String endpoint;
TreeConfig tree;
Paths paths;
String callbackUrl;

/** CONSTRUCTOR(S) **/
public IrsConfig(Boolean enabled, String endpoint, TreeConfig tree, Paths paths, String callbackUrl) {
this.enabled = enabled;
this.endpoint = endpoint;
this.tree = tree;
this.paths = paths;
this.callbackUrl = callbackUrl;
}
public IrsConfig() {
}

public IrsConfig(String endpoint, TreeConfig tree, Paths paths) {
this.endpoint = endpoint;
this.tree = tree;
this.paths = paths;
}

public IrsConfig(String endpoint, TreeConfig tree, Paths paths, String callbackUrl) {
this.endpoint = endpoint;
this.tree = tree;
this.paths = paths;
this.callbackUrl = callbackUrl;
}

/** GETTERS AND SETTERS **/

public String getEndpoint() {
return endpoint;
}

public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}

public Paths getPaths() {
return paths;
}

public void setPaths(Paths paths) {
this.paths = paths;
}

public TreeConfig getTree() {
return tree;
}

public void setTree(TreeConfig tree) {
this.tree = tree;
}

public String getCallbackUrl() {
return callbackUrl;
}

public void setCallbackUrl(String callbackUrl) {
this.callbackUrl = callbackUrl;
}

public Boolean getEnabled() {
return enabled;
}

public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}

/** INNER CLASSES **/

/**
* This class consists exclusively to define the attributes and methods needed for the IRS Tree configurations.
**/
public static class TreeConfig{

/** ATTRIBUTES **/
String fileName;

Boolean indent;


public TreeConfig(String fileName) {
this.fileName = fileName;
}

public TreeConfig(String fileName, Boolean indent) {
this.fileName = fileName;
this.indent = indent;
}

public TreeConfig() {
}

/** GETTERS AND SETTERS **/
public String getFileName() {
return fileName;
}

public void setFileName(String fileName) {
this.fileName = fileName;
}

public Boolean getIndent() {
return indent;
}

public void setIndent(Boolean indent) {
this.indent = indent;
}
}


/**
* This class consists exclusively to define the attributes and methods needed for the job path configuration.
**/
public static class Paths{
String job;

public Paths(String job) {
this.job = job;
}

public Paths() {
}

public String getJob() {
return job;
}

public void setJob(String job) {
this.job = job;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.eclipse.tractusx.productpass.config.DtrConfig;
import org.eclipse.tractusx.productpass.config.IrsConfig;
import org.eclipse.tractusx.productpass.config.ProcessConfig;
import org.eclipse.tractusx.productpass.exceptions.ControllerException;
import org.eclipse.tractusx.productpass.managers.ProcessManager;
import org.eclipse.tractusx.productpass.managers.TreeManager;
import org.eclipse.tractusx.productpass.models.catenax.Dtr;
import org.eclipse.tractusx.productpass.models.dtregistry.DigitalTwin;
import org.eclipse.tractusx.productpass.models.dtregistry.EndPoint;
Expand All @@ -45,10 +47,12 @@
import org.eclipse.tractusx.productpass.models.http.Response;
import org.eclipse.tractusx.productpass.models.http.requests.Search;
import org.eclipse.tractusx.productpass.models.manager.History;
import org.eclipse.tractusx.productpass.models.manager.Node;
import org.eclipse.tractusx.productpass.models.manager.SearchStatus;
import org.eclipse.tractusx.productpass.models.manager.Status;
import org.eclipse.tractusx.productpass.services.AasService;
import org.eclipse.tractusx.productpass.services.DataPlaneService;
import org.eclipse.tractusx.productpass.services.IrsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.*;
Expand Down Expand Up @@ -83,11 +87,19 @@ public class AppController {
PassportUtil passportUtil;
@Autowired
AasService aasService;

@Autowired
IrsService irsService;

@Autowired
TreeManager treeManager;
@Autowired
DataPlaneService dataPlaneService;
@Autowired
ProcessManager processManager;
@Autowired
IrsConfig irsConfig;
@Autowired
DtrConfig dtrConfig;
@SuppressWarnings("Unused")
private @Autowired ProcessConfig processConfig;
Expand Down Expand Up @@ -189,7 +201,7 @@ public Response getDigitalTwin(@RequestBody Object body, @PathVariable String pr
if (endpoint == null) {
throw new ControllerException(this.getClass().getName(), "No EDC endpoint found in DTR SubModel!");
}
Map<String, String> subProtocolBody = endpoint.getProtocolInformation().getParsedSubprotocolBody();
Map<String, String> subProtocolBody = endpoint.getProtocolInformation().parseSubProtocolBody();
connectorAddress = subProtocolBody.get(dtrConfig.getDspEndpointKey()); // Get DSP endpoint address
assetId = subProtocolBody.get("id"); // Get Asset Id
dataPlaneUrl = endpoint.getProtocolInformation().getEndpointAddress(); // Get the HREF endpoint
Expand All @@ -208,10 +220,23 @@ public Response getDigitalTwin(@RequestBody Object body, @PathVariable String pr
if (connectorAddress.isEmpty() || assetId.isEmpty()) {
LogUtil.printError("Failed to parse endpoint [" + connectorAddress + "] or the assetId is not found!");
}
processManager.setEndpoint(processId, connectorAddress, dataPlaneUrl);
processManager.setBpn(processId, dtr.getBpn());
processManager.setSemanticId(processId, semanticId);
String bpn = dtr.getBpn();
Boolean childrenCondition = search.getChildren();
processManager.saveTransferInfo(processId, connectorAddress, semanticId, dataPlaneUrl, bpn, childrenCondition);
processManager.saveDigitalTwin(processId, digitalTwin, dtRequestTime);

// IRS FUNCTIONALITY START
if(this.irsConfig.getEnabled() && search.getChildren()) {
// Update tree
String globalAssetId = digitalTwin.getGlobalAssetId();
String actualPath = status.getTreeState() + "/" + globalAssetId;
processManager.setTreeState(processId, actualPath);
this.treeManager.setNodeByPath(processId, actualPath, new Node(digitalTwin));

// Get children from the node
this.irsService.getChildren(processId, actualPath, globalAssetId, bpn);
}

LogUtil.printDebug("[PROCESS " + processId + "] Digital Twin [" + digitalTwin.getIdentification() + "] and Submodel [" + subModel.getIdentification() + "] with EDC endpoint [" + connectorAddress + "] retrieved from DTR");
processManager.setStatus(processId, "digital-twin-found", new History(
assetId,
Expand Down
Loading

0 comments on commit 697d380

Please sign in to comment.