Skip to content

Commit

Permalink
Add semanticId to SelfDescription
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-schmidt committed Dec 17, 2023
1 parent de86db6 commit a3f7471
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ public CustomAssetAdministrationShellEnvironment getAasEnvWithUrls(URL aasServic
Encoder.encodeBase64(submodel.getIdentification().getId())));
submodel.getSubmodelElements()
.forEach(elem -> putUrlRec(
format("%s/submodels/%s/submodel/submodel-elements", aasServiceUrlString,
Encoder.encodeBase64(submodel.getIdentification().getId())),
elem));
format("%s/submodels/%s/submodel/submodel-elements", aasServiceUrlString,
Encoder.encodeBase64(submodel.getIdentification().getId())),
elem));
});
model.getSubmodels().forEach(submodel -> AASUtil.getAllSubmodelElements(submodel)
.forEach(element -> element.setSourceUrl(
Expand All @@ -165,10 +165,12 @@ private CustomAssetAdministrationShellEnvironment readModel(URL aasServiceUrl)
String conceptResponse;
String submodelResponse;
try {
shellResponse =
Objects.requireNonNull(httpRestClient.get(aasServiceUrl.toURI().resolve("/shells").toURL()).body()).string();
submodelResponse =
Objects.requireNonNull(httpRestClient.get(aasServiceUrl.toURI().resolve("/submodels").toURL()).body()).string();
shellResponse = Objects
.requireNonNull(httpRestClient.get(aasServiceUrl.toURI().resolve("/shells").toURL()).body())
.string();
submodelResponse = Objects
.requireNonNull(httpRestClient.get(aasServiceUrl.toURI().resolve("/submodels").toURL()).body())
.string();
conceptResponse = Objects.requireNonNull(httpRestClient.get(aasServiceUrl.toURI().resolve("/concept" +
"-descriptions").toURL()).body())
.string();
Expand All @@ -195,8 +197,10 @@ private CustomAssetAdministrationShellEnvironment readModel(URL aasServiceUrl)
customIdentification.setIdType(submodel.getIdentification().getIdType().toString());
customIdentification.setId(submodel.getIdentification().getIdentifier());
customSubmodel.setIdentification(customIdentification);

customSubmodel.setIdShort(submodel.getIdShort());
if (Objects.nonNull(submodel.getSemanticId().getKeys())) {
customSubmodel.setSemanticId(new CustomSemanticId(submodel.getSemanticId().getKeys()));
}

// Recursively add submodelElements
var customElements = AASUtil.getCustomSubmodelElementStructureFromSubmodel(submodel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@
*/
package de.fraunhofer.iosb.app.model.aas;

import com.fasterxml.jackson.annotation.JsonProperty;

/*
* Collect common attributes of every AAS element.
*/
public class AASElement extends IdsAssetElement {

protected String idShort;

@JsonProperty("semanticId")
protected CustomSemanticId customSemanticId;

public String getIdShort() {
return idShort;
Expand All @@ -29,4 +34,12 @@ public String getIdShort() {
public void setIdShort(String idShort) {
this.idShort = idShort;
}

public CustomSemanticId getCustomSemanticId() {
return customSemanticId;
}

public void setSemanticId(CustomSemanticId semanticId) {
this.customSemanticId = semanticId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package de.fraunhofer.iosb.app.model.aas;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

import io.adminshell.aas.v3.model.Key;

import com.fasterxml.jackson.annotation.JsonTypeInfo;

@JsonAutoDetect
@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION)
@JsonInclude(Include.NON_NULL)
public class CustomSemanticId {
private List<CustomSemanticIdKey> keys;

public List<CustomSemanticIdKey> getKeys() {
return keys;
}

public void setKeys(List<CustomSemanticIdKey> keys) {
this.keys = keys;
}

public CustomSemanticId() {
this.keys = Collections.emptyList();
}

public CustomSemanticId(List<Key> keys) {
this.keys = new ArrayList<>();
for (Key key : keys) {

var customSemanticIdKey = new CustomSemanticIdKey();

customSemanticIdKey.setIdType(key.getIdType());
customSemanticIdKey.setType(key.getType());
customSemanticIdKey.setValue(key.getValue());

this.keys.add(customSemanticIdKey);

}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package de.fraunhofer.iosb.app.model.aas;


import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

import io.adminshell.aas.v3.model.KeyElements;
import io.adminshell.aas.v3.model.KeyType;

import com.fasterxml.jackson.annotation.JsonTypeInfo;

@JsonAutoDetect
@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION)
@JsonInclude(Include.NON_NULL)
public class CustomSemanticIdKey {
private KeyType idType;
private KeyElements type;
private String value;


public KeyType getIdType() {
return idType;
}

public void setIdType(KeyType idType) {
this.idType = idType;
}

public KeyElements getType() {
return type;
}

public void setType(KeyElements type) {
this.type = type;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ private static Collection<CustomSubmodelElement> unpackElements(Collection<Submo
} else {
var customSubmodelElement = new CustomSubmodelElement();
customSubmodelElement.setIdShort(submodelElement.getIdShort());

if (Objects.nonNull(submodelElement.getSemanticId().getKeys())) {
customSubmodelElement
.setSemanticId(new CustomSemanticId(submodelElement.getSemanticId().getKeys()));
}

customSubmodelElements.add(customSubmodelElement);
}
}
Expand All @@ -96,7 +102,7 @@ private static Collection<CustomSubmodelElement> unpackElements(Collection<Submo
* flat structure.
*/
private static Collection<CustomSubmodelElement> flattenElements(Collection<CustomSubmodelElement> flatList,
Collection<CustomSubmodelElement> submodelElements) {
Collection<CustomSubmodelElement> submodelElements) {

for (CustomSubmodelElement submodelElement : submodelElements) {

Expand Down

0 comments on commit a3f7471

Please sign in to comment.