Skip to content

Commit

Permalink
Merge pull request #132 from catenax-ng/release/v1.1.0-registry-lookup
Browse files Browse the repository at this point in the history
[ 4° ] - Release/v1.1.0 registry lookup: update lookup endpoint to the dDTR
  • Loading branch information
matbmoser authored Sep 25, 2023
2 parents b0bccae + 147681d commit 4163c43
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 24 deletions.
2 changes: 1 addition & 1 deletion charts/digital-product-pass/values-int.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ backend:
endpointInterface: 'SUBMODEL-3.0'
internalDtr: "https://materialpass.int.demo.catena-x.net/BPNL000000000000" # -- If there is an internal DTR available it can be referenced here and will be injected in the list of DTRs
decentralApis:
search: "/lookup/shells/query"
search: "/lookup/shells"
digitalTwin: "/shell-descriptors"
subModel: "/submodel-descriptors"
timeouts:
Expand Down
2 changes: 1 addition & 1 deletion charts/digital-product-pass/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ backend:
internalDtr: "" # -- ff there is an internal DTR available it can be referenced here and will be injected in the list of DTRs
# -- decentral digital twin apis
decentralApis:
search: "/lookup/shells/query"
search: "/lookup/shells"
digitalTwin: "/shell-descriptors"
subModel: "/submodel-descriptors"
# -- timeouts for the digital twin registry async negotiation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public class DigitalTwin3 {
@JsonProperty("idShort")
String idShort;

@JsonProperty("assetKind")
String assetKind;

@JsonProperty("assetType")
String assetType;

@JsonProperty("globalAssetId")
String globalAssetId;
@JsonProperty("displayName")
Expand Down Expand Up @@ -81,6 +87,18 @@ public DigitalTwin3(ArrayList<JsonNode> description, String idShort, String glob
this.submodelDescriptors = submodelDescriptors;
}

public DigitalTwin3(ArrayList<JsonNode> description, String idShort, String assetKind, String assetType, String globalAssetId, Object displayName, String identification, ArrayList<JsonNode> specificAssetIds, ArrayList<SubModel3> submodelDescriptors) {
this.description = description;
this.idShort = idShort;
this.assetKind = assetKind;
this.assetType = assetType;
this.globalAssetId = globalAssetId;
this.displayName = displayName;
this.identification = identification;
this.specificAssetIds = specificAssetIds;
this.submodelDescriptors = submodelDescriptors;
}


public ArrayList<JsonNode> getDescription() {
return description;
Expand Down Expand Up @@ -137,5 +155,20 @@ public String getGlobalAssetId() {
public void setGlobalAssetId(String globalAssetId) {
this.globalAssetId = globalAssetId;
}
}

public String getAssetKind() {
return assetKind;
}

public void setAssetKind(String assetKind) {
this.assetKind = assetKind;
}

public String getAssetType() {
return assetType;
}

public void setAssetType(String assetType) {
this.assetType = assetType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@

import java.util.ArrayList;


@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SubModel3 {
@JsonProperty("description")
ArrayList<JsonNode> description;
@JsonProperty("idShort")
String idShort;

@JsonProperty("supplementalSemanticId")
Object supplementalSemanticId;

@JsonProperty("id")
String identification;
@JsonProperty("semanticId")
Expand All @@ -57,6 +60,15 @@ public SubModel3(ArrayList<JsonNode> description, String idShort, String identif
public SubModel3() {
}

public SubModel3(ArrayList<JsonNode> description, String idShort, Object supplementalSemanticId, String identification, JsonNode semanticId, ArrayList<EndPoint3> endpoints) {
this.description = description;
this.idShort = idShort;
this.supplementalSemanticId = supplementalSemanticId;
this.identification = identification;
this.semanticId = semanticId;
this.endpoints = endpoints;
}

public ArrayList<JsonNode> getDescription() {
return description;
}
Expand Down Expand Up @@ -96,4 +108,12 @@ public ArrayList<EndPoint3> getEndpoints() {
public void setEndpoints(ArrayList<EndPoint3> endpoints) {
this.endpoints = endpoints;
}

public Object getSupplementalSemanticId() {
return supplementalSemanticId;
}

public void setSupplementalSemanticId(Object supplementalSemanticId) {
this.supplementalSemanticId = supplementalSemanticId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void init(Environment env) {
Object decentralApis = dtrConfig.getDecentralApis();
if (decentralApis == null) { // If the configuration is null use the default variables
decentralApis = Map.of(
"search", "/lookup/shells/query",
"search", "/lookup/shells",
"digitalTwin", "/shell-descriptors",
"subModel", "/submodel-descriptors"
);
Expand Down Expand Up @@ -519,36 +519,40 @@ public ArrayList<String> queryDigitalTwin(String assetType, String assetId, Stri
ResponseEntity<?> response = null;
if (!this.central && registryUrl != null && edr != null) {
// Set request body as post if the central query is disabled
Object body = Map.of(
"query", Map.of(
"assetIds", List.of(
Map.of(
"name", assetType,
"value", assetId
)
)
)
// Query as GET if the central query is enabled
Map<String, ?> assetIds = Map.of(
"name", assetType,
"value", assetId
);

String jsonString = jsonUtil.toJson(assetIds, false);
HttpHeaders headers = this.getTokenHeader(edr);
response = httpUtil.doPost(url, ArrayList.class, headers, httpUtil.getParams(), body, false, false);
headers.remove("Content-Type"); // This should be fixed by the dtr team to allow content-type as application/json
params.put("assetIds", jsonString);
response = httpUtil.doGet(url, Map.class, headers, params, true, false);
if(response == null){
return null;
}
Map<String,Object> responseBody = (Map<String,Object>) response.getBody();
return (ArrayList<String>) responseBody.get("result");

} else {
// Query as GET if the central query is enabled
Map<String, ?> assetIds = Map.of(
"key", assetType,
"name", assetType,
"value", assetId
);

String jsonString = jsonUtil.toJson(assetIds, false);
HttpHeaders headers = httpUtil.getHeadersWithToken(this.authService.getToken().getAccessToken());;
HttpHeaders headers = httpUtil.getHeadersWithToken(this.authService.getToken().getAccessToken());
params.put("assetIds", jsonString);
response = httpUtil.doGet(url, ArrayList.class, headers, params, true, false);
if(response == null){
return null;
}
ArrayList<String> responseBody = (ArrayList<String>) response.getBody();
return responseBody;
}
if(response == null){
return null;
}
ArrayList<String> responseBody = (ArrayList<String>) response.getBody();
return responseBody;

} catch (Exception e) {
throw new ServiceException(this.getClass().getName() + "." + "queryDigitalTwin",
e,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ configuration:
dspEndpointKey: 'dspEndpoint'
internalDtr: "https://materialpass.int.demo.catena-x.net/BPNL000000000000" # -- If there is an internal DTR available it can be referenced here and will be injected in the list of DTRs
decentralApis:
search: "/lookup/shells/query"
search: "/lookup/shells"
digitalTwin: "/shell-descriptors"
subModel: "/submodel-descriptors"
timeouts:
Expand Down

0 comments on commit 4163c43

Please sign in to comment.