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

Commit dd04871

Browse files
Working on deserialization, add deserialization of View
1 parent 391a3ac commit dd04871

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public AssetAdministrationShellEnvironment map(CAEXFile aml) throws MappingExcep
7171
mappingProvider.register(new OperationCollectionMapper());
7272
mappingProvider.register(new FileMapper());
7373
mappingProvider.register(new RangeMapper());
74+
mappingProvider.register(new ViewMapper());
7475
AbstractClassNamingStrategy classNamingStrategy = new NumberingClassNamingStrategy();
7576

7677
PropertyNamingStrategy propertyNamingStrategy = new PropertyNamingStrategy();
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.adminshell.aas.v3.dataformat.aml.deserialization.mappers;
17+
18+
import io.adminshell.aas.v3.dataformat.aml.deserialization.AmlParser;
19+
import io.adminshell.aas.v3.dataformat.aml.deserialization.DefaultMapper;
20+
import io.adminshell.aas.v3.dataformat.aml.deserialization.MappingContext;
21+
import io.adminshell.aas.v3.dataformat.aml.model.caex.InternalElementType;
22+
import io.adminshell.aas.v3.dataformat.core.util.AasUtils;
23+
import io.adminshell.aas.v3.dataformat.mapping.MappingException;
24+
import io.adminshell.aas.v3.model.View;
25+
26+
import java.beans.PropertyDescriptor;
27+
import java.util.List;
28+
29+
/**
30+
*
31+
*/
32+
public class ViewMapper extends DefaultMapper<View> {
33+
34+
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+
}
40+
41+
@Override
42+
protected void mapProperties(Object parent, AmlParser parser, MappingContext context) throws MappingException {
43+
if (parent == null || context == null) {
44+
return;
45+
}
46+
47+
if (!InternalElementType.class.isAssignableFrom(parser.getCurrent().getClass())) return;
48+
InternalElementType internalElementType_View = (InternalElementType) parser.getCurrent();
49+
50+
((View) parent).setIdShort(internalElementType_View.getName());
51+
52+
List<InternalElementType> internalElementTypeList = internalElementType_View.getInternalElement();
53+
internalElementTypeList.stream().forEach(x -> {
54+
String idToReference = x.getRefBaseSystemUnitPath();
55+
if (idToReference != null) {
56+
parser.resolveIdToReferenceLater(parent, AasUtils.getProperty(View.class, CONTAINED_ELEMENTS), idToReference);
57+
}
58+
});
59+
60+
super.mapProperties(parent, parser, context);
61+
}
62+
}

0 commit comments

Comments
 (0)