Skip to content
This repository was archived by the owner on Feb 15, 2024. It is now read-only.

Commit af11589

Browse files
authored
Merge pull request #25 from JensMueller2709/feature/aml-deserializer
AML Deserializer - Adjust FileMapper and ViewMapper
2 parents f3169a0 + e798a87 commit af11589

3 files changed

Lines changed: 9 additions & 13 deletions

File tree

dataformat-aml/src/main/java/io/adminshell/aas/v3/dataformat/aml/deserialization/mappers/FileMapper.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import io.adminshell.aas.v3.dataformat.core.util.AasUtils;
2424
import io.adminshell.aas.v3.dataformat.mapping.MappingException;
2525
import io.adminshell.aas.v3.model.File;
26+
2627
import java.beans.PropertyDescriptor;
2728
import java.util.List;
2829

@@ -35,8 +36,8 @@ public class FileMapper extends DefaultMapper<File> {
3536
protected static PropertyDescriptor PROPERTY_MIME_TYPE = AasUtils.getProperty(File.class, "mimeType");
3637

3738
private static final String FILE_DATA_REFERENCE = "AssetAdministrationShellInterfaceClassLib/FileDataReference";
38-
private static final String MIME_TYPE_ATTRIBUTE_NAME = "MIMEType";
39-
private static final String REF_URI_ATTRIBUTE_NAME = "refUri";
39+
private static final String MIME_TYPE_ATTRIBUTE_PATH = "AAS:File/MIMEType";
40+
private static final String REF_URI_ATTRIBUTE_PATH = "AAS:File/refURI";
4041

4142
public FileMapper() {
4243
super(PROPERTY_VALUE.getName(), PROPERTY_MIME_TYPE.getName());
@@ -56,11 +57,12 @@ protected void mapProperties(Object parent, AmlParser parser, MappingContext con
5657
throw new MappingException(String.format("multiple external interfaces are found in file %s %s", parser.getCurrent().getID(), parser.getCurrent().getName()));
5758

5859
List<AttributeType> attributeTypes = externalInterfaces.get(0).getAttribute();
60+
5961
AttributeType mimeTypeAttribute = attributeTypes.stream()
60-
.filter(x -> x.getName().equalsIgnoreCase(MIME_TYPE_ATTRIBUTE_NAME))
62+
.filter(x -> x.getRefSemantic().get(0).getCorrespondingAttributePath().equalsIgnoreCase(MIME_TYPE_ATTRIBUTE_PATH))
6163
.findFirst().orElse(null);
6264
AttributeType refUriAttribute = attributeTypes.stream()
63-
.filter(x -> x.getName().equalsIgnoreCase(REF_URI_ATTRIBUTE_NAME)).findFirst().orElse(null);
65+
.filter(x -> x.getRefSemantic().get(0).getCorrespondingAttributePath().equalsIgnoreCase(REF_URI_ATTRIBUTE_PATH)).findFirst().orElse(null);
6466

6567
if (refUriAttribute != null)
6668
((File) parent).setValue(refUriAttribute.getValue() == null ? null : refUriAttribute.getValue().toString());

dataformat-aml/src/main/java/io/adminshell/aas/v3/dataformat/aml/deserialization/mappers/ViewMapper.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@
3232
public class ViewMapper extends DefaultMapper<View> {
3333

3434
private static final String CONTAINED_ELEMENTS = "containedElements";
35-
private static final PropertyDescriptor PROPERTY_VALUE_TYPE = AasUtils.getProperty(View.class, "idShort");
36-
37-
public ViewMapper() {
38-
super(PROPERTY_VALUE_TYPE.getName());
39-
}
4035

4136
@Override
4237
protected void mapProperties(Object parent, AmlParser parser, MappingContext context) throws MappingException {
@@ -47,9 +42,6 @@ protected void mapProperties(Object parent, AmlParser parser, MappingContext con
4742
if (!InternalElementType.class.isAssignableFrom(parser.getCurrent().getClass())) return;
4843
InternalElementType internalElementType_View = (InternalElementType) parser.getCurrent();
4944

50-
//TODO remove after adjustment of serializer
51-
((View) parent).setIdShort(internalElementType_View.getName());
52-
5345
List<InternalElementType> internalElementTypeList = internalElementType_View.getInternalElement();
5446
internalElementTypeList.stream().forEach(x -> {
5547
String idToReference = x.getRefBaseSystemUnitPath();

dataformat-aml/src/test/java/io/adminshell/aas/v3/dataformat/aml/deserialize/AmlDeserializerTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ private void swapSubmodelIdx(AssetAdministrationShellEnvironment env, int idxSrc
7474
private void adaptSubmodels(AssetAdministrationShellEnvironment env) {
7575
//non referenced submodels are not considered in AML
7676
List<String> submodelIds = new ArrayList<>();
77-
env.getAssetAdministrationShells().stream().forEach(x -> x.getSubmodels().stream().forEach(y -> y.getKeys().stream().forEach(z ->submodelIds.add(z.getValue()))));
77+
env.getAssetAdministrationShells().stream().forEach(
78+
x -> x.getSubmodels().stream()
79+
.forEach(y -> y.getKeys().stream().forEach(z ->submodelIds.add(z.getValue()))));
7880

7981
List<Submodel> referencedSubmodels = env.getSubmodels().stream().filter(x -> submodelIds.contains(x.getIdentification().getIdentifier())).collect(Collectors.toList());
8082
env.setSubmodels(referencedSubmodels);

0 commit comments

Comments
 (0)