Skip to content

Commit

Permalink
Merge pull request #56 from catenax-ng/ver-2.1.0
Browse files Browse the repository at this point in the history
[feat|sde-v2.1.0] DDTR update, support for batch model v2.0 ,added external specific asset id and feign Client changes updated for child aspect relationship.
  • Loading branch information
almadigabor authored Aug 30, 2023
2 parents 479591f + dc2fa7a commit 4a71c04
Show file tree
Hide file tree
Showing 32 changed files with 490 additions and 169 deletions.
20 changes: 17 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
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.1.0] - 2023-08-30
### Fixed
- Added external subject in specific asset Ids.
- Update AAS submodel endpoints subprotocolBody.
- Supported Batch submodel version 2.0.0.
- DDTR update with latest version.
- Feign Client changes updated for child aspect relationship.

## [2.0.11] - 2023-08-29
### Changed
- Docker image name changed.

## [2.0.10] - 2023-08-23
### Fixed
- Updated openAPI file for kics issue.
Expand Down Expand Up @@ -203,9 +215,11 @@ 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/dftbackend-2.0.10...main
[2.0.10]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/dftbackend-2.0.9...dftbackend-2.0.10
[2.0.9]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/dftbackend-2.0.8...dftbackend-2.0.9
[unreleased]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/v2.1.0...main
[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
[2.0.10]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/sdebackend-2.0.9...v2.0.10
[2.0.9]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/sdebackend-2.0.8...sdebackend-2.0.9
[2.0.8]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/dftbackend-2.0.2...dftbackend-2.0.8
[2.0.2]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/dftbackend-2.0.1...dftbackend-2.0.2
[2.0.1]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/dftbackend-2.0.0...dftbackend-2.0.1
Expand Down
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ For more details, please refer configuration section from [README.md](README.md)
- Postgres 11.9.13

#### Steps
1. Clone the GitHub Repository - https://github.com/eclipse-tractusx/dft-backend.
1. Clone the GitHub Repository - https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend.
2. Get your instance of postgres running (Create **dftdb** new database).
3. Setup your project environment to JDK 18.
4. Provide require application configuration in application.properties as specified in step configuration.properties.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ private CommonConstants() {
public static final String MANUFACTURER_ID = "manufacturerId";
public static final String CUSTOMER_PART_ID = "customerPartId";
public static final String ASSET_LIFECYCLE_PHASE = "assetLifecyclePhase";
public static final String HTTP = "http";
public static final String HTTP = "HTTP";
public static final String HTTPS = "HTTPS";
public static final String ENDPOINT_PROTOCOL_VERSION = "0.1";
public static final String ENDPOINT_PROTOCOL_VERSION = "1.1";
public static final String PREFIX = "urn:uuid:";

public static final String INTERFACE_EDC = "EDC";
public static final String SUB_PROTOCOL = "IDS";
public static final String SUB_PROTOCOL = "DSP";
public static final String SUBMODEL_CONTEXT_URL = "/submodel";

public static final String AS_PLANNED = "AsPlanned";

public static final String EXTERNAL_REFERENCE = "ExternalReference";
public static final String GLOBAL_REFERENCE = "GlobalReference";
public static final String BODY_ENCODING = "plain";
public static final String INTERFACE = "https://admin-shell.io/aas/API/3/0/SubmodelServiceSpecification/SSP-003";
public static final String INTERFACE = "SUBMODEL-3.0";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/********************************************************************************
* 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.digitaltwins.entities.common;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

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

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class ExternalSubjectId {

private String type;

private List<Keys> keys;

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,31 @@

package org.eclipse.tractusx.sde.digitaltwins.entities.common;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;

@Data
@NoArgsConstructor
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class KeyValuePair {

private String name;
private String value;
private ExternalSubjectId externalSubjectId;

@SneakyThrows
public String toJsonString() {
final ObjectMapper mapper = new ObjectMapper();
return mapper.writeValueAsString(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/********************************************************************************
* 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.digitaltwins.entities.common;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

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

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class LookupQuery {

private String type;
private List<KeyValuePair> assetIds;
private List<String> semanticIds;



}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ public class ProtocolInformation {
private String subProtocol;
private String subprotocolBody;
private String subprotocolBodyEncoding;
private List<SecurityAttributes> securityAttributes;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/********************************************************************************
* 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.digitaltwins.entities.common;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

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

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class SecurityAttributes {


private String type;
private String key;
private String value;

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@

import java.util.List;

import org.eclipse.tractusx.sde.digitaltwins.entities.common.KeyValuePair;
import org.eclipse.tractusx.sde.digitaltwins.entities.common.MultiLanguage;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.ObjectMapper;

import lombok.AllArgsConstructor;
Expand All @@ -38,13 +40,15 @@
@NoArgsConstructor
@AllArgsConstructor
@Getter
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(Include.NON_NULL)
public class ShellDescriptorRequest {

private String idShort;
private String id;
private List<MultiLanguage> description;
private String globalAssetId;
private List<KeyValuePair> specificAssetIds;
private List<Object> specificAssetIds;

@SneakyThrows
public String toJsonString() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/********************************************************************************
* 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.digitaltwins.entities.request;

import org.eclipse.tractusx.sde.digitaltwins.entities.common.LookupQuery;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Builder
@NoArgsConstructor
@AllArgsConstructor
@Getter
public class ShellLookupQueryRequest {

private LookupQuery query;




}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Base64;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.eclipse.tractusx.sde.common.exception.ServiceException;
import org.eclipse.tractusx.sde.digitaltwins.entities.request.CreateSubModelRequest;
import org.eclipse.tractusx.sde.digitaltwins.entities.request.ShellDescriptorRequest;
Expand Down Expand Up @@ -55,20 +56,24 @@ public class DigitalTwinsFacilitator {
@Value(value = "${digital-twins.api:/api/v3.0}")
private String dtApiUri;

@Value(value = "${manufacturerId}")
public String manufacturerId;

public List<String> shellLookup(ShellLookupRequest request) throws ServiceException {
return shellLookupFromDDTR(request, null);
return shellLookupFromDDTR(request, null, manufacturerId);
}

@SneakyThrows
public List<String> shellLookupFromDDTR(ShellLookupRequest request, String ddtrUrl) throws ServiceException {
public List<String> shellLookupFromDDTR(ShellLookupRequest request, String ddtrUrl, String edcBpn)
throws ServiceException {

URI dtURL = (ddtrUrl == null || ddtrUrl.length() <= 0) ? getDtURL(digitalTwinsHost) : getDtURL(ddtrUrl);
URI dtURL = StringUtils.isAllEmpty(ddtrUrl) ? getDtURL(digitalTwinsHost) : getDtURL(ddtrUrl);

List<String> shellIds = List.of();

try {
ResponseEntity<ShellLookupResponse> response = digitalTwinsFeignClient.shellLookup(dtURL,
request.toJsonString());
request.toJsonString(), edcBpn);

ShellLookupResponse body = response.getBody();
if (response.getStatusCode() == HttpStatus.OK && body != null) {
Expand Down Expand Up @@ -106,17 +111,17 @@ public List<ShellDescriptorResponse> getShellDescriptorsWithSubmodelDetails(List

List<ShellDescriptorResponse> items = new ArrayList<>();
for (String shellId : shellIds) {
items.add(getShellDetailsById(shellId, ddtrUrl));
items.add(getShellDetailsById(shellId, ddtrUrl, manufacturerId));
}
return items;
}

public ShellDescriptorResponse getShellDetailsById(String shellId, String ddtrUrl) {
public ShellDescriptorResponse getShellDetailsById(String shellId, String ddtrUrl, String edcBpn) {

URI dtURL = (ddtrUrl == null || ddtrUrl.length() <= 0) ? getDtURL(digitalTwinsHost) : getDtURL(ddtrUrl);
URI dtURL = StringUtils.isAllEmpty(ddtrUrl) ? getDtURL(digitalTwinsHost) : getDtURL(ddtrUrl);

ResponseEntity<ShellDescriptorResponse> shellDescriptorResponse = digitalTwinsFeignClient
.getShellDescriptorByShellId(dtURL, encodeShellIdBase64Utf8(shellId));
.getShellDescriptorByShellId(dtURL, encodeShellIdBase64Utf8(shellId), edcBpn);
return shellDescriptorResponse.getBody();
}

Expand All @@ -142,6 +147,18 @@ public ShellDescriptorResponse createShellDescriptor(ShellDescriptorRequest requ
return responseBody;
}

public void updateShellSpecificAssetIdentifiers(String shellId, List<Object> specificAssetIds) {

digitalTwinsFeignClient.deleteShellSpecificAttributes(getDtURL(digitalTwinsHost),
encodeShellIdBase64Utf8(shellId), manufacturerId);

ResponseEntity<List<Object>> registerSubmodel = digitalTwinsFeignClient.createShellSpecificAttributes(
getDtURL(digitalTwinsHost), encodeShellIdBase64Utf8(shellId), manufacturerId, specificAssetIds);
if (registerSubmodel.getStatusCode() != HttpStatus.CREATED) {
log.error("Error in shell SpecificAssetIdentifiers deletion: " + registerSubmodel.toString());
}
}

public void createSubModel(String shellId, CreateSubModelRequest request) {

request.setDescription(List.of());
Expand Down
Loading

0 comments on commit 4a71c04

Please sign in to comment.